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


C# XmlReaderDelegator.ReadElementContentAsString方法代码示例

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


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

示例1: ReadXmlValue

 public override object ReadXmlValue(XmlReaderDelegator reader, XmlObjectSerializerReadContext context)
 {
     if (context != null)
     {
         return base.HandleReadValue(reader.ReadElementContentAsString(), context);
     }
     if (!base.TryReadNullAtTopLevel(reader))
     {
         return reader.ReadElementContentAsString();
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:StringDataContract.cs

示例2: ReadJsonValueCore

 public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     if (context != null)
     {
         return JsonDataContract.HandleReadValue(jsonReader.ReadElementContentAsString(), context);
     }
     if (!JsonDataContract.TryReadNullAtTopLevel(jsonReader))
     {
         return jsonReader.ReadElementContentAsString();
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:JsonStringDataContract.cs

示例3: ReadJsonValueCore

        public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
        {
            object obj;
            string contentMode = jsonReader.GetAttribute(JsonGlobals.typeString);

            switch (contentMode)
            {
                case JsonGlobals.nullString:
                    jsonReader.Skip();
                    obj = null;
                    break;
                case JsonGlobals.booleanString:
                    obj = jsonReader.ReadElementContentAsBoolean();
                    break;
                case JsonGlobals.stringString:
                case null:
                    obj = jsonReader.ReadElementContentAsString();
                    break;
                case JsonGlobals.numberString:
                    obj = ParseJsonNumber(jsonReader.ReadElementContentAsString());
                    break;
                case JsonGlobals.objectString:
                    jsonReader.Skip();
                    obj = new object();
                    break;
                case JsonGlobals.arrayString:
                    // Read as object array
                    return DataContractJsonSerializer.ReadJsonValue(DataContract.GetDataContract(Globals.TypeOfObjectArray), jsonReader, context);
                default:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                        XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.JsonUnexpectedAttributeValue, contentMode)));
            }

            if (context != null)
            {
                context.AddNewObject(obj);
            }
            return obj;
        }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:39,代码来源:JsonObjectDataContract.cs

示例4: ReadJsonValueCore

 public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     object obj2;
     string s = jsonReader.ReadElementContentAsString();
     DataContractSerializer serializer = new DataContractSerializer(base.TraditionalDataContract.UnderlyingType, this.GetKnownTypesFromContext(context, (context == null) ? null : context.SerializerKnownTypeList), 1, false, false, null);
     MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(s));
     XmlDictionaryReaderQuotas readerQuotas = ((JsonReaderDelegator) jsonReader).ReaderQuotas;
     if (readerQuotas == null)
     {
         obj2 = serializer.ReadObject(stream);
     }
     else
     {
         obj2 = serializer.ReadObject(XmlDictionaryReader.CreateTextReader(stream, readerQuotas));
     }
     if (context != null)
     {
         context.AddNewObject(obj2);
     }
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:21,代码来源:JsonXmlDataContract.cs

