Beispiel #1
0
        //generate UpdateVMClass body
        public void GenerateUpdateVMClassBody()
        {
            var s0 = new StatementGen();

            foreach (var p in EInfo.PropMapping)
            {
                if (!ExceptProps.Contains(p.Key))
                {
                    if (JsonIgnoreProps.Contains(p.Key))
                    {
                        s0.Add("//[JsonIgnore]");
                    }
                    else
                    {
                        s0.Add("//[JsonProperty(\"" + GeneralHelper.ToJsonPropertyFormat(p.Key, Style) + "\")]");//+ "\", DefaultValueHandling = DefaultValueHandling.Ignore)]");
                    }
                    s0.Add("public Wrapper<" + p.Value + "> " + p.Key + " { get; set; }");
                }
            }
            foreach (var p in EInfo.NavPropMapping)
            {
                if (!ExceptProps.Contains(p.Key))
                {
                    if (JsonIgnoreProps.Contains(p.Key))
                    {
                        s0.Add("//[JsonIgnore]");
                    }
                    else
                    {
                        s0.Add("//[JsonProperty(\"" + GeneralHelper.ToJsonPropertyFormat(p.Key, Style) + "\")]");// + "\", DefaultValueHandling = DefaultValueHandling.Ignore)]");
                    }
                    s0.Add("//public " + p.Value + " " + p.Key + "VM { get; set; }");
                }
            }
            foreach (var p in EInfo.NavCollectionPropMapping)
            {
                if (!ExceptProps.Contains(p.Key))
                {
                    if (JsonIgnoreProps.Contains(p.Key))
                    {
                        s0.Add("//[JsonIgnore]");
                    }
                    else
                    {
                        s0.Add("//[JsonProperty(\"" + GeneralHelper.ToJsonPropertyFormat(p.Key, Style) + "\")]");// + "\", DefaultValueHandling = DefaultValueHandling.Ignore)]");
                    }
                    s0.Add("//public " + p.Value + " " + p.Key + "VM { get; set; }");
                }
            }

            UpdateVMClassBody.Add(
                s0, new StatementGen(""));
        }
Beispiel #2
0
        //generate VMClass body
        public void GenerateVMClassBody()
        {
            var s0 = new StatementGen();

            foreach (var p in EInfo.PropMapping)
            {
                if (!ExceptProps.Contains(p.Key))
                {
                    if (JsonIgnoreProps.Contains(p.Key))
                    {
                        s0.Add("[JsonIgnore]");
                    }
                    else
                    {
                        s0.Add("[JsonProperty(\"" + GeneralHelper.ToJsonPropertyFormat(p.Key, Style) + "\")]");//+ "\", DefaultValueHandling = DefaultValueHandling.Ignore)]");
                    }
                    s0.Add("public " + p.Value + " " + p.Key + " { get; set; }");
                }
            }
            foreach (var p in EInfo.NavPropMapping)
            {
                if (!ExceptProps.Contains(p.Key))
                {
                    if (JsonIgnoreProps.Contains(p.Key))
                    {
                        s0.Add("[JsonIgnore]");
                    }
                    else
                    {
                        s0.Add("[JsonProperty(\"" + GeneralHelper.ToJsonPropertyFormat(p.Key, Style) + "\")]");// + "\", DefaultValueHandling = DefaultValueHandling.Ignore)]");
                    }
                    s0.Add("public " + p.Value + " " + p.Key + "VM { get; set; }");
                }
            }
            foreach (var p in EInfo.NavCollectionPropMapping)
            {
                if (!ExceptProps.Contains(p.Key))
                {
                    if (JsonIgnoreProps.Contains(p.Key))
                    {
                        s0.Add("[JsonIgnore]");
                    }
                    else
                    {
                        s0.Add("[JsonProperty(\"" + GeneralHelper.ToJsonPropertyFormat(p.Key, Style) + "\")]");// + "\", DefaultValueHandling = DefaultValueHandling.Ignore)]");
                    }
                    s0.Add("public " + p.Value + " " + p.Key + "VM { get; set; }");
                }
            }

            var c2 = new ContainerGen();

            c2.Signature = "public `entityVM`(`entity` entity) : this()";
            c2.Body.Add(new StatementGen("FromEntity(entity);"));

            var c21 = new ContainerGen();

            c21.Signature = "public `entityVM`()";
            foreach (var p in EInfo.NavCollectionPropMapping)
            {
                var type         = p.Value;
                var firstBracket = type.IndexOf('<') + 1;
                type = type.Substring(firstBracket, type.IndexOf('>') - firstBracket);
                c21.Body.Add(new StatementGen("this." + p.Key + "VM = new HashSet<" + type + ">();"));
            }

            VMClassBody.Add(
                s0, new StatementGen(""),
                c2, new StatementGen(""),
                c21, new StatementGen(""));
        }