当前位置: 首页>>代码示例>>C#>>正文


C# System.LocalDataStoreSlot类代码示例

本文整理汇总了C#中System.LocalDataStoreSlot的典型用法代码示例。如果您正苦于以下问题:C# LocalDataStoreSlot类的具体用法?C# LocalDataStoreSlot怎么用?C# LocalDataStoreSlot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LocalDataStoreSlot类属于System命名空间,在下文中一共展示了LocalDataStoreSlot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetData

        /*=========================================================================
        ** Retrieves the value from the specified slot.
        =========================================================================*/
        public Object GetData(LocalDataStoreSlot slot)
        {
            Object o = null;

            // Validate the slot.
            m_Manager.ValidateSlot(slot);

            // Cache the slot index to avoid synchronization issues.
            int slotIdx = slot.Slot;

            if (slotIdx >= 0)
            {
                // Delay expansion of m_DataTable if we can
                if (slotIdx >= m_DataTable.Length)
                    return null;

                // Retrieve the data from the given slot.
                o = m_DataTable[slotIdx];
            }

            // Check if the slot has become invalid.
            if (!slot.IsValid())
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
            return o;
        }
开发者ID:ArildF,项目名称:masters,代码行数:28,代码来源:_localdatastore.cs

示例2: AllocateDataSlot

 public LocalDataStoreSlot AllocateDataSlot()
 {
     LocalDataStoreSlot slot2;
     bool lockTaken = false;
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         long num4;
         Monitor.Enter(this, ref lockTaken);
         int length = this.m_SlotInfoTable.Length;
         if (this.m_FirstAvailableSlot >= length)
         {
             int num2;
             if (length < 0x200)
             {
                 num2 = length * 2;
             }
             else
             {
                 num2 = length + 0x80;
             }
             bool[] destinationArray = new bool[num2];
             Array.Copy(this.m_SlotInfoTable, destinationArray, length);
             this.m_SlotInfoTable = destinationArray;
             this.m_FirstAvailableSlot = length;
             length = num2;
         }
         int firstAvailableSlot = this.m_FirstAvailableSlot;
         while (true)
         {
             if (!this.m_SlotInfoTable[firstAvailableSlot])
             {
                 break;
             }
             firstAvailableSlot++;
         }
         this.m_SlotInfoTable[firstAvailableSlot] = true;
         this.m_CookieGenerator = (num4 = this.m_CookieGenerator) + 1L;
         LocalDataStoreSlot slot = new LocalDataStoreSlot(this, firstAvailableSlot, num4);
         firstAvailableSlot++;
         while (firstAvailableSlot < length)
         {
             if (this.m_SlotInfoTable[firstAvailableSlot])
             {
                 break;
             }
             firstAvailableSlot++;
         }
         this.m_FirstAvailableSlot = firstAvailableSlot;
         slot2 = slot;
     }
     finally
     {
         if (lockTaken)
         {
             Monitor.Exit(this);
         }
     }
     return slot2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:60,代码来源:LocalDataStoreMgr.cs

