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


C# XmlDictionaryReader.ReadContentAsInt方法代码示例

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


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

示例1: ReadHeader

        public static WsrmAcknowledgmentInfo ReadHeader(ReliableMessagingVersion reliableMessagingVersion,
            XmlDictionaryReader reader, MessageHeaderInfo header)
        {
            WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
            XmlDictionaryString wsrmNs = WsrmIndex.GetNamespace(reliableMessagingVersion);

            UniqueId sequenceID;
            SequenceRangeCollection rangeCollection;
            bool final;
            ReadAck(reliableMessagingVersion, reader, out sequenceID, out rangeCollection, out final);

            int bufferRemaining = -1;

            // Parse the extensibility section.
            while (reader.IsStartElement())
            {
                if (reader.IsStartElement(wsrmFeb2005Dictionary.BufferRemaining,
                    XD.WsrmFeb2005Dictionary.NETNamespace))
                {
                    if (bufferRemaining != -1)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
                            SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType,
                            MessageStrings.Body)));
                    }

                    reader.ReadStartElement();
                    bufferRemaining = reader.ReadContentAsInt();
                    reader.ReadEndElement();

                    if (bufferRemaining < 0)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
                            SR.GetString(SR.InvalidBufferRemaining, bufferRemaining)));
                    }

                    // Found BufferRemaining, continue parsing.
                    continue;
                }

                if (reader.IsStartElement(wsrmFeb2005Dictionary.AcknowledgementRange, wsrmNs))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
                        SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType,
                        MessageStrings.Body)));
                }
                else if (reader.IsStartElement(wsrmFeb2005Dictionary.Nack, wsrmNs))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
                        SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType,
                        MessageStrings.Body)));
                }
                else if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
                {
                    Wsrm11Dictionary wsrm11Dictionary = DXD.Wsrm11Dictionary;

                    if (reader.IsStartElement(wsrm11Dictionary.None, wsrmNs)
                        || reader.IsStartElement(wsrm11Dictionary.Final, wsrmNs))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
                            SR.GetString(SR.UnexpectedXmlChildNode, reader.Name, reader.NodeType,
                            wsrmFeb2005Dictionary.SequenceAcknowledgement)));
                    }
                }

                // Advance the reader in all cases.
                reader.Skip();
            }

            reader.ReadEndElement();

            return new WsrmAcknowledgmentInfo(sequenceID, rangeCollection, final, bufferRemaining, header);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:73,代码来源:WsrmMessageInfo.cs

