AllocateNamedDataSlot() private method

private AllocateNamedDataSlot ( String name ) : LocalDataStoreSlot
name String
return LocalDataStoreSlot
Ejemplo n.º 1
0
        /// <summary>Looks up a named data slot.</summary>
        /// <returns>Returns a local data slot.</returns>
        /// <param name="name">The data slot name. </param>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
        /// </PermissionSet>
        public static LocalDataStoreSlot GetNamedDataSlot(string name)
        {
            object             syncRoot = Context.namedSlots.SyncRoot;
            LocalDataStoreSlot result;

            lock (syncRoot)
            {
                LocalDataStoreSlot localDataStoreSlot = Context.namedSlots[name] as LocalDataStoreSlot;
                if (localDataStoreSlot == null)
                {
                    result = Context.AllocateNamedDataSlot(name);
                }
                else
                {
                    result = localDataStoreSlot;
                }
            }
            return(result);
        }