本文整理汇总了C#中FieldDescriptor.AutomaticLazyGetCollectionOrMap方法的典型用法代码示例。如果您正苦于以下问题:C# FieldDescriptor.AutomaticLazyGetCollectionOrMap方法的具体用法?C# FieldDescriptor.AutomaticLazyGetCollectionOrMap怎么用?C# FieldDescriptor.AutomaticLazyGetCollectionOrMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldDescriptor
的用法示例。
在下文中一共展示了FieldDescriptor.AutomaticLazyGetCollectionOrMap方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddToMapOrMarkUnresolved
private void AddToMapOrMarkUnresolved(object root, FieldDescriptor currentFieldDescriptor, object subRoot,
string simplId)
{
IDictionary collection =
(IDictionary) currentFieldDescriptor.AutomaticLazyGetCollectionOrMap(root);
if (subRoot != null)
{
var mappable = subRoot as IMappable<object>;
if (mappable != null)
{
var key = mappable.Key();
collection.Add(key, mappable);
}
}
else
translationContext.RefObjectNeedsIdResolve(collection, null, simplId);
}
示例2: DeserializeAndAddToCollection
private void DeserializeAndAddToCollection(object root, FieldDescriptor currentFieldDescriptor, string tagName, int actualCollectionSizeIncludingRefs)
{
string simplId;
var collection = (IList) currentFieldDescriptor.AutomaticLazyGetCollectionOrMap(root);
object subRoot = GetSubRoot(currentFieldDescriptor, tagName, out simplId);
if (subRoot != null)
{
try
{
collection.Add(subRoot);
}
catch (ArgumentException e)
{
// type of subroot does not match collection.
Debug.WriteLine(e.Message);
}
}
else if (simplId != null)
translationContext.RefObjectNeedsIdResolve(collection, actualCollectionSizeIncludingRefs, simplId);
}
示例3: DeserializeCompositeMapElement
/// <summary>
///
/// </summary>
/// <param name="root"></param>
/// <param name="fd"></param>
private void DeserializeCompositeMapElement(object root, FieldDescriptor fd)
{
String compositeTagName = CurrentTag;
Object subRoot = GetSubRoot(fd, compositeTagName, root);
if (subRoot != null)
{
IDictionary dictionary = (IDictionary) fd.AutomaticLazyGetCollectionOrMap(root);
Object key = (subRoot is IMappable<Object>) ? ((IMappable<Object>)subRoot).Key() :
fd.GetMapKeyFieldValue(subRoot);
if (key != null)
{
if (dictionary.Contains(key))
{
//Note: overriding a key in map, duplicate data in xml.
dictionary[key] = subRoot;
}
else
{
dictionary.Add(key, subRoot);
}
}
}
}
示例4: DeserializeCompositeCollectionElement
/// <summary>
///
/// </summary>
/// <param name="root"></param>
/// <param name="fd"></param>
private void DeserializeCompositeCollectionElement(object root, FieldDescriptor fd)
{
String compositeTagName = CurrentTag;
Object subRoot = GetSubRoot(fd, compositeTagName, root);
if (subRoot != null)
{
IList collection = (IList) fd.AutomaticLazyGetCollectionOrMap(root);
collection.Add(subRoot);
}
}
示例5: DeserializeCompositeMapElement
/// <summary>
///
/// </summary>
/// <param name="root"></param>
/// <param name="fd"></param>
/// <returns></returns>
private int DeserializeCompositeMapElement(Object root, FieldDescriptor fd)
{
int length = _blockLength;
object subRoot = GetSubRoot(fd, root);
if (subRoot is IMappable<Object>)
{
Object key = ((IMappable<Object>) subRoot).Key();
IDictionary dictionary = (IDictionary) fd.AutomaticLazyGetCollectionOrMap(root);
if (dictionary.Contains(key))
{
//Note: overriding a key in map, duplicate data?.
dictionary[key] = subRoot;
}
else
{
dictionary.Add(key, subRoot);
}
}
return length;
}
示例6: DeserializeCompositeCollectionElement
/// <summary>
///
/// </summary>
/// <param name="root"></param>
/// <param name="fd"></param>
/// <returns></returns>
private int DeserializeCompositeCollectionElement(Object root, FieldDescriptor fd)
{
int length = _blockLength;
object subRoot = GetSubRoot(fd, root);
if (subRoot != null)
{
IList collection = (IList) fd.AutomaticLazyGetCollectionOrMap(root);
collection.Add(subRoot);
}
return length;
}