示例2: WriteTextNode

 protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
 {
     Type type = reader.ValueType;
     if (type == typeof(string))
     {
         XmlDictionaryString value;
         if (reader.TryGetValueAsDictionaryString(out value))
         {
             WriteString(value);
         }
         else
         {
             if (reader.CanReadValueChunk)
             {
                 if (_chars == null)
                 {
                     _chars = new char[256];
                 }
                 int count;
                 while ((count = reader.ReadValueChunk(_chars, 0, _chars.Length)) > 0)
                 {
                     this.WriteChars(_chars, 0, count);
                 }
             }
             else
             {
                 WriteString(reader.Value);
             }
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else if (type == typeof(byte[]))
     {
         if (reader.CanReadBinaryContent)
         {
             // Its best to read in buffers that are a multiple of 3 so we don't break base64 boundaries when converting text
             if (_bytes == null)
             {
                 _bytes = new byte[384];
             }
             int count;
             while ((count = reader.ReadValueAsBase64(_bytes, 0, _bytes.Length)) > 0)
             {
                 this.WriteBase64(_bytes, 0, count);
             }
         }
         else
         {
             WriteString(reader.Value);
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else if (type == typeof(int))
         WriteValue(reader.ReadContentAsInt());
     else if (type == typeof(long))
         WriteValue(reader.ReadContentAsLong());
     else if (type == typeof(bool))
         WriteValue(reader.ReadContentAsBoolean());
     else if (type == typeof(double))
         WriteValue(reader.ReadContentAsDouble());
     else if (type == typeof(DateTime))
         WriteValue(reader.ReadContentAsDateTimeOffset().DateTime);
     else if (type == typeof(float))
         WriteValue(reader.ReadContentAsFloat());
     else if (type == typeof(decimal))
         WriteValue(reader.ReadContentAsDecimal());
     else if (type == typeof(UniqueId))
         WriteValue(reader.ReadContentAsUniqueId());
     else if (type == typeof(Guid))
         WriteValue(reader.ReadContentAsGuid());
     else if (type == typeof(TimeSpan))
         WriteValue(reader.ReadContentAsTimeSpan());
     else
         WriteValue(reader.ReadContentAsObject());
 }
开发者ID:chcosta,项目名称:corefx,代码行数:81,代码来源:XmlBinaryWriter.cs

示例3: WriteTextNode

 protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute)
 {
     Type valueType = reader.ValueType;
     if (valueType == typeof(string))
     {
         XmlDictionaryString str;
         if (reader.TryGetValueAsDictionaryString(out str))
         {
             this.WriteString(str);
         }
         else if (reader.CanReadValueChunk)
         {
             int num;
             if (this.chars == null)
             {
                 this.chars = new char[0x100];
             }
             while ((num = reader.ReadValueChunk(this.chars, 0, this.chars.Length)) > 0)
             {
                 this.WriteChars(this.chars, 0, num);
             }
         }
         else
         {
             this.WriteString(reader.Value);
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else if (valueType == typeof(byte[]))
     {
         if (reader.CanReadBinaryContent)
         {
             int num2;
             if (this.bytes == null)
             {
                 this.bytes = new byte[0x180];
             }
             while ((num2 = reader.ReadValueAsBase64(this.bytes, 0, this.bytes.Length)) > 0)
             {
                 this.WriteBase64(this.bytes, 0, num2);
             }
         }
         else
         {
             this.WriteString(reader.Value);
         }
         if (!attribute)
         {
             reader.Read();
         }
     }
     else if (valueType == typeof(int))
     {
         this.WriteValue(reader.ReadContentAsInt());
     }
     else if (valueType == typeof(long))
     {
         this.WriteValue(reader.ReadContentAsLong());
     }
     else if (valueType == typeof(bool))
     {
         this.WriteValue(reader.ReadContentAsBoolean());
     }
     else if (valueType == typeof(double))
     {
         this.WriteValue(reader.ReadContentAsDouble());
     }
     else if (valueType == typeof(DateTime))
     {
         this.WriteValue(reader.ReadContentAsDateTime());
     }
     else if (valueType == typeof(float))
     {
         this.WriteValue(reader.ReadContentAsFloat());
     }
     else if (valueType == typeof(decimal))
     {
         this.WriteValue(reader.ReadContentAsDecimal());
     }
     else if (valueType == typeof(UniqueId))
     {
         this.WriteValue(reader.ReadContentAsUniqueId());
     }
     else if (valueType == typeof(Guid))
     {
         this.WriteValue(reader.ReadContentAsGuid());
     }
     else if (valueType == typeof(TimeSpan))
     {
         this.WriteValue(reader.ReadContentAsTimeSpan());
     }
     else
     {
         this.WriteValue(reader.ReadContentAsObject());
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:99,代码来源:XmlBinaryWriter.cs

示例4: ReadDerivedKeyTokenParameters

            // xml format
            //<DerivedKeyToken wsu:Id="..." wsse:Algorithm="..."> id required, alg optional (curr disallowed)
            //  <SecurityTokenReference>...</SecurityTokenReference> - required
            //  <Properties>...</Properties> - disallowed (optional in spec, but we disallow it)
            // choice begin - (schema requires a choice - we allow neither on read - we always write one)
            //  <Generation>...</Generation> - optional
            //  <Offset>...</Offset> - optional
            // choice end
            //  <Length>...</Length> - optional - default 32 on read (default specified in spec, not in schema - we always write it)
            //  <Label>...</Label> - optional
            //  <Nonce>...</Nonce> - required (optional in spec, but we require it)
            //</DerivedKeyToken>
            public virtual void ReadDerivedKeyTokenParameters(XmlDictionaryReader reader, SecurityTokenResolver tokenResolver, out string id, out string derivationAlgorithm, out string label, out int length, out byte[] nonce, out int offset, out int generation, out SecurityKeyIdentifierClause tokenToDeriveIdentifier, out SecurityToken tokenToDerive)
            {
                if (tokenResolver == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("tokenResolver");
                }

                id = reader.GetAttribute(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace);

                derivationAlgorithm = reader.GetAttribute(XD.XmlSignatureDictionary.Algorithm, null);
                if (derivationAlgorithm == null)
                {
                    derivationAlgorithm = parent.DerivationAlgorithm;
                }

                reader.ReadStartElement();

                tokenToDeriveIdentifier = null;
                tokenToDerive = null;

                if (reader.IsStartElement(XD.SecurityJan2004Dictionary.SecurityTokenReference, XD.SecurityJan2004Dictionary.Namespace))
                {
                    tokenToDeriveIdentifier = parent.WSSecurityTokenSerializer.ReadKeyIdentifierClause(reader);
                    tokenResolver.TryResolveToken(tokenToDeriveIdentifier, out tokenToDerive);
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.DerivedKeyTokenRequiresTokenReference)));
                }

                // no support for properties

                generation = -1;
                if (reader.IsStartElement(parent.SerializerDictionary.Generation, parent.SerializerDictionary.Namespace))
                {
                    reader.ReadStartElement();
                    generation = reader.ReadContentAsInt();
                    reader.ReadEndElement();
                    if (generation < 0)
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.DerivedKeyInvalidGenerationSpecified, generation)));
                }

                offset = -1;
                if (reader.IsStartElement(parent.SerializerDictionary.Offset, parent.SerializerDictionary.Namespace))
                {
                    reader.ReadStartElement();
                    offset = reader.ReadContentAsInt();
                    reader.ReadEndElement();
                    if (offset < 0)
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.DerivedKeyInvalidOffsetSpecified, offset)));
                }

                length = DerivedKeySecurityToken.DefaultDerivedKeyLength;
                if (reader.IsStartElement(parent.SerializerDictionary.Length, parent.SerializerDictionary.Namespace))
                {
                    reader.ReadStartElement();
                    length = reader.ReadContentAsInt();
                    reader.ReadEndElement();
                }

                if ((offset == -1) && (generation == -1))
                    offset = 0;

                // verify that the offset is not larger than the max allowed
                DerivedKeySecurityToken.EnsureAcceptableOffset(offset, generation, length, this.maxKeyDerivationOffset);

                label = null;
                if (reader.IsStartElement(parent.SerializerDictionary.Label, parent.SerializerDictionary.Namespace))
                {
                    reader.ReadStartElement();
                    label = reader.ReadString();
                    reader.ReadEndElement();
                }
                if (label != null && label.Length > this.maxKeyDerivationLabelLength)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new MessageSecurityException(SR.GetString(SR.DerivedKeyTokenLabelTooLong, label.Length, this.maxKeyDerivationLabelLength)));
                }

                nonce = null;
                reader.ReadStartElement(parent.SerializerDictionary.Nonce, parent.SerializerDictionary.Namespace);
                nonce = reader.ReadContentAsBase64();
                reader.ReadEndElement();

                if (nonce != null && nonce.Length > this.maxKeyDerivationNonceLength)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new MessageSecurityException(SR.GetString(SR.DerivedKeyTokenNonceTooLong, nonce.Length, this.maxKeyDerivationNonceLength)));
                }

