예제 #1
0
        private CacheManager CreateCacheManager(string cacheManagerName)
        {
            CacheManager cacheManager = cacheManagers[cacheManagerName] as CacheManager;

            if (cacheManager != null)
            {
                return(cacheManager);
            }

            CachingConfigurationView      view             = new CachingConfigurationView(ConfigurationContext);
            CacheManagerData              cacheManagerData = view.GetCacheManagerData(cacheManagerName);
            CacheCapacityScavengingPolicy scavengingPolicy =
                new CacheCapacityScavengingPolicy(cacheManagerName, view);

            IBackingStore backingStore = backingStoreFactory.CreateBackingStore(cacheManagerName);
            Cache         cache        = new Cache(backingStore, scavengingPolicy);

            ExpirationPollTimer timer          = new ExpirationPollTimer();
            ExpirationTask      expirationTask = CreateExpirationTask(cache);
            ScavengerTask       scavengerTask  = new ScavengerTask(cacheManagerName, view, scavengingPolicy, cache);
            BackgroundScheduler scheduler      = new BackgroundScheduler(expirationTask, scavengerTask);

            cache.Initialize(scheduler);

            scheduler.Start();
            timer.StartPolling(new TimerCallback(scheduler.ExpirationTimeoutExpired), cacheManagerData.ExpirationPollFrequencyInSeconds * 1000);

            cacheManager = new CacheManager(cache, scheduler, timer);
            cacheManagers.Add(cacheManagerName, cacheManager);
            return(cacheManager);
        }
        void IContainerPolicyCreator.CreatePolicies(
            IPolicyList policyList,
            string instanceName,
            ConfigurationElement configurationObject,
            IConfigurationSource configurationSource)
        {
            CacheManagerData castConfigurationObject = (CacheManagerData)configurationObject;
            var cacheManagerName = instanceName;
            var cacheStorageName = castConfigurationObject.CacheStorage;
            var maximumElementsInCacheBeforeScavenging = castConfigurationObject.MaximumElementsInCacheBeforeScavenging;
            var numberToRemoveWhenScavenging           = castConfigurationObject.NumberToRemoveWhenScavenging;
            var expirationPollFrequencyInSeconds       = castConfigurationObject.ExpirationPollFrequencyInSeconds;

            policyList.Set <IBuildPlanPolicy>(
                new DelegateBuildPlanPolicy(
                    context =>
            {
                IBuilderContext backingStoreContext
                    = context.CloneForNewBuild(NamedTypeBuildKey.Make <IBackingStore>(cacheStorageName), null);
                IBackingStore backingStore = (IBackingStore)context.Strategies.ExecuteBuildUp(backingStoreContext);
                CachingInstrumentationProvider instrumentationProvider
                    = CreateInstrumentationProvider(cacheManagerName, configurationSource);
                return(new CacheManagerFactoryHelper().BuildCacheManager(
                           cacheManagerName,
                           backingStore,
                           maximumElementsInCacheBeforeScavenging,
                           numberToRemoveWhenScavenging,
                           expirationPollFrequencyInSeconds,
                           instrumentationProvider));
            }),
                NamedTypeBuildKey.Make <CacheManager>(cacheManagerName));
        }
예제 #3
0
        public ShellPresenter(IBackingStore backingStore, IWorkspacePresenter workspacePresenter)
        {
            _backingStore = backingStore;

            Screens.Add(workspacePresenter);
            Workspace = workspacePresenter;
        }
        /// <summary>
        /// Made public for testing purposes.
        /// </summary>
        public CacheManager BuildCacheManager(
            string cacheManagerName,
            IBackingStore backingStore,
            int maximumElementsInCacheBeforeScavenging,
            int numberToRemoveWhenScavenging,
            int expirationPollFrequencyInSeconds,
            CachingInstrumentationProvider instrumentationProvider)
        {
            CacheCapacityScavengingPolicy scavengingPolicy =
                new CacheCapacityScavengingPolicy(maximumElementsInCacheBeforeScavenging);

            Cache cache = new Cache(backingStore, scavengingPolicy, instrumentationProvider);

            ExpirationPollTimer timer          = new ExpirationPollTimer();
            ExpirationTask      expirationTask = CreateExpirationTask(cache, instrumentationProvider);
            ScavengerTask       scavengerTask  = new ScavengerTask(numberToRemoveWhenScavenging, scavengingPolicy, cache, instrumentationProvider);
            BackgroundScheduler scheduler      = new BackgroundScheduler(expirationTask, scavengerTask, instrumentationProvider);

            cache.Initialize(scheduler);

            scheduler.Start();
            timer.StartPolling(new TimerCallback(scheduler.ExpirationTimeoutExpired), expirationPollFrequencyInSeconds * 1000);

            return(new CacheManager(cache, scheduler, timer));
        }
