private static bool BuildConfigConvertClass(System.Type t)
        {
            if (t == null)
            {
                return(false);
            }
            // 先找标记了的类
            bool ret = false;

            object[] attrs = t.GetCustomAttributes(false);
            if (attrs != null && attrs.Length > 0)
            {
                for (int i = 0; i < attrs.Length; ++i)
                {
                    ConfigConvertAttribute attr = attrs[i] as ConfigConvertAttribute;
                    if (attr == null || string.IsNullOrEmpty(attr.ConfigName))
                    {
                        continue;
                    }
                    ConvertClassInfo info = new ConvertClassInfo(t, attr);
                    m_ConvertClassMap[attr.ConfigName] = info;
                    m_TargetNameMap[info.convertName]  = info;
                    ret = true;
                    break;
                }
            }

            return(ret);
        }
 public ConvertClassInfo(System.Type target, ConfigConvertAttribute attr)
 {
     this.type           = target;
     this.configName     = attr.ConfigName;
     this.DictionaryType = attr.MapType;
     this.convertName    = attr.ConvertName;
     if (string.IsNullOrEmpty(convertName))
     {
         this.convertName = configName;
     }
 }
Exemple #3
0
        // 注册简易配置,例如:Dictionary<string, string >
        public static void RegisterSimpleTypeConfig(string configName, System.Type dictionaryType, string convertName = "")
        {
            if (string.IsNullOrEmpty(configName))
            {
                return;
            }
            ConfigConvertAttribute attr = new ConfigConvertAttribute(configName, dictionaryType, convertName);
            ConvertClassInfo       ret  = new ConvertClassInfo(typeof(string), attr);

            m_ConvertClassMap[configName]    = ret;
            m_TargetNameMap[ret.convertName] = ret;
        }