当前位置: 首页>>代码示例>>C#>>正文


C# FieldDescriptor.AutomaticLazyGetCollectionOrMap方法代码示例

本文整理汇总了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);
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:18,代码来源:JsonPullDeserializer.cs

示例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);
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:22,代码来源:JsonPullDeserializer.cs

示例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);
             }
         }
     }
 }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:28,代码来源:XMLPullDeserializer.cs

示例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);
     }
 }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:15,代码来源:XMLPullDeserializer.cs

示例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;
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:28,代码来源:TlvPullDeserializer.cs

示例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;
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:18,代码来源:TlvPullDeserializer.cs


注:本文中的FieldDescriptor.AutomaticLazyGetCollectionOrMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。