当前位置: 首页>>代码示例>>C#>>正文


C# Xml.ParserContext类代码示例

本文整理汇总了C#中Spring.Objects.Factory.Xml.ParserContext的典型用法代码示例。如果您正苦于以下问题:C# ParserContext类的具体用法?C# ParserContext怎么用?C# ParserContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ParserContext类属于Spring.Objects.Factory.Xml命名空间,在下文中一共展示了ParserContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoParse

        protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {

            builder.AddPropertyReference(TxNamespaceUtils.TRANSACTION_MANAGER_PROPERTY,
                GetAttributeValue(element, TxNamespaceUtils.TRANSACTION_MANAGER_ATTRIBUTE));
            XmlNodeList txAttributes = element.SelectNodes("*[local-name()='attributes' and namespace-uri()='" + element.NamespaceURI + "']");
            if (txAttributes.Count > 1 )
            {
                parserContext.ReaderContext.ReportException(element, "tx advice", "Element <attributes> is allowed at most once inside element <advice>");
            }
            else if (txAttributes.Count == 1)
            {
                //using xml defined source
                XmlElement attributeSourceElement = txAttributes[0] as XmlElement;
                AbstractObjectDefinition attributeSourceDefinition =
                    ParseAttributeSource(attributeSourceElement, parserContext);
                builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, attributeSourceDefinition);
            }
            else
            {
                //Assume attibutes source
                ObjectDefinitionBuilder txAttributeSourceBuilder = 
                    parserContext.ParserHelper.CreateRootObjectDefinitionBuilder(typeof (AttributesTransactionAttributeSource));

                builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE,
                                         txAttributeSourceBuilder.ObjectDefinition);

            }
        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:29,代码来源:TxAdviceObjectDefinitionParser.cs

示例2: ParseInterceptors

        public ManagedList ParseInterceptors(XmlElement element, ParserContext parserContext)
        {
            ManagedList interceptors = new ManagedList();
            foreach(XmlNode child in element.ChildNodes) {

            /* TODO:
             * check full elementname (incl. NamespaceUri)
            */
            if (child.NodeType == XmlNodeType.Element) {
                XmlElement childElement = (XmlElement) child;
                string localName = child.LocalName;
                if ("object".Equals(localName)) {
                    ObjectDefinitionHolder holder = parserContext.ParserHelper.ParseObjectDefinitionElement(childElement);
                    interceptors.Add(holder);
                }
                else if ("ref".Equals(localName)) {
                    string reference = childElement.GetAttribute("object");
                    interceptors.Add(new RuntimeObjectReference(reference));
                }
                else {
                    if (!parsers.ContainsKey(localName)) {
                        parserContext.ReaderContext.ReportException(childElement, localName, "unsupported interceptor element");
                    }
                    IObjectDefinitionRegisteringParser parser = parsers[localName];
                    string interceptorObjectName = parser.Parse(childElement, parserContext);
                    interceptors.Add(new RuntimeObjectReference(interceptorObjectName));
                }
            }
            }
            return interceptors;
        }
开发者ID:rlxrlxrlx,项目名称:spring-net-integration,代码行数:31,代码来源:ChannelInterceptorParser.cs

