We need you! We're working hard on the next version of Developer Fusion - Let us know what you think we should be up to!

The Labs \ Source Viewer \ SSCLI \ System.Runtime.Remoting.Activation \ UrlAttribute

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** File:    UrlAttribute.cs
  18. **
  19. **                                           
  20. **
  21. ** Purpose: Defines an attribute which can be used at the callsite to
  22. **          specify the URL at which the activation will happen.
  23. **
  24. ** Date:    March 30, 2000
  25. **
  26. ===========================================================*/
  27. namespace System.Runtime.Remoting.Activation
  28. {
  29.     using System.Runtime.Remoting;
  30.     using System.Runtime.Remoting.Contexts;
  31.     using System.Runtime.Remoting.Messaging;
  32.     using System.Security.Permissions;
  33.     using System;
  34.     [Serializable()]
  35.     [System.Runtime.InteropServices.ComVisible(true)]
  36.     public sealed class UrlAttribute : ContextAttribute
  37.     {
  38.         private string url;
  39.         private static string propertyName = "UrlAttribute";
  40.        
  41.         [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
  42.         public UrlAttribute(string callsiteURL) : base(propertyName)
  43.         {
  44.             if (null == callsiteURL) {
  45.                 // Invalid arg
  46.                 throw new ArgumentNullException("callsiteURL");
  47.             }
  48.             url = callsiteURL;
  49.         }
  50.        
  51.        
  52.         #pragma warning disable 688 // link demand on override
  53.         // Object::Equals
  54.         // Override the default implementation which just compares the names
  55.         public override bool Equals(object o)
  56.         {
  57.             return (o is IContextProperty) && (o is UrlAttribute) && (((UrlAttribute)o).UrlValue.Equals(url));
  58.         }
  59.        
  60.         public override int GetHashCode()
  61.         {
  62.             return this.url.GetHashCode();
  63.         }
  64.         #pragma warning disable
  65.        
  66.         // Override ContextAttribute's implementation of IContextAttribute::IsContextOK
  67.         [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
  68.         [System.Runtime.InteropServices.ComVisible(true)]
  69.         public override bool IsContextOK(Context ctx, IConstructionCallMessage msg)
  70.         {
  71.             return false;
  72.         }
  73.        
  74.         // Override ContextAttribute's impl. of IContextAttribute::GetPropForNewCtx
  75.         [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
  76.         [System.Runtime.InteropServices.ComVisible(true)]
  77.         public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
  78.         {
  79.             // We are not interested in contributing any properties to the
  80.             // new context since the only purpose of this property is to force
  81.             // the creation of the context and the server object inside it at
  82.             // the specified URL.
  83.             return;
  84.         }
  85.        
  86.         public string UrlValue {
  87.             [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
  88.             get { return url; }
  89.         }
  90.     }
  91. }
  92. // namespace

Developer Fusion