예제 #1
0
        private Panel GetConfigPanel(Type config_type, object config_instance, ConfigurationHolderAttribute class_holder)
        {
            if (m_configuration_region_dict.TryGetValue(config_instance, out var region))
            {
                return(region.Panel);
            }

            region = new ConfigurationPanel(config_type, config_instance, class_holder);
            if (region.Panel.Children.Count != 0)
            {
                m_configuration_region_dict.Add(config_instance, region);
            }
            return(region.Panel);
        }
예제 #2
0
        private bool CheckValueVaild(PropertyInfo info, ConfigurationElement element, ConfigurationHolderAttribute classHolder)
        {
            var  configAttribute = info.GetCustomAttribute <BaseConfigurationAttribute>();
            bool noCheck         = configAttribute?.NoCheck ?? classHolder?.NoCheck ?? true;

            if (configAttribute == null)
            {
                return(true);
            }

            if (!noCheck)
            {
                if (!configAttribute.Check(element))
                {
                    configAttribute.CheckFailedNotify(element);
                    return(false);
                }
            }

            return(true);
        }
예제 #3
0
        public ConfigurationPanel(Type configuration_type, object configuration_instance, ConfigurationHolderAttribute class_holder)
        {
            //each PluginConfiuration
            foreach (var prop in configuration_type.GetProperties())
            {
                if (prop.PropertyType != typeof(ConfigurationElement))
                {
                    continue;
                }

                var  config_attr = prop.GetCustomAttribute <BaseConfigurationAttribute>();
                bool hide        = config_attr?.Hide ?? class_holder?.Hide ?? false;

                if (hide == true)
                {
                    continue;
                }
                if (config_attr == null)
                {
                    config_attr = new StringAttribute();
                }

                string name = prop.Name;

                var item_panel = ConfigurationItemFactory.Instance.CreateItemPanel(config_attr, prop, configuration_instance);
                if (item_panel == null)
                {
                    throw new NullReferenceException($"Creator return null! Config attribute type: {config_attr}");
                }
                Panel.Children.Add(item_panel);
            }
        }