示例3: ParseTestObjectDefinition

        private ObjectDefinitionHolder ParseTestObjectDefinition(XmlElement rootElement, ParserContext parserContext)
        {
            MutablePropertyValues properties = new MutablePropertyValues();
            
            XmlNodeList childNodes = rootElement.ChildNodes;

            //Get all properties (from non whitespace nodes)
            foreach (XmlNode childNode in childNodes)
            {                
                if (XmlNodeType.Whitespace != childNode.NodeType)
                {
                    properties.Add(new PropertyValue(childNode.LocalName, childNode.InnerText));
                }
            }
            IConfigurableObjectDefinition od = new RootObjectDefinition(typeof (TestObject), null, properties);
            od.IsSingleton = false;

            //HardCoded for now.
            string id = "testObject";
            //id = ObjectDefinitionReaderUtils.GenerateObjectName(od, reader.ObjectReader.Registry);

            return new ObjectDefinitionHolder(od, id);


        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:25,代码来源:TestObjectConfigParser.cs

示例4: ParseInternal

        protected override AbstractObjectDefinition ParseInternal(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = BuildObjectDefinition(element, parserContext);
            ManagedList interceptors = null;
            XmlElement interceptorsElement = DomUtils.GetChildElementByTagName(element, "interceptors");

            if(interceptorsElement != null) {
                ChannelInterceptorParser interceptorParser = new ChannelInterceptorParser();
                interceptors = interceptorParser.ParseInterceptors(interceptorsElement, new ParserContext(parserContext.ParserHelper, builder.RawObjectDefinition));
            }
            if(interceptors == null) {
                interceptors = new ManagedList();
            }

            string datatypeAttr = element.GetAttribute("datatype");
            if(StringUtils.HasText(datatypeAttr)) {
                string[] datatypes = StringUtils.CommaDelimitedListToStringArray(datatypeAttr);
                RootObjectDefinition selectorDef = new RootObjectDefinition();
                selectorDef.ObjectTypeName = IntegrationNamespaceUtils.SELECTOR_PACKAGE + ".PayloadTypeSelector";
                selectorDef.ConstructorArgumentValues.AddGenericArgumentValue(datatypes);
                string selectorObjectName = parserContext.ReaderContext.RegisterWithGeneratedName(selectorDef);

                RootObjectDefinition interceptorDef = new RootObjectDefinition();
                interceptorDef.ObjectTypeName = IntegrationNamespaceUtils.CHANNEL_INTERCEPTOR_PACKAGE + ".MessageSelectingInterceptor";
                interceptorDef.ConstructorArgumentValues.AddGenericArgumentValue(new RuntimeObjectReference(selectorObjectName));
                string interceptorObjectName = parserContext.ReaderContext.RegisterWithGeneratedName(interceptorDef);

                interceptors.Add(new RuntimeObjectReference(interceptorObjectName));
            }

            builder.AddPropertyValue("interceptors", interceptors);
            return builder.ObjectDefinition;
        }
开发者ID:rlxrlxrlx,项目名称:spring-net-integration,代码行数:33,代码来源:AbstractChannelParser.cs

示例5: DoParse

        /// <summary>The do parse.</summary>
        /// <param name="element">The element.</param>
        /// <param name="parserContext">The parser context.</param>
        /// <param name="builder">The builder.</param>
        protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {
            var parser = new ObjectDefinitionParserHelper(parserContext);
            var map = parser.ParseMapElement(element, builder.RawObjectDefinition);

            builder.AddPropertyValue("SourceDictionary", map);
        }
开发者ID:yonglehou,项目名称:spring-net-amqp,代码行数:11,代码来源:QueueArgumentsParser.cs

示例6: ParseInternal

 protected override AbstractObjectDefinition ParseInternal(XmlElement element, ParserContext parserContext)
 {
     ObjectDefinitionBuilder handlerBuilder = ParseHandler(element, parserContext);
     IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(handlerBuilder, element, "output-channel");
     IntegrationNamespaceUtils.SetValueIfAttributeDefined(handlerBuilder, element, "order");
     AbstractObjectDefinition handlerBeanDefinition = handlerBuilder.ObjectDefinition;
     string inputChannelAttributeName = InputChannelAttributeName;
     if(!element.HasAttribute(inputChannelAttributeName)) {
         if(!parserContext.IsNested) {
             parserContext.ReaderContext.ReportException(element, element.Name, "The '" + inputChannelAttributeName
                     + "' attribute is required for top-level endpoint elements.");
         }
         return handlerBeanDefinition;
     }
     ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CONFIG_PACKAGE + ".ConsumerEndpointFactoryObject");
     string handlerBeanName = parserContext.ReaderContext.RegisterWithGeneratedName(handlerBeanDefinition);
     builder.AddConstructorArgReference(handlerBeanName);
     string inputChannelName = element.GetAttribute(inputChannelAttributeName);
     if(!parserContext.Registry.ContainsObjectDefinition(inputChannelName)) {
         ObjectDefinitionBuilder channelDef = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CHANNEL_PACKAGE + ".DirectChannel");
         ObjectDefinitionHolder holder = new ObjectDefinitionHolder(channelDef.ObjectDefinition, inputChannelName);
         ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, parserContext.Registry);
     }
     builder.AddPropertyValue("inputChannelName", inputChannelName);
     XmlElement pollerElement = DomUtils.GetChildElementByTagName(element, "poller");
     if(pollerElement != null) {
         IntegrationNamespaceUtils.ConfigurePollerMetadata(pollerElement, builder, parserContext);
     }
     IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "auto-startup");
     return builder.ObjectDefinition;
 }
