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


C# XmlDictionaryReader.ReadElementContentAsString方法代码示例

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


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

示例1: RawFaultException

 public RawFaultException(XmlDictionaryReader reader) :
     base("The service returned a fault - see FaultMessage, FaultStackTrace, and FaultType.")
 {
     reader.ReadToFollowing("Message");
     m_faultMessage = reader.ReadElementContentAsString();
     m_stackTrace = reader.ReadElementContentAsString("StackTrace", reader.NamespaceURI);
     m_type = Type.GetType(reader.ReadElementContentAsString("Type", reader.NamespaceURI));
 }
开发者ID:akalafrancis,项目名称:sipsorcery-mono,代码行数:8,代码来源:SecurityHeader.cs

示例2: ReadObject

        public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName)
        {
            if (this.isCustomSerialization)
            {
                object result = Activator.CreateInstance(this.type);

                byte[] contents;

                if (m_IsCompress)
                {
                    contents = reader.ReadElementContentAsBinHex();
                }
                else
                {
                    switch (m_ContentType)
                    {
                        case SerializeContentTypes.BinHex:
                            contents = reader.ReadElementContentAsBinHex();
                            break;
                        case SerializeContentTypes.String:
                            contents = Encoding.UTF8.GetBytes(reader.ReadElementContentAsString());
                            break;
                        default:
                            contents = Encoding.UTF8.GetBytes(reader.ReadElementContentAsString());
                            break;
                    }
                }

                using (MemoryStream ms = new MemoryStream(contents))
                {
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(this.type);

                    if (m_IsCompress)
                    {
                        using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress))
                        {
                            result = ser.ReadObject(ds);
                            ds.Close();
                        }
                    }
                    else
                    {
                        result = ser.ReadObject(ms);
                    }

                    ms.Close();
                    ser = null;
                    return result;
                }
            }
            else
            {
                return this.fallbackSerializer.ReadObject(reader, verifyObjectName);
            }
        }
开发者ID:JackFong,项目名称:GenericWcfServiceHostAndClient,代码行数:55,代码来源:JsonSerializer.cs

示例3: FromReader

 public static UserSoapHeader FromReader(XmlDictionaryReader reader)
 {
     UserSoapHeader header = new UserSoapHeader();
     
     while (!reader.EOF)
     {                
         if (reader.Name == "token")
             header.Token = reader.ReadElementContentAsString();
         else if (reader.Name == "lan")
             header.Lan = reader.ReadElementContentAsString();
         else if (reader.Name == "SOAP-ENV:Body")
             break;
         else
             reader.Read();
     }
                
     return header;
 }
开发者ID:dalinhuang,项目名称:tdcodes,代码行数:18,代码来源:UserSoapHeader.cs

示例4: ReadObject

 public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName)
 {
     string content = reader.ReadElementContentAsString();
     var data = Convert.FromBase64String(content);
     if (UseEncryption())
         data = Decrypt(data);
     var graph = Deserialize(data);
     return graph;
 }
开发者ID:Turntwo,项目名称:nvents,代码行数:9,代码来源:EncryptableNetDataContractSerializer.cs

