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


C# MetadataImporter.NormalizePolicy方法代码示例

本文整理汇总了C#中System.ServiceModel.Description.MetadataImporter.NormalizePolicy方法的典型用法代码示例。如果您正苦于以下问题:C# MetadataImporter.NormalizePolicy方法的具体用法?C# MetadataImporter.NormalizePolicy怎么用?C# MetadataImporter.NormalizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.Description.MetadataImporter的用法示例。


在下文中一共展示了MetadataImporter.NormalizePolicy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryGetNestedPolicyAlternatives

        public virtual bool TryGetNestedPolicyAlternatives(MetadataImporter importer, XmlElement assertion, out Collection<Collection<XmlElement>> alternatives)
        {
            alternatives = null;

            XmlElement policyElement = null;
            foreach (XmlNode node in assertion.ChildNodes)
            {
                if (node is XmlElement && node.LocalName == PolicyName && (node.NamespaceURI == WspNamespace || node.NamespaceURI == Wsp15Namespace))
                {
                    policyElement = (XmlElement)node;
                    break;
                }
            }

            if (policyElement == null)
            {
                alternatives = null;
            }
            else
            {
                IEnumerable<IEnumerable<XmlElement>> enumerableAlternatives = importer.NormalizePolicy(new XmlElement[] { policyElement });

                alternatives = new Collection<Collection<XmlElement>>();
                foreach (IEnumerable<XmlElement> enumerableAlternative in enumerableAlternatives)
                {
                    Collection<XmlElement> alternative = new Collection<XmlElement>();
                    alternatives.Add(alternative);
                    foreach (XmlElement e in enumerableAlternative)
                    {
                        alternative.Add(e);
                    }
                }
            }

            return alternatives != null;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:36,代码来源:WSSecurityPolicy.cs

示例2: TryGetNestedPolicyAlternatives

 public virtual bool TryGetNestedPolicyAlternatives(MetadataImporter importer, XmlElement assertion, out Collection<Collection<XmlElement>> alternatives)
 {
     alternatives = null;
     XmlElement element = null;
     foreach (System.Xml.XmlNode node in assertion.ChildNodes)
     {
         if (((node is XmlElement) && (node.LocalName == "Policy")) && ((node.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/policy") || (node.NamespaceURI == "http://www.w3.org/ns/ws-policy")))
         {
             element = (XmlElement) node;
             break;
         }
     }
     if (element == null)
     {
         alternatives = null;
     }
     else
     {
         IEnumerable<IEnumerable<XmlElement>> enumerable = importer.NormalizePolicy(new XmlElement[] { element });
         alternatives = new Collection<Collection<XmlElement>>();
         foreach (IEnumerable<XmlElement> enumerable2 in enumerable)
         {
             Collection<XmlElement> collection;
             collection = new Collection<XmlElement> {
                 collection
             };
             foreach (XmlElement element2 in enumerable2)
             {
                 collection.Add(element2);
             }
         }
     }
     return (alternatives != null);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:WSSecurityPolicy.cs

示例3: TryImportDeliveryAssurance

            bool TryImportDeliveryAssurance(MetadataImporter importer, XmlElement node)
            {
                string wsrmNs = ReliableSessionPolicyStrings.ReliableSession11Namespace;

                if (!IsElement(node, wsrmNs, ReliableSessionPolicyStrings.DeliveryAssurance))
                {
                    return false;
                }

                // Policy
                IEnumerator policyNodes = node.ChildNodes.GetEnumerator();
                XmlNode policyNode = SkipToNode(policyNodes);
                XmlElement policyElement = ThrowIfNotPolicyElement(policyNode, ReliableMessagingVersion.WSReliableMessaging11);
                IEnumerable<IEnumerable<XmlElement>> alternatives = importer.NormalizePolicy(new XmlElement[] { policyElement });

                foreach (IEnumerable<XmlElement> alternative in alternatives)
                {
                    State state = State.Assurance;

                    foreach (XmlElement element in alternative)
                    {
                        if (state == State.Assurance)
                        {
                            state = State.Order;

                            if (!IsElement(element, wsrmNs, ReliableSessionPolicyStrings.ExactlyOnce)
                                && !IsElement(element, wsrmNs, ReliableSessionPolicyStrings.AtMostOnce)
                                && !IsElement(element, wsrmNs, ReliableSessionPolicyStrings.AtMostOnce))
                            {
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException(SR.GetString(
                                    SR.DeliveryAssuranceRequired,
                                    wsrmNs,
                                    element.LocalName,
                                    element.NamespaceURI)));
                            }

                            // Found required DeliveryAssurance, ignore the value and skip to InOrder
                            continue;
                        }

                        if (state == State.Order)
                        {
                            state = State.Done;

                            // InOrder
                            if (IsElement(element, wsrmNs, ReliableSessionPolicyStrings.InOrder))
                            {
                                // set ordered
                                if (!this.isOrdered)
                                {
                                    this.isOrdered = true;
                                }

                                continue;
                            }
                        }

                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException(SR.GetString(
                            SR.UnexpectedXmlChildNode,
                            element.LocalName,
                            element.NodeType,
                            ReliableSessionPolicyStrings.DeliveryAssurance)));
                    }

                    if (state == State.Assurance)
                    {
                        string exceptionString = SR.GetString(SR.DeliveryAssuranceRequiredNothingFound, wsrmNs);
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException(exceptionString));
                    }
                }

                policyNode = SkipToNode(policyNodes);

                if (policyNode != null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException(SR.GetString(
                        SR.UnexpectedXmlChildNode,
                        policyNode.LocalName,
                        policyNode.NodeType,
                        node.LocalName)));
                }

                return true;
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:84,代码来源:ReliableSessionBindingElementImporter.cs

示例4: ProcessWsrm11Policy

        static void ProcessWsrm11Policy(MetadataImporter importer, XmlNode node, ReliableSessionBindingElement settings)
        {
            XmlElement element = ThrowIfNotPolicyElement(node, ReliableMessagingVersion.WSReliableMessaging11);
            IEnumerable<IEnumerable<XmlElement>> alternatives = importer.NormalizePolicy(new XmlElement[] { element });
            List<Wsrm11PolicyAlternative> wsrmAlternatives = new List<Wsrm11PolicyAlternative>();

            foreach (IEnumerable<XmlElement> alternative in alternatives)
            {
                Wsrm11PolicyAlternative wsrm11Policy = Wsrm11PolicyAlternative.ImportAlternative(importer, alternative);
                wsrmAlternatives.Add(wsrm11Policy);
            }

            if (wsrmAlternatives.Count == 0)
            {
                // No specific policy other than turn on WS-RM.
                return;
            }

            foreach (Wsrm11PolicyAlternative wsrmAlternative in wsrmAlternatives)
            {
                // The only policy setting that affects the binding is the InOrder assurance.
                // Even that setting does not affect the binding since InOrder is a server delivery assurance.
                // Transfer any that is valid.
                if (wsrmAlternative.HasValidPolicy)
                {
                    wsrmAlternative.TransferSettings(settings);
                    return;
                }
            }

            // Found only invalid policy.
            // This throws an exception about security since that is the only invalid policy we have.
            Wsrm11PolicyAlternative.ThrowInvalidBindingException();
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:34,代码来源:ReliableSessionBindingElementImporter.cs

示例5: ProcessWsrm11Policy

 private static void ProcessWsrm11Policy(MetadataImporter importer, System.Xml.XmlNode node, ReliableSessionBindingElement settings)
 {
     XmlElement element = ThrowIfNotPolicyElement(node, ReliableMessagingVersion.WSReliableMessaging11);
     IEnumerable<IEnumerable<XmlElement>> enumerable = importer.NormalizePolicy(new XmlElement[] { element });
     List<Wsrm11PolicyAlternative> list = new List<Wsrm11PolicyAlternative>();
     foreach (IEnumerable<XmlElement> enumerable2 in enumerable)
     {
         Wsrm11PolicyAlternative item = Wsrm11PolicyAlternative.ImportAlternative(importer, enumerable2);
         list.Add(item);
     }
     if (list.Count != 0)
     {
         foreach (Wsrm11PolicyAlternative alternative2 in list)
         {
             if (alternative2.HasValidPolicy)
             {
                 alternative2.TransferSettings(settings);
                 return;
             }
         }
         Wsrm11PolicyAlternative.ThrowInvalidBindingException();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:ReliableSessionBindingElementImporter.cs

示例6: TryImportDeliveryAssurance

 private bool TryImportDeliveryAssurance(MetadataImporter importer, XmlElement node)
 {
     string ns = "http://docs.oasis-open.org/ws-rx/wsrmp/200702";
     if (!ReliableSessionBindingElementImporter.IsElement(node, ns, "DeliveryAssurance"))
     {
         return false;
     }
     IEnumerator nodes = node.ChildNodes.GetEnumerator();
     XmlElement element = ReliableSessionBindingElementImporter.ThrowIfNotPolicyElement(ReliableSessionBindingElementImporter.SkipToNode(nodes), ReliableMessagingVersion.WSReliableMessaging11);
     foreach (IEnumerable<XmlElement> enumerable2 in importer.NormalizePolicy(new XmlElement[] { element }))
     {
         ReliableSessionBindingElementImporter.State assurance = ReliableSessionBindingElementImporter.State.Assurance;
         foreach (XmlElement element2 in enumerable2)
         {
             switch (assurance)
             {
                 case ReliableSessionBindingElementImporter.State.Assurance:
                 {
                     assurance = ReliableSessionBindingElementImporter.State.Order;
                     if ((!ReliableSessionBindingElementImporter.IsElement(element2, ns, "ExactlyOnce") && !ReliableSessionBindingElementImporter.IsElement(element2, ns, "AtMostOnce")) && !ReliableSessionBindingElementImporter.IsElement(element2, ns, "AtMostOnce"))
                     {
                         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException(System.ServiceModel.SR.GetString("DeliveryAssuranceRequired", new object[] { ns, element2.LocalName, element2.NamespaceURI })));
                     }
                     continue;
                 }
                 case ReliableSessionBindingElementImporter.State.Order:
                     assurance = ReliableSessionBindingElementImporter.State.Done;
                     if (ReliableSessionBindingElementImporter.IsElement(element2, ns, "InOrder"))
                     {
                         if (!this.isOrdered)
                         {
                             this.isOrdered = true;
                         }
                         continue;
                     }
                     break;
             }
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { element2.LocalName, element2.NodeType, "DeliveryAssurance" })));
         }
         if (assurance == ReliableSessionBindingElementImporter.State.Assurance)
         {
             string message = System.ServiceModel.SR.GetString("DeliveryAssuranceRequiredNothingFound", new object[] { ns });
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException(message));
         }
     }
     System.Xml.XmlNode node2 = ReliableSessionBindingElementImporter.SkipToNode(nodes);
     if (node2 != null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { node2.LocalName, node2.NodeType, node.LocalName })));
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:52,代码来源:ReliableSessionBindingElementImporter.cs


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