开发者ID:rlxrlxrlx,项目名称:spring-net-integration,代码行数:31,代码来源:AbstractConsumerEndpointParser.cs

示例7: ParseInternal

        /// <summary>
        /// Central template method to actually parse the supplied XmlElement
        /// into one or more IObjectDefinitions.
        /// </summary>
        /// <param name="element">The element that is to be parsed into one or more <see cref="IObjectDefinition"/>s</param>
        /// <param name="parserContext">The the object encapsulating the current state of the parsing process;
        /// provides access to a <see cref="IObjectDefinitionRegistry"/></param>
        /// <returns>
        /// The primary IObjectDefinition resulting from the parsing of the supplied XmlElement
        /// </returns>
        protected override AbstractObjectDefinition ParseInternal(XmlElement element, ParserContext parserContext)
        {
            ConfigureAutoProxyCreator(parserContext, element);

            //Create the TransactionAttributeSource
            RootObjectDefinition sourceDef = new RootObjectDefinition(typeof(AttributesTransactionAttributeSource));
            sourceDef.Role = ObjectRole.ROLE_INFRASTRUCTURE;
            string sourceName = parserContext.ReaderContext.RegisterWithGeneratedName(sourceDef);

            //Create the TransactionInterceptor definition.
            RootObjectDefinition interceptorDefinition = new RootObjectDefinition(typeof(TransactionInterceptor));
            interceptorDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE;
            RegisterTransactionManager(element, interceptorDefinition);
            interceptorDefinition.PropertyValues.Add(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, new RuntimeObjectReference(sourceName));
            String interceptorName = parserContext.ReaderContext.RegisterWithGeneratedName(interceptorDefinition);

            // Create the TransactionAttributeSourceAdvisor definition.
            RootObjectDefinition advisorDef = new RootObjectDefinition(typeof(ObjectFactoryTransactionAttributeSourceAdvisor));
            advisorDef.Role = ObjectRole.ROLE_INFRASTRUCTURE;
            advisorDef.PropertyValues.Add("transactionAttributeSource", new RuntimeObjectReference(sourceName));
            advisorDef.PropertyValues.Add("adviceObjectName", interceptorName);

            if (element.HasAttribute(ORDER))
            {
                advisorDef.PropertyValues.Add(ORDER, GetAttributeValue(element, ORDER));
            }

            return advisorDef;
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:39,代码来源:AttributeDrivenObjectDefinitionParser.cs

示例8: ParseHandler

 protected override ObjectDefinitionBuilder ParseHandler(XmlElement element, ParserContext parserContext)
 {
     ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.AGGREGATOR_PACKAGE + ".MethodInvokingAggregator");
     string refatr = element.GetAttribute(RefAttribute);
     if(!StringUtils.HasText(refatr)) {
         parserContext.ReaderContext.ReportException(element, element.Name, "The '" + RefAttribute + "' attribute is required.");
     }
     builder.AddConstructorArgReference(refatr);
     if(StringUtils.HasText(element.GetAttribute(MethodAttribute))) {
         string method = element.GetAttribute(MethodAttribute);
         builder.AddConstructorArg(method);
     }
     IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, DiscardChannelAttribute);
     IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, SendTimeoutAttribute);
     IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, SendPartialResultOnTimeoutAttribute);
     IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, ReaperIntervalAttribute);
     IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, TrackedCorrelationIdCapacityAttribute);
     IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "auto-startup");
     IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, TimeoutAttribute);
     string completionStrategyRef = element.GetAttribute(CompletionStrategyRefAttribute);
     string completionStrategyMethod = element.GetAttribute(CompletionStrategyMethodAttribute);
     if(StringUtils.HasText(completionStrategyRef)) {
         if(StringUtils.HasText(completionStrategyMethod)) {
             string adapterBeanName = CreateCompletionStrategyAdapter(
                     completionStrategyRef, completionStrategyMethod, parserContext);
             builder.AddPropertyReference(CompletionStrategyProperty, adapterBeanName);
         }
         else {
             builder.AddPropertyReference(CompletionStrategyProperty, completionStrategyRef);
         }
     }
     return builder;
 }
