internal static bool TryGetDefaultValue(ChoCommandLineArgObject target, string propName,
                                                ChoDefaultCommandLineArgAttribute memberInfoAttribute, out string defaultValue)
        {
            defaultValue = null;

            ChoGuard.ArgumentNotNull(target, "CommandLineArgObject");
            ChoGuard.ArgumentNotNull(propName, "PropertyName");

            ChoPropertyInfos propertyInfo = GetPropertyInfos(target);

            if (propertyInfo != null)
            {
                ChoPropertyInfo propInfo = propertyInfo[propName];
                if (propInfo == null)
                {
                    if (memberInfoAttribute != null && memberInfoAttribute.IsDefaultValueSpecified)
                    {
                        defaultValue = memberInfoAttribute.DefaultValue;
                        return(memberInfoAttribute.IsDefaultValueSpecified);
                    }
                }

                defaultValue = propInfo != null && propInfo.DefaultValue != null ? propInfo.DefaultValue.Value : null;
                return(propInfo != null ? propInfo.IsDefaultValueSpecified : false);
            }
            else if (memberInfoAttribute != null && memberInfoAttribute.IsDefaultValueSpecified)
            {
                defaultValue = memberInfoAttribute.DefaultValue;
                return(memberInfoAttribute.IsDefaultValueSpecified);
            }

            return(false);
        }
        private static ChoPropertyInfos ConstructPropertyInfos(ChoCommandLineArgObject cmdLineArgObject)
        {
            if (cmdLineArgObject != null)
            {
                Dictionary <string, ChoPropertyInfos> propDict = _propDict;
                string elementPath = cmdLineArgObject.GetType().Name;

                if (elementPath.IsNullOrWhiteSpace())
                {
                    return(ChoPropertyInfos.Default);
                }

                if (!propDict.ContainsKey(elementPath))
                {
                    lock (_padLock)
                    {
                        if (!propDict.ContainsKey(elementPath))
                        {
                            MemberInfo[] memberInfos = ChoTypeMembersCache.GetAllMemberInfos(cmdLineArgObject.GetType());
                            if (memberInfos != null && memberInfos.Length > 0)
                            {
                                //Set member values
                                List <ChoPropertyInfo>            propertyInfoList    = new List <ChoPropertyInfo>();
                                ChoDefaultCommandLineArgAttribute memberInfoAttribute = null;

                                foreach (MemberInfo memberInfo in memberInfos)
                                {
                                    memberInfoAttribute = (ChoDefaultCommandLineArgAttribute)ChoType.GetMemberAttributeByBaseType(memberInfo, typeof(ChoDefaultCommandLineArgAttribute));
                                    if (memberInfoAttribute == null)
                                    {
                                        continue;
                                    }

                                    ChoPropertyInfo propInfo = new ChoPropertyInfo();

                                    propInfo.Name = ChoType.GetMemberName(memberInfo);

                                    if (ChoType.GetMemberType(memberInfo) != typeof(bool))
                                    {
                                        propInfo.DefaultValue             = new ChoCDATA(memberInfoAttribute.DefaultValue);
                                        propInfo.FallbackValue            = new ChoCDATA(memberInfoAttribute.FallbackValue);
                                        propInfo.IsDefaultValueSpecified  = memberInfoAttribute.IsDefaultValueSpecified;
                                        propInfo.IsFallbackValueSpecified = memberInfoAttribute.IsFallbackValueSpecified;
                                        propertyInfoList.Add(propInfo);
                                    }
                                }

                                if (propertyInfoList != null)
                                {
                                    ChoPropertyInfos propertyInfos = new ChoPropertyInfos();
                                    propertyInfos.PropertyInfoArr = propertyInfoList.ToArray();

                                    SetMetaDataSection(cmdLineArgObject, propertyInfos);
                                    return(propertyInfos);
                                }
                            }
                        }
                    }
                }
            }

            return(ChoPropertyInfos.Default);
        }