本文整理汇总了C#中__BinaryWriter类的典型用法代码示例。如果您正苦于以下问题:C# __BinaryWriter类的具体用法?C# __BinaryWriter怎么用?C# __BinaryWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
__BinaryWriter类属于命名空间,在下文中一共展示了__BinaryWriter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
public void Write(__BinaryWriter sout)
{
this.majorVersion = this.binaryFormatterMajorVersion;
this.minorVersion = this.binaryFormatterMinorVersion;
sout.WriteByte((byte) this.binaryHeaderEnum);
sout.WriteInt32(this.topId);
sout.WriteInt32(this.headerId);
sout.WriteInt32(this.binaryFormatterMajorVersion);
sout.WriteInt32(this.binaryFormatterMinorVersion);
}
示例2: Write
public void Write(__BinaryWriter sout)
{
if (nullCount == 1)
{
sout.WriteByte((Byte)BinaryHeaderEnum.ObjectNull);
}
else if (nullCount < 256)
{
sout.WriteByte((Byte)BinaryHeaderEnum.ObjectNullMultiple256);
sout.WriteByte((Byte)nullCount);
//Console.WriteLine("Write nullCount "+nullCount);
}
else
{
sout.WriteByte((Byte)BinaryHeaderEnum.ObjectNullMultiple);
sout.WriteInt32(nullCount);
//Console.WriteLine("Write nullCount "+nullCount);
}
}
示例3: Serialize
internal void Serialize(Stream serializationStream, object graph, Header[] headers, bool fCheck)
{
if (serializationStream == null)
{
throw new ArgumentNullException("serializationStream", Environment.GetResourceString("ArgumentNull_WithParamName", new object[] { serializationStream }));
}
InternalFE formatterEnums = new InternalFE {
FEtypeFormat = this.m_typeFormat,
FEserializerTypeEnum = InternalSerializerTypeE.Binary,
FEassemblyFormat = this.m_assemblyFormat
};
ObjectWriter objectWriter = new ObjectWriter(this.m_surrogates, this.m_context, formatterEnums, this.m_binder);
__BinaryWriter serWriter = new __BinaryWriter(serializationStream, objectWriter, this.m_typeFormat);
objectWriter.Serialize(graph, headers, serWriter, fCheck);
this.m_crossAppDomainArray = objectWriter.crossAppDomainArray;
}
示例4: Serialize
[System.Security.SecurityCritical] // auto-generated
internal void Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, bool fCheck)
{
if (graph == null)
throw new ArgumentNullException("graph", Environment.GetResourceString("ArgumentNull_Graph"));
if (serWriter == null)
throw new ArgumentNullException("serWriter", Environment.GetResourceString("ArgumentNull_WithParamName", "serWriter"));
Contract.EndContractBlock();
SerTrace.Log(this, "Serialize Entry 2 ", graph, ((headers == null) ? " no headers " : "headers "));
if (fCheck)
{
CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
}
this.serWriter = serWriter;
this.headers = inHeaders;
SerTrace.Log( this, "Serialize New SerializedTypeTable");
serWriter.WriteBegin();
long headerId = 0;
Object obj;
long objectId;
bool isNew;
bool bMethodCall = false;
bool bMethodReturn = false;
#if FEATURE_REMOTING
// Special case IMethodCallMessage and IMethodReturnMessage for performance
IMethodCallMessage mess = graph as IMethodCallMessage;
if (mess != null)
{
bMethodCall = true;
graph = WriteMethodCall(mess);
}
else
{
IMethodReturnMessage mr = graph as IMethodReturnMessage;
if (mr != null)
{
bMethodReturn = true;
graph = WriteMethodReturn(mr);
}
}
#endif // FEATURE_REMOTING
if (graph == null)
{
WriteSerializedStreamHeader(topId, headerId);
if (bMethodCall)
serWriter.WriteMethodCall();
else if (bMethodReturn)
serWriter.WriteMethodReturn();
serWriter.WriteSerializationHeaderEnd();
serWriter.WriteEnd();
return;
}
// allocations if methodCall or methodResponse and no graph
m_idGenerator = new ObjectIDGenerator();
m_objectQueue = new Queue();
m_formatterConverter = new FormatterConverter();
serObjectInfoInit = new SerObjectInfoInit();
topId = InternalGetId(graph, false, null, out isNew);
if (headers != null)
headerId = InternalGetId(headers, false, null, out isNew);
else
headerId = -1;
WriteSerializedStreamHeader(topId, headerId);
if (bMethodCall)
serWriter.WriteMethodCall();
else if (bMethodReturn)
serWriter.WriteMethodReturn();
SerTrace.Log( this, "Serialize Schedule 0");
// Write out SerializedStream header
if ((headers != null) && (headers.Length > 0))
m_objectQueue.Enqueue(headers);
if (graph != null)
m_objectQueue.Enqueue(graph);
while ((obj = GetNext(out objectId))!=null)
{
SerTrace.Log( this, "Serialize GetNext ",obj);
WriteObjectInfo objectInfo = null;
// GetNext will return either an object or a WriteObjectInfo.
// A WriteObjectInfo is returned if this object was member of another object
if (obj is WriteObjectInfo)
//.........这里部分代码省略.........
示例5: WriteWithCode
internal static void WriteWithCode(Type type, Object value, __BinaryWriter sout)
{
if ((object)type == null)
sout.WriteByte((Byte)InternalPrimitiveTypeE.Null);
else if (Object.ReferenceEquals(type, Converter.typeofString))
WriteStringWithCode((String)value, sout);
else
{
InternalPrimitiveTypeE code = Converter.ToCode(type);
sout.WriteByte((Byte)code);
sout.WriteValue(code, value);
}
}
示例6: WriteStringWithCode
internal static void WriteStringWithCode(String value, __BinaryWriter sout)
{
if (value == null)
sout.WriteByte((Byte)InternalPrimitiveTypeE.Null);
else
{
sout.WriteByte((Byte)InternalPrimitiveTypeE.String);
sout.WriteString(value);
}
}
示例7: WriteTypeInfo
// Writes the type information on the wire
internal static void WriteTypeInfo(BinaryTypeEnum binaryTypeEnum, Object typeInformation, int assemId, __BinaryWriter sout)
{
SerTrace.Log( "BinaryConverter", "WriteTypeInfo Entry ",((Enum)binaryTypeEnum).ToString()," ",typeInformation," assemId ",assemId);
switch (binaryTypeEnum)
{
case BinaryTypeEnum.Primitive:
case BinaryTypeEnum.PrimitiveArray:
Contract.Assert(typeInformation!=null, "[BinaryConverter.WriteTypeInfo]typeInformation!=null");
sout.WriteByte((Byte)((InternalPrimitiveTypeE)typeInformation));
break;
case BinaryTypeEnum.String:
case BinaryTypeEnum.Object:
case BinaryTypeEnum.StringArray:
case BinaryTypeEnum.ObjectArray:
break;
case BinaryTypeEnum.ObjectUrt:
Contract.Assert(typeInformation!=null, "[BinaryConverter.WriteTypeInfo]typeInformation!=null");
sout.WriteString(typeInformation.ToString());
break;
case BinaryTypeEnum.ObjectUser:
Contract.Assert(typeInformation!=null, "[BinaryConverter.WriteTypeInfo]typeInformation!=null");
sout.WriteString(typeInformation.ToString());
sout.WriteInt32(assemId);
break;
default:
throw new SerializationException(Environment.GetResourceString("Serialization_TypeWrite",((Enum)binaryTypeEnum).ToString()));
}
SerTrace.Log( "BinaryConverter", "WriteTypeInfo Exit");
}
示例8: Serialize
// Commences the process of serializing the entire graph. All of the data (in the appropriate format
// is emitted onto the stream).
internal void Serialize(Stream serializationStream, Object graph, Header[] headers, bool fCheck)
{
if (serializationStream==null)
{
throw new ArgumentNullException("serializationStream", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentNull_WithParamName"),serializationStream));
}
SerTrace.Log(this, "Serialize Entry");
InternalFE formatterEnums = new InternalFE();
formatterEnums.FEtypeFormat = m_typeFormat;
formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Binary;
formatterEnums.FEassemblyFormat = m_assemblyFormat;
ObjectWriter sow = new ObjectWriter(m_surrogates, m_context, formatterEnums);
__BinaryWriter binaryWriter = new __BinaryWriter(serializationStream, sow, m_typeFormat);
sow.Serialize(graph, headers, binaryWriter, fCheck);
m_crossAppDomainArray = sow.crossAppDomainArray;
}