예제 #5
0
 public UnboundedCache(IBackingStore <TKey, TValue> backingStore, TaskScheduler taskScheduler = null)
 {
     _backingStore  = backingStore;
     _taskScheduler = taskScheduler ?? TaskScheduler.Default;
     _taskFactory   = new TaskFactory(_taskScheduler);
     _cache         = new Dictionary <TKey, TValue>();
 }
        private void DoStringContains(Stack <IOperand> operands, IBackingStore variables, long parserPosition)
        {
            IOperand second = OperatorActions.PopAndResolve(operands, variables);
            IOperand first  = OperatorActions.PopAndResolve(operands, variables);

            operands.Push(new Operand(-1, OperandType.Bool, ((string)first.GetValue()).Contains((string)second.GetValue())));
        }
        private static void DoExp(Stack <IOperand> stack, IBackingStore store, long paramCount)
        {
            IOperand first  = OperatorActions.PopAndResolve(stack, store);
            double   val    = Convert.ToDouble(first.GetValue());
            var      result = Math.Exp(val);

            stack.Push(new Operand(-1, OperandType.Double, result));
        }
 /// <summary>
 /// Dispose of the backing store before garbage collection.
 /// </summary>
 /// <param name="disposing">
 /// <see langword="true"/> if disposing; otherwise, <see langword="false"/>.
 /// </param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         backingStore.Dispose();
         backingStore = null;
     }
 }
        public NonExpiringCache(IBackingStore storage)
        {
            if (storage == null)
            {
                throw new ArgumentNullException(nameof(storage));
            }

            this.storage = storage;
        }
        internal static void DoMultiply(Stack <IOperand> stack, IBackingStore backingStore, long parserPosition)
        {
            IOperand second = PopAndResolve(stack, backingStore);
            IOperand first  = PopAndResolve(stack, backingStore);

            // Don't do this in production code.
            var matrix = Parser.FunctionMatrices.MultiplyMatrix.Create();

            stack.Push(matrix.PerformDelegate(first, second));
        }
예제 #11
0
 protected void SetUp()
 {
     mockery                 = new Mockery();
     mockBackingStore        = mockery.NewMock <IBackingStore>();
     fakeBackingStoreRequest = (Int32 key) =>
     {
         return(mockBackingStore.Retrieve(key));
     };
     testLRUCache = new LRUCache <Int32, String>(fakeBackingStoreRequest, 3, out expiryQueue);
 }
예제 #12
0
파일: Cache.cs 프로젝트: bnantz/NCS-V1-1
        public Cache(IBackingStore backingStore, CacheCapacityScavengingPolicy scavengingPolicy)
        {
            this.backingStore = backingStore;
            this.scavengingPolicy = scavengingPolicy;

            Hashtable initialItems = backingStore.Load();
            inMemoryCache = Hashtable.Synchronized(initialItems);

            CachingServiceItemTurnoverEvent.SetItemsTotal(Count);
        }
예제 #13
0
파일: Cache.cs 프로젝트: smillea1/NCS-V1-1
        public Cache(IBackingStore backingStore, CacheCapacityScavengingPolicy scavengingPolicy)
        {
            this.backingStore     = backingStore;
            this.scavengingPolicy = scavengingPolicy;

            Hashtable initialItems = backingStore.Load();

            inMemoryCache = Hashtable.Synchronized(initialItems);

            CachingServiceItemTurnoverEvent.SetItemsTotal(Count);
        }
        public static OperandStack Evaluate(ExpressionTree tree, IBackingStore backingStore)
        {
            var operandStack = new OperandStack();

            for (int c = tree.RootNodeList.Count - 1; c >= 0; c--)
            {
                Evaluate(tree.RootNodeList[c], operandStack, backingStore);
            }

            return(operandStack);
        }
