private static bool Equals(Key_Value key1, Key_Value key2)
 {
     if (key1.Key == key2.Key && key1.Value == key2.Value)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
        /// <summary>
        /// [新]取所有资源文件key的参数
        /// </summary>
        /// <returns></returns>
        public static List <Key_Value> AllRes_new(List <Grids> grids)
        {
            List <Key_Value> vs = new List <Key_Value>();

            foreach (var marx in grids)
            {
                foreach (var btn in marx.strs)
                {
                    var temp = new Key_Value
                    {
                        Key   = Buttons.command(btn, ""),
                        Value = btn
                    };
                    if (!CreateClass.Contains(vs, temp))
                    {
                        vs.Add(temp);
                    }
                }
                foreach (var ds in marx.grids)
                {
                    if (ds.CONTROL_NAME != "NEXT_LINE")
                    {
                        var key = new Key_Value
                        {
                            Key   = ds.CODE,
                            Value = ds.NAME
                        };
                        if (!CreateClass.Contains(vs, key))
                        {
                            vs.Add(key);
                        }
                    }
                }
                var pageName = new Key_Value
                {
                    Key   = marx.PageCode,
                    Value = marx.PageName
                };
                if (!CreateClass.Contains(vs, pageName))
                {
                    vs.Add(pageName);
                }
            }
            return(vs);
        }
        /// <summary>
        /// [新]生成模型
        /// </summary>
        public static string LoadModel_new(List <Grids> lists, string projName)
        {
            if (lists == null)
            {
                return("");
            }
            List <Key_Value> vs = new List <Key_Value>();

            foreach (var grid in lists)
            {
                foreach (var ds in grid.grids)
                {
                    var key = new Key_Value
                    {
                        Key   = ds.CODE,
                        Value = ds.NAME
                    };
                    if (ds.CONTROL_NAME == "DATAGRID" && !Contains(vs, key))
                    {
                        vs.Add(key);
                    }
                }
            }

            string s = "using DAF.Plugin.Common;using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace " + projName + "{public class Model : ValidationBase{";

            s += "public string ID {get;set;}";
            s += "public string Color {get;set;}";
            s += "public string TextState {get;set;}";
            foreach (var marx in vs)
            {
                string model = "";
                model += "        //[Excel(Width =5000, Title =\"" + marx.Value + "\")]\r\n";
                model += "        public string " + marx.Key.ToUpper() + " {get;set;}";
                s     += model;
            }
            s += "private bool _IsChecked;public bool IsChecked{get{return _IsChecked;}set{_IsChecked = value;NotifyPropertyChanged(\"IsChecked\");}}}}";
            return(Common.format(s));
        }
        public static bool Contains(List <Key_Value> vs, Key_Value key)
        {
            var cot = vs.Where(e => e.Key == key.Key).Count();

            return(cot > 0 ? true : false);
        }