开发者ID:rlxrlxrlx,项目名称:spring-net-integration,代码行数:33,代码来源:AggregatorParser.cs

示例9: ParseElement

        public IObjectDefinition ParseElement(XmlElement element, ParserContext parserContext)
        {
            IObjectDefinitionFactory factory = parserContext.ReaderContext.ObjectDefinitionFactory;
            AssertUtils.ArgumentNotNull(factory, "factory");

            string id = element.GetAttribute(ObjectNames.MongoConventionProfileId);
            string defaultId = StringUtils.HasText(id) ? id : ObjectNames.MongoConventionProfileDefaultId;

            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(typeof(ConventionProfileFactory));

            SetConvention(element, builder, ObjectNames.ConventionProfileDefaultValue, ConventionProfileFactory.DefaultValueConventionProperty);
            SetConvention(element, builder, ObjectNames.ConventionProfileElementName, ConventionProfileFactory.ElementNameConventionProperty);
            SetConvention(element, builder, ObjectNames.ConventionProfileExtraElementsMember, ConventionProfileFactory.ExtraElementsMemberConventionProperty);
            SetConvention(element, builder, ObjectNames.ConventionProfileIdGenerator, ConventionProfileFactory.IdGeneratorConventionProperty);
            SetConvention(element, builder, ObjectNames.ConventionProfileIdMember, ConventionProfileFactory.IdMemberConventionProperty);
            SetConvention(element, builder, ObjectNames.ConventionProfileIgnoreExtraElements, ConventionProfileFactory.IgnoreExtraElementsConventionProperty);
            SetConvention(element, builder, ObjectNames.ConventionProfileIgnoreIfDefault, ConventionProfileFactory.IgnoreIfDefaultConventionProperty);
            SetConvention(element, builder, ObjectNames.ConventionProfileIgnoreIfNull, ConventionProfileFactory.IgnoreIfNullConventionProperty);
            SetConvention(element, builder, ObjectNames.ConventionProfileMemberFinder, ConventionProfileFactory.MemberFinderConventionProperty);
            SetConvention(element, builder, ObjectNames.ConventionProfileSerializationOptions, ConventionProfileFactory.SerializationOptionsConventionProperty);

            parserContext.Registry.RegisterObjectDefinition(defaultId, builder.ObjectDefinition);

            return null;
        }
开发者ID:thomast74,项目名称:spring-net-data-mongodb,代码行数:25,代码来源:MongoConventionProfileParser.cs

示例10: WhenConfigFileIsNotValid

        public void WhenConfigFileIsNotValid()
        {
            //            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
            //<objects xmlns='http://www.springframework.net' xmlns:v='http://www.springframework.net/validation'>
            //    <v:required test='#this'>
            //        <v:message id='error.airportCode.required' providers='summary'/>
            //        <v:action type='Spring.Validation.Actions.ExpressionAction, Spring.Core' when='true'/>
            //    </v:required>
            //</objects>
            //";
            XmlDocument doc = GetValidatedXmlResource("_WhenConfigFileIsNotValid.xml");

            MockObjectDefinitionRegistry registry = new MockObjectDefinitionRegistry();
            IObjectDefinitionDocumentReader reader = new DefaultObjectDefinitionDocumentReader();

            XmlReaderContext readerContext = new XmlReaderContext(null, new XmlObjectDefinitionReader(registry));
            ObjectDefinitionParserHelper helper = new ObjectDefinitionParserHelper(readerContext);
            helper.InitDefaults(doc.DocumentElement);
            ParserContext parserContext = new ParserContext(helper.ReaderContext, helper);

            ValidationNamespaceParser parser = new ValidationNamespaceParser();
            foreach (XmlElement element in doc.DocumentElement.ChildNodes)
            {
                if (element.NamespaceURI == "http://www.springframework.net/validation")
                {
                    parser.ParseElement(element, parserContext);
                }
            }
        }
