Exemplo n.º 1
0
        private void WriteCode()
        {
            // create writer
            var writer = new CodeWriter();

            // create generator
            var propertyGenerator = new CodeGenerator();
            var classGenerator    = new ClassGenerator();

            classGenerator.Init(buildArgs.type, propertyGenerator);
            propertyGenerator.Init(buildArgs);

            // generate code
            CodeGeneratorUtility.GenerateCode(classGenerator, writer);

            // generate output path
            string fileName = buildArgs.type.FullName;

            if (!string.IsNullOrEmpty(buildArgs.type.Namespace))
            {
                fileName = buildArgs.type.FullName.Substring(buildArgs.type.Namespace.Length + 1);
            }

            string outputPath = string.Format("{0}/{1}.Code.cs", settings.outputDirectory, fileName);

            Debug.LogFormat("Write code to \"{0}\"", outputPath);
            CodeGeneratorUtility.WriteCode(settings.templatePath, outputPath, writer);

            // save it
            lastOutputPath = outputPath;
        }
Exemplo n.º 2
0
        public override void Generate()
        {
            WriteLine("// Generated class");
            WriteLine("namespace {0}", type.Namespace);
            WriteLine("{");
            {
                IndentLevel++;

                Write("public partial class {0}", type.Name);
                WriteLine();
                WriteLine("{");
                {
                    IndentLevel++;

                    // call internal generator
                    CodeGeneratorUtility.GenerateCode(internalGenerator, Writer);

                    IndentLevel--;
                }
                WriteLine("}");

                IndentLevel--;
            }
            WriteLine("}");
        }
Exemplo n.º 3
0
        public void GenerateCode()
        {
            if (buildArgs == null)
            {
                Debug.LogWarning("Type is not loaded");
                return;
            }

            // create writer
            var writer = new CodeWriter();

            // create generator
            var propertyGenerator = new CodeGenerator();
            var classGenerator    = new ClassGenerator();

            var outputType = typeof(ImplicitConverter);

            classGenerator.Init(outputType, propertyGenerator);
            propertyGenerator.Init(buildArgs);

            // generate code
            CodeGeneratorUtility.GenerateCode(classGenerator, writer);

            // generate output path
            string fileName = outputType.FullName;

            if (!string.IsNullOrEmpty(outputType.Namespace))
            {
                fileName = outputType.FullName.Substring(outputType.Namespace.Length + 1);
            }

            string outputPath = string.Format("{0}/{1}.Code.cs", settings.outputDirectory, fileName);

            Debug.LogFormat("Write code to \"{0}\"", outputPath);
            CodeGeneratorUtility.WriteCode(settings.templatePath, outputPath, writer);

            // save it
            lastOutputPath = outputPath;
        }
Exemplo n.º 4
0
        public void GenerateCodeSnippet()
        {
            if (buildArgs == null)
            {
                Debug.LogWarning("Class is not loaded");
                return;
            }

            // create writer
            var writer = new CodeWriter();

            // create generator
            var propertyGenerator = new CodeGenerator();

            propertyGenerator.Init(buildArgs);

            // generate code
            CodeGeneratorUtility.GenerateCode(propertyGenerator, writer);

            // copy to system pasteboard
            GUIUtility.systemCopyBuffer = writer.GetText();

            Debug.LogFormat("Copy code snippet to system pasteboard");
        }