本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}