开发者ID:serra,项目名称:spring-net,代码行数:29,代码来源:ValidationNamespaceParserTests.cs

示例11: DoParse

 protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
 {
     if(!StringUtils.HasText(element.GetAttribute("id"))) {
         parserContext.ReaderContext.ReportException(element, element.Name, "id is required");
     }
     ParseSelectorChain(builder, element, parserContext);
 }
开发者ID:rlxrlxrlx,项目名称:spring-net-integration,代码行数:7,代码来源:SelectorChainParser.cs

示例12: ParseHandler

        protected override ObjectDefinitionBuilder ParseHandler(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(typeof(NmsOutboundGateway));
            builder.AddPropertyReference("connectionFactory", element.GetAttribute("connection-factory"));
            String requestDestination = element.GetAttribute("request-destination");
            String requestDestinationName = element.GetAttribute("request-destination-name");
            if (!(StringUtils.HasText(requestDestination) ^ StringUtils.HasText(requestDestinationName)))
            {
                parserContext.ReaderContext.ReportException(element, "request-destination or request-destination-name",
                        "Exactly one of the 'request-destination' or 'request-destination-name' attributes is required.");
            }
            if (StringUtils.HasText(requestDestination))
            {
                builder.AddPropertyReference("requestDestination", requestDestination);
            }
            else if (StringUtils.HasText(requestDestinationName))
            {
                builder.AddPropertyValue("requestDestinationName", requestDestinationName);
            }
            IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "reply-destination");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "reply-destination-name");
            IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "reply-channel");
            IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "message-converter");
            IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "header-mapper");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "extract-request-payload");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "extract-reply-payload");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "receive-timeout");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "pub-sub-domain");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "delivery-mode");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "time-to-live");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "priority");

            return builder;
        }
开发者ID:rlxrlxrlx,项目名称:spring-net-integration,代码行数:34,代码来源:NmsOutboundGatewayParser.cs

示例13: ParseHandler

 protected override ObjectDefinitionBuilder ParseHandler(XmlElement element, ParserContext parserContext)
 {
     ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.FILTER_PACKAGE + ".MessageFilter");
     builder.AddConstructorArgReference(ParseSelector(element, parserContext));
     IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "throw-exception-on-rejection");
     return builder;
 }
开发者ID:rlxrlxrlx,项目名称:spring-net-integration,代码行数:7,代码来源:FilterParser.cs

示例14: ParseElement

 /// <summary>
 /// Parse the specified element and register any resulting
 /// IObjectDefinitions with the IObjectDefinitionRegistry that is
 /// embedded in the supplied ParserContext.
 /// </summary>
 /// <param name="element">The element to be parsed into one or more IObjectDefinitions</param>
 /// <param name="parserContext">The object encapsulating the current state of the parsing
 /// process.</param>
 /// <returns>
 /// The primary IObjectDefinition (can be null as explained above)
 /// </returns>
 /// <remarks>
 /// Implementations should return the primary IObjectDefinition
 /// that results from the parse phase if they wish to used nested
 /// inside (for example) a <code>&lt;property&gt;</code> tag.
 /// <para>Implementations may return null if they will not
 /// be used in a nested scenario.
 /// </para>
 /// </remarks>
 public override IObjectDefinition ParseElement(XmlElement element, ParserContext parserContext)
 {
     ParseElementCalled = true;
     ObjectDefinitionHolder holder = ParseTestObjectDefinition(element, parserContext);
     ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, parserContext.Registry);
     return null;
 }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:26,代码来源:TestObjectConfigParser.cs

示例15: ParseUrl

 protected static string ParseUrl(XmlElement element, ParserContext parserContext)
 {
     string url = element.GetAttribute("url");
     if(!StringUtils.HasText(url)) {
         parserContext.ReaderContext.ReportException(element, "url", "The 'url' attribute is required.");
     }
     return url;
 }
开发者ID:rlxrlxrlx,项目名称:spring-net-integration,代码行数:8,代码来源:AbstractRemotingOutboundGatewayParser.cs


注:本文中的Spring.Objects.Factory.Xml.ParserContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。