Example #1
0
        public static OrderPipeline Create(string piplelineID)
        {
            OrderPipelineElements els = FindElements(piplelineID);

            if (els == null)
            {
                throw new KeyNotFoundException("Invalid pipeline id '" + piplelineID + "'.");
            }
            return(new OrderPipeline(els));
        }
Example #2
0
        private static OrderPipelineElements FindElements(string piplelineID)
        {
            string key  = "OrderPipeline_" + piplelineID;
            object item = MemoryCache.Default.Get(key);

            if (item != null && item is OrderPipelineElements)
            {
                return((OrderPipelineElements)item);
            }
            OrderPipelineElements els = OrderPipelineConfiguration.GetElements(piplelineID);

            if (els != null)
            {
                var policy = new CacheItemPolicy();
                policy.SlidingExpiration = TimeSpan.FromMinutes(OrderPipelineConfiguration.CacheSlidingExpirationMinutes);
                MemoryCache.Default.Set(new CacheItem(key, els), policy);
            }
            return(els);
        }
Example #3
0
 private OrderPipeline(OrderPipelineElements elements)
 {
     m_Elements = elements;
 }
Example #4
0
        public static OrderPipelineElements GetElements(string pipelineID)
        {
            if (File.Exists(s_ConfigFilePath) == false)
            {
                return(null);
            }
            XmlDocument x = new XmlDocument();

            x.Load(s_ConfigFilePath);
            XmlNode node = x.SelectSingleNode("//pipelineList/pipeline[@id='" + pipelineID + "']");

            if (node == null)
            {
                return(null);
            }
            OrderPipelineElements els = new OrderPipelineElements();
            string tmp = GetNodeAttribute(node, "breakOnceValidationError");

            els.BreakOnceValidationError = (tmp != null && tmp.Trim().ToUpper() == "TRUE");
            tmp = GetNodeAttribute(node, "transactionWithPersisters");
            els.TransactionWithPersisters = (tmp == null || tmp.Trim().ToUpper() != "FALSE");

            List <string> initializerTypeList = GetTypeNameList(node, "initializers", "item");

            if (initializerTypeList.Count > 0)
            {
                els.Initializers = new List <IInitialize>(initializerTypeList.Count);
                foreach (string typeName in initializerTypeList)
                {
                    els.Initializers.Add((IInitialize)Activator.CreateInstance(Type.GetType(typeName, true)));
                }
            }

            List <string> preValidatorTypeList = GetTypeNameList(node, "preValidators", "item");

            if (preValidatorTypeList.Count > 0)
            {
                els.PreValidators = new List <IValidate>(preValidatorTypeList.Count);
                foreach (string typeName in preValidatorTypeList)
                {
                    els.PreValidators.Add((IValidate)Activator.CreateInstance(Type.GetType(typeName, true)));
                }
            }

            List <string> calculatorTypeList = GetTypeNameList(node, "calculators", "item");

            if (calculatorTypeList.Count > 0)
            {
                els.Calculators = new List <ICalculate>(calculatorTypeList.Count);
                foreach (string typeName in calculatorTypeList)
                {
                    els.Calculators.Add((ICalculate)Activator.CreateInstance(Type.GetType(typeName, true)));
                }
            }

            List <string> postValidatorTypeList = GetTypeNameList(node, "postValidators", "item");

            if (postValidatorTypeList.Count > 0)
            {
                els.PostValidators = new List <IValidate>(postValidatorTypeList.Count);
                foreach (string typeName in postValidatorTypeList)
                {
                    els.PostValidators.Add((IValidate)Activator.CreateInstance(Type.GetType(typeName, true)));
                }
            }

            List <string> persisterTypeList = GetTypeNameList(node, "persisters", "item");

            if (persisterTypeList.Count > 0)
            {
                els.Persisters = new List <IPersist>(persisterTypeList.Count);
                foreach (string typeName in persisterTypeList)
                {
                    els.Persisters.Add((IPersist)Activator.CreateInstance(Type.GetType(typeName, true)));
                }
            }

            return(els);
        }