public static IEnumerable <FilePath> GetAllNetworkFilesFor(EntitySave entitySave)
        {
            yield return(CodeGeneratorCommonLogic.GetGeneratedElementNetworkFilePathFor(entitySave));

            yield return(CodeGeneratorCommonLogic.GetCustomElementNetworkFilePathFor(entitySave));

            yield return(CodeGeneratorCommonLogic.GetGeneratedNetStateFilePathFor(entitySave));

            yield return(CodeGeneratorCommonLogic.GetCustomNetStateFilePathFor(entitySave));
        }
Exemplo n.º 2
0
        public static void GenerateCodeFor(EntitySave entitySave, bool save = true)
        {
            var isNetworkEntity = NetworkEntityViewModel.IsNetworked(entitySave);

            if (isNetworkEntity)
            {
                var entityGeneratedCode            = GetGeneratedEntityNetworkCode(entitySave);
                var generatedEntityNetworkFilePath = CodeGeneratorCommonLogic.GetGeneratedElementNetworkFilePathFor(entitySave);

                CodeGeneratorCommonLogic.SaveFile(entityGeneratedCode, generatedEntityNetworkFilePath);
                CodeGeneratorCommonLogic.AddCodeFileToProject(generatedEntityNetworkFilePath);

                var netStateGeneratedCode     = GenerateNetStateGeneratedCode(entitySave);
                var generatedNetStateFilePath = CodeGeneratorCommonLogic.GetGeneratedNetStateFilePathFor(entitySave);

                CodeGeneratorCommonLogic.SaveFile(netStateGeneratedCode, generatedNetStateFilePath);
                CodeGeneratorCommonLogic.AddCodeFileToProject(generatedNetStateFilePath);

                var customNetStateFilePath = CodeGeneratorCommonLogic.GetCustomNetStateFilePathFor(entitySave);
                if (customNetStateFilePath.Exists() == false)
                {
                    var customNetStateCode = GenerateEmptyCustomNetStateCode(entitySave);
                    CodeGeneratorCommonLogic.SaveFile(customNetStateCode, customNetStateFilePath);
                }
                CodeGeneratorCommonLogic.AddCodeFileToProject(customNetStateFilePath);

                var customEntityNetworkFilePath = CodeGeneratorCommonLogic.GetCustomElementNetworkFilePathFor(entitySave);
                if (customEntityNetworkFilePath.Exists() == false)
                {
                    var customEntityNetworkCode = GenerateEmptyCustomEntityNetworkCode(entitySave);
                    CodeGeneratorCommonLogic.SaveFile(customEntityNetworkCode, customEntityNetworkFilePath);
                }
                CodeGeneratorCommonLogic.AddCodeFileToProject(customEntityNetworkFilePath);

                GlueCommands.Self.ProjectCommands.MakeGeneratedCodeItemsNested();

                if (save)
                {
                    GlueCommands.Self.ProjectCommands.SaveProjects();
                }
            }
        }