コード例 #1
0
        /// <summary>
        /// Register types for service/repository
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        private static void UpdateBootStrapper(BusinessView view, Settings settings)
        {
            var moduleId   = view.Properties[BusinessView.ModuleId];
            var entityName = view.Properties[BusinessView.EntityName];
            var pathProj   = settings.Projects[ProcessGeneration.ServicesKey][moduleId].ProjectFolder;
            var bsName     = moduleId + "Bootstrapper.cs";
            var bsFile     = Path.Combine(pathProj, bsName);

            if (File.Exists(bsFile))
            {
                var      register = "\t\t\tUnityUtil.RegisterType";
                string[] tags     =
                {
                    @"private void RegisterService(IUnityContainer container)",
                    @"private void RegisterRepositories(IUnityContainer container)",
                };

                string[] linesToAdded =
                {
                    string.Format(register + "<Interfaces.Services.I{0}Service<Models.{0}>, {0}EntityService<Models.{0}>>(container);",                                                                                                                                                 entityName),
                    string.Format(register + "<IExportImportRepository, BusinessRepository.{2}Repository<Models.{2}>>(container, \"{1}{0}\", new InjectionConstructor(typeof(Context)));",                                                                                              entityName.ToLower(),moduleId.ToLower(),  entityName),
                    string.Format(register + "(container, typeof(Interfaces.BusinessRepository.I{0}Entity<Models.{0}>), typeof(BusinessRepository.{0}Repository<Models.{0}>), UnityInjectionType.Default, new InjectionConstructor(typeof(Context)));",                                 entityName),
                    string.Format(register + "(container, typeof(Interfaces.BusinessRepository.I{0}Entity<Models.{0}>), typeof(BusinessRepository.{0}Repository<Models.{0}>), UnityInjectionType.Session, new InjectionConstructor(typeof(Context), typeof(IBusinessEntitySession)));", entityName)
                };

                var txtLines  = File.ReadAllLines(bsFile).ToList();
                var trimLines = (File.ReadAllLines(bsFile)).Select(l => l.Trim()).ToList();
                for (var i = 0; i < 2; i++)
                {
                    var index = trimLines.IndexOf(tags[i]) + 2 + i;
                    txtLines.Insert(index, linesToAdded[i]);
                    if (i == 1)
                    {
                        txtLines.Insert(++index, linesToAdded[2]);
                        txtLines.Insert(++index, linesToAdded[3]);
                    }
                }
                File.WriteAllLines(bsFile, txtLines);
            }
        }
