コード例 #1
0
        public CodeCompileUnit Compile(TypeSafeDataUnit dataUnit)
        {
            var compileUnit = new CodeCompileUnit();

            compileUnit.UserData.Add(Strings.CompileUnitUserDataKey, dataUnit.FileName);

            CompilerUtil.WriteHeader(compileUnit);

            var ns = new CodeNamespace(Namespace);

            compileUnit.Namespaces.Add(ns);

            var className = CompilerUtil.GetSafeName(dataUnit.ClassName, false, false);

            if (className != dataUnit.ClassName)
            {
                TSLog.LogWarning(LogCategory.Compile,
                                 string.Format("Class name was modified to conform to C# standards ({0} -> {1})", dataUnit.ClassName, className));
            }

            var container = CompilerUtil.CreateStaticType(className);

            CompilerUtil.AddTypeSafeTag(container);

            PopulateClass(dataUnit, container);

            ns.Types.Add(container);
            return(compileUnit);
        }
コード例 #2
0
        public CodeCompileUnit Compile(ResourceDatabase database)
        {
            var unit = new CodeCompileUnit();

            unit.UserData.Add(Strings.CompileUnitUserDataKey, "Resources");

            CompilerUtil.WriteHeader(unit);

            var ns = new CodeNamespace(Namespace);

            unit.Namespaces.Add(ns);

            var container = CompilerUtil.CreateStaticType(ClassName);

            CompilerUtil.AddTypeSafeTag(container);

            WriteFolder(container, database.RootFolder);

            ns.Types.Add(container);

            return(unit);
        }