예제 #15
0
		/// <summary>
		/// Initialzie a new instance of a <see cref="Cache"/> class with a backing store, and scavenging policy.
		/// </summary>
		/// <param name="backingStore">The cache backing store.</param>
		/// <param name="scavengingPolicy">The scavenging policy.</param>
		/// <param name="instrumentationProvider">The instrumentation provider.</param>
		public Cache(IBackingStore backingStore, CacheCapacityScavengingPolicy scavengingPolicy, CachingInstrumentationProvider instrumentationProvider)
        {
            this.backingStore = backingStore;
            this.scavengingPolicy = scavengingPolicy;
			this.instrumentationProvider = instrumentationProvider;

            Hashtable initialItems = backingStore.Load();
            inMemoryCache = Hashtable.Synchronized(initialItems);

			this.instrumentationProvider.FireCacheUpdated(initialItems.Count, initialItems.Count);
        }
예제 #16
0
파일: Feature.cs 프로젝트: ilmax/Ensign
 public Feature(
     IBackingStore backingStore,
     string name,
     int percentageEnabled = 0,
     List <IGroup> groups  = null)
 {
     _backingStore    = backingStore;
     _groups          = groups ?? new List <IGroup>();
     Name             = name;
     GlobalPercentage = percentageEnabled;
 }
예제 #17
0
        /// <summary>
        /// Initialzie a new instance of a <see cref="Cache"/> class with a backing store, and scavenging policy.
        /// </summary>
        /// <param name="backingStore">The cache backing store.</param>
        /// <param name="scavengingPolicy">The scavenging policy.</param>
        /// <param name="instrumentationProvider">The instrumentation provider.</param>
        public Cache(IBackingStore backingStore, CacheCapacityScavengingPolicy scavengingPolicy, CachingInstrumentationProvider instrumentationProvider)
        {
            this.backingStore            = backingStore;
            this.scavengingPolicy        = scavengingPolicy;
            this.instrumentationProvider = instrumentationProvider;

            Hashtable initialItems = backingStore.Load();

            inMemoryCache = Hashtable.Synchronized(initialItems);

            this.instrumentationProvider.FireCacheUpdated(initialItems.Count, initialItems.Count);
        }
        public void SetUp()
        {
            instrumentationProvider = new CachingInstrumentationProvider();
            instrumentationListener = new MockCachingInstrumentationListener();

            ReflectionInstrumentationBinder binder = new ReflectionInstrumentationBinder();

            binder.Bind(instrumentationProvider, instrumentationListener);

            backingStore  = new NullBackingStore();
            factoryHelper = new MockCacheManagerFactoryHelper();
        }
예제 #19
0
파일: Cache.cs 프로젝트: CrazyTiger/Test
        /// <summary>
        /// </summary>
        /// <param name="backingStore">Резервное хранилище.</param>
        /// <param name="instrumentationProvider">Инструментарий для событий</param>
        public Cache(IBackingStore backingStore, ICachingInstrumentationProvider instrumentationProvider)
        {
            if (backingStore == null) throw new ArgumentNullException("backingStore");
            if (instrumentationProvider == null) throw new ArgumentNullException("instrumentationProvider");

            this.backingStore = backingStore;
            this.instrumentationProvider = instrumentationProvider;

            var initialItems = backingStore.Load();
            inMemoryCache = Hashtable.Synchronized(initialItems);

            this.instrumentationProvider.FireCacheUpdated(initialItems.Count, initialItems.Count);
        }
            public static CacheManager Create(string name, IConfigurationSource configurationSource)
            {
                CachingConfigurationView configurationView   = new CachingConfigurationView(configurationSource);
                CacheManagerData         objectConfiguration = configurationView.GetCacheManagerData(name);

                IBackingStore backingStore =
                    EnterpriseLibraryFactory.BuildUp <IBackingStore>(objectConfiguration.CacheStorage, configurationSource);

                return(new MockCacheManagerFactoryHelper().BuildCacheManager(
                           name,
                           backingStore,
                           objectConfiguration.MaximumElementsInCacheBeforeScavenging,
                           objectConfiguration.NumberToRemoveWhenScavenging,
                           objectConfiguration.ExpirationPollFrequencyInSeconds,
                           new CachingInstrumentationProvider()));
            }
        protected override void WithContext()
        {
            mockPartition1 = MockRepository.GenerateStub<IPartition>();
            mockPartition2 = MockRepository.GenerateStub<IPartition>();
            mockBackingStore1 = MockRepository.GenerateMock<IBackingStore>();
            mockBackingStore2 = MockRepository.GenerateMock<IBackingStore>();
            mockQuery = MockRepository.GenerateStub<IPartitionedQuery>();

            backingStores = new Dictionary<IPartition, IBackingStore>
                {
                    {mockPartition1, mockBackingStore1},
                    {mockPartition2, mockBackingStore2}
                };

            sut = new PartitioningBackingStore(backingStores);
        }
