本文整理汇总了C#中ExportContext.writeLength方法的典型用法代码示例。如果您正苦于以下问题:C# ExportContext.writeLength方法的具体用法?C# ExportContext.writeLength怎么用?C# ExportContext.writeLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExportContext
的用法示例。
在下文中一共展示了ExportContext.writeLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: writeObject
public override void writeObject(ExportContext ctx, object value, TypeData[] typeArgs = null)
{
// make a list of all the fields that have changed, then send only those
// TODO: Improve this.. Perhaps it writes them all to a new stream, a byte[], so that
// we can insert the length afterwards... ugh...
List<FieldData> fields = null;
foreach (FieldData field in _fields) {
if (field.hasChanged(value)) {
(fields ?? (fields = new List<FieldData>())).Add(field);
}
}
if (fields == null) {
ctx.writeLength(0);
return;
}
ctx.writeLength(fields.Count);
foreach (FieldData field in fields) {
field.writeField(ctx, this, value);
}
}
示例2: writeObject
public override void writeObject(ExportContext ctx, object value, TypeData[] typeArgs = null)
{
// TODO: we should consider making a non-generic IMuliset interface for easy wildcarding
TypeData elementType = typeArgs[0];
Type fullType = value.GetType();
int size = (int)fullType.GetProperty("ElementCount").GetValue(value, null);
ctx.writeLength(size);
if (size == 0) {
return;
}
IEnumerable en = (IEnumerable)fullType.GetMethod("EntrySet").Invoke(value, null);
PropertyInfo getKey = null, getVal = null;
foreach (var entry in en) {
if (getKey == null) {
Type entryType = entry.GetType();
getKey = entryType.GetProperty("Key");
getVal = entryType.GetProperty("Value");
}
this.logInfo("Writing value of multiset",
"value", getKey.GetValue(entry, null));
ctx.writeObject(getKey.GetValue(entry, null), elementType);
ctx.writeLength((int)getVal.GetValue(entry, null));
}
}
示例3: writeEntries
protected void writeEntries(
ExportContext ctx, IEnumerable enumerable, int size, TypeData expectedElementType)
{
ctx.writeLength(size);
foreach (object entry in enumerable) {
ctx.writeObject(entry, expectedElementType);
}
}