本文整理汇总了C#中IReader.ReadObject方法的典型用法代码示例。如果您正苦于以下问题:C# IReader.ReadObject方法的具体用法?C# IReader.ReadObject怎么用?C# IReader.ReadObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReader
的用法示例。
在下文中一共展示了IReader.ReadObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
/// <summary>外部=>实体,从外部读取信息并写入到实体对象</summary>
/// <param name="entity">实体对象</param>
/// <param name="eop">实体操作。为空时由内部构建,但可在遍历调用访问器时由外部构造一次传入,以提高性能。</param>
public override void Read(IEntity entity, IEntityOperate eop = null)
{
reader = GetReader();
reader.Stream = Stream;
reader.Settings.Encoding = Encoding;
try
{
if (AllFields)
{
Object obj = entity;
reader.ReadObject(null, ref obj, null);
}
else
base.Read(entity, eop);
}
finally
{
//reader.Dispose();
reader = null;
}
}
示例2: ReadValue
private static bool ReadValue(IScope scope, IReader reader, object obj, IElementDef def, IPropertyDef property, out object value)
{
var type = property.Type;
if (type == typeof(object))
{
value = reader.ReadObject();
return true;
}
if (scope.TryRead(() => reader.ReadString(), type, out value))
return true;
var xmlReader = reader as XmlReaderImpl;
if (xmlReader != null)
{
var surrogate = scope.GetSurrogate(type);
if (surrogate != null)
{
value = CreateElement(property, obj);
surrogate.Read(xmlReader.XmlReader, value);
return true;
}
}
var elementDef = scope.GetElementDef(type);
if (elementDef != null)
{
var subScope = elementDef as IScope;
value = ReadElement(subScope ?? scope, reader, elementDef, () => CreateElement(property, obj));
return true;
}
if (ReadEnumElement(reader, type, out value))
return true;
// try read collection
var elementType = Reflector.GetItemType(type);
if (elementType != null)
{
elementDef = new CollectionDef(scope, property.Name, type, elementType);
value = def.IsImmutable ? CreateList(elementType) : CreateElement(property, obj);
ReadElement(scope, reader, elementDef, value);
return true;
}
value = null;
return false;
}