本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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"));
}
示例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");
}
示例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"));
}
示例8: SaveContextToStore
private static void SaveContextToStore(LocalDataStoreSlot storeSlot, CSContext context)
{
Thread.SetData(storeSlot, context);
}
示例9: ValidateSlot
public void ValidateSlot(LocalDataStoreSlot slot)
{
if (slot == null || slot.Manager != this)
{
throw new ArgumentException(Environment.GetResourceString("Argument_ALSInvalidSlot"));
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例13: EventProvider
public EventProvider(Guid providerGuid)
{
this.m_providerId = providerGuid;
s_returnCodeSlot = Thread.AllocateDataSlot();
Thread.SetData(s_returnCodeSlot, 0);
this.EtwRegister();
}
示例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);
}
示例15: TxDataContextDriver
static TxDataContextDriver()
{
AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;
_threadStorageSlot = Thread.AllocateDataSlot();
CopySampleTraces();
}