本文整理汇总了C#中IStorage.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# IStorage.Serialize方法的具体用法?C# IStorage.Serialize怎么用?C# IStorage.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStorage
的用法示例。
在下文中一共展示了IStorage.Serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
public Data.Node Serialize(IStorage storage, Reflect.Type type, object data, Uri.Locator locator)
{
Data.Branch result = new Data.Branch(data, type);
foreach (Reflect.Field field in data.GetFields())
{
Uri.Locator l = locator.Copy();
string name = field.Name.Convert(Casing.Camel, storage.Casing);
l.Fragment = (l.Fragment.NotEmpty() ? l.Fragment + "." : "") + name;
result.Nodes.Add(storage.Serialize(field.Type, field.Data, l).UpdateName(name));
}
return result;
}
示例2: Serialize
public Data.Node Serialize(IStorage storage, Reflect.Type type, object data, Uri.Locator locator)
{
Data.Collection result = new Data.Collection(data, type);
Reflect.Type elementType = this.GetElementType(type);
int c = 0;
foreach (object child in data as System.Collections.IEnumerable)
{
Uri.Locator l = null;
if (locator.NotNull())
{
l = locator.Copy();
l.Fragment = (l.Fragment.NotEmpty() ? l.Fragment + "/" : "") + (c++).ToString();
}
result.Nodes.Add(storage.Serialize(elementType, child, l));
}
return result;
}
示例3: Serialize
public Data.Node Serialize(IStorage storage, Reflect.Type type, object data, Uri.Locator resource)
{
Data.Node result;
Uri.Locator l = storage.Resolver.Update(data, resource);
if (l.NotNull())
result = new Data.Link(l);
else
{
result = new Data.Branch(data, type);
foreach (Reflect.Property property in data.GetProperties())
{
ParameterAttribute[] attributes = property.GetAttributes<ParameterAttribute>();
if (attributes.Length == 1 && property.Data.NotNull())
{
string name = attributes[0].Name ?? property.Name.Convert(Casing.Pascal, storage.Casing);
if (resource.NotNull())
{
l = resource.Copy();
l.Fragment = (l.Fragment.NotEmpty() ? l.Fragment + "/" : "") + name;
}
(result as Data.Branch).Nodes.Add(storage.Serialize(property.Type, property.Data, l).UpdateName(name).UpdateAttribute(attributes[0]).UpdateLocator(resource));
}
}
}
return result;
}