예제 #22
0
        /// <summary>
        /// Called by the Evaluator when it encounters 'StringContains'
        /// long StringContains(string source, string subString, bool isCaseSensitive)
        /// Returns index of subString, or -1
        /// </summary>
        private void DoStringContains(Stack <IOperand> operands, IBackingStore backingStore, long parserPosition)
        {
            // Pop the correct number of parameters from the operands stack, ** in reverse order **
            // If an operand is a variable, it is resolved from the variables provided
            IOperand third  = OperatorActions.PopAndResolve(operands, backingStore);
            IOperand second = OperatorActions.PopAndResolve(operands, backingStore);
            IOperand first  = OperatorActions.PopAndResolve(operands, backingStore);

            string           strSource    = (string)first.GetValue();
            string           strSubstring = (string)second.GetValue();
            StringComparison comparison   = (bool)third.GetValue() == true ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;

            long result = strSource.IndexOf(strSubstring, comparison);

            operands.Push(new Operand(-1, OperandType.Long, result));
        }
        public static OperandStack Evaluate(IEnumerable <IToken> rpnTokens, IBackingStore backingStore)
        {
            var operandStack = new OperandStack();

            foreach (IToken token in rpnTokens)
            {
                if (token.TokenType == TokenType.Operand)
                {
                    operandStack.Push((IOperand)token);
                }
                else
                {
                    ((OperatorWrapper)token).WrappedOperator.DoOperation(operandStack, backingStore, token.ParserPosition);
                }
            }
            return(operandStack);
        }
예제 #24
0
        public ICacheManager Assemble(IBuilderContext context, CacheManagerDataBase objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            CacheManagerData cacheManagerData = (CacheManagerData)objectConfiguration;
            IBackingStore    backingStore
                = BackingStoreCustomFactory.Instance.Create(context, cacheManagerData.CacheStorage, configurationSource, reflectionCache);
            CachingInstrumentationProvider instrumentationProvider = CreateInstrumentationProvider(cacheManagerData.Name, configurationSource, reflectionCache);
            CacheManager createdObject
                = new CacheManagerFactoryHelper().BuildCacheManager(
                      cacheManagerData.Name,
                      backingStore,
                      cacheManagerData.MaximumElementsInCacheBeforeScavenging,
                      cacheManagerData.NumberToRemoveWhenScavenging,
                      cacheManagerData.ExpirationPollFrequencyInSeconds,
                      instrumentationProvider);

            return(createdObject);
        }
        private static void DoLerp(Stack <IOperand> operandStack, IBackingStore backingStore, long paramCount)
        {
            // Pop the correct number of parameters from the operands stack, ** in reverse order **
            // If an operand is a variable, it is resolved from the backing store provided
            IOperand third  = OperatorActions.PopAndResolve(operandStack, backingStore);
            IOperand second = OperatorActions.PopAndResolve(operandStack, backingStore);
            IOperand first  = OperatorActions.PopAndResolve(operandStack, backingStore);

            double a = Convert.ToDouble(first.GetValue());
            double b = Convert.ToDouble(second.GetValue());
            double t = Convert.ToDouble(third.GetValue());

            // The result is of type double
            double result = a + t * (b - a);

            // Push the result back onto the operand stack
            operandStack.Push(new Operand(-1, OperandType.Double, result));
        }
        public static OperandStack Evaluate(IEnumerable <IToken> rpnTokens, IBackingStore backingStore)
        {
            var tree         = new ExpressionTree(rpnTokens);
            var operandStack = new OperandStack();

            foreach (var node in tree.RootNodeList)
            {
                Evaluate(node, operandStack, backingStore);
            }

            var resultStack = new OperandStack();

            while (operandStack.Count != 0)
            {
                resultStack.Push(operandStack.Pop());
            }

            return(resultStack);
        }
        /// <summary>
        /// Peeks an operand from the stack. If it's a variable it returns an operand holding the variable value, otherwise it returns the operand.
        /// </summary>
        /// <param name="stack"></param>
        /// <param name="variables"></param>
        /// <returns></returns>
        public static IOperand PeekAndResolve(Stack <IOperand> stack, IBackingStore backingStore)
        {
            IOperand operand = stack.Peek();

            if (operand.Type == OperandType.Variable)
            {
                //var variable = ResolveVariable(variables, retVal);

                try
                {
                    var valueAndType = backingStore.GetValue((string)operand.GetValue());
                    operand = new Operand(operand.ParserPosition, valueAndType.type, valueAndType.value);
                }
                catch// (KeyNotFoundException)
                {
                    throw new ExpressionEvaluatorException(operand.ParserPosition, ExpressionEvaluatorException.ExceptionCause.UndefinedVariable, $"'{operand.GetValue().ToString()}'");
                }
            }
            return(operand);
        }
        /// <summary>
        /// Initialzie a new instance of a <see cref="Cache"/> class with a backing store, and scavenging policy.
        /// </summary>
        /// <param name="backingStore">The cache backing store.</param>
        /// <param name="instrumentationProvider">The instrumentation provider.</param>
        public Cache(IBackingStore backingStore, ICachingInstrumentationProvider instrumentationProvider)
        {
            if (backingStore == null)
            {
                throw new ArgumentNullException("backingStore");
            }
            if (instrumentationProvider == null)
            {
                throw new ArgumentNullException("instrumentationProvider");
            }

            this.backingStore            = backingStore;
            this.instrumentationProvider = instrumentationProvider;

            Hashtable initialItems = backingStore.Load();

            inMemoryCache = Hashtable.Synchronized(initialItems);

            this.instrumentationProvider.FireCacheUpdated(initialItems.Count, initialItems.Count);
        }
