本文整理汇总了C#中System.Runtime.Serialization.XmlWriterDelegator.WriteString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriterDelegator.WriteString方法的具体用法?C# XmlWriterDelegator.WriteString怎么用?C# XmlWriterDelegator.WriteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.Serialization.XmlWriterDelegator
的用法示例。
在下文中一共展示了XmlWriterDelegator.WriteString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJsonValueCore
public override void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
{
DataContractSerializer serializer = new DataContractSerializer(Type.GetTypeFromHandle(declaredTypeHandle), this.GetKnownTypesFromContext(context, (context == null) ? null : context.SerializerKnownTypeList), 1, false, false, null);
MemoryStream stream = new MemoryStream();
serializer.WriteObject(stream, obj);
stream.Position = 0L;
string str = new StreamReader(stream).ReadToEnd();
jsonWriter.WriteString(str);
}
示例2: WriteString
internal override void WriteString(XmlWriterDelegator xmlWriter, string value, XmlDictionaryString name, XmlDictionaryString ns)
#endif
{
if (value == null)
WriteNull(xmlWriter, typeof(string), true/*isMemberTypeSerializable*/, name, ns);
else
{
xmlWriter.WriteStartElementPrimitive(name, ns);
if (!OnHandleReference(xmlWriter, value, false /*canContainCyclicReference*/))
xmlWriter.WriteString(value);
xmlWriter.WriteEndElementPrimitive();
}
}
示例3: WriteXmlValue
public override void WriteXmlValue(XmlWriterDelegator writer, object obj, XmlObjectSerializerWriteContext context)
{
writer.WriteString((string)obj);
}
示例4: WriteEnumValue
internal void WriteEnumValue(XmlWriterDelegator writer, object value)
{
long longValue = IsULong ? (long)Convert.ToUInt64(value, null) : Convert.ToInt64(value, null);
for (int i = 0; i < Values.Count; i++)
{
if (longValue == Values[i])
{
writer.WriteString(ChildElementNames[i].Value);
return;
}
}
if (IsFlags)
{
int zeroIndex = -1;
bool noneWritten = true;
for (int i = 0; i < Values.Count; i++)
{
long current = Values[i];
if (current == 0)
{
zeroIndex = i;
continue;
}
if (longValue == 0)
break;
if ((current & longValue) == current)
{
if (noneWritten)
noneWritten = false;
else
writer.WriteString(DictionaryGlobals.Space.Value);
writer.WriteString(ChildElementNames[i].Value);
longValue &= ~current;
}
}
// enforce that enum value was completely parsed
if (longValue != 0)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.InvalidEnumValueOnWrite, value, DataContract.GetClrTypeFullName(UnderlyingType))));
if (noneWritten && zeroIndex >= 0)
writer.WriteString(ChildElementNames[zeroIndex].Value);
}
else
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.InvalidEnumValueOnWrite, value, DataContract.GetClrTypeFullName(UnderlyingType))));
}
示例5: WriteString
public override void WriteString(XmlWriterDelegator xmlWriter, string value)
{
if (!OnHandleReference(xmlWriter, value, false /*canContainCyclicReference*/))
xmlWriter.WriteString(value);
}
示例6: WriteEnumValue
internal void WriteEnumValue(XmlWriterDelegator writer, object value)
{
long num = this.IsULong ? ((long) ((IConvertible) value).ToUInt64(null)) : ((IConvertible) value).ToInt64(null);
for (int i = 0; i < this.Values.Count; i++)
{
if (num == this.Values[i])
{
writer.WriteString(this.ChildElementNames[i].Value);
return;
}
}
if (!this.IsFlags)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("InvalidEnumValueOnWrite", new object[] { value, DataContract.GetClrTypeFullName(base.UnderlyingType) })));
}
int index = -1;
bool flag = true;
for (int j = 0; j < this.Values.Count; j++)
{
long num5 = this.Values[j];
if (num5 == 0L)
{
index = j;
}
else
{
if (num == 0L)
{
break;
}
if ((num5 & num) == num5)
{
if (flag)
{
flag = false;
}
else
{
writer.WriteString(DictionaryGlobals.Space.Value);
}
writer.WriteString(this.ChildElementNames[j].Value);
num &= ~num5;
}
}
}
if (num != 0L)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("InvalidEnumValueOnWrite", new object[] { value, DataContract.GetClrTypeFullName(base.UnderlyingType) })));
}
if (flag && (index >= 0))
{
writer.WriteString(this.ChildElementNames[index].Value);
}
}