本文整理汇总了C#中System.Runtime.Serialization.XmlWriterDelegator类的典型用法代码示例。如果您正苦于以下问题:C# XmlWriterDelegator类的具体用法?C# XmlWriterDelegator怎么用?C# XmlWriterDelegator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlWriterDelegator类属于System.Runtime.Serialization命名空间,在下文中一共展示了XmlWriterDelegator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ReflectionWriteMembers
internal int ReflectionWriteMembers(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context, ClassDataContract classContract, ClassDataContract derivedMostClassContract)
{
int memberCount = (classContract.BaseContract == null) ? 0 :
ReflectionWriteMembers(xmlWriter, obj, context, classContract.BaseContract, derivedMostClassContract);
Type classType = classContract.UnadaptedClassType;
XmlDictionaryString[] memberNames = classContract.MemberNames;
XmlDictionaryString ns = classContract.Namespace;
context.IncrementItemCount(classContract.Members.Count);
for (int i = 0; i < classContract.Members.Count; i++, memberCount++)
{
DataMember member = classContract.Members[i];
Type memberType = member.MemberType;
if (member.IsGetOnlyCollection)
{
context.StoreIsGetOnlyCollection();
}
bool writeXsiType = CheckIfMemberHasConflict(member, classContract, derivedMostClassContract);
MemberInfo memberInfo = member.MemberInfo;
object memberValue = ReflectionGetMemberValue(obj, memberInfo);
if (writeXsiType || !ReflectionTryWritePrimitive(xmlWriter, context, memberType, memberValue, member.MemberInfo, null /*arrayItemIndex*/, ns, memberNames[i] /*nameLocal*/, i + _childElementIndex))
{
ReflectionWriteStartElement(memberType, ns, ns.Value, member.Name, 0);
if (classContract.ChildElementNamespaces[i + _childElementIndex] != null)
{
var nsChildElement = classContract.ChildElementNamespaces[i + _childElementIndex];
_arg0XmlWriter.WriteNamespaceDecl(nsChildElement);
}
ReflectionWriteValue(memberType, memberValue, writeXsiType);
ReflectionWriteEndElement();
}
}
return 0;
}
开发者ID:SGuyGe,项目名称:corefx,代码行数:35,代码来源:ReflectionXmlFormatWriter.cs
示例2: SerializeWithXsiType
protected override void SerializeWithXsiType(XmlWriterDelegator xmlWriter, object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, int declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
{
DataContract dataContract;
bool verifyKnownType = false;
bool isInterface = declaredType.IsInterface;
if (isInterface && CollectionDataContract.IsCollectionInterface(declaredType))
{
dataContract = this.GetDataContract(declaredTypeHandle, declaredType);
}
else if (declaredType.IsArray)
{
dataContract = this.GetDataContract(declaredTypeHandle, declaredType);
}
else
{
dataContract = this.GetDataContract(objectTypeHandle, objectType);
DataContract declaredContract = (declaredTypeID >= 0) ? this.GetDataContract(declaredTypeID, declaredTypeHandle) : this.GetDataContract(declaredTypeHandle, declaredType);
verifyKnownType = this.WriteTypeInfo(xmlWriter, dataContract, declaredContract);
this.HandleCollectionAssignedToObject(declaredType, ref dataContract, ref obj, ref verifyKnownType);
}
if (isInterface)
{
VerifyObjectCompatibilityWithInterface(dataContract, obj, declaredType);
}
base.SerializeAndVerifyType(dataContract, xmlWriter, obj, verifyKnownType, declaredType.TypeHandle, declaredType);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:XmlObjectSerializerWriteContextComplexJson.cs
示例3: WriteObjectHandleExceptions
internal void WriteObjectHandleExceptions(XmlWriterDelegator writer, object graph, DataContractResolver dataContractResolver)
{
try
{
CheckNull(writer, "writer");
if (DiagnosticUtility.ShouldTraceInformation)
{
TraceUtility.Trace(TraceEventType.Information, TraceCode.WriteObjectBegin,
SR.GetString(SR.TraceCodeWriteObjectBegin), new StringTraceRecord("Type", GetTypeInfo(GetSerializeType(graph))));
InternalWriteObject(writer, graph, dataContractResolver);
TraceUtility.Trace(TraceEventType.Information, TraceCode.WriteObjectEnd,
SR.GetString(SR.TraceCodeWriteObjectEnd), new StringTraceRecord("Type", GetTypeInfo(GetSerializeType(graph))));
}
else
{
InternalWriteObject(writer, graph, dataContractResolver);
}
}
catch (XmlException ex)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(GetTypeInfoError(SR.ErrorSerializing, GetSerializeType(graph), ex), ex));
}
catch (FormatException ex)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(GetTypeInfoError(SR.ErrorSerializing, GetSerializeType(graph), ex), ex));
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:27,代码来源:XmlObjectSerializer.cs
示例4: ReflectionWriteClass
public void ReflectionWriteClass(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context, ClassDataContract classContract, XmlDictionaryString[] memberNames)
{
InvokeOnSerializing(obj, context, classContract);
obj = ResolveAdapterType(obj, classContract);
ReflectionWriteMembers(xmlWriter, obj, context, classContract, classContract, 0 /*childElementIndex*/, memberNames);
InvokeOnSerialized(obj, context, classContract);
}
开发者ID:swaroop-sridhar,项目名称:corefx,代码行数:7,代码来源:ReflectionClassWriter.cs
示例5: 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);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:JsonXmlDataContract.cs
示例6: 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();
}
}
开发者ID:johnhhm,项目名称:corefx,代码行数:13,代码来源:XmlObjectSerializerWriteContextComplex.cs
示例7: WriteRootElement
internal override void WriteRootElement(XmlWriterDelegator writer, XmlDictionaryString name, XmlDictionaryString ns)
{
if (object.ReferenceEquals(ns, DictionaryGlobals.SerializationNamespace))
{
writer.WriteStartElement("z", name, ns);
}
else if (((ns != null) && (ns.Value != null)) && (ns.Value.Length > 0))
{
writer.WriteStartElement("q", name, ns);
}
else
{
writer.WriteStartElement(name, ns);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:QNameDataContract.cs
示例8: ReflectionInitArgs
private void ReflectionInitArgs(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context, ClassDataContract classContract)
{
if (obj.GetType() == typeof(DateTimeOffset))
{
obj = DateTimeOffsetAdapter.GetDateTimeOffsetAdapter((DateTimeOffset)obj);
}
else if (obj.GetType().GetTypeInfo().IsGenericType && obj.GetType().GetGenericTypeDefinition() == typeof(KeyValuePair<,>))
{
obj = classContract.KeyValuePairAdapterConstructorInfo.Invoke(new object[] { obj });
}
_arg0XmlWriter = xmlWriter;
_arg1Object = obj;
_arg2Context = context;
_arg3ClassDataContract = classContract;
}
开发者ID:SGuyGe,项目名称:corefx,代码行数:16,代码来源:ReflectionXmlFormatWriter.cs
示例9: WriteCollectionToXml
public void WriteCollectionToXml (XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context, CollectionDataContract collectionContract)
{
this.writer = xmlWriter;
this.obj = obj;
this.ctx = context;
this.dataContract = collectionContract;
InitArgs (collectionContract.UnderlyingType);
// DemandMemberAccessPermission(memberAccessFlag);
if (collectionContract.IsReadOnlyContract)
{
DataContract.ThrowInvalidDataContractException (collectionContract.SerializationExceptionMessage, null);
}
WriteCollection (collectionContract);
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:17,代码来源:XmlFormatWriterGenerator_static.cs
示例10: WriteObjectHandleExceptions
internal void WriteObjectHandleExceptions(XmlWriterDelegator writer, object graph, DataContractResolver dataContractResolver)
{
try
{
CheckNull(writer, nameof(writer));
{
InternalWriteObject(writer, graph, dataContractResolver);
}
}
catch (XmlException ex)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(GetTypeInfoError(SR.ErrorSerializing, GetSerializeType(graph), ex), ex));
}
catch (FormatException ex)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(GetTypeInfoError(SR.ErrorSerializing, GetSerializeType(graph), ex), ex));
}
}
开发者ID:dotnet,项目名称:corefx,代码行数:18,代码来源:XmlObjectSerializer.cs
示例11: WriteToXml
public void WriteToXml (XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context, ClassDataContract dataContract)
{
this.writer = xmlWriter;
this.obj = obj;
this.ctx = context;
this.dataContract = dataContract;
InitArgs (classContract.UnderlyingType);
// DemandSerializationFormatterPermission (classContract) - irrelevant
// DemandMemberAccessPermission (memberAccessFlag) - irrelevant
if (classContract.IsReadOnlyContract)
{
DataContract.ThrowInvalidDataContractException (classContract.SerializationExceptionMessage, null);
}
WriteClass (classContract);
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:19,代码来源:XmlFormatWriterGenerator_static.cs
示例12: WriteXmlValue
public override void WriteXmlValue(XmlWriterDelegator writer, object obj, XmlObjectSerializerWriteContext context)
{
writer.WriteChar((char) obj);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:CharDataContract.cs
示例13: WriteJsonValue
public void WriteJsonValue(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
{
PushKnownDataContracts(context);
WriteJsonValueCore(jsonWriter, obj, context, declaredTypeHandle);
PopKnownDataContracts(context);
}
开发者ID:johnhhm,项目名称:corefx,代码行数:6,代码来源:JsonDataContract.cs
示例14: WriteJsonValueCore
public virtual void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
{
TraditionalDataContract.WriteXmlValue(jsonWriter, obj, context);
}
开发者ID:johnhhm,项目名称:corefx,代码行数:4,代码来源:JsonDataContract.cs
示例15: TryWritePrimitive
private bool TryWritePrimitive(Type type, object value, XmlWriterDelegator writer, XmlObjectSerializerWriteContext context)
{
PrimitiveDataContract primitiveContract = PrimitiveDataContract.GetPrimitiveDataContract(type);
if (primitiveContract == null || primitiveContract.UnderlyingType == Globals.TypeOfObject)
return false;
writer.WriteAttributeString(Globals.XsiPrefix, "type", null, "x:" + primitiveContract.StableName.Name);
primitiveContract.WriteXmlValue(writer, value, context);
return true;
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:12,代码来源:ExceptionDataContract.cs
示例16: WriteSystemExceptionRequiredValues
private void WriteSystemExceptionRequiredValues(XmlWriterDelegator writer, object value, XmlObjectSerializerWriteContext context)
{
Dictionary<string, object> exceptionFields = GetExceptionFieldValues((Exception)value);
object val;
foreach (string key in exceptionFields.Keys)
{
if (!exceptionFields.TryGetValue(key, out val))
continue;
Type fieldType;
FieldInfo FieldFind = Globals.TypeOfException.GetField(key, BindingFlags.Instance | BindingFlags.NonPublic);
if (FieldFind == null)
{
val = null; // need to nullify because the private fields that are necessary in Exception have changed.
fieldType = typeof(int); // can be any type, it doesn't matter. field type will be used to recover a contract, but the type won't be utilized.
}
else
fieldType = FieldFind.FieldType;
string fieldDisplayName;
if (EssentialExceptionFields.TryGetValue(key, out fieldDisplayName))
writer.WriteStartElement(fieldDisplayName, "");
else
writer.WriteStartElement(key, "");
DataContract fieldDataContract = context.GetDataContract(fieldType);
if (val != null && fieldDataContract != null && !TryCheckIfNoCountIDictionary(fieldType, val))
{
if (!TryWritePrimitive(fieldType, val, writer, context))
{
writer.WriteAttributeString(Globals.XsiPrefix, "type", null, "a:" + fieldDataContract.StableName.Name);
writer.WriteXmlnsAttribute("a", new XmlDictionary(1).Add(fieldDataContract.StableName.Namespace));
fieldDataContract.WriteXmlValue(writer, val, context);
}
}
else
{
writer.WriteAttributeString(Globals.XsiPrefix, "nil", null, "true");
}
writer.WriteEndElement();
}
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:43,代码来源:ExceptionDataContract.cs
示例17: InternalWriteEndObject
internal override void InternalWriteEndObject(XmlWriterDelegator writer)
{
if (!IsRootXmlAny(_rootName, RootContract))
{
writer.WriteEndElement();
}
}
开发者ID:nadyalo,项目名称:corefx,代码行数:7,代码来源:DataContractSerializer.cs
示例18: InternalWriteObjectContent
internal override void InternalWriteObjectContent(XmlWriterDelegator writer, object graph)
{
InternalWriteObjectContent(writer, graph, null);
}
开发者ID:nadyalo,项目名称:corefx,代码行数:4,代码来源:DataContractSerializer.cs
示例19: InternalWriteObject
internal override void InternalWriteObject(XmlWriterDelegator writer, object graph, DataContractResolver dataContractResolver)
{
InternalWriteStartObject(writer, graph);
InternalWriteObjectContent(writer, graph, dataContractResolver);
InternalWriteEndObject(writer);
}
开发者ID:nadyalo,项目名称:corefx,代码行数:6,代码来源:DataContractSerializer.cs
示例20: InternalWriteStartObject
internal override void InternalWriteStartObject(XmlWriterDelegator writer, object graph)
{
WriteRootElement(writer, RootContract, _rootName, _rootNamespace, _needsContractNsAtRoot);
}
开发者ID:nadyalo,项目名称:corefx,代码行数:4,代码来源:DataContractSerializer.cs
注:本文中的System.Runtime.Serialization.XmlWriterDelegator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论