本文整理汇总了C#中System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo类的典型用法代码示例。如果您正苦于以下问题:C# WriteObjectInfo类的具体用法?C# WriteObjectInfo怎么用?C# WriteObjectInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WriteObjectInfo类属于System.Runtime.Serialization.Formatters.Binary命名空间,在下文中一共展示了WriteObjectInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAssemblyId
private long GetAssemblyId(WriteObjectInfo objectInfo)
{
if (this.assemblyToIdTable == null)
{
this.assemblyToIdTable = new Hashtable(5);
}
long num = 0L;
bool isNew = false;
string assemblyString = objectInfo.GetAssemblyString();
string str2 = assemblyString;
if (assemblyString.Length == 0)
{
return 0L;
}
if (assemblyString.Equals(Converter.urtAssemblyString))
{
return 0L;
}
if (this.assemblyToIdTable.ContainsKey(assemblyString))
{
num = (long) this.assemblyToIdTable[assemblyString];
isNew = false;
}
else
{
num = this.InternalGetId("___AssemblyString___" + assemblyString, false, null, out isNew);
this.assemblyToIdTable[assemblyString] = num;
}
this.serWriter.WriteAssembly(objectInfo.objectType, str2, (int) num, isNew);
return num;
}
示例2: GetBinaryTypeInfo
internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, string typeName, ObjectWriter objectWriter, out object typeInformation, out int assemId)
{
BinaryTypeEnum primitive;
assemId = 0;
typeInformation = null;
if (object.ReferenceEquals(type, Converter.typeofString))
{
return BinaryTypeEnum.String;
}
if (((objectInfo == null) || ((objectInfo != null) && !objectInfo.isSi)) && object.ReferenceEquals(type, Converter.typeofObject))
{
return BinaryTypeEnum.Object;
}
if (object.ReferenceEquals(type, Converter.typeofStringArray))
{
return BinaryTypeEnum.StringArray;
}
if (object.ReferenceEquals(type, Converter.typeofObjectArray))
{
return BinaryTypeEnum.ObjectArray;
}
if (Converter.IsPrimitiveArray(type, out typeInformation))
{
return BinaryTypeEnum.PrimitiveArray;
}
InternalPrimitiveTypeE ee = objectWriter.ToCode(type);
switch (ee)
{
case InternalPrimitiveTypeE.Invalid:
{
string fullName = null;
if (objectInfo == null)
{
fullName = type.Assembly.FullName;
typeInformation = type.FullName;
}
else
{
fullName = objectInfo.GetAssemblyString();
typeInformation = objectInfo.GetTypeFullName();
}
if (fullName.Equals(Converter.urtAssemblyString))
{
primitive = BinaryTypeEnum.ObjectUrt;
assemId = 0;
return primitive;
}
primitive = BinaryTypeEnum.ObjectUser;
assemId = (int) objectInfo.assemId;
if (assemId == 0)
{
throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId", new object[] { typeInformation }));
}
return primitive;
}
}
primitive = BinaryTypeEnum.Primitive;
typeInformation = ee;
return primitive;
}
示例3: CheckForNull
private bool CheckForNull(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo, object data)
{
bool flag = false;
if (data == null)
{
flag = true;
}
if (flag && ((((this.formatterEnums.FEserializerTypeEnum == InternalSerializerTypeE.Binary) || memberNameInfo.NIisArrayItem) || (memberNameInfo.NItransmitTypeOnObject || memberNameInfo.NItransmitTypeOnMember)) || (objectInfo.isSi || this.CheckTypeFormat(this.formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))))
{
if (typeNameInfo.NIisArrayItem)
{
if (typeNameInfo.NIarrayEnum == InternalArrayTypeE.Single)
{
this.serWriter.WriteDelayedNullItem();
return flag;
}
this.serWriter.WriteNullItem(memberNameInfo, typeNameInfo);
return flag;
}
this.serWriter.WriteNullMember(memberNameInfo, typeNameInfo);
}
return flag;
}
示例4: WriteObjectByteArray
[System.Security.SecurityCritical] // auto-generated
internal void WriteObjectByteArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Byte[] byteA)
{
#if _DEBUG
arrayNameInfo.Dump("WriteObjectByteArray arrayNameInfo");
arrayElemTypeNameInfo.Dump("WriteObjectByteArray arrayElemTypeNameInfo");
#endif
InternalWriteItemNull();
WriteSingleArray(memberNameInfo, arrayNameInfo, objectInfo, arrayElemTypeNameInfo, length, lowerBound, byteA);
}
示例5: Schedule
private long Schedule(Object obj, bool assignUniqueIdToValueType, Type type, WriteObjectInfo objectInfo)
{
SerTrace.Log( this, "Schedule Entry obj ",obj," type ", type, " objectInfo ",objectInfo);
bool isNew;
long id;
if (obj==null)
{
SerTrace.Log(this, "Schedule Obj Null, id = 0 ");
return 0;
}
id = InternalGetId(obj, assignUniqueIdToValueType, type, out isNew);
if (isNew && id > 0)
{
if (objectInfo == null)
m_objectQueue.Enqueue(obj);
else
m_objectQueue.Enqueue(objectInfo);
}
SerTrace.Log( this, "Schedule Exit, id: ",id," isNew: ",isNew);
return id;
}
示例6: WriteRectangle
[System.Security.SecurityCritical] // auto-generated
private void WriteRectangle(WriteObjectInfo objectInfo, int rank, int[] maxA, System.Array array, NameInfo arrayElemNameTypeInfo, int[] lowerBoundA)
{
IndexTraceMessage("WriteRectangle Entry "+rank, maxA);
int[] currentA = new int[rank];
int[] indexMap = null;
bool isLowerBound = false;
if (lowerBoundA != null)
{
for (int i=0; i<rank; i++)
{
if (lowerBoundA[i] != 0)
isLowerBound = true;
}
}
if (isLowerBound)
indexMap = new int[rank];
bool isLoop = true;
while (isLoop)
{
isLoop = false;
if (isLowerBound)
{
for (int i=0; i<rank; i++)
{
indexMap[i] = currentA[i]+lowerBoundA[i];
}
WriteArrayMember(objectInfo, arrayElemNameTypeInfo, array.GetValue(indexMap));
}
else
WriteArrayMember(objectInfo, arrayElemNameTypeInfo, array.GetValue(currentA));
for (int irank = rank-1; irank>-1; irank--)
{
// Find the current or lower dimension which can be incremented.
if (currentA[irank] < maxA[irank]-1)
{
// The current dimension is at maximum. Increase the next lower dimension by 1
currentA[irank]++;
if (irank < rank-1)
{
// The current dimension and higher dimensions are zeroed.
for (int i = irank+1; i<rank; i++)
currentA[i] = 0;
}
isLoop = true;
break;
}
}
}
SerTrace.Log( this, "WriteRectangle Exit ");
}
示例7: GetBinaryTypeInfo
// From the type create the BinaryTypeEnum and typeInformation which describes the type on the wire
internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, String typeName, ObjectWriter objectWriter, out Object typeInformation, out int assemId)
{
SerTrace.Log("BinaryConverter", "GetBinaryTypeInfo Entry type ",type,", typeName ",typeName," objectInfo "+objectInfo);
BinaryTypeEnum binaryTypeEnum;
assemId = 0;
typeInformation = null;
if (Object.ReferenceEquals(type, Converter.typeofString))
binaryTypeEnum = BinaryTypeEnum.String;
else if (((objectInfo == null) || ((objectInfo != null) && !objectInfo.isSi))
&& (Object.ReferenceEquals(type, Converter.typeofObject)))
{
// If objectInfo.Si then can be a surrogate which will change the type
binaryTypeEnum = BinaryTypeEnum.Object;
}
else if (Object.ReferenceEquals(type, Converter.typeofStringArray))
binaryTypeEnum = BinaryTypeEnum.StringArray;
else if (Object.ReferenceEquals(type, Converter.typeofObjectArray))
binaryTypeEnum = BinaryTypeEnum.ObjectArray;
else if (Converter.IsPrimitiveArray(type, out typeInformation))
binaryTypeEnum = BinaryTypeEnum.PrimitiveArray;
else
{
InternalPrimitiveTypeE primitiveTypeEnum = objectWriter.ToCode(type);
switch (primitiveTypeEnum)
{
case InternalPrimitiveTypeE.Invalid:
String assembly = null;
if (objectInfo == null)
{
assembly = type.Assembly.FullName;
typeInformation = type.FullName;
}
else
{
assembly = objectInfo.GetAssemblyString();
typeInformation = objectInfo.GetTypeFullName();
}
if (assembly.Equals(Converter.urtAssemblyString))
{
binaryTypeEnum = BinaryTypeEnum.ObjectUrt;
assemId = 0;
}
else
{
binaryTypeEnum = BinaryTypeEnum.ObjectUser;
Contract.Assert(objectInfo!=null, "[BinaryConverter.GetBinaryTypeInfo]objectInfo null for user object");
assemId = (int)objectInfo.assemId;
if (assemId == 0)
throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId",typeInformation));
}
break;
default:
binaryTypeEnum = BinaryTypeEnum.Primitive;
typeInformation = primitiveTypeEnum;
break;
}
}
SerTrace.Log( "BinaryConverter", "GetBinaryTypeInfo Exit ",((Enum)binaryTypeEnum).ToString(),", typeInformation ",typeInformation," assemId ",assemId);
return binaryTypeEnum;
}
示例8: WriteJaggedArray
internal void WriteJaggedArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound)
{
BinaryArrayTypeEnum jagged;
this.InternalWriteItemNull();
int[] lengthA = new int[] { length };
int[] lowerBoundA = null;
object typeInformation = null;
int assemId = 0;
if (lowerBound == 0)
{
jagged = BinaryArrayTypeEnum.Jagged;
}
else
{
jagged = BinaryArrayTypeEnum.JaggedOffset;
lowerBoundA = new int[] { lowerBound };
}
BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, this.objectWriter, out typeInformation, out assemId);
if (this.binaryArray == null)
{
this.binaryArray = new BinaryArray();
}
this.binaryArray.Set((int) arrayNameInfo.NIobjectId, 1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, jagged, assemId);
long nIobjectId = arrayNameInfo.NIobjectId;
this.binaryArray.Write(this);
}
示例9: WriteArray
[System.Security.SecurityCritical] // auto-generated
private void WriteArray(WriteObjectInfo objectInfo, NameInfo memberNameInfo, WriteObjectInfo memberObjectInfo)
{
SerTrace.Log( this, "WriteArray Entry ",objectInfo.obj," ",objectInfo.objectId);
bool isAllocatedMemberNameInfo = false;
if (memberNameInfo == null)
{
memberNameInfo = TypeToNameInfo(objectInfo);
isAllocatedMemberNameInfo = true;
}
memberNameInfo.NIisArray = true;
long objectId = objectInfo.objectId;
memberNameInfo.NIobjectId = objectInfo.objectId;
// Get array type
System.Array array = (System.Array)objectInfo.obj;
//Type arrayType = array.GetType();
Type arrayType = objectInfo.objectType;
// Get type of array element
Type arrayElemType = arrayType.GetElementType();
WriteObjectInfo arrayElemObjectInfo = null;
if (!arrayElemType.IsPrimitive)
{
arrayElemObjectInfo = WriteObjectInfo.Serialize(arrayElemType, m_surrogates, m_context, serObjectInfoInit, m_formatterConverter, m_binder);
arrayElemObjectInfo.assemId = GetAssemblyId(arrayElemObjectInfo);
}
NameInfo arrayElemTypeNameInfo = null;
if (arrayElemObjectInfo == null)
arrayElemTypeNameInfo = TypeToNameInfo(arrayElemType);
else
arrayElemTypeNameInfo = TypeToNameInfo(arrayElemObjectInfo);
arrayElemTypeNameInfo.NIisArray = arrayElemTypeNameInfo.NItype.IsArray;
NameInfo arrayNameInfo = memberNameInfo;
arrayNameInfo.NIobjectId = objectId;
arrayNameInfo.NIisArray = true;
arrayElemTypeNameInfo.NIobjectId = objectId;
arrayElemTypeNameInfo.NItransmitTypeOnMember = memberNameInfo.NItransmitTypeOnMember;
arrayElemTypeNameInfo.NItransmitTypeOnObject = memberNameInfo.NItransmitTypeOnObject;
arrayElemTypeNameInfo.NIisParentTypeOnObject = memberNameInfo.NIisParentTypeOnObject;
// Get rank and length information
int rank = array.Rank;
int[] lengthA = new int[rank];
int[] lowerBoundA = new int[rank];
int[] upperBoundA = new int[rank];
for (int i=0; i<rank; i++)
{
lengthA[i] = array.GetLength(i);
lowerBoundA[i] = array.GetLowerBound(i);
upperBoundA[i] = array.GetUpperBound(i);
}
InternalArrayTypeE arrayEnum;
if (arrayElemTypeNameInfo.NIisArray)
{
if (rank == 1)
arrayEnum = InternalArrayTypeE.Jagged;
else
arrayEnum = InternalArrayTypeE.Rectangular;
}
else if (rank == 1)
arrayEnum = InternalArrayTypeE.Single;
else
arrayEnum = InternalArrayTypeE.Rectangular;
arrayElemTypeNameInfo.NIarrayEnum = arrayEnum;
SerTrace.Log( this, "WriteArray ArrayInfo type ",arrayType," rank ",rank);
// Byte array
if ((Object.ReferenceEquals(arrayElemType, Converter.typeofByte)) && (rank == 1) && (lowerBoundA[0] == 0))
{
serWriter.WriteObjectByteArray(memberNameInfo, arrayNameInfo, arrayElemObjectInfo, arrayElemTypeNameInfo, lengthA[0], lowerBoundA[0], (byte[])array);
return;
}
if (Object.ReferenceEquals(arrayElemType, Converter.typeofObject) || (object)Nullable.GetUnderlyingType(arrayElemType) != null)
{
memberNameInfo.NItransmitTypeOnMember = true;
arrayElemTypeNameInfo.NItransmitTypeOnMember = true;
}
if (CheckTypeFormat(formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
{
memberNameInfo.NItransmitTypeOnObject = true;
arrayElemTypeNameInfo.NItransmitTypeOnObject = true;
}
if (arrayEnum == InternalArrayTypeE.Single)
{
// Single Dimensional array
//.........这里部分代码省略.........
示例10: PutObjectInfo
private static void PutObjectInfo(SerObjectInfoInit serObjectInfoInit, WriteObjectInfo objectInfo)
{
serObjectInfoInit.oiPool.Push(objectInfo);
//SerTrace.Log( "PutObjectInfo",objectInfo.objectInfoId," PutObjectInfo to pool");
}
示例11: TypeToNameInfo
private NameInfo TypeToNameInfo(WriteObjectInfo objectInfo, NameInfo nameInfo)
{
return TypeToNameInfo(objectInfo.objectType, objectInfo, ToCode(objectInfo.objectType), nameInfo);
}
示例12: WriteSingleArray
internal void WriteSingleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Array array)
{
BinaryArrayTypeEnum single;
int num;
this.InternalWriteItemNull();
int[] lengthA = new int[] { length };
int[] lowerBoundA = null;
object typeInformation = null;
if (lowerBound == 0)
{
single = BinaryArrayTypeEnum.Single;
}
else
{
single = BinaryArrayTypeEnum.SingleOffset;
lowerBoundA = new int[] { lowerBound };
}
BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, this.objectWriter, out typeInformation, out num);
if (this.binaryArray == null)
{
this.binaryArray = new BinaryArray();
}
this.binaryArray.Set((int) arrayNameInfo.NIobjectId, 1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, single, num);
long nIobjectId = arrayNameInfo.NIobjectId;
this.binaryArray.Write(this);
if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo.NIprimitiveTypeEnum) && (lowerBound == 0))
{
if (arrayElemTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Byte)
{
this.WriteBytes((byte[]) array);
}
else if (arrayElemTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Char)
{
this.WriteChars((char[]) array);
}
else
{
this.WriteArrayAsBytes(array, Converter.TypeLength(arrayElemTypeNameInfo.NIprimitiveTypeEnum));
}
}
}
示例13: GetObjectInfo
private static WriteObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit)
{
WriteObjectInfo objectInfo = null;
if (!serObjectInfoInit.oiPool.IsEmpty())
{
objectInfo = (WriteObjectInfo)serObjectInfoInit.oiPool.Pop();
objectInfo.InternalInit();
//SerTrace.Log( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo from pool");
}
else
{
objectInfo = new WriteObjectInfo();
objectInfo.objectInfoId = serObjectInfoInit.objectInfoIdCount++;
//SerTrace.Log( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo new not from pool");
}
return objectInfo;
}
示例14: WriteRectangleArray
internal void WriteRectangleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int rank, int[] lengthA, int[] lowerBoundA)
{
this.InternalWriteItemNull();
BinaryArrayTypeEnum rectangular = BinaryArrayTypeEnum.Rectangular;
object typeInformation = null;
int assemId = 0;
BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, this.objectWriter, out typeInformation, out assemId);
if (this.binaryArray == null)
{
this.binaryArray = new BinaryArray();
}
for (int i = 0; i < rank; i++)
{
if (lowerBoundA[i] != 0)
{
rectangular = BinaryArrayTypeEnum.RectangularOffset;
break;
}
}
this.binaryArray.Set((int) arrayNameInfo.NIobjectId, rank, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, rectangular, assemId);
long nIobjectId = arrayNameInfo.NIobjectId;
this.binaryArray.Write(this);
}
示例15: WriteObjectByteArray
internal void WriteObjectByteArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, byte[] byteA)
{
this.InternalWriteItemNull();
this.WriteSingleArray(memberNameInfo, arrayNameInfo, objectInfo, arrayElemTypeNameInfo, length, lowerBound, byteA);
}