本文整理汇总了C#中System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.GetMemberInfo方法的典型用法代码示例。如果您正苦于以下问题:C# WriteObjectInfo.GetMemberInfo方法的具体用法?C# WriteObjectInfo.GetMemberInfo怎么用?C# WriteObjectInfo.GetMemberInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo
的用法示例。
在下文中一共展示了WriteObjectInfo.GetMemberInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
// Writes a given object to the stream.
private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
{
object obj = objectInfo._obj;
if (obj == null)
{
throw new ArgumentNullException(nameof(objectInfo) + "." + nameof(objectInfo._obj));
}
Type objType = objectInfo._objectType;
long objectId = objectInfo._objectId;
if (ReferenceEquals(objType, Converter.s_typeofString))
{
// Top level String
memberNameInfo._objectId = objectId;
_serWriter.WriteObjectString((int)objectId, obj.ToString());
}
else
{
if (objectInfo._isArray)
{
WriteArray(objectInfo, memberNameInfo, null);
}
else
{
string[] memberNames;
Type[] memberTypes;
object[] memberData;
objectInfo.GetMemberInfo(out memberNames, out memberTypes, out memberData);
// Only Binary needs to transmit types for ISerializable because the binary formatter transmits the types in URT format.
// Soap transmits all types as strings, so it is up to the ISerializable object to convert the string back to its URT type
if (objectInfo._isSi || CheckTypeFormat(_formatterEnums._typeFormat, FormatterTypeStyle.TypesAlways))
{
memberNameInfo._transmitTypeOnObject = true;
memberNameInfo._isParentTypeOnObject = true;
typeNameInfo._transmitTypeOnObject = true;
typeNameInfo._isParentTypeOnObject = true;
}
var memberObjectInfos = new WriteObjectInfo[memberNames.Length];
// Get assembly information
// Binary Serializer, assembly names need to be
// written before objects are referenced.
// GetAssemId here will write out the
// assemblyStrings at the right Binary
// Serialization object boundary.
for (int i = 0; i < memberTypes.Length; i++)
{
Type type =
memberTypes[i] != null ? memberTypes[i] :
memberData[i] != null ? GetType(memberData[i]) :
Converter.s_typeofObject;
InternalPrimitiveTypeE code = ToCode(type);
if ((code == InternalPrimitiveTypeE.Invalid) &&
(!ReferenceEquals(type, Converter.s_typeofString)))
{
if (memberData[i] != null)
{
memberObjectInfos[i] = WriteObjectInfo.Serialize(
memberData[i],
_surrogates,
_context,
_serObjectInfoInit,
_formatterConverter,
this,
_binder);
memberObjectInfos[i]._assemId = GetAssemblyId(memberObjectInfos[i]);
}
else
{
memberObjectInfos[i] = WriteObjectInfo.Serialize(
memberTypes[i],
_surrogates,
_context,
_serObjectInfoInit,
_formatterConverter,
_binder);
memberObjectInfos[i]._assemId = GetAssemblyId(memberObjectInfos[i]);
}
}
}
Write(objectInfo, memberNameInfo, typeNameInfo, memberNames, memberTypes, memberData, memberObjectInfos);
}
}
}
示例2: Write
[System.Security.SecurityCritical] // auto-generated
private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
{
#if _DEBUG
SerTrace.Log( this, "Write 1 Entry objectInfo ",objectInfo,", memberNameInfo ",memberNameInfo,", typeNameInfo ",typeNameInfo);
memberNameInfo.Dump("Write memberNameInfo");
typeNameInfo.Dump("Write typeNameInfo");
#endif
Object obj = objectInfo.obj;
if (obj==null)
throw new ArgumentNullException("objectInfo.obj", Environment.GetResourceString("ArgumentNull_Obj"));
SerTrace.Log( this, "Write 1 objectInfo obj ",objectInfo.obj," objectId ", objectInfo.objectId, " objectType ", objectInfo.objectType);
Type objType = objectInfo.objectType;
long objectId = objectInfo.objectId;
SerTrace.Log( this, "Write 1 ",obj," ObjectId ",objectId);
if (Object.ReferenceEquals(objType, Converter.typeofString))
{
// Top level String
memberNameInfo.NIobjectId = objectId;
serWriter.WriteObjectString((int)objectId, obj.ToString());
}
else
{
if (objectInfo.isArray)
{
WriteArray(objectInfo, memberNameInfo, null);
}
else
{
String[] memberNames;
Type[] memberTypes;
Object[] memberData;
objectInfo.GetMemberInfo(out memberNames, out memberTypes, out memberData);
// Only Binary needs to transmit types for ISerializable because the binary formatter transmits the types in URT format.
// Soap transmits all types as strings, so it is up to the ISerializable object to convert the string back to its URT type
if (objectInfo.isSi || CheckTypeFormat(formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
{
SerTrace.Log( this, "Write 1 TransmitOnObject ");
memberNameInfo.NItransmitTypeOnObject = true;
memberNameInfo.NIisParentTypeOnObject = true;
typeNameInfo.NItransmitTypeOnObject = true;
typeNameInfo.NIisParentTypeOnObject = true;
}
WriteObjectInfo[] memberObjectInfos = new WriteObjectInfo[memberNames.Length];
// Get assembly information
// Binary Serializer, assembly names need to be
// written before objects are referenced.
// GetAssemId here will write out the
// assemblyStrings at the right Binary
// Serialization object boundary.
for (int i=0; i<memberTypes.Length; i++)
{
Type type;
if ((object)memberTypes[i] != null)
type = memberTypes[i];
else if (memberData[i] != null)
type = GetType(memberData[i]);
else
type = Converter.typeofObject;
SerTrace.Log( this, "Write 1 member type ",type);
InternalPrimitiveTypeE code = ToCode(type);
if ((code == InternalPrimitiveTypeE.Invalid) &&
(!Object.ReferenceEquals(type, Converter.typeofString)))
{
SerTrace.Log( this, "Write 1 Create ObjectInfo ", memberTypes[i], " memberData ",memberData[i]);
if (memberData[i] != null)
{
memberObjectInfos[i] =
WriteObjectInfo.Serialize
(
memberData[i],
m_surrogates,
m_context,
serObjectInfoInit,
m_formatterConverter,
this,
m_binder);
memberObjectInfos[i].assemId = GetAssemblyId(memberObjectInfos[i]);
}
else
{
memberObjectInfos[i] =
WriteObjectInfo.Serialize
(
memberTypes[i],
m_surrogates,
m_context,
serObjectInfoInit,
m_formatterConverter,
m_binder
//.........这里部分代码省略.........
示例3: Write
private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
{
object obj2 = objectInfo.obj;
if (obj2 == null)
{
throw new ArgumentNullException("objectInfo.obj", Environment.GetResourceString("ArgumentNull_Obj"));
}
Type objectType = objectInfo.objectType;
long objectId = objectInfo.objectId;
if (object.ReferenceEquals(objectType, Converter.typeofString))
{
memberNameInfo.NIobjectId = objectId;
this.serWriter.WriteObjectString((int) objectId, obj2.ToString());
}
else if (objectInfo.isArray)
{
this.WriteArray(objectInfo, memberNameInfo, null);
}
else
{
string[] strArray;
Type[] typeArray;
object[] objArray;
objectInfo.GetMemberInfo(out strArray, out typeArray, out objArray);
if (objectInfo.isSi || this.CheckTypeFormat(this.formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
{
memberNameInfo.NItransmitTypeOnObject = true;
memberNameInfo.NIisParentTypeOnObject = true;
typeNameInfo.NItransmitTypeOnObject = true;
typeNameInfo.NIisParentTypeOnObject = true;
}
WriteObjectInfo[] memberObjectInfos = new WriteObjectInfo[strArray.Length];
for (int i = 0; i < typeArray.Length; i++)
{
Type type;
if (typeArray[i] != null)
{
type = typeArray[i];
}
else if (objArray[i] != null)
{
type = this.GetType(objArray[i]);
}
else
{
type = Converter.typeofObject;
}
if ((this.ToCode(type) == InternalPrimitiveTypeE.Invalid) && !object.ReferenceEquals(type, Converter.typeofString))
{
if (objArray[i] != null)
{
memberObjectInfos[i] = WriteObjectInfo.Serialize(objArray[i], this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, this, this.m_binder);
memberObjectInfos[i].assemId = this.GetAssemblyId(memberObjectInfos[i]);
}
else
{
memberObjectInfos[i] = WriteObjectInfo.Serialize(typeArray[i], this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, this.m_binder);
memberObjectInfos[i].assemId = this.GetAssemblyId(memberObjectInfos[i]);
}
}
}
this.Write(objectInfo, memberNameInfo, typeNameInfo, strArray, typeArray, objArray, memberObjectInfos);
}
}