示例5: ReadXmlValue

 public override object ReadXmlValue(XmlReaderDelegator reader, XmlObjectSerializerReadContext context)
 {
     if (context == null)
     {
         return TryReadNullAtTopLevel(reader) ? null : reader.ReadElementContentAsString();
     }
     else
     {
         return HandleReadValue(reader.ReadElementContentAsString(), context);
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:PrimitiveDataContract.cs

示例6: ReadEnumValue

        internal object ReadEnumValue(XmlReaderDelegator reader)
        {
            string stringValue = reader.ReadElementContentAsString();
            long longValue = 0;
            int i = 0;
            if (IsFlags)
            {
                // Skip initial spaces
                for (; i < stringValue.Length; i++)
                    if (stringValue[i] != ' ')
                        break;

                // Read space-delimited values
                int startIndex = i;
                int count = 0;
                for (; i < stringValue.Length; i++)
                {
                    if (stringValue[i] == ' ')
                    {
                        count = i - startIndex;
                        if (count > 0)
                            longValue |= ReadEnumValue(stringValue, startIndex, count);
                        for (++i; i < stringValue.Length; i++)
                            if (stringValue[i] != ' ')
                                break;
                        startIndex = i;
                        if (i == stringValue.Length)
                            break;
                    }
                }
                count = i - startIndex;
                if (count > 0)
                    longValue |= ReadEnumValue(stringValue, startIndex, count);
            }
            else
            {
                if (stringValue.Length == 0)
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.InvalidEnumValueOnRead, stringValue, DataContract.GetClrTypeFullName(UnderlyingType))));
                longValue = ReadEnumValue(stringValue, 0, stringValue.Length);
            }

            if (IsULong)
                return Enum.ToObject(UnderlyingType, (object)(ulong)longValue);
            return Enum.ToObject(UnderlyingType, (object)longValue);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:45,代码来源:EnumDataContract.cs

示例7: ReadJsonValueCore

        public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
        {
            object obj2;
            string attribute = jsonReader.GetAttribute("type");
            string key = attribute;
            if (key != null)
            {
                int num;
                if (<PrivateImplementationDetails>{D290E7C2-4296-4D66-A436-0C17851A078B}.$$method0x60012be-1.TryGetValue(key, out num))
                {
                    switch (num)
                    {
                        case 0:
                            jsonReader.Skip();
                            obj2 = null;
                            goto Label_011B;

                        case 1:
                            obj2 = jsonReader.ReadElementContentAsBoolean();
                            goto Label_011B;

                        case 2:
                            goto Label_00BB;

                        case 3:
                            obj2 = ParseJsonNumber(jsonReader.ReadElementContentAsString());
                            goto Label_011B;

                        case 4:
                            jsonReader.Skip();
                            obj2 = new object();
                            goto Label_011B;

                        case 5:
                            return DataContractJsonSerializer.ReadJsonValue(DataContract.GetDataContract(Globals.TypeOfObjectArray), jsonReader, context);
                    }
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("JsonUnexpectedAttributeValue", new object[] { attribute })));
            }
        Label_00BB:
            obj2 = jsonReader.ReadElementContentAsString();
        Label_011B:
            if (context != null)
            {
                context.AddNewObject(obj2);
            }
            return obj2;
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:48,代码来源:JsonObjectDataContract.cs

示例8: ReadEnumValue

 internal object ReadEnumValue(XmlReaderDelegator reader)
 {
     string str = reader.ReadElementContentAsString();
     long num = 0L;
     int num2 = 0;
     if (!this.IsFlags)
     {
         if (str.Length == 0)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("InvalidEnumValueOnRead", new object[] { str, DataContract.GetClrTypeFullName(base.UnderlyingType) })));
         }
         num = this.ReadEnumValue(str, 0, str.Length);
     }
     else
     {
         while (num2 < str.Length)
         {
             if (str[num2] != ' ')
             {
                 break;
             }
             num2++;
         }
         int index = num2;
         int count = 0;
         while (num2 < str.Length)
         {
             if (str[num2] == ' ')
             {
                 count = num2 - index;
                 if (count > 0)
                 {
                     num |= this.ReadEnumValue(str, index, count);
                 }
                 num2++;
                 while (num2 < str.Length)
                 {
                     if (str[num2] != ' ')
                     {
                         break;
                     }
                     num2++;
                 }
                 index = num2;
                 if (num2 == str.Length)
                 {
                     break;
                 }
             }
             num2++;
         }
         count = num2 - index;
         if (count > 0)
         {
             num |= this.ReadEnumValue(str, index, count);
         }
     }
     if (this.IsULong)
     {
         return Enum.ToObject(base.UnderlyingType, (ulong) num);
     }
     return Enum.ToObject(base.UnderlyingType, num);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:63,代码来源:EnumDataContract.cs


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