예제 #29
0
        public void CanBuildCustomBackingStoreFromGivenConfiguration()
        {
            CustomCacheStorageData customData
                = new CustomCacheStorageData("custom", typeof(MockCustomStorageBackingStore));

            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            CacheManagerSettings settings = new CacheManagerSettings();

            settings.BackingStores.Add(customData);
            settings.CacheManagers.Add(new CacheManagerData("ignore", 0, 0, 0, "custom"));
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();

            configurationSource.Add(CacheManagerSettings.SectionName, settings);

            IBackingStore custom
                = EnterpriseLibraryContainer.CreateDefaultContainer(configurationSource).GetInstance <IBackingStore>("custom");

            Assert.IsNotNull(custom);
            Assert.AreSame(typeof(MockCustomStorageBackingStore), custom.GetType());
            Assert.AreEqual("value1", ((MockCustomStorageBackingStore)custom).customValue);
        }
        /// <summary>
        /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
        /// Builds a <see cref="CacheManagerData"/> described by the <see cref="CacheManagerSettings"/> configuration section.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="name">The name of the instance to build. It is part of the <see cref="ICustomFactory.CreateObject(IBuilderContext, string, IConfigurationSource, ConfigurationReflectionCache)"/> method, but it is not used in this implementation.</param>
        /// <param name="configurationSource">The source for configuration objects.</param>
        /// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
        /// <returns>A fully initialized instance of <see cref="CacheManager"/>.</returns>
        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            CacheManagerData objectConfiguration = GetConfiguration(name, configurationSource);

            IBackingStore backingStore
                = BackingStoreCustomFactory.Instance.Create(context, objectConfiguration.CacheStorage, configurationSource, reflectionCache);

            CachingInstrumentationProvider instrumentationProvider = CreateInstrumentationProvider(objectConfiguration.Name, configurationSource, reflectionCache);

            CacheManager createdObject
                = new CacheManagerFactoryHelper().BuildCacheManager(
                      objectConfiguration.Name,
                      backingStore,
                      objectConfiguration.MaximumElementsInCacheBeforeScavenging,
                      objectConfiguration.NumberToRemoveWhenScavenging,
                      objectConfiguration.ExpirationPollFrequencyInSeconds,
                      instrumentationProvider);

            RegisterObject(context, name, createdObject);

            return(createdObject);
        }
