Beispiel #1
0
        public IPipeline CreatePipelineFromType(Type pipelineType)
        {
            if (pipelineType == null)
            {
                throw new ArgumentNullException("pipelineType");
            }
            object target = Activator.CreateInstance(pipelineType);
            object obj3   = pipelineType.InvokeMember("XmlContent", BindingFlags.GetProperty, null, target, null, CultureInfo.InvariantCulture);

            if (obj3 == null)
            {
                throw new InvalidOperationException("XmlContent property of the pipeline object returned null");
            }
            XmlDocument document = new XmlDocument();

            document.LoadXml((string)obj3);
            XmlNode node = document.SelectSingleNode("/Document/CategoryId");

            if (node == null)
            {
                throw new InvalidOperationException("CategoryId node can not be found in the pipeline XML content");
            }
            IPipeline pipeline   = null;
            Guid      categoryId = new Guid(node.InnerText);

            if (categoryId == SendCategoryId)
            {
                pipeline = new SendPipeline(categoryId);
            }
            else
            {
                if (categoryId != ReceiveCategoryId)
                {
                    throw new InvalidOperationException("Unknown pipeline category Id");
                }
                pipeline = new ReceivePipeline(categoryId);
            }
            foreach (XmlNode node2 in document.SelectNodes("/Document/Stages/Stage"))
            {
                XmlNode node3 = node2.SelectSingleNode("PolicyFileStage");
                if (node3 == null)
                {
                    throw new InvalidOperationException("PolicyFileStage element is missing");
                }
                XmlNode node4 = node3.Attributes["Name"];
                if (node4 == null)
                {
                    throw new InvalidOperationException("Name attribute is missing");
                }
                string  innerText = node4.InnerText;
                XmlNode node5     = node3.Attributes["execMethod"];
                if (node5 == null)
                {
                    throw new InvalidOperationException("execMethod attribute is missing");
                }
                ExecuteMethod executeMethod = (ExecuteMethod)Enum.Parse(typeof(ExecuteMethod), node5.InnerText, true);
                XmlNode       node6         = node3.Attributes["stageId"];
                if (node6 == null)
                {
                    throw new InvalidOperationException("stageId attribute is missing");
                }
                Guid  id    = new Guid(node6.InnerText);
                Stage stage = new Stage(innerText, executeMethod, id, pipeline);
                pipeline.Stages.Add(stage);
                foreach (XmlNode node7 in node2.SelectNodes("Components/Component"))
                {
                    IBaseComponent component = this.CreatePipelineComponent(node7);
                    stage.AddComponent(component);
                }
            }
            return(pipeline);
        }
Beispiel #2
0
        public IPipeline CreatePipelineFromFile(string pipelineFileName)
        {
            XmlNode         node3;
            Guid            guid;
            StageDescriptor descriptor;
            Stage           stage;
            IBaseComponent  component;
            XmlDocument     document = new XmlDocument();

            document.Load(pipelineFileName);
            XmlNode node = document.SelectSingleNode("/Document/@PolicyFilePath");

            if (node == null)
            {
                throw new InvalidOperationException("PolicyFilePath attribute can not be found in the pipeline XML content");
            }
            IPipeline pipeline  = null;
            string    innerText = node.InnerText;

            if (innerText != null)
            {
                if (!(innerText == "BTSTransmitPolicy.xml"))
                {
                    if (innerText == "BTSReceivePolicy.xml")
                    {
                        pipeline = new ReceivePipeline(ReceiveCategoryId);
                        goto Label_0077;
                    }
                }
                else
                {
                    pipeline = new SendPipeline(SendCategoryId);
                    goto Label_0077;
                }
            }
            throw new InvalidOperationException("Unknown policy file name");
Label_0077:
Label_016D:
            foreach (XmlNode node2 in document.SelectNodes("/Document/Stages/Stage"))
            {
                node3 = node2.Attributes["CategoryId"];
                if (node3 == null)
                {
                    throw new InvalidOperationException("CategoryId attribute is missing");
                }
                guid       = new Guid(node3.InnerText);
                descriptor = (StageDescriptor)this.StageDescriptors[guid];
                if (descriptor == null)
                {
                    throw new InvalidOperationException("Unknown stage category Id");
                }
                stage = new Stage(descriptor.Name, descriptor.ExecuteMethod, guid, pipeline);
                pipeline.Stages.Add(stage);
                foreach (XmlNode node4 in node2.SelectNodes("Components/Component"))
                {
                    component = this.CreatePipelineComponent(node4);
                    stage.AddComponent(component);
                }
                goto Label_016D;
            }
            return(pipeline);
        }