コード例 #1
0
        public virtual string TransformText()
        {
            this.GenerationEnvironment = null;

            #line 3 "Templates\UnityTypeGenerator.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(CommonGeneratorUtils.GetGeneratedHeader()));

            #line default
            #line hidden

            #line 3 "Templates\UnityTypeGenerator.tt"
            this.Write("\r\n\r\nusing System.Linq;\r\nusing Improbable.Gdk.Core;\r\n\r\nnamespace ");

            #line default
            #line hidden

            #line 8 "Templates\UnityTypeGenerator.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(qualifiedNamespace));

            #line default
            #line hidden

            #line 8 "Templates\UnityTypeGenerator.tt"
            this.Write("\r\n{ \r\n");

            #line default
            #line hidden

            #line 10 "Templates\UnityTypeGenerator.tt"

            var generator = new UnityTypeContent();


            #line default
            #line hidden

            #line 13 "Templates\UnityTypeGenerator.tt"
            this.Write("    ");

            #line default
            #line hidden

            #line 13 "Templates\UnityTypeGenerator.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(CommonGeneratorUtils.IndentEveryNewline(generator.Generate(typeDefinition, enumSet))));

            #line default
            #line hidden

            #line 13 "Templates\UnityTypeGenerator.tt"
            this.Write("\r\n}\r\n");

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }
コード例 #2
0
        public static CodeWriter Generate(UnityTypeDetails details)
        {
            return(CodeWriter.Populate(cgw =>
            {
                cgw.UsingDirectives(
                    "System.Linq",
                    "Improbable.Gdk.Core",
                    "UnityEngine"
                    );

                cgw.Namespace(details.Namespace, ns =>
                {
                    ns.Type(UnityTypeContent.Generate(details, details.Namespace));
                });
            }));
        }
コード例 #3
0
        public static string Generate(UnityTypeDetails details, string package)
        {
            var qualifiedNamespace = package;

            return(CodeWriter.Populate(cgw =>
            {
                cgw.UsingDirectives(
                    "System.Linq",
                    "Improbable.Gdk.Core",
                    "UnityEngine"
                    );

                cgw.Namespace(qualifiedNamespace, ns =>
                {
                    ns.Type(UnityTypeContent.Generate(details, qualifiedNamespace));
                });
            }).Format());
        }