예제 #31
0
        public IFeature HydrateFrom(string dehydratedFeature, IBackingStore backingStore)
        {
            try
            {
                var majorChunks = dehydratedFeature.Split(MajorDiv);

                var name       = string.Empty;
                var percentage = 0;
                var groups     = new List <IGroup>();

                for (var i = 0; i < majorChunks.Length; i++)
                {
                    switch (i)
                    {
                    case 0:
                        name = majorChunks[0];
                        break;

                    case 1:
                        percentage = int.Parse(majorChunks[1]);
                        break;

                    default:
                        groups.Add(ParseGroup(majorChunks[i]));
                        break;
                    }
                }

                return(new Feature(backingStore, name, percentage, groups));
            }
            catch
            {
                throw new HydrationException(
                          "Could not rehydrate feature from string. Please check the format.",
                          dehydratedFeature);
            }
        }
        public void CanBuildCustomBackingStoreFromSavedConfiguration()
        {
            CustomCacheStorageData customData
                = new CustomCacheStorageData("custom", typeof(MockCustomStorageBackingStore));

            customData.SetAttributeValue(MockCustomProviderBase.AttributeKey, "value1");
            CacheManagerSettings settings = new CacheManagerSettings();

            settings.BackingStores.Add(customData);
            settings.CacheManagers.Add(new CacheManagerData("ignore", 0, 0, 0, "custom"));

            IDictionary <string, ConfigurationSection> sections = new Dictionary <string, ConfigurationSection>(1);

            sections[CacheManagerSettings.SectionName] = settings;
            IConfigurationSource configurationSource
                = ConfigurationTestHelper.SaveSectionsInFileAndReturnConfigurationSource(sections);

            IBackingStore custom
                = EnterpriseLibraryFactory.BuildUp <IBackingStore>("custom", configurationSource);

            Assert.IsNotNull(custom);
            Assert.AreSame(typeof(MockCustomStorageBackingStore), custom.GetType());
            Assert.AreEqual("value1", ((MockCustomStorageBackingStore)custom).customValue);
        }
예제 #33
0
		/// <summary>
		/// Dispose of the backing store before garbage collection.
		/// </summary>
        /// <param name="disposing">
		/// <see langword="true"/> if disposing; otherwise, <see langword="false"/>.
		/// </param>
		protected virtual void Dispose(bool disposing)
        {
            if(disposing)
            {
                backingStore.Dispose();
                backingStore = null;
            }
        }
예제 #34
0
 public void StoreStatusChanging_DummyHandlerWhichThrows(IBackingStore sender, StoreStatusChangeEventArgs ea)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #35
0
 internal void _Store_StoreStatusChanging(IBackingStore sender, StoreStatusChangeEventArgs ea)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #36
0
 internal virtual void _Store_StoreStatusChanged(IBackingStore sender, StoreStatusChangeEventArgs ea)
 {
     if (sender != null)
     {
         if (ea.OldStatus == BackingStoreStatus.UnAvailable && ea.NewStatus == BackingStoreStatus.Available)
         {
             OutputStatus = PayLoadStatus.Available;
         }
         else if (ea.OldStatus == BackingStoreStatus.Available && ea.NewStatus == BackingStoreStatus.UnAvailable)
         {
             OutputStatus = PayLoadStatus.Unavailable;
         }
         else if (ea.OldStatus == BackingStoreStatus.Available && ea.NewStatus == BackingStoreStatus.Available)
         {
             OutputStatus = PayLoadStatus.Available;
         }
     }
 }
예제 #37
0
 void ISetBackingStore.SetBackingStore(IBackingStore store)
 {
     BlobStore = store as INeutralBackingStore;
 }
예제 #38
0
 internal override void _Store_StoreStatusChanged(IBackingStore sender, StoreStatusChangeEventArgs ea)
 {
     _Store_StoreStatusChanged_TimesCalled++;
     RecievedEventArgs = ea;
     RecievedSender = sender;
 }
예제 #39
0
 public StandInInternalSession(IRegistry registry, IBackingStore backingStore)
     : base(registry, backingStore)
 {
 }
예제 #40
0
        /// <summary>
        /// Made public for testing purposes.
        /// </summary>
        public CacheManager BuildCacheManager(
			string cacheManagerName,
			IBackingStore backingStore,
			int maximumElementsInCacheBeforeScavenging,
			int numberToRemoveWhenScavenging,
			int expirationPollFrequencyInSeconds,
			CachingInstrumentationProvider instrumentationProvider)
        {
            CacheCapacityScavengingPolicy scavengingPolicy =
                new CacheCapacityScavengingPolicy(maximumElementsInCacheBeforeScavenging);

            Cache cache = new Cache(backingStore, scavengingPolicy, instrumentationProvider);

            ExpirationPollTimer timer = new ExpirationPollTimer();
            ExpirationTask expirationTask = CreateExpirationTask(cache, instrumentationProvider);
            ScavengerTask scavengerTask = new ScavengerTask(numberToRemoveWhenScavenging, scavengingPolicy, cache, instrumentationProvider);
            BackgroundScheduler scheduler = new BackgroundScheduler(expirationTask, scavengerTask, instrumentationProvider);
            cache.Initialize(scheduler);

            scheduler.Start();
            timer.StartPolling(new TimerCallback(scheduler.ExpirationTimeoutExpired), expirationPollFrequencyInSeconds * 1000);

            return new CacheManager(cache, scheduler, timer);
        }
 public OperandStack Evaluate(IBackingStore backingStore)
 {
     return(ExpressionEvaluator.Evaluate(this, backingStore));
 }
예제 #42
0
 void ISetBackingStore.SetBackingStore(IBackingStore store)
 {
     NetworkObjStore = store as INetworkBackingStore;
 }
예제 #43
0
 void ISetBackingStore.SetBackingStore(IBackingStore store)
 {
     DataObjStore = store as IDataBackingStore;
 }
        internal static Tuple <OperandType> DoUnaryCastOperation(DoubleOperandFunctionMatrix matrix, Stack <IOperand> operandStack, IBackingStore backingStore, Operand castTo)
        {
            IOperand operand = PopAndResolve(operandStack, backingStore);

            IOperand result = matrix.PerformDelegate(operand, castTo);

            if (result != null)
            {
                operandStack.Push(result);
                return(null);
            }
            else
            {
                // Signal an error ...
                return(new Tuple <OperandType>(operand.Type));
            }
        }
        /// <summary>
        /// This ought to be implemented with a FunctionMartix but it would be huge.
        /// This way is easier!
        /// </summary>
        internal static Tuple <OperandType, OperandType> DoSetEquals(DoubleOperandFunctionMatrix matrix, Stack <IOperand> stack, IBackingStore backingStore, long parserPosition)
        {
            IOperand second = PopAndResolve(stack, backingStore);
            IOperand first  = stack.Pop();      // Not PopAndResolve. LHS must be a variable.

            if (first.Type != OperandType.Variable)
            {
                throw new ExpressionEvaluatorException(parserPosition, ExpressionEvaluatorException.ExceptionCause.BadOperand, "LHS of '=' is a '" + first.Type + "' when it must be a variable");
            }
            else
            {
                string varName = (string)first.GetValue();

                (OperandType type, object value)valueAndType;
                try
                {
                    // We need the type, don't need the value because it's going to be overwritten.
                    valueAndType = backingStore.GetValue(varName);
                }
                catch (Exception ex)
                {
                    throw new ExpressionEvaluatorException(-1, ExpressionEvaluatorException.ExceptionCause.UndefinedVariable, $"'{varName}'");
                }

                // type is needed so we can pick out the correct martrix operation. Value is irrelevant as it is overwritten.
                var firstOperand = new Operand(first.ParserPosition, valueAndType.type, valueAndType.value);

                IOperand result = matrix.PerformDelegate(firstOperand, second);

                if (result != null)
                {
                    backingStore.SetValue(varName, result.GetValue());
                    stack.Push(result);
                    return(null);
                }
                else
                {
                    // Signal an error ...
                    return(new Tuple <OperandType, OperandType>(first.Type, second.Type));
                }
            }
        }
예제 #46
0
 internal void _Store_StoreStatusChanging(IBackingStore sender, StoreStatusChangeEventArgs ea)
 {
     throw new NotImplementedException("Not currently being used");
 }
예제 #47
0
 public void StoreStatusChanging_DummyHandler(IBackingStore sender, StoreStatusChangeEventArgs ea)
 {
     StoreStatusChanging_TimesCalled++;
 }
예제 #48
0
 public abstract void EngageBackingStore(IBackingStore backingStore);
예제 #49
0
파일: Cache.cs 프로젝트: CrazyTiger/Test
 public Cache(IBackingStore backingStore, ICachingInstrumentationProvider instrumentationProvider);
 public void Setup()
 {
     _store = new NetworkBackingStore();
     _asSetId = _store as ISetId;
     _asIId = _store as IId;
 }
 public void Setup()
 {
     _store = new DataBackingStore();
     _asSetId = _store as ISetId;
     _asIId = _store as IId;
 }
 public void Setup()
 {
     _store = new FakeBackingStore();
     _asSetParentId = _store as ISetParentId;
     _asIParentId = _store as IParentId;
 }