dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Runtime/Remoting/Cont


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Runtime/Remoting/Contexts Context.cs, 1.3, 1.4 ContextAttribute.cs, 1.1, 1.2
Date: Sat, 23 Aug 2003 05:44:21 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Runtime/Remoting/Contexts
In directory 
subversions:/tmp/cvs-serv16164/runtime/System/Runtime/Remoting/Contexts

Modified Files:
        Context.cs ContextAttribute.cs 
Log Message:


Support code for remoting contexts.


Index: Context.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Runtime/Remoting/Contexts/Context.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Context.cs  25 Apr 2003 04:45:13 -0000      1.3
--- Context.cs  23 Aug 2003 09:44:19 -0000      1.4
***************
*** 25,39 ****
  #if CONFIG_REMOTING
  
  public class Context
  {
        // Internal state.
        private int contextID;
        private IContextProperty[] properties;
  
        // Constructor.
-       [TODO]
        public Context()
                        {
!                               // TODO
                        }
  
--- 25,45 ----
  #if CONFIG_REMOTING
  
+ using System.Threading;
+ 
  public class Context
  {
        // Internal state.
+       private static int nextContextID = 0;
        private int contextID;
        private IContextProperty[] properties;
+       private bool freeze;
  
        // Constructor.
        public Context()
                        {
!                               lock(typeof(Context))
!                               {
!                                       contextID = ++nextContextID;
!                               }
                        }
  
***************
*** 41,61 ****
        ~Context()
                        {
!                               // TODO
                        }
  
        // Allocate a local data slot.
-       [TODO]
        public static LocalDataStoreSlot AllocateDataSlot()
                        {
!                               // TODO
!                               return null;
                        }
  
        // Allocate a named local data slot.
-       [TODO]
        public static LocalDataStoreSlot AllocateNamedDataSlot(String name)
                        {
!                               // TODO
!                               return null;
                        }
  
--- 47,63 ----
        ~Context()
                        {
!                               // Nothing to do here.
                        }
  
        // Allocate a local data slot.
        public static LocalDataStoreSlot AllocateDataSlot()
                        {
!                               return Thread.AllocateDataSlot();
                        }
  
        // Allocate a named local data slot.
        public static LocalDataStoreSlot AllocateNamedDataSlot(String name)
                        {
!                               return Thread.AllocateNamedDataSlot("context_" 
+ name);
                        }
  
***************
*** 68,105 ****
  
        // Free a named local data slot.
-       [TODO]
        public static void FreeNamedDataSlot(String name)
                        {
!                               // TODO
                        }
  
        // Freeze this context.
-       [TODO]
        public virtual void Freeze()
                        {
!                               // TODO
                        }
  
        // Get the data stored in a particular data store slot.
-       [TODO]
        public static Object GetData(LocalDataStoreSlot slot)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Get a named data store slot.
-       [TODO]
        public static LocalDataStoreSlot GetNamedDataSlot(String name)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Get a property from this context.
-       [TODO]
        public virtual IContextProperty GetProperty(String name)
                        {
!                               // TODO
                                return null;
                        }
--- 70,128 ----
  
        // Free a named local data slot.
        public static void FreeNamedDataSlot(String name)
                        {
!                               Thread.FreeNamedDataSlot("context_" + name);
                        }
  
        // Freeze this context.
        public virtual void Freeze()
                        {
!                               lock(this)
!                               {
!                                       if(freeze)
!                                       {
!                                               throw new 
InvalidOperationException
!                                                       
(_("Invalid_ContextFrozen"));
!                                       }
!                                       freeze = true;
!                                       if(properties != null)
!                                       {
!                                               foreach(IContextProperty prop 
in properties)
!                                               {
!                                                       prop.Freeze(this);
!                                               }
!                                       }
!                               }
                        }
  
        // Get the data stored in a particular data store slot.
        public static Object GetData(LocalDataStoreSlot slot)
                        {
!                               return Thread.GetData(slot);
                        }
  
        // Get a named data store slot.
        public static LocalDataStoreSlot GetNamedDataSlot(String name)
                        {
!                               return Thread.GetNamedDataSlot("context_" + 
name);
                        }
  
        // Get a property from this context.
        public virtual IContextProperty GetProperty(String name)
                        {
!                               lock(this)
!                               {
!                                       if(name == null || properties == null)
!                                       {
!                                               return null;
!                                       }
!                                       foreach(IContextProperty prop in 
properties)
!                                       {
!                                               if(prop.Name == name)
!                                               {
!                                                       return prop;
!                                               }
!                                       }
!                               }
                                return null;
                        }
***************
*** 115,137 ****
  
        // Set the value of a local data store slot.
-       [TODO]
        public static void SetData(LocalDataStoreSlot slot, Object value)
                        {
!                               // TODO
                        }
  
        // Set a property on this context.
-       [TODO]
        public virtual void SetProperty(IContextProperty prop)
                        {
!                               // TODO
                        }
  
        // Convert this object into a string.
-       [TODO]
        public override String ToString()
                        {
!                               // TODO
!                               return null;
                        }
  
--- 138,202 ----
  
        // Set the value of a local data store slot.
        public static void SetData(LocalDataStoreSlot slot, Object value)
                        {
!                               Thread.SetData(slot, value);
                        }
  
        // Set a property on this context.
        public virtual void SetProperty(IContextProperty prop)
                        {
!                               if(prop == null)
!                               {
!                                       throw new ArgumentNullException("prop");
!                               }
!                               if(prop.Name == null)
!                               {
!                                       throw new 
ArgumentNullException("prop.Name");
!                               }
!                               lock(this)
!                               {
!                                       // The context must not be currently 
frozen.
!                                       if(freeze)
!                                       {
!                                               throw new 
InvalidOperationException
!                                                       
(_("Invalid_ContextFrozen"));
!                                       }
! 
!                                       // Bail out if there is already a 
property with this name.
!                                       if(properties != null)
!                                       {
!                                               foreach(IContextProperty prop2 
in properties)
!                                               {
!                                                       if(prop.Name == 
prop2.Name)
!                                                       {
!                                                               throw new 
InvalidOperationException
!                                                                       
(_("Invalid_PropertyClash"));
!                                                       }
!                                               }
!                                       }
! 
!                                       // Expand the property array and add 
the new element.
!                                       if(properties == null)
!                                       {
!                                               properties = new 
IContextProperty [1];
!                                               properties[0] = prop;
!                                       }
!                                       else
!                                       {
!                                               IContextProperty[] 
newProperties;
!                                               newProperties = new 
IContextProperty
!                                                       [properties.Length + 1];
!                                               Array.Copy(properties, 0, 
newProperties, 0,
!                                                                  
properties.Length);
!                                               properties[properties.Length] = 
prop;
!                                               newProperties = properties;
!                                       }
!                               }
                        }
  
        // Convert this object into a string.
        public override String ToString()
                        {
!                               return "ContextID: " + contextID.ToString();
                        }
  
***************
*** 159,174 ****
                                get
                                {
!                                       return properties;
                                }
                        }
  
!       // Get the default context.
!       [TODO]
        public static Context DefaultContext
                        {
                                get
                                {
!                                       // TODO
!                                       return null;
                                }
                        }
--- 224,252 ----
                                get
                                {
!                                       lock(this)
!                                       {
!                                               if(properties == null)
!                                               {
!                                                       return null;
!                                               }
!                                               return 
(IContextProperty[])(properties.Clone());
!                                       }
                                }
                        }
  
!       // Get the default context for the current application domain.
        public static Context DefaultContext
                        {
                                get
                                {
!                                       AppDomain domain = Thread.GetDomain();
!                                       lock(typeof(Context))
!                                       {
!                                               if(domain.defaultContext == 
null)
!                                               {
!                                                       domain.defaultContext = 
new Context();
!                                               }
!                                               return domain.defaultContext;
!                                       }
                                }
                        }

Index: ContextAttribute.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Runtime/Remoting/Contexts/ContextAttribute.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ContextAttribute.cs 17 Apr 2003 10:36:09 -0000      1.1
--- ContextAttribute.cs 23 Aug 2003 09:44:19 -0000      1.2
***************
*** 79,91 ****
                                (IConstructionCallMessage ctorMsg)
                        {
!                               // TODO
                        }
  
        // Determine if a context is OK with respect to this attribute.
        public virtual bool IsContextOK
!                               (Context ctx, IConstructionCallMessage msg)
                        {
!                               // TODO
!                               return false;
                        }
  
--- 79,107 ----
                                (IConstructionCallMessage ctorMsg)
                        {
!                               if(ctorMsg == null)
!                               {
!                                       throw new 
ArgumentNullException("ctorMsg");
!                               }
!                               ctorMsg.ContextProperties.Add(this);
                        }
  
        // Determine if a context is OK with respect to this attribute.
        public virtual bool IsContextOK
!                               (Context ctx, IConstructionCallMessage ctorMsg)
                        {
!                               if(ctx == null)
!                               {
!                                       throw new ArgumentNullException("ctx");
!                               }
!                               if(ctorMsg == null)
!                               {
!                                       throw new 
ArgumentNullException("ctorMsg");
!                               }
!                               if(!ctorMsg.ActivationType.IsContextful)
!                               {
!                                       return true;
!                               }
!                               Object value = ctx.GetProperty(AttributeName);
!                               return (value != null && this.Equals(value));
                        }
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]