//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:WSSecureConversation.cs

示例5: ReadHeader

 public static WsrmAcknowledgmentInfo ReadHeader(ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader, MessageHeaderInfo header)
 {
     UniqueId id;
     SequenceRangeCollection ranges;
     bool flag;
     WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
     XmlDictionaryString namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);
     ReadAck(reliableMessagingVersion, reader, out id, out ranges, out flag);
     int bufferRemaining = -1;
     while (reader.IsStartElement())
     {
         if (reader.IsStartElement(dictionary.BufferRemaining, XD.WsrmFeb2005Dictionary.NETNamespace))
         {
             if (bufferRemaining != -1)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, "Body" })));
             }
             reader.ReadStartElement();
             bufferRemaining = reader.ReadContentAsInt();
             reader.ReadEndElement();
             if (bufferRemaining < 0)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidBufferRemaining", new object[] { bufferRemaining })));
             }
         }
         else
         {
             if (reader.IsStartElement(dictionary.AcknowledgementRange, namespaceUri))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, "Body" })));
             }
             if (reader.IsStartElement(dictionary.Nack, namespaceUri))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, "Body" })));
             }
             if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
             {
                 Wsrm11Dictionary dictionary2 = DXD.Wsrm11Dictionary;
                 if (reader.IsStartElement(dictionary2.None, namespaceUri) || reader.IsStartElement(dictionary2.Final, namespaceUri))
                 {
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("UnexpectedXmlChildNode", new object[] { reader.Name, reader.NodeType, dictionary.SequenceAcknowledgement })));
                 }
             }
             reader.Skip();
         }
     }
     reader.ReadEndElement();
     return new WsrmAcknowledgmentInfo(id, ranges, flag, bufferRemaining, header);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:49,代码来源:WsrmAcknowledgmentInfo.cs


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