GetDynamicMemberNames() private méthode

private GetDynamicMemberNames ( ) : System.Collections.Generic.IEnumerable
Résultat System.Collections.Generic.IEnumerable
 public DynamicObjectMemberNode(ObjectNode parent, DynamicObject item, int maxDepth, DataContextDriver dcDriver) : base(parent, item, maxDepth, dcDriver)
 {
     base.Name = "DynamicObject";
     base.Summary = item.ToString();
     if (base.Summary.Length > 150)
     {
         base.Summary = base.Summary.Substring(0, 150) + "...";
     }
     IEnumerable<string> dynamicMemberNames = item.GetDynamicMemberNames();
     if (dynamicMemberNames.Any<string>() && (base.CyclicReference == null))
     {
         if (!(!base.IsAtNestingLimit() || (base.Parent is ListNode)))
         {
             base.GraphTruncated = true;
         }
         else
         {
             foreach (string str in dynamicMemberNames)
             {
                 object propValue = this.GetPropValue(item, str);
                 base.Members.Add(new MemberData(str, null, ObjectNode.Create(this, propValue, false, maxDepth, dcDriver)));
             }
         }
     }
 }
Exemple #2
0
 public void Dump(DynamicObject obj)
 {
     foreach (var memberName in obj.GetDynamicMemberNames())
     {
         _appender(GetDynamicMember(obj, memberName).ToString());
         Print("\n");
     }
 }
        /// <summary>
        /// 获取动态类型的值
        /// </summary>
        /// <param name="dynamicObject">实例</param>
        /// <param name="key">键名</param>
        /// <param name="value">值</param>
        /// <returns></returns>
        private bool TryGetValue(DynamicObject dynamicObject, string key, out object value)
        {
            var keys = dynamicObject.GetDynamicMemberNames();
            key = keys.FirstOrDefault(item => string.Equals(item, key, StringComparison.OrdinalIgnoreCase));

            if (key != null)
            {
                return dynamicObject.TryGetMember(new KeyBinder(key, false), out value);
            }

            value = null;
            return false;
        }
        public static DynamicViewModel Create(DynamicObject entity)
        {
            var result = new DynamicViewModel();

            foreach (var memberName in entity.GetDynamicMemberNames())
            {
                object value;
                if (entity.TryGetMember(new GetBinder(memberName, false), out value))
                {
                    result.Set(memberName, value);
                }
            }

            return result;
        }
Exemple #5
0
        static List<PropertyItem> ParseDynamicObject(DynamicObject target)
        {
            var result = new List<PropertyItem>();

              foreach (var propertyName in target.GetDynamicMemberNames())
              {
            var value = DynamicHelper.GetValue(target, propertyName);
            var propertyType = value != null ? value.GetType() : typeof(object);
            var property = new PropertyItem(target, value, new DynamicPropertyInfo(propertyName, propertyType), false);
            result.Add(property);
              }

              return result;
        }