public void FreeNamedDataSlotRemovesData()
        {
            IThreadStorage storage = CreateStorage();

            object value1 = new object();

            storage.SetData("key", value1);
            Assert.AreSame(value1, storage.GetData("key"));
            storage.FreeNamedDataSlot("key");
            Assert.AreSame(null, storage.GetData("key"));
        }
        public void AllowReplaceData()
        {
            IThreadStorage storage = CreateStorage();

            object value1 = new object();
            object value2 = new object();

            storage.SetData("key", value1);
            Assert.AreSame(value1, storage.GetData("key"));
            storage.SetData("key", value2);
            Assert.AreSame(value2, storage.GetData("key"));
            storage.SetData("key", null);
            Assert.AreSame(null, storage.GetData("key"));
        }
        public void IsCaseSensitive()
        {
            IThreadStorage storage = CreateStorage();

            object value1 = new object();
            object value2 = new object();
            object value3 = new object();

            storage.SetData("key", value1);
            storage.SetData("KEY", value2);
            storage.SetData("KeY", value3);

            Assert.AreSame(value1, storage.GetData("key"));
            Assert.AreSame(value2, storage.GetData("KEY"));
            Assert.AreSame(value3, storage.GetData("KeY"));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Retrieves an object with the specified <paramref name="name"/>.
 /// </summary>
 /// <param name="name">The name of the item.</param>
 /// <returns>
 /// The object in the current thread's context associated with the
 /// specified <paramref name="name"/> or null if no object has been stored previously
 /// </returns>
 public object GetData(string name)
 {
     if (primaryStorage.IsAvailable())
     {
         return(primaryStorage.GetData(name));
     }
     else if (secondaryStorage.IsAvailable())
     {
         return(secondaryStorage.GetData(name));
     }
     else
     {
         throw createNotSupportedException();
     }
 }
 /// <summary>
 /// Retrieves an object with the specified name.
 /// </summary>
 /// <param name="name">The name of the item.</param>
 /// <returns>The object in the context associated with the specified name or null if no object has been stored previously</returns>
 public static object GetData(string name)
 {
     return(threadStorage.GetData(name));
 }
        public void UnknownKeyReturnsNull()
        {
            IThreadStorage storage = CreateStorage();

            Assert.AreSame(null, storage.GetData("key"));
        }
 private void Run()
 {
     outer.ThreadSetup();
     value = storage.GetData("key");
 }
Exemplo n.º 8
0
 public static T GetData <T>(string name)
 {
     return(threadStorage.GetData <T>(name));
 }