Example #1
0
        private static void GetCopy(Type type, StringBuilder code)
        {
            var up         = new AssemblyUpgrader();
            var dictionary = up.GetConfig();
            ClassUpgradeConfig upgradeConfig;

            if (!dictionary.TryGetValue(type.Name, out upgradeConfig))
            {
                return;
            }
            GetCopy(type.BaseType, code);
            code.Append($@"
            //{type.FullName}");

            foreach (var field in upgradeConfig.Properties.Values)
            {
                if (!field.CanWrite || !field.IsJsonAttribute)
                {
                    continue;
                }
                code.Append($@"
            {field.Name} = source.{field.Name};//{field.Caption.Replace('\n', ' ')}");
            }
            foreach (var field in upgradeConfig.Fields.Values)
            {
                if (!field.IsJsonAttribute)
                {
                    continue;
                }
                code.Append($@"
            {field.Name} = source.{field.Name};//{field.Caption.Replace('\n', ' ')}");
            }
        }
Example #2
0
        private static void TypeDataForm(StringBuilder code, Type type)
        {
            var up         = new AssemblyUpgrader();
            var dictionary = up.GetConfig(type.Assembly);
            ClassUpgradeConfig upgradeConfig;

            if (!dictionary.TryGetValue(type.Name, out upgradeConfig))
            {
                return;
            }

            code.Append($@"
        <DataTemplate x:Key=""{upgradeConfig.Name}Template"">
            <StackPanel DataContext=""{{Binding RelativeSource={{RelativeSource Mode=FindAncestor,AncestorType={{x:Type UserControl}}}},Path=DataContext}}"">");
            foreach (var category in upgradeConfig.Properties.Values.GroupBy(p => p.Category))
            {
                code.Append($@"
        <GroupBox Header=""{category.Key}"" Margin=""5"">
            <WrapPanel>");
                foreach (var field in category)
                {
                    var model = field.CanWrite ? "TwoWay" : "OneWay";
                    code.Append($@"
                <StackPanel>
                    <Label Content=""{field.Caption}""/>");

                    if (field.ConfigType == typeof(bool))
                    {
                        code.Append($@"
                    <ComboBox Style=""{{StaticResource BoolCombo}}"" SelectedValue=""{{Binding {field.Name},Mode={model}}}""/>");
                    }
                    else if (field.ConfigType.IsEnum)
                    {
                        code.Append($@"
                    <ComboBox ItemsSource=""{{x:Static defaults:EnumHelper.{field.TypeName}List}}"" SelectedValue=""{{Binding {field.Name},Mode={model}}}""/>");
                    }
                    else
                    {
                        code.Append($@"
                    <TextBox Text=""{{Binding {field.Name},Mode={model}}}""/>");
                    }
                    code.Append(@"
                </StackPanel>");
                }
                code.Append(@"
            </WrapPanel>
        </GroupBox>");
            }

            code.Append(@"
            </StackPanel>
        </DataTemplate>");
        }
Example #3
0
        /// <summary>
        /// 升级配置类
        /// </summary>
        /// <returns></returns>
        public string NewConfigDefault()
        {
            var up    = new AssemblyUpgrader();
            var types = up.GetConfig();

            foreach (var type in types.Values)
            {
                var builder = new UpgradeEntityBuilder
                {
                    Config = type
                };
                builder.CreateBaseCode(@"C:\Projects\AgebullDesigner\Defaults\Config");
            }


            return("在文件里看");
        }