示例5: ReadHeaderValue

 public static string ReadHeaderValue(XmlDictionaryReader reader, AddressingVersion addressingVersion)
 {
     string s = reader.ReadElementContentAsString();
     if ((s.Length <= 0) || ((s[0] > ' ') && (s[s.Length - 1] > ' ')))
     {
         return s;
     }
     return XmlUtil.Trim(s);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:ActionHeader.cs

示例6: FromReader

        /// <summary>
        /// 解析Message的头
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static ExceptionSoapHeader FromReader(XmlDictionaryReader reader)
        {
            ExceptionSoapHeader header = new ExceptionSoapHeader();
            while (!reader.EOF)
            {
                reader.Read();
                if (reader.Name == "type" && reader.IsStartElement())
                    header.ExceptionType = (SoapExceptionType)Enum.Parse(typeof(SoapExceptionType), reader.ReadElementContentAsString());
                else if (reader.Name == "message" && reader.IsStartElement())
                    header.Message = reader.ReadElementContentAsString();
                else if (reader.Name == "stack" && reader.IsStartElement())
                    header.Stack = reader.ReadElementContentAsString();
                else if (reader.Name == "appversion" && reader.IsStartElement())
                    header.AppVersion = reader.ReadElementContentAsString();
                else
                    continue;
                
            }

            return header;
        }
开发者ID:dalinhuang,项目名称:tdcodes,代码行数:26,代码来源:ExceptionSoapHeader.cs

示例7: ReadHeaderValue

 public static Uri ReadHeaderValue(XmlDictionaryReader reader, AddressingVersion version, UriCache uriCache)
 {
     string uriString = reader.ReadElementContentAsString();
     if (uriString == version.Anonymous)
     {
         return version.AnonymousUri;
     }
     if (uriCache == null)
     {
         return new Uri(uriString);
     }
     return uriCache.CreateUri(uriString);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:ToHeader.cs

示例8: Create

        public static MakeConnectionMessageInfo Create(XmlDictionaryReader reader)
        {
            MakeConnectionMessageInfo makeConnectionInfo = new MakeConnectionMessageInfo();

            if (reader.IsStartElement(MakeConnectionConstants.MakeConnectionMessage.Name, MakeConnectionConstants.Namespace))
            {
                reader.ReadStartElement();
                reader.MoveToContent();

                while (reader.IsStartElement())
                {
                    if (reader.IsStartElement(MakeConnectionConstants.MakeConnectionMessage.AddressElement, MakeConnectionConstants.Namespace))
                    {
                        if (!string.IsNullOrEmpty(makeConnectionInfo.Address))
                        {
                            makeConnectionInfo.MultipleAddressHeaders = true;
                            reader.Skip();
                        }
                        else
                        {
                            makeConnectionInfo.Address = reader.ReadElementContentAsString();
                        }
                    }
                    else if (reader.IsStartElement(MakeConnectionConstants.MakeConnectionMessage.IdentifierElement, MakeConnectionConstants.Namespace))
                    {
                        if (makeConnectionInfo.Identifier != null)
                        {
                            makeConnectionInfo.MultipleIdentifierHeaders = true;
                            reader.Skip();
                        }
                        else
                        {
                            makeConnectionInfo.Identifier = reader.ReadElementContentAsUniqueId();
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(makeConnectionInfo.UnknownSelection))
                        {
                            makeConnectionInfo.UnknownSelection = reader.LocalName;
                        }

                        reader.Skip();
                    }
                }

                reader.ReadEndElement();
            }

            return makeConnectionInfo;
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:51,代码来源:MakeConnectionBodyWriter.cs

示例9: Create

 public static CreateSequenceResponseInfo Create(AddressingVersion addressingVersion, ReliableMessagingVersion reliableMessagingVersion, XmlDictionaryReader reader)
 {
     CreateSequenceResponseInfo info = new CreateSequenceResponseInfo();
     WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
     XmlDictionaryString namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);
     reader.ReadStartElement(dictionary.CreateSequenceResponse, namespaceUri);
     reader.ReadStartElement(dictionary.Identifier, namespaceUri);
     info.Identifier = reader.ReadContentAsUniqueId();
     reader.ReadEndElement();
     if (reader.IsStartElement(dictionary.Expires, namespaceUri))
     {
         reader.ReadElementContentAsTimeSpan();
     }
     if ((reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11) && reader.IsStartElement(DXD.Wsrm11Dictionary.IncompleteSequenceBehavior, namespaceUri))
     {
         string str2 = reader.ReadElementContentAsString();
         if (((str2 != "DiscardEntireSequence") && (str2 != "DiscardFollowingFirstGap")) && (str2 != "NoDiscard"))
         {
             string message = System.ServiceModel.SR.GetString("CSResponseWithInvalidIncompleteSequenceBehavior");
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(message));
         }
     }
     if (reader.IsStartElement(dictionary.Accept, namespaceUri))
     {
         reader.ReadStartElement();
         info.AcceptAcksTo = EndpointAddress.ReadFrom(addressingVersion, reader, dictionary.AcksTo, namespaceUri);
         while (reader.IsStartElement())
         {
             reader.Skip();
         }
         reader.ReadEndElement();
     }
     while (reader.IsStartElement())
     {
         reader.Skip();
     }
     reader.ReadEndElement();
     return info;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:CreateSequenceResponse.cs

示例10: ReadHeaderObject

		object ReadHeaderObject (Type type, XmlObjectSerializer serializer, XmlDictionaryReader reader)
		{
			// FIXME: it's a nasty workaround just to avoid UniqueId output as a string.
			// Seealso MessageHeader.DefaultMessageHeader.OnWriteHeaderContents().
			// Note that msg.Headers.GetHeader<UniqueId> () simply fails (on .NET too) and it is useless. The API is lame by design.
			if (type == typeof (UniqueId))
				return new UniqueId (reader.ReadElementContentAsString ());
			else
				return serializer.ReadObject (reader);
		}
开发者ID:pasko,项目名称:mono,代码行数:10,代码来源:BaseMessagesFormatter.cs

示例11: ReadHeaderValue

        public static Uri ReadHeaderValue(XmlDictionaryReader reader, AddressingVersion version, UriCache uriCache)
        {
            Fx.Assert(reader.IsStartElement(XD.AddressingDictionary.To, version.DictionaryNamespace), "");

            string toString = reader.ReadElementContentAsString();

            if ((object)toString == (object)version.Anonymous)
            {
                return version.AnonymousUri;
            }

            if (uriCache == null)
            {
                return new Uri(toString);
            }

            return uriCache.CreateUri(toString);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:18,代码来源:Addressing.cs

示例12: ReadTokenCore

            public override SecurityToken ReadTokenCore(XmlDictionaryReader reader, SecurityTokenResolver tokenResolver)
            {
                string wsuId = reader.GetAttribute(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace);
                string valueTypeUri = reader.GetAttribute(ValueTypeAttribute, null);
                string encoding = reader.GetAttribute(EncodingTypeAttribute, null);

                byte[] binaryData;
                if (encoding == null || encoding == EncodingTypeValueBase64Binary)
                {
                    binaryData = reader.ReadElementContentAsBase64();
                }
                else if (encoding == EncodingTypeValueHexBinary)
                {
                    binaryData = HexBinary.Parse(reader.ReadElementContentAsString()).Value;
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.UnknownEncodingInBinarySecurityToken)));
                }

                return ReadBinaryCore(wsuId, valueTypeUri, binaryData);
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:22,代码来源:WSSecurityJan2004.cs

示例13: ReadMessagePart

		object ReadMessagePart (MessagePartDescription part, XmlDictionaryReader r)
		{
			if (part.Type == typeof (Stream))
				// FIXME: it seems TransferMode.Streamed* has different serialization than .Buffered. Need to differentiate serialization somewhere (not limited to here).
				return new MemoryStream (Convert.FromBase64String (r.ReadElementContentAsString (part.Name, part.Namespace)));
			else
				return GetSerializer (part).ReadObject (r);
		}
开发者ID:pasko,项目名称:mono,代码行数:8,代码来源:BaseMessagesFormatter.cs

示例14: Deserialize

        public static object Deserialize(XmlDictionaryReader reader, Type targetType)
        {
            object returnValue = null;

            if (reader.IsStartElement())
            {
                switch (reader.LocalName)
                {
                    case XmlRpcProtocol.Nil:
                        returnValue = null;
                        break;
                    case XmlRpcProtocol.Bool:
                        returnValue = Convert.ChangeType((reader.ReadElementContentAsInt()==1),targetType);
                        break;
                    case XmlRpcProtocol.ByteArray:
                        if (targetType == typeof(Stream))
                        {
                            returnValue = new MemoryStream(reader.ReadElementContentAsBase64());
                        }
                        else
                        {
                            returnValue = Convert.ChangeType(reader.ReadElementContentAsBase64(), targetType);
                        }
                        break;
                    case XmlRpcProtocol.DateTime:
                        returnValue = Convert.ChangeType(reader.ReadElementContentAsDateTime(),targetType);
                        break;
                    case XmlRpcProtocol.Double:
                        returnValue = Convert.ChangeType(reader.ReadElementContentAsDouble(),targetType);
                        break;
                    case XmlRpcProtocol.Int32:
                    case XmlRpcProtocol.Integer:
                        returnValue = Convert.ChangeType(reader.ReadElementContentAsString(),targetType);
                        break;
                    case XmlRpcProtocol.String:
                        if (targetType == typeof(Uri))
                        {
                            returnValue = new Uri(reader.ReadElementContentAsString());
                        }
                        else
                        {
                            returnValue = Convert.ChangeType(reader.ReadElementContentAsString(), targetType);
                        }
                        break;
                    case XmlRpcProtocol.Struct:
                        returnValue = DeserializeStruct(reader, targetType);
                        break;
                    case XmlRpcProtocol.Array:
                        if (targetType.IsArray || targetType is IEnumerable || targetType is IList || targetType is ICollection)
                        {
                            reader.ReadStartElement(XmlRpcProtocol.Array);
                            ArrayList arrayData = new ArrayList();
                            reader.ReadStartElement(XmlRpcProtocol.Data);
                            reader.MoveToContent();
                            while (reader.IsStartElement(XmlRpcProtocol.Value))
                            {
                                reader.ReadStartElement();
                                arrayData.Add(Deserialize(reader, targetType.GetElementType()));
                                reader.ReadEndElement();
                                reader.MoveToContent();
                            }
                            if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == XmlRpcProtocol.Data)
                            {
                                reader.ReadEndElement();
                            }
                            reader.ReadEndElement();

                            if (targetType is IEnumerable || targetType is IList || targetType is ICollection)
                            {
                                returnValue = arrayData;
                            }
                            else
                            {
                                returnValue = arrayData.ToArray(targetType.GetElementType());
                            }                            
                        }
                        else
                        {
                            throw new InvalidOperationException();
                        }
                        break;
                }
            }
            return returnValue;
        }