コード例 #2
0
        /// <summary>
        /// Modify module level security const string class to add view security resource ID
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        public static void UpdateSecurityClass(BusinessView view, Settings settings)
        {
            var moduleId               = view.Properties[BusinessView.ModuleId];
            var entityName             = view.Properties[BusinessView.EntityName];
            var pathBusinessRepository = settings.Projects[ProcessGeneration.BusinessRepositoryKey][moduleId].ProjectFolder;
            var filePath               = Path.Combine(pathBusinessRepository, @"Security\Security.cs");
            var f           = Environment.NewLine + TabTwo;
            var commentLine = f + "/// <summary>" + f + "/// Security resourceID for " + moduleId + " " + entityName + f + "/// </summary>" + Environment.NewLine;
            var constName   = moduleId + entityName;
            var constLine   = f + "public const string " + constName + " = \"" + constName.ToUpper() + "\";" + Environment.NewLine;

            if (File.Exists(filePath))
            {
                var text = File.ReadAllText(filePath);
                var pos  = text.IndexOf('}');
                if (pos > -1)
                {
                    var updateText = text.Substring(0, pos) + commentLine + constLine + text.Substring(pos - 2);
                    File.WriteAllText(filePath, updateText);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Register types for service/repository
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        private static void UpdateHeaderDetailModuleBootStrapper(BusinessView view, Settings settings)
        {
            var moduleId   = view.Properties[BusinessView.ModuleId];
            var entityName = view.Properties[BusinessView.EntityName];
            var modelName  = view.Properties[BusinessView.ModelName];
            var pathProj   = settings.Projects[ProcessGeneration.ServicesKey][moduleId].ProjectFolder;
            var bsName     = moduleId + "Bootstrapper.cs";
            var bsFile     = Path.Combine(pathProj, bsName);

            if (File.Exists(bsFile))
            {
                var    register     = "\t\t\tUnityUtil.RegisterType";
                string tags         = @"private void RegisterService(IUnityContainer container)";
                string linesToAdded = string.Format(register + "<I{0}Repository, {0}Repository>(container);", settings.EntitiesContainerName, settings.EntitiesContainerName);

                string[] nameSpace =
                {
                    "using " + settings.CompanyNamespace + "." + moduleId + ".BusinessRepository;",
                    "using " + settings.CompanyNamespace + "." + moduleId + ".Interfaces.BusinessRepository;"
                };

                var txtLines  = File.ReadAllLines(bsFile).ToList();
                var trimLines = (File.ReadAllLines(bsFile)).Select(l => l.Trim()).ToList();

                for (var i = 0; i < nameSpace.Count(); i++)
                {
                    if (trimLines.IndexOf(nameSpace[i]) < 0)
                    {
                        txtLines.Insert(2, nameSpace[i]);
                    }
                }


                var index = trimLines.IndexOf(tags) + 2;
                txtLines.Insert(index + 2, linesToAdded);

                File.WriteAllLines(bsFile, txtLines);
            }
        }
コード例 #4
0
        /// <summary>
        /// Register types for Finder
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        private static void UpdateWebBootStrapperForFinder(BusinessView view, Settings settings)
        {
            var moduleId   = view.Properties[BusinessView.Constants.ModuleId];
            var entityName = view.Properties[BusinessView.Constants.EntityName];
            var modelName  = view.Properties[BusinessView.Constants.ModelName];
            var pathProj   = settings.Projects[ProcessGeneration.Constants.WebKey][moduleId].ProjectFolder;

            var filename = moduleId + Constants.WebBootstrapperFilenameBase;
            var filePath = Path.Combine(pathProj, filename);

            if (File.Exists(filePath))
            {
                var pos = 1;

                // Load the file and make the working lists
                MakeLists(filePath,
                          out List <string> trimLines,
                          out List <string> txtLines);

                string       methodSignature = @"private void RegisterFinder(IUnityContainer container)";
                const string register        = "\t\t\tUnityUtil.RegisterType";
                var          lineToAdd       = string.Format(register + "<IFinder, Find{0}ControllerInternal<{3}>>(container, \"{1}{2}\", new InjectionConstructor(typeof(Context)));",
                                                             entityName, moduleId.ToLower(), entityName.ToLower(), modelName);

                var methodSignatureIndex = trimLines.IndexOf(methodSignature);
                var insertionIndex       = methodSignatureIndex + 1 + pos;

                // Need to remove the tabs '\t' before doing the lookup.
                if (trimLines.IndexOf(lineToAdd.Trim()) == Constants.NotFoundInList)
                {
                    // Line was not found so we will now insert it.
                    txtLines.Insert(insertionIndex, lineToAdd);
                }

                File.WriteAllLines(filePath, txtLines);
            }
        }
コード例 #5
0
        /// <summary>
        /// Register types for service/repository
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        public static void UpdateFlatBootStrappers(BusinessView view, Settings settings)
        {
            // Get the flags
            var generateClientFiles = view.Options[BusinessView.Constants.GenerateClientFiles];
            var generateFinder      = view.Options[BusinessView.Constants.GenerateFinder];

            if (generateClientFiles || generateFinder)
            {
                UpdateWebBootStrapperNamespaces(view, settings);
            }

            if (generateClientFiles)
            {
                if (view.Options[BusinessView.Constants.GenerateGrid])
                {
                    UpdateHeaderDetailBootStrappers(view, settings);
                }
                else
                {
                    UpdateWebBootStrapper(view, settings);
                    UpdateBootStrapper(view, settings);
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// Register types for service/repository
 /// </summary>
 /// <param name="view">Business View</param>
 /// <param name="settings">Settings</param>
 public static void UpdateFlatBootStrappers(BusinessView view, Settings settings)
 {
     UpdateWebBootStrapper(view, settings);
     UpdateBootStrapper(view, settings);
 }
コード例 #7
0
        /// <summary>
        /// Register types for service/repository
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        private static void UpdateProcessBootStrapper(BusinessView view, Settings settings)
        {
            var moduleId   = view.Properties[BusinessView.ModuleId];
            var entityName = view.Properties[BusinessView.EntityName];
            var modelName  = view.Properties[BusinessView.ModelName];
            var pathProj   = settings.Projects[ProcessGeneration.ServicesKey][moduleId].ProjectFolder;

            var businessProjNs   = settings.Projects[ProcessGeneration.BusinessRepositoryKey][moduleId].ProjectName + ".Process";
            var interfacesProjNs = settings.Projects[ProcessGeneration.InterfacesKey][moduleId].ProjectName;
            var modelProjNs      = settings.Projects[ProcessGeneration.ModelsKey][moduleId].ProjectName + ".Process";
            var servicesProjNs   = settings.Projects[ProcessGeneration.ServicesKey][moduleId].ProjectName + ".Process";

            var bsName = moduleId + "Bootstrapper.cs";
            var bsFile = Path.Combine(pathProj, bsName);

            if (File.Exists(bsFile))
            {
                var register  = "\t\t\tUnityUtil.RegisterType";
                var txtLines  = File.ReadAllLines(bsFile).ToList();
                var trimLines = (File.ReadAllLines(bsFile)).Select(l => l.Trim()).ToList();
                var pos       = 1;

                string[] nameSpace =
                {
                    "using " + businessProjNs + ";",
                    "using " + interfacesProjNs + ".BusinessRepository.Process;",
                    "using " + interfacesProjNs + ".Services.Process;",
                    "using " + modelProjNs + ";",
                    "using " + servicesProjNs + ";"
                };

                for (var i = 0; i <= 4; i++)
                {
                    if (trimLines.IndexOf(nameSpace[i]) < 0)
                    {
                        txtLines.Insert(++pos, nameSpace[i]);
                    }
                }

                string[] tags =
                {
                    @"private void RegisterService(IUnityContainer container)",
                    @"private void RegisterRepositories(IUnityContainer container)"
                };

                string[] linesToAdded =
                {
                    string.Format(register + "<I{0}Service<{1}>, {0}Service<{1}>>(container);",                                                                                                          entityName, modelName),
                    string.Format(register + "<I{0}Entity<{1}>, {0}Repository<{1}>>(container, UnityInjectionType.Default, new InjectionConstructor(typeof(Context)));",                                 entityName, modelName),
                    string.Format(register + "<I{0}Entity<{1}>, {0}Repository<{1}>>(container, UnityInjectionType.Session, new InjectionConstructor(typeof(Context), typeof(IBusinessEntitySession)));", entityName, modelName)
                };



                for (var i = 0; i < 2; i++)
                {
                    var index = trimLines.IndexOf(tags[i]) + pos + i;
                    if (i == 0)
                    {
                        index = index + 2;
                        txtLines.Insert(index, linesToAdded[i]);
                    }
                    else
                    {
                        txtLines.Insert(++index, linesToAdded[1]);
                        txtLines.Insert(++index, linesToAdded[2]);
                    }
                }
                File.WriteAllLines(bsFile, txtLines);
            }
        }
コード例 #8
0
 public static void UpdateHeaderDetailBootStrappers(BusinessView view, Settings settings)
 {
     UpdateHeaderDetailWebBootStrapper(view, settings);
     UpdateHeaderDetailModuleBootStrapper(view, settings);
 }
コード例 #9
0
        /// <summary>
        /// Register types for controller/Finder/ImportExport
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        private static void UpdateWebBootStrapper(BusinessView view, Settings settings)
        {
            var moduleId   = view.Properties[BusinessView.ModuleId];
            var entityName = view.Properties[BusinessView.EntityName];
            var modelName  = view.Properties[BusinessView.ModelName];
            var pathProj   = settings.Projects[ProcessGeneration.WebKey][moduleId].ProjectFolder;

            var webProjNs   = settings.Projects[ProcessGeneration.WebKey][moduleId].ProjectName;
            var modelProjNs = settings.Projects[ProcessGeneration.ModelsKey][moduleId].ProjectName;

            var bsName = moduleId + "WebBootstrapper.cs";
            var bsFile = Path.Combine(pathProj, bsName);

            if (File.Exists(bsFile))
            {
                const string register  = "\t\t\tUnityUtil.RegisterType";
                var          trimLines = (File.ReadAllLines(bsFile)).Select(l => l.Trim()).ToList();
                var          txtLines  = File.ReadAllLines(bsFile).ToList();
                var          pos       = 1;

                string[] nameSpace =
                {
                    "using " + modelProjNs + ";",
                    "using " + webProjNs + ".Areas." + moduleId + ".Controllers;",
                    "using " + webProjNs + ".Areas." + moduleId + ".Controllers.Finder;"
                };

                for (var i = 0; i <= 2; i++)
                {
                    if (trimLines.IndexOf(nameSpace[i]) < 0)
                    {
                        txtLines.Insert(++pos, nameSpace[i]);
                    }
                }

                string[] tags =
                {
                    @"private void RegisterController(IUnityContainer container)",
                    @"private void RegisterFinder(IUnityContainer container)",
                    @"private void RegisterExportImportController(IUnityContainer container)"
                };
                string[] linesToAdded =
                {
                    string.Format(register + "<IController, {0}Controller<{2}>>(container, \"{1}{0}\");",                                                                entityName, moduleId,           modelName),
                    string.Format(register + "<IFinder, Find{0}ControllerInternal<{3}>>(container, \"{1}{2}\", new InjectionConstructor(typeof(Context)));",             entityName, moduleId.ToLower(), entityName.ToLower(),modelName),
                    string.Format(register + "<IExportImportController, {0}ControllerInternal<{3}>>(container, \"{1}{2}\", new InjectionConstructor(typeof(Context)));", entityName, moduleId.ToLower(), entityName.ToLower(),modelName)
                };

                for (var i = 0; i <= 2; i++)
                {
                    if (!view.Options[BusinessView.GenerateFinder] && i == 1)
                    {
                        pos--;
                        continue;
                    }
                    var index = trimLines.IndexOf(tags[i]) + 1 + i + pos;
                    txtLines.Insert(index, linesToAdded[i]);
                }
                File.WriteAllLines(bsFile, txtLines);
            }
        }
コード例 #10
0
        /// <summary>
        /// Register types for service/repository
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        private static void UpdateProcessBootStrapper(BusinessView view, Settings settings)
        {
            var moduleId   = view.Properties[BusinessView.Constants.ModuleId];
            var entityName = view.Properties[BusinessView.Constants.EntityName];
            var modelName  = view.Properties[BusinessView.Constants.ModelName];
            var pathProj   = settings.Projects[ProcessGeneration.Constants.ServicesKey][moduleId].ProjectFolder;

            var businessProjNs   = settings.Projects[ProcessGeneration.Constants.BusinessRepositoryKey][moduleId].ProjectName + ".Process";
            var interfacesProjNs = settings.Projects[ProcessGeneration.Constants.InterfacesKey][moduleId].ProjectName;
            var modelProjNs      = settings.Projects[ProcessGeneration.Constants.ModelsKey][moduleId].ProjectName + ".Process";
            var servicesProjNs   = settings.Projects[ProcessGeneration.Constants.ServicesKey][moduleId].ProjectName + ".Process";

            var filename = moduleId + Constants.BootstrapperFilenameBase;
            var filePath = Path.Combine(pathProj, filename);

            const int RegisterServiceMethodIndex      = 0;
            const int RegisterRepositoriesMethodIndex = 1;

            if (File.Exists(filePath))
            {
                var pos = 1;

                // Load the file and make the working lists
                MakeLists(filePath,
                          out List <string> trimLines,
                          out List <string> txtLines);

                string[] namespaces =
                {
                    "using " + businessProjNs + ";",
                    "using " + interfacesProjNs + ".BusinessRepository.Process;",
                    "using " + interfacesProjNs + ".Services.Process;",
                    "using " + modelProjNs + ";",
                    "using " + servicesProjNs + ";"
                };

                for (var i = 0; i < namespaces.Length; i++)
                {
                    if (trimLines.IndexOf(namespaces[i]) < 0)
                    {
                        txtLines.Insert(++pos, namespaces[i]);
                    }
                }

                string[] methodSignatures =
                {
                    @"private void RegisterService(IUnityContainer container)",
                    @"private void RegisterRepositories(IUnityContainer container)"
                };

                var      register   = "\t\t\tUnityUtil.RegisterType";
                string[] linesToAdd =
                {
                    string.Format(register + "<I{0}Service<{1}>, {0}Service<{1}>>(container);",                                                                                                          entityName, modelName),
                    string.Format(register + "<I{0}Entity<{1}>, {0}Repository<{1}>>(container, UnityInjectionType.Default, new InjectionConstructor(typeof(Context)));",                                 entityName, modelName),
                    string.Format(register + "<I{0}Entity<{1}>, {0}Repository<{1}>>(container, UnityInjectionType.Session, new InjectionConstructor(typeof(Context), typeof(IBusinessEntitySession)));", entityName, modelName)
                };

                for (var i = 0; i < methodSignatures.Length; i++)
                {
                    var methodSignature      = methodSignatures[i];
                    var methodSignatureIndex = trimLines.IndexOf(methodSignature);
                    var insertionIndex       = methodSignatureIndex + pos + i;

                    if (i == RegisterServiceMethodIndex)
                    {
                        insertionIndex++;
                        var lineToAdd = linesToAdd[i];

                        // Need to remove the tabs '\t' before doing the lookup.
                        if (trimLines.IndexOf(lineToAdd.Trim()) == Constants.NotFoundInList)
                        {
                            // Line was not found so we will now insert it.
                            txtLines.Insert(insertionIndex, lineToAdd);
                        }
                    }
                    else if (i == RegisterRepositoriesMethodIndex)
                    {
                        var lineToAdd = linesToAdd[1];

                        // Need to remove the tabs '\t' before doing the lookup.
                        if (trimLines.IndexOf(lineToAdd.Trim()) == Constants.NotFoundInList)
                        {
                            // Line was not found so we will now insert it.
                            txtLines.Insert(++insertionIndex, lineToAdd);
                        }

                        lineToAdd = linesToAdd[2];

                        // Need to remove the tabs '\t' before doing the lookup.
                        if (trimLines.IndexOf(lineToAdd.Trim()) == Constants.NotFoundInList)
                        {
                            // Line was not found so we will now insert it.
                            txtLines.Insert(++insertionIndex, lineToAdd);
                        }
                    }
                }
                File.WriteAllLines(filePath, txtLines);
            }
        }
コード例 #11
0
        /// <summary>
        /// Register types for controller
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        private static void UpdateProcessWebBootStrapper(BusinessView view, Settings settings)
        {
            var moduleId   = view.Properties[BusinessView.Constants.ModuleId];
            var entityName = view.Properties[BusinessView.Constants.EntityName];
            var modelName  = view.Properties[BusinessView.Constants.ModelName];
            var pathProj   = settings.Projects[ProcessGeneration.Constants.WebKey][moduleId].ProjectFolder;

            var webProjNs   = settings.Projects[ProcessGeneration.Constants.WebKey][moduleId].ProjectName;
            var modelProjNs = settings.Projects[ProcessGeneration.Constants.ModelsKey][moduleId].ProjectName + ".Process";

            var filename = moduleId + Constants.WebBootstrapperFilenameBase;
            var filePath = Path.Combine(pathProj, filename);

            if (File.Exists(filePath))
            {
                var pos = 1;

                // Load the file and make the working lists
                MakeLists(filePath,
                          out List <string> trimLines,
                          out List <string> txtLines);

                string[] namespaces =
                {
                    "using " + modelProjNs + ";",
                    "using " + webProjNs + ".Areas." + moduleId + ".Controllers.Process;",
                };

                for (var i = 0; i <= 1; i++)
                {
                    if (trimLines.IndexOf(namespaces[i]) < 0)
                    {
                        txtLines.Insert(++pos, namespaces[i]);
                    }
                }

                string[] methodSignatures =
                {
                    @"private void RegisterController(IUnityContainer container)",
                };

                const string register   = "\t\t\tUnityUtil.RegisterType";
                string[]     linesToAdd =
                {
                    string.Format(register + "<IController, {0}Controller<{2}>>(container, \"{1}{0}\");", entityName, moduleId, modelName)
                };

                for (var i = 0; i <= 0; i++)
                {
                    var lineToAdd            = linesToAdd[i];
                    var methodSignature      = methodSignatures[i];
                    var methodSignatureIndex = trimLines.IndexOf(methodSignature);
                    var insertionIndex       = methodSignatureIndex + 1 + i + pos;

                    // Need to remove the tabs '\t' before doing the lookup.
                    if (trimLines.IndexOf(lineToAdd.Trim()) == Constants.NotFoundInList)
                    {
                        // Line was not found so we will now insert it.
                        txtLines.Insert(insertionIndex, lineToAdd);
                    }
                }

                File.WriteAllLines(filePath, txtLines);
            }
        }
コード例 #12
0
        /// <summary>
        /// Register types for service/repository
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        private static void UpdateBootStrapper(BusinessView view, Settings settings)
        {
            var moduleId   = view.Properties[BusinessView.Constants.ModuleId];
            var entityName = view.Properties[BusinessView.Constants.EntityName];
            var modelName  = view.Properties[BusinessView.Constants.ModelName];
            var pathProj   = settings.Projects[ProcessGeneration.Constants.ServicesKey][moduleId].ProjectFolder;
            var filename   = moduleId + Constants.BootstrapperFilenameBase;
            var filePath   = Path.Combine(pathProj, filename);

            //const int RegisterServiceMethodIndex = 0;
            const int RegisterRepositoriesMethodIndex = 1;

            if (File.Exists(filePath))
            {
                string[] methodSignatures =
                {
                    @"private void RegisterService(IUnityContainer container)",
                    @"private void RegisterRepositories(IUnityContainer container)",
                };

                var      register   = "\t\t\tUnityUtil.RegisterType";
                string[] linesToAdd =
                {
                    string.Format(register + "<Interfaces.Services.I{0}Service<Models.{1}>, {0}EntityService<Models.{1}>>(container);",                                                                                                                                                 entityName,           modelName),
                    string.Format(register + "<IExportImportRepository, BusinessRepository.{2}Repository<Models.{3}>>(container, \"{1}{0}\", new InjectionConstructor(typeof(Context)));",                                                                                              entityName.ToLower(), moduleId.ToLower(),entityName,  modelName),
                    string.Format(register + "(container, typeof(Interfaces.BusinessRepository.I{0}Entity<Models.{1}>), typeof(BusinessRepository.{0}Repository<Models.{1}>), UnityInjectionType.Default, new InjectionConstructor(typeof(Context)));",                                 entityName,           modelName),
                    string.Format(register + "(container, typeof(Interfaces.BusinessRepository.I{0}Entity<Models.{1}>), typeof(BusinessRepository.{0}Repository<Models.{1}>), UnityInjectionType.Session, new InjectionConstructor(typeof(Context), typeof(IBusinessEntitySession)));", entityName,           modelName)
                };

                // Load the file and make the working lists
                MakeLists(filePath,
                          out List <string> trimLines,
                          out List <string> txtLines);

                for (var i = 0; i < methodSignatures.Length; i++)
                {
                    var methodSignature      = methodSignatures[i];
                    var methodSignatureIndex = trimLines.IndexOf(methodSignature);
                    var insertionIndex       = methodSignatureIndex + 2 + i;
                    var lineToAdd            = linesToAdd[i];

                    // Need to remove the tabs '\t' before doing the lookup.
                    if (trimLines.IndexOf(lineToAdd.Trim()) == Constants.NotFoundInList)
                    {
                        // Line was not found so we will now insert it.
                        txtLines.Insert(insertionIndex, lineToAdd);
                    }

                    if (i == RegisterRepositoriesMethodIndex)
                    {
                        lineToAdd = linesToAdd[2];

                        // Need to remove the tabs '\t' before doing the lookup.
                        if (trimLines.IndexOf(lineToAdd.Trim()) == Constants.NotFoundInList)
                        {
                            // Line was not found so we will now insert it.
                            txtLines.Insert(++insertionIndex, lineToAdd);
                        }

                        lineToAdd = linesToAdd[3];

                        // Need to remove the tabs '\t' before doing the lookup.
                        if (trimLines.IndexOf(lineToAdd.Trim()) == Constants.NotFoundInList)
                        {
                            // Line was not found so we will now insert it.
                            txtLines.Insert(++insertionIndex, lineToAdd);
                        }
                    }
                }
                File.WriteAllLines(filePath, txtLines);
            }
        }
コード例 #13
0
        /// <summary>
        /// Register types for controller/Finder/ImportExport
        /// </summary>
        /// <param name="view">Business View</param>
        /// <param name="settings">Settings</param>
        private static void UpdateHeaderDetailWebBootStrapper(BusinessView view, Settings settings)
        {
            var moduleId   = view.Properties[BusinessView.Constants.ModuleId];
            var entityName = view.Properties[BusinessView.Constants.EntityName];
            var modelName  = view.Properties[BusinessView.Constants.ModelName];
            var pathProj   = settings.Projects[ProcessGeneration.Constants.WebKey][moduleId].ProjectFolder;

            var webProjNs   = settings.Projects[ProcessGeneration.Constants.WebKey][moduleId].ProjectName;
            var modelProjNs = settings.Projects[ProcessGeneration.Constants.ModelsKey][moduleId].ProjectName;

            var filename = moduleId + Constants.WebBootstrapperFilenameBase;
            var filePath = Path.Combine(pathProj, filename);

            if (File.Exists(filePath))
            {
                var pos = 1;

                // Load the file and make the working lists
                MakeLists(filePath,
                          out List <string> trimLines,
                          out List <string> txtLines);

                string[] namespaces =
                {
                    "using " + modelProjNs + ";",
                    "using " + webProjNs + ".Areas." + moduleId + ".Controllers;",
                    "using Sage.CA.SBS.ERP.Sage300.Common.Web.Controllers.ExportImport;",
                    "using " + settings.Projects[ProcessGeneration.Constants.InterfacesKey][moduleId].ProjectName + ".BusinessRepository;"
                };

                for (var i = 0; i < namespaces.Length; i++)
                {
                    if (trimLines.IndexOf(namespaces[i]) < 0)
                    {
                        txtLines.Insert(++pos, namespaces[i]);
                    }
                }

                string[] methodSignatures =
                {
                    @"private void RegisterController(IUnityContainer container)",
                    @"private void RegisterExportImportController(IUnityContainer container)"
                };

                const string register   = "\t\t\tUnityUtil.RegisterType";
                string[]     linesToAdd =
                {
                    string.Format(register + "<IController, {0}Controller>(container, \"{1}{0}\");",                                                                                         settings.EntitiesContainerName, moduleId),
                    string.Format(register + "<IExportImportController, ImportExportControllerInternal<I{0}Repository>>(container, \"{1}{2}\", new InjectionConstructor(typeof(Context)));", settings.EntitiesContainerName, moduleId.ToLower(), settings.EntitiesContainerName.ToLower())
                };

                for (var i = 0; i < methodSignatures.Length; i++)
                {
                    var lineToAdd            = linesToAdd[i];
                    var methodSignature      = methodSignatures[i];
                    var methodSignatureIndex = trimLines.IndexOf(methodSignature);
                    var insertionIndex       = methodSignatureIndex + i + pos + 1;

                    // Need to remove the tabs '\t' before doing the lookup.
                    if (trimLines.IndexOf(lineToAdd.Trim()) == Constants.NotFoundInList)
                    {
                        // Line was not found so we will now insert it.
                        txtLines.Insert(insertionIndex, lineToAdd);
                    }
                }
                File.WriteAllLines(filePath, txtLines);
            }
        }
コード例 #14
0
 /// <summary>
 /// Register types for service/repository
 /// </summary>
 /// <param name="view">Business View</param>
 /// <param name="settings">Settings</param>
 public static void UpdateProcessBootStrappers(BusinessView view, Settings settings)
 {
     UpdateProcessWebBootStrapper(view, settings);
     UpdateProcessBootStrapper(view, settings);
 }