示例3: PopulateElement

		private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot)
		{
			bool flag = false;
			RuntimeHelpers.PrepareConstrainedRegions();
			LocalDataStoreElement result;
			try
			{
				Monitor.Enter(this.m_Manager, ref flag);
				int slot2 = slot.Slot;
				if (slot2 < 0)
				{
					throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
				}
				if (slot2 >= this.m_DataTable.Length)
				{
					int slotTableLength = this.m_Manager.GetSlotTableLength();
					LocalDataStoreElement[] array = new LocalDataStoreElement[slotTableLength];
					Array.Copy(this.m_DataTable, array, this.m_DataTable.Length);
					this.m_DataTable = array;
				}
				if (this.m_DataTable[slot2] == null)
				{
					this.m_DataTable[slot2] = new LocalDataStoreElement(slot.Cookie);
				}
				result = this.m_DataTable[slot2];
			}
			finally
			{
				if (flag)
				{
					Monitor.Exit(this.m_Manager);
				}
			}
			return result;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:35,代码来源:LocalDataStore.cs

示例4: AllocateDataSlot

 public LocalDataStoreSlot AllocateDataSlot()
 {
     LocalDataStoreSlot slot2;
     bool tookLock = false;
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         LocalDataStoreSlot slot;
         int num3;
         Monitor.ReliableEnter(this, ref tookLock);
         int length = this.m_SlotInfoTable.Length;
         if (this.m_FirstAvailableSlot < length)
         {
             slot = new LocalDataStoreSlot(this, this.m_FirstAvailableSlot);
             this.m_SlotInfoTable[this.m_FirstAvailableSlot] = 1;
             int index = this.m_FirstAvailableSlot + 1;
             while (index < length)
             {
                 if ((this.m_SlotInfoTable[index] & 1) == 0)
                 {
                     break;
                 }
                 index++;
             }
             this.m_FirstAvailableSlot = index;
             return slot;
         }
         if (length < 0x200)
         {
             num3 = length * 2;
         }
         else
         {
             num3 = length + 0x80;
         }
         byte[] destinationArray = new byte[num3];
         Array.Copy(this.m_SlotInfoTable, destinationArray, length);
         this.m_SlotInfoTable = destinationArray;
         slot = new LocalDataStoreSlot(this, length);
         this.m_SlotInfoTable[length] = 1;
         this.m_FirstAvailableSlot = length + 1;
         slot2 = slot;
     }
     finally
     {
         if (tookLock)
         {
             Monitor.Exit(this);
         }
     }
     return slot2;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:52,代码来源:LocalDataStoreMgr.cs

示例5: SetData

		public void SetData(LocalDataStoreSlot slot, object data)
		{
			this.m_Manager.ValidateSlot(slot);
			int slot2 = slot.Slot;
			if (slot2 >= 0)
			{
				LocalDataStoreElement localDataStoreElement = (slot2 < this.m_DataTable.Length) ? this.m_DataTable[slot2] : null;
				if (localDataStoreElement == null)
				{
					localDataStoreElement = this.PopulateElement(slot);
				}
				if (localDataStoreElement.Cookie == slot.Cookie)
				{
					localDataStoreElement.Value = data;
					return;
				}
			}
			throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:19,代码来源:LocalDataStore.cs

示例6: TestDatastore

		public void TestDatastore ()
		{
			otherCtx = cbo.GetContext ();
			
			slot = Context.AllocateDataSlot ();
			LocalDataStoreSlot namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
			LocalDataStoreSlot namedSlot2 = Context.GetNamedDataSlot ("slot2");
			
			Context.SetData (slot, "data");
			Context.SetData (namedSlot1, "data1");
			Context.SetData (namedSlot2, "data2");
			
			otherCtx.DoCallBack (new CrossContextDelegate (CheckOtherContextDatastore));
			
			Assert.IsTrue (Context.GetData (slot).Equals ("data"), "Wrong data 1");
			Assert.IsTrue (Context.GetData (namedSlot1).Equals ("data1"), "Wrong data 2");
			Assert.IsTrue (Context.GetData (namedSlot2).Equals ("data2"), "Wrong data 3");
			
			try
			{
				namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
				Assert.Fail ("Exception expected");
			}
			catch {}
			
			Context.FreeNamedDataSlot ("slot1");
			Context.FreeNamedDataSlot ("slot2");
			
			try
			{
				namedSlot1 = Context.AllocateNamedDataSlot ("slot1");
			}
			catch 
			{
				Assert.Fail ("Exception not expected");
			}
			
			Context.FreeNamedDataSlot ("slot1");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:39,代码来源:ContextTest.cs

示例7: GetData

		public object GetData(LocalDataStoreSlot slot)
		{
			this.m_Manager.ValidateSlot(slot);
			int slot2 = slot.Slot;
			if (slot2 >= 0)
			{
				if (slot2 >= this.m_DataTable.Length)
				{
					return null;
				}
				LocalDataStoreElement localDataStoreElement = this.m_DataTable[slot2];
				if (localDataStoreElement == null)
				{
					return null;
				}
				if (localDataStoreElement.Cookie == slot.Cookie)
				{
					return localDataStoreElement.Value;
				}
			}
			throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:22,代码来源:LocalDataStore.cs

示例8: SaveContextToStore

 private static void SaveContextToStore(LocalDataStoreSlot storeSlot, CSContext context)
 {
     Thread.SetData(storeSlot, context);
 }
开发者ID:pcstx,项目名称:OA,代码行数:4,代码来源:CSContext.cs

示例9: ValidateSlot

		public void ValidateSlot(LocalDataStoreSlot slot)
		{
			if (slot == null || slot.Manager != this)
			{
				throw new ArgumentException(Environment.GetResourceString("Argument_ALSInvalidSlot"));
			}
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:7,代码来源:LocalDataStoreMgr.cs

示例10: PopulateElement

        [System.Security.SecuritySafeCritical]  // auto-generated
        private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot)
        {
            bool tookLock = false;
            RuntimeHelpers.PrepareConstrainedRegions();
            try {
                Monitor.Enter(m_Manager, ref tookLock);

                // Make sure that the slot was not freed in the meantime
                int slotIdx = slot.Slot;
                if (slotIdx < 0)
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));

                if (slotIdx >= m_DataTable.Length)
                {
                    int capacity = m_Manager.GetSlotTableLength();

                    // Validate that the specified capacity is larger than the current one.
                    Contract.Assert(capacity >= m_DataTable.Length, "LocalDataStore corrupted: capacity >= m_DataTable.Length");

                    // Allocate the new data table.
                    LocalDataStoreElement[] NewDataTable = new LocalDataStoreElement[capacity];

                    // Copy all the objects into the new table.
                    Array.Copy(m_DataTable, NewDataTable, m_DataTable.Length);

                    // Save the new table.
                    m_DataTable = NewDataTable;
                }

                // Validate that there is enough space in the local data store now
                Contract.Assert(slotIdx < m_DataTable.Length, "LocalDataStore corrupted: slotIdx < m_DataTable.Length");

                if (m_DataTable[slotIdx] == null)
                    m_DataTable[slotIdx] = new LocalDataStoreElement(slot.Cookie);

                return m_DataTable[slotIdx];
            }
            finally {
                if (tookLock)
                    Monitor.Exit(m_Manager);
            }
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:43,代码来源:_LocalDataStore.cs

示例11: Repository

 /// <summary>
 /// Static constructor creates a new session factory used by all instances
 /// of this class.
 /// </summary>
 static Repository()
 {
     Configuration cfg = new Configuration();
     cfg.AddAssembly("SFASystem.Domain");
     factory = cfg.BuildSessionFactory();
     mysessions =  Thread.AllocateDataSlot();
 }
开发者ID:tsubik,项目名称:SFASystem,代码行数:11,代码来源:repository.cs

示例12: DatabaseControl

        static DatabaseControl()
        {
            //log4net.Config.XmlConfigurator.Configure();

            AutoMappingConfiguration cfg = new AutoMappingConfiguration();

            System.Reflection.Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(w => w.FullName.Contains("ComprasColetivas.Domain.Model")).ToArray();

            factory = Fluently.Configure()

                .Database(MsSqlConfiguration.MsSql2008.ConnectionString(Properties.Settings.Default.ConnectionStringSQLServer).ShowSql())
                .Mappings(m =>
                {
                    m.AutoMappings.Add(AutoMap.Assemblies(cfg, assemblies).Conventions.Setup(c =>
                    {
                        c.Add<PrimaryKeyConvention>();
                        c.Add<CustomForeignKeyConvention>();
                        c.Add<DefaultStringLengthConvention>();
                        c.Add<TableConvention>();
                        c.Add<EnumMappingConvention>();

                    })
                                                                                                   );
                    m.AutoMappings.ToList()[0].IncludeBase<Pessoa>();
                    m.AutoMappings.ToList()[0].IncludeBase<Pagamento>();

                }).ExposeConfiguration(BuildSchema).BuildSessionFactory();

            mysessions = Thread.AllocateDataSlot();
        }
开发者ID:hmattoso,项目名称:scc,代码行数:30,代码来源:DatabaseControl.cs

示例13: EventProvider

 public EventProvider(Guid providerGuid)
 {
     this.m_providerId = providerGuid;
     s_returnCodeSlot = Thread.AllocateDataSlot();
     Thread.SetData(s_returnCodeSlot, 0);
     this.EtwRegister();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:EventProvider.cs

示例14: InitHttpEnv

		/// <summary>
		/// 根据Request对象初始化所需环境信息
		/// </summary>
		/// <param name="request"></param>
		public static void InitHttpEnv(HttpRequest request)
		{
			HttpEnvInfo hei = new HttpEnvInfo(request);

			_HttpEnvSlot = Thread.AllocateDataSlot();
			Thread.SetData(_HttpEnvSlot, hei as IHttpEnvInterface);
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:11,代码来源:GlobalInfo.cs

示例15: TxDataContextDriver

        static TxDataContextDriver()
        {
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;
            _threadStorageSlot = Thread.AllocateDataSlot();

            CopySampleTraces();
        }
开发者ID:modulexcite,项目名称:Tx,代码行数:7,代码来源:TxDataContextDriver.cs


注:本文中的System.LocalDataStoreSlot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。