コード例 #4
0
        public virtual string TransformText()
        {
            this.GenerationEnvironment = null;

            #line 3 "Templates\UnityTypeContent.tt"

            var typeDetails      = GetTypeDetails();
            var fieldDetailsList = GetFieldDetailsList();


            #line default
            #line hidden

            #line 7 "Templates\UnityTypeContent.tt"
            this.Write("\r\npublic struct ");

            #line default
            #line hidden

            #line 8 "Templates\UnityTypeContent.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(typeDetails.CapitalisedName));

            #line default
            #line hidden

            #line 8 "Templates\UnityTypeContent.tt"
            this.Write("\r\n{\r\n");

            #line default
            #line hidden

            #line 10 "Templates\UnityTypeContent.tt"
            foreach (var fieldDetails in fieldDetailsList)
            {
            #line default
            #line hidden

            #line 11 "Templates\UnityTypeContent.tt"
                this.Write("    public ");

            #line default
            #line hidden

            #line 11 "Templates\UnityTypeContent.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(fieldDetails.Type));

            #line default
            #line hidden

            #line 11 "Templates\UnityTypeContent.tt"
                this.Write(" ");

            #line default
            #line hidden

            #line 11 "Templates\UnityTypeContent.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(fieldDetails.PascalCaseName));

            #line default
            #line hidden

            #line 11 "Templates\UnityTypeContent.tt"
                this.Write(";\r\n");

            #line default
            #line hidden

            #line 12 "Templates\UnityTypeContent.tt"
            }

            #line default
            #line hidden

            #line 13 "Templates\UnityTypeContent.tt"

            if (fieldDetailsList.Count > 0)
            {
                var constructorArgs = GetConstructorArgs();


            #line default
            #line hidden

            #line 18 "Templates\UnityTypeContent.tt"
                this.Write("\r\n    public ");

            #line default
            #line hidden

            #line 19 "Templates\UnityTypeContent.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(typeDetails.CapitalisedName));

            #line default
            #line hidden

            #line 19 "Templates\UnityTypeContent.tt"
                this.Write("(");

            #line default
            #line hidden

            #line 19 "Templates\UnityTypeContent.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(constructorArgs));

            #line default
            #line hidden

            #line 19 "Templates\UnityTypeContent.tt"
                this.Write(")\r\n    {\r\n");

            #line default
            #line hidden

            #line 21 "Templates\UnityTypeContent.tt"
                foreach (var fieldDetails in fieldDetailsList)
                {
            #line default
            #line hidden

            #line 22 "Templates\UnityTypeContent.tt"
                    this.Write("        ");

            #line default
            #line hidden

            #line 22 "Templates\UnityTypeContent.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(fieldDetails.PascalCaseName));

            #line default
            #line hidden

            #line 22 "Templates\UnityTypeContent.tt"
                    this.Write(" = ");

            #line default
            #line hidden

            #line 22 "Templates\UnityTypeContent.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(fieldDetails.CamelCaseName));

            #line default
            #line hidden

            #line 22 "Templates\UnityTypeContent.tt"
                    this.Write(";\r\n");

            #line default
            #line hidden

            #line 23 "Templates\UnityTypeContent.tt"
                }

            #line default
            #line hidden

            #line 24 "Templates\UnityTypeContent.tt"
                this.Write("    }\r\n");

            #line default
            #line hidden

            #line 25 "Templates\UnityTypeContent.tt"
            }

            #line default
            #line hidden

            #line 26 "Templates\UnityTypeContent.tt"
            this.Write("\r\n    public static class Serialization\r\n    {\r\n        public static void Serial" +
                       "ize(");

            #line default
            #line hidden

            #line 29 "Templates\UnityTypeContent.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(typeDetails.CapitalisedName));

            #line default
            #line hidden

            #line 29 "Templates\UnityTypeContent.tt"
            this.Write(" instance, global::Improbable.Worker.Core.SchemaObject obj)\r\n        {\r\n");

            #line default
            #line hidden

            #line 31 "Templates\UnityTypeContent.tt"
            foreach (var fieldDetails in fieldDetailsList)
            {
            #line default
            #line hidden

            #line 32 "Templates\UnityTypeContent.tt"
                this.Write("            {\r\n                ");

            #line default
            #line hidden

            #line 33 "Templates\UnityTypeContent.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(fieldDetails.GetSerializationString("instance." + fieldDetails.PascalCaseName, "obj", 4)));

            #line default
            #line hidden

            #line 33 "Templates\UnityTypeContent.tt"
                this.Write("\r\n            }\r\n");

            #line default
            #line hidden

            #line 35 "Templates\UnityTypeContent.tt"
            }

            #line default
            #line hidden

            #line 36 "Templates\UnityTypeContent.tt"
            this.Write("        }\r\n\r\n        public static ");

            #line default
            #line hidden

            #line 38 "Templates\UnityTypeContent.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(typeDetails.CapitalisedName));

            #line default
            #line hidden

            #line 38 "Templates\UnityTypeContent.tt"
            this.Write(" Deserialize(global::Improbable.Worker.Core.SchemaObject obj)\r\n        {\r\n       " +
                       "     var instance = new ");

            #line default
            #line hidden

            #line 40 "Templates\UnityTypeContent.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(typeDetails.CapitalisedName));

            #line default
            #line hidden

            #line 40 "Templates\UnityTypeContent.tt"
            this.Write("();\r\n");

            #line default
            #line hidden

            #line 41 "Templates\UnityTypeContent.tt"
            foreach (var fieldDetails in fieldDetailsList)
            {
            #line default
            #line hidden

            #line 42 "Templates\UnityTypeContent.tt"
                this.Write("            {\r\n                ");

            #line default
            #line hidden

            #line 43 "Templates\UnityTypeContent.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(fieldDetails.GetDeserializeString("instance." + fieldDetails.PascalCaseName, "obj", 4)));

            #line default
            #line hidden

            #line 43 "Templates\UnityTypeContent.tt"
                this.Write("\r\n            }\r\n");

            #line default
            #line hidden

            #line 45 "Templates\UnityTypeContent.tt"
            }

            #line default
            #line hidden

            #line 46 "Templates\UnityTypeContent.tt"
            this.Write("            return instance;\r\n        }\r\n    }\r\n");

            #line default
            #line hidden

            #line 49 "Templates\UnityTypeContent.tt"

            var typeGenerator = new UnityTypeContent();
            foreach (var nestedType in nestedTypes)
            {
            #line default
            #line hidden

            #line 54 "Templates\UnityTypeContent.tt"
                this.Write("\r\n    ");

            #line default
            #line hidden

            #line 55 "Templates\UnityTypeContent.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(CommonGeneratorUtils.IndentEveryNewline(typeGenerator.Generate(nestedType, enumSet))));

            #line default
            #line hidden

            #line 55 "Templates\UnityTypeContent.tt"
                this.Write("\r\n");

            #line default
            #line hidden

            #line 56 "Templates\UnityTypeContent.tt"
            }

            #line default
            #line hidden

            #line 57 "Templates\UnityTypeContent.tt"

            var enumGenerator = new UnityEnumContent();
            foreach (var nestedEnum in nestedEnums)
            {
            #line default
            #line hidden

            #line 62 "Templates\UnityTypeContent.tt"
                this.Write("\r\n    ");

            #line default
            #line hidden

            #line 63 "Templates\UnityTypeContent.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(CommonGeneratorUtils.IndentEveryNewline(enumGenerator.Generate(nestedEnum))));

            #line default
            #line hidden

            #line 63 "Templates\UnityTypeContent.tt"
                this.Write("\r\n");

            #line default
            #line hidden

            #line 64 "Templates\UnityTypeContent.tt"
            }

            #line default
            #line hidden

            #line 65 "Templates\UnityTypeContent.tt"
            this.Write("}\r\n");

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }