示例#1
0
        private void BuildConfig(MasterStore.ProjectsRow project)
        {
            //bool buildIfDefault = false;
            if(project != null)
            {
                string newConfig = configTemplate;

                StringBuilder sbConnections = new StringBuilder();
                List<int> addedConnections = new List<int>();
                foreach(MasterStore.ProvidersRow provider in project.Providers())
                {
                    if(!provider.IsConnectionStringIdNull() && !addedConnections.Contains(provider.ConnectionStringId))
                    {
                        sbConnections.AppendLine("\t\t<add name=\"" + provider.ConnectionString.Name + "\" connectionString=\"" + provider.ConnectionString.ConnectionString +
                                                 "\"/>");
                        addedConnections.Add(provider.ConnectionStringId);
                    }
                }
                newConfig = newConfig.Replace(TEMPLATE_CONNECTION_STRINGS, sbConnections.ToString());

                if(!project.IsDefaultProviderNull())
                    newConfig = newConfig.Replace(TEMPLATE_DEFAULT_PROVIDER, project.DefaultProviderEntry.Name);
                newConfig = newConfig.Replace(TEMPLATE_TEMPLATE_DIRECTORY, project.TemplateDirectory);
                newConfig = newConfig.Replace(TEMPLATE_ENABLE_TRACE, project.EnableTrace.ToString().ToLower());

                StringBuilder sbService = new StringBuilder();
                foreach(MasterStore.ProvidersRow provider in project.Providers())
                    sbService.Append(GetProviderConfigText(provider));

                newConfig = newConfig.Replace(TEMPLATE_PROVIDERS, sbService.ToString());
                tbxConfigOutput.Text = newConfig;

                ActivateConfig();
                InstantiateProvider(project);
            }
        }