Exemplo n.º 1
0
 public void AddAllValues(MemberType memberType = MemberType.Instance | MemberType.Public | MemberType.Field | MemberType.Property)
 {
     foreach (TreeValue <TypeValueInfo> treeValueInfo in _type.zGetTypeAllValuesInfos(memberType, options: TypeReflectionOptions.ValueType | TypeReflectionOptions.NotValueType))
     {
         TypeValueNode typeValueNode = new TypeValueNode {
             TypeValueAccess = new TypeValueAccess(treeValueInfo.Value, treeValueInfo.Value.TreeName)
         };
         TypeValueNode parent = null;
         if (treeValueInfo.Value.ParentName != null)
         {
             parent = _typeValueNodes[treeValueInfo.Value.ParentName];
             typeValueNode.SetParent(parent);
         }
         //if (typeValueNode.TypeValueAccess.IsValueType)
         //    yield return typeValueNode;
         // $$$$$$$$$$$$ bug $$$$$$$$$$$$ il peut y avoir des doublons
         _typeValueNodes.Add(treeValueInfo.Value.TreeName, typeValueNode);
     }
 }
Exemplo n.º 2
0
        public TypeValueNode AddValue(string name, MemberType memberType = MemberType.Instance | MemberType.Public | MemberType.Field | MemberType.Property, bool notEnumerable = false)
        {
            string        parentName    = null;
            TypeValueNode parent        = null;
            Type          type          = _type;
            TypeValueNode typeValueNode = null;

            foreach (string valueName in name.Split('.'))
            {
                string treeName = valueName;
                if (parentName != null)
                {
                    treeName = parentName + "." + treeName;
                }
                typeValueNode = null;
                if (!_typeValueNodes.ContainsKey(treeName))
                {
                    TypeValueInfo typeValueInfo = type.zGetTypeValueInfo(valueName, memberType);
                    if (typeValueInfo == null)
                    {
                        throw new PBException("unknow value \"{0}\" from type {1} memberType {2}", valueName, type.zGetTypeName(), memberType.ToString());
                    }
                    typeValueNode = new TypeValueNode {
                        TypeValueAccess = new TypeValueAccess(typeValueInfo, treeName)
                    };
                    if (notEnumerable)
                    {
                        typeValueNode.TypeValueAccess.IsEnumerable = false;
                    }
                    typeValueNode.SetParent(parent);
                    _typeValueNodes.Add(treeName, typeValueNode);
                }
                else
                {
                    typeValueNode = _typeValueNodes[valueName];
                }
                parentName = treeName;
                parent     = typeValueNode;
                type       = typeValueNode.TypeValueAccess.ValueType;
            }
            return(typeValueNode);
        }