MonikerProxyAttribute.cs 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.ComIntegration
  5. {
  6. using System.Runtime;
  7. using System.Runtime.InteropServices;
  8. using System.Runtime.Remoting.Proxies;
  9. [AttributeUsage(AttributeTargets.Class)]
  10. internal sealed class MonikerProxyAttribute : ProxyAttribute, ICustomFactory
  11. {
  12. public override MarshalByRefObject CreateInstance(Type serverType)
  13. {
  14. if (serverType != typeof(ServiceMoniker))
  15. {
  16. throw Fx.AssertAndThrow("MonikerProxyAttribute can only be used for the service Moniker");
  17. }
  18. return MonikerBuilder.CreateMonikerInstance();
  19. }
  20. MarshalByRefObject ICustomFactory.CreateInstance(Type serverType)
  21. {
  22. if (serverType != typeof(ServiceMoniker))
  23. {
  24. throw Fx.AssertAndThrow("MonikerProxyAttribute can only be used for the service Moniker");
  25. }
  26. return MonikerBuilder.CreateMonikerInstance();
  27. }
  28. }
  29. }