public static bool IsPossibleConfig(MemberInfo info)
        {
            if (MemberInfoExtensions.HasAttribute(info, typeof(ConfigSettingAttribute)))
            {
                return(true);
            }
            if (MemberInfoExtensions.HasAttribute(info, typeof(NotConfigurable)))
            {
                return(false);
            }

            if (info.DeclaringType.IsEnum)
            {
                return(false);
            }
            {
                var inf = info as FieldInfo;
                if (inf != null && (inf.IsStatic || ConfigSettingAttribute.IsSingletonClass(inf.DeclaringType)) &&
                    !inf.IsInitOnly && !inf.IsLiteral)
                {
                    if (MemberInfoExtensions.IsSettableType(inf.FieldType))
                    {
                        if (inf.DeclaringType.IsValueType)
                        {
                            return(false);
                        }
                        return(true);
                    }
                }
            }
            {
                var inf = info as PropertyInfo;
                if (inf != null)
                {
                    if (inf.GetSetMethod() == null)
                    {
                        return(false);
                    }
                    info = inf.GetGetMethod();
                    var inf0 = info as MethodInfo;
                    if (inf0 != null && (inf0.IsStatic || ConfigSettingAttribute.IsSingletonClass(inf0.DeclaringType)) &&
                        inf.CanRead && inf.CanWrite)
                    {
                        if (MemberInfoExtensions.IsSettableType(inf.PropertyType))
                        {
                            if (inf0.DeclaringType.IsValueType)
                            {
                                return(false);
                            }
                            return(true);
                        }
                        ;
                    }
                }
            }
            return(false);
        }
        private static bool SkipOnExit(MemberInfo s)
        {
            ConfigSettingAttribute cs0 = FindConfigSetting(s, false);

            if (cs0.VSkipSaveOnExit.HasValue)
            {
                return(cs0.VSkipSaveOnExit.Value);
            }
            ConfigSettingAttribute cs1 = FindConfigSetting(s.DeclaringType, false);

            if (cs1 != null && cs1.VSkipSaveOnExit.HasValue)
            {
                return(cs1.VSkipSaveOnExit.Value);
            }
            return(false);
        }
        public static object GuessSingletonForType(this Type m)
        {
            if (ConfigSettingAttribute.CantBeSingletonValueMember(m))
            {
                return(null);
            }
            object _singleton;

            {
                foreach (var fnd0 in
                         m.ReflectedType.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy))
                {
                    var mrt = fnd0.MemberReturnType();
                    if (mrt == null)
                    {
                        continue;
                    }
                    if (!m.IsAssignableFrom(mrt))
                    {
                        continue;
                    }
                    if (ConfigSettingAttribute.CantBeSingletonValueMember(fnd0))
                    {
                        continue;
                    }
                    _singleton = MemberInfoExtensions.MemberValue(fnd0, null);
                    if (_singleton != null)
                    {
                        return(_singleton);
                    }
                }
            }
            {
                if (ConfigSettingAttribute.sysvarCtx != null)
                {
                    _singleton = MemberInfoExtensions.FindSubValueOfType(ConfigSettingAttribute.sysvarCtx,
                                                                         m, 2);
                    if (_singleton != null)
                    {
                        return(_singleton);
                    }
                }
            }
            return(null);
        }
        public static ConfigSettingAttribute FindConfigSetting(MemberInfo s, bool forceCreate)
        {
            const bool             createIfDeclared = true;
            ConfigSettingAttribute cs0;

            lock (M2C)
            {
                if (!M2C.TryGetValue(s, out cs0))
                {
                    if (createIfDeclared)
                    {
                        if (s.IsDefined(typeof(ConfigSettingAttribute), true))
                        {
                            var cs = s.GetCustomAttributes(typeof(ConfigSettingAttribute), true);
                            if (cs != null && cs.Length > 0)
                            {
                                cs0 = (ConfigSettingAttribute)cs[0];
                                cs0.SetMember(s);
                            }
                            else
                            {
                                cs0 = null;
                            }
                        }
                        M2C[s] = cs0;
                    }
                }
                if (cs0 == null && forceCreate)
                {
                    cs0 = new ConfigSettingAttribute();
                    cs0.SetMember(s);
                    M2C[s] = cs0;
                }
            }
            return(cs0);
        }