public CacheDebugEntry(IContextKey key, GlobalPersistentContext value)
            {
                this.Value = value;
                var fields = key.GetType().GetFields(Flags.InstanceAnyDeclaredOnly);

                for (int i = 0; i < fields.Length; i++)
                {
                    switch (i)
                    {
                    case 0:
                        this.Alpha = fields[i].GetValue(key).ToString();
                        break;

                    case 1:
                        this.Beta = fields[i].GetValue(key).ToString();
                        break;

                    case 2:
                        this.Delta = fields[i].GetValue(key).ToString();
                        break;

                    case 3:
                        this.Epsilon = fields[i].GetValue(key).ToString();
                        break;

                    case 4:
                        this.Gamma = fields[i].GetValue(key).ToString();
                        break;
                    }
                }
            }
		private LocalPersistentContext(GlobalPersistentContext<T> global)
		{
			if (global == null) { throw new ArgumentNullException("global"); }

			this.context = global;
			this.localValue = this.context.Value;
		}
Exemplo n.º 3
0
        private GlobalPersistentContext <TValue> TryGetContext <TValue>(IContextKey key, out bool isNew)
        {
            GlobalPersistentContext context;

            if (this.EnableCaching && this.cache.TryGetValue(key, out context) && context is GlobalPersistentContext <TValue> )
            {
                isNew = false;
                return((GlobalPersistentContext <TValue>)context);
            }
            else
            {
                isNew = true;
                GlobalPersistentContext <TValue> c = GlobalPersistentContext <TValue> .Create();

                this.cache[key] = c;

                return(c);
            }
        }
		/// <summary>
		/// Creates a local context object for the provided global context.
		/// </summary>
		/// <param name="global">The global context object.</param>
		public static LocalPersistentContext<T> Create(GlobalPersistentContext<T> global)
		{
			return new LocalPersistentContext<T>(global);
		}