开发者ID:ehabqadah,项目名称:Distributed-Nodes-Network-Management,代码行数:85,代码来源:XmlRpcDataContractSerializer.cs

示例15: ReadFrom

 private static void ReadFrom(CoordinationContext that, XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString ns, Microsoft.Transactions.Wsat.Protocol.ProtocolVersion protocolVersion)
 {
     try
     {
         Uri uri;
         CoordinationXmlDictionaryStrings strings = CoordinationXmlDictionaryStrings.Version(protocolVersion);
         AtomicTransactionStrings strings2 = AtomicTransactionStrings.Version(protocolVersion);
         reader.ReadFullStartElement(localName, strings.Namespace);
         reader.MoveToStartElement(strings.Identifier, strings.Namespace);
         that.unknownIdentifierAttributes = ReadOtherAttributes(reader, strings.Namespace);
         that.contextId = reader.ReadElementContentAsString().Trim();
         if ((that.contextId.Length == 0) || (that.contextId.Length > 0x100))
         {
             throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
         }
         if (!Uri.TryCreate(that.contextId, UriKind.Absolute, out uri))
         {
             throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
         }
         if (reader.IsStartElement(strings.Expires, strings.Namespace))
         {
             that.unknownExpiresAttributes = ReadOtherAttributes(reader, strings.Namespace);
             int num = reader.ReadElementContentAsInt();
             if (num < 0)
             {
                 throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
             }
             that.expiration = (uint) num;
             that.expiresPresent = true;
         }
         reader.MoveToStartElement(strings.CoordinationType, strings.Namespace);
         if (reader.ReadElementContentAsString().Trim() != strings2.Namespace)
         {
             throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
         }
         that.registrationRef = EndpointAddress.ReadFrom(MessagingVersionHelper.AddressingVersion(protocolVersion), reader, strings.RegistrationService, strings.Namespace);
         if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationLevel, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
         {
             that.isoLevel = (System.Transactions.IsolationLevel) reader.ReadElementContentAsInt();
             if (((that.IsolationLevel < System.Transactions.IsolationLevel.Serializable) || (that.IsolationLevel > System.Transactions.IsolationLevel.Unspecified)) || (that.IsolationLevel == System.Transactions.IsolationLevel.Snapshot))
             {
                 throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext")));
             }
         }
         if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationFlags, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
         {
             that.isoFlags = (System.ServiceModel.Transactions.IsolationFlags) reader.ReadElementContentAsInt();
         }
         if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.Description, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
         {
             that.description = reader.ReadElementContentAsString().Trim();
         }
         if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
         {
             that.localTxId = reader.ReadElementContentAsGuid();
         }
         if (OleTxTransactionHeader.IsStartPropagationTokenElement(reader))
         {
             that.propToken = OleTxTransactionHeader.ReadPropagationTokenElement(reader);
         }
         if (reader.IsStartElement())
         {
             XmlDocument document = new XmlDocument();
             that.unknownData = new List<System.Xml.XmlNode>(5);
             while (reader.IsStartElement())
             {
                 System.Xml.XmlNode item = document.ReadNode(reader);
                 that.unknownData.Add(item);
             }
         }
         reader.ReadEndElement();
     }
     catch (XmlException exception)
     {
         throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"), exception));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:77,代码来源:CoordinationContext.cs


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