本文整理汇总了C#中BinaryWriter.WriteObject方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteObject方法的具体用法?C# BinaryWriter.WriteObject怎么用?C# BinaryWriter.WriteObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.WriteObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteQueryArgs
/// <summary>
/// Write query arguments.
/// </summary>
/// <param name="writer">Writer.</param>
/// <param name="args">Arguments.</param>
internal static void WriteQueryArgs(BinaryWriter writer, object[] args)
{
if (args == null)
writer.WriteInt(0);
else
{
writer.WriteInt(args.Length);
foreach (var arg in args)
writer.WriteObject(arg);
}
}
示例2: WriteProxyMethod
/// <summary>
/// Writes proxy method invocation data to the specified writer.
/// </summary>
/// <param name="writer">Writer.</param>
/// <param name="method">Method.</param>
/// <param name="arguments">Arguments.</param>
public static void WriteProxyMethod(BinaryWriter writer, MethodBase method, object[] arguments)
{
Debug.Assert(writer != null);
Debug.Assert(method != null);
writer.WriteString(method.Name);
if (arguments != null)
{
writer.WriteBoolean(true);
writer.WriteInt(arguments.Length);
foreach (var arg in arguments)
writer.WriteObject(arg);
}
else
writer.WriteBoolean(false);
}
示例3: WriteArgForPlatforms
/// <summary>
/// Writes the argument in platform-compatible format.
/// </summary>
private static void WriteArgForPlatforms(BinaryWriter writer, ParameterInfo param, object arg)
{
var hnd = GetPlatformArgWriter(param, arg);
if (hnd != null)
hnd(writer, arg);
else
writer.WriteObject(arg);
}
示例4: WriteProxyMethod
/// <summary>
/// Writes proxy method invocation data to the specified writer.
/// </summary>
/// <param name="writer">Writer.</param>
/// <param name="method">Method.</param>
/// <param name="arguments">Arguments.</param>
/// <param name="platform">The platform.</param>
public static void WriteProxyMethod(BinaryWriter writer, MethodBase method, object[] arguments,
Platform platform)
{
Debug.Assert(writer != null);
Debug.Assert(method != null);
writer.WriteString(method.Name);
if (arguments != null)
{
writer.WriteBoolean(true);
writer.WriteInt(arguments.Length);
if (platform == Platform.DotNet)
{
// Write as is
foreach (var arg in arguments)
writer.WriteObject(arg);
}
else
{
// Other platforms do not support Serializable, need to convert arrays and collections
var methodArgs = method.GetParameters();
Debug.Assert(methodArgs.Length == arguments.Length);
for (int i = 0; i < arguments.Length; i++)
WriteArgForPlatforms(writer, methodArgs[i], arguments[i]);
}
}
else
writer.WriteBoolean(false);
}