Example #1
0
        public string GenerateCode(IisPoolAndSitesOptions options)
        {
            IISObjectFactory objectFactory = new IISObjectFactory();
            StringBuilder    sb            = new StringBuilder();

            List <SiteDesiredState> sites = objectFactory.BuildSites(options);
            List <PoolDesiredState> pools = objectFactory.BuildPools(options);

            string baseIndent = CodeGenHelpers.GetIndentString(2);
            string code;

            sb.AppendLine(baseIndent + "# Note this code does not detect server level IIS overrides (it assumes the IIS level settings");
            sb.AppendLine(baseIndent + "# have not been overriden).  See the wiki for information about detecting server level changes.\n");

            if (options.IisPoolAndSitesGenerationMode == IisPoolAndSitesGenerationMode.ConfigFileOrder)
            {
                code = GeneratePools(pools);
                sb.AppendLine(code);

                code = GenerateSites(sites);
                sb.AppendLine(code);
            }
            else
            {
                code = GenerateSitesAndPools(sites, pools);
                sb.AppendLine(code);
            }

            return(sb.ToString());
        }
Example #2
0
        public override string GetChildCode(int baseIndentDepth)
        {
            string baseIndent = CodeGenHelpers.GetIndentString(baseIndentDepth);

            var code = "";

            code += GetChildListCode("BindingInfo", this.Bindings.ToList <DesiredStateBase>(), baseIndentDepth, baseIndent);

            code += GetChildListCode("WebConfigProp", this.AuthDesiredStateList.ToList <DesiredStateBase>(), baseIndentDepth, baseIndent);

            return(code);
        }
Example #3
0
        public override string GetChildCode(int baseIndentDepth)
        {
            string baseIndent = CodeGenHelpers.GetIndentString(baseIndentDepth);

            string code = "";

            if (AuthenticationInfo != null)
            {
                code += baseIndent + "AuthenticationInfo = \n" + this.AuthenticationInfo.GetCode(baseIndentDepth + 2, CodeGenType.SingleChild);
            }

            return(code);
        }
        public string GenerateIisSiteImports()
        {
            string        code = "";
            StringBuilder sb   = new StringBuilder();

            string indent = CodeGenHelpers.GetIndentString(1);

            sb.AppendLine(indent + "# Information about where to get needed modules and required version information can ");
            sb.AppendLine(indent + "# be found here: https://github.com/kevinsea/dsc-generator/wiki/Powershell-Modules");
            sb.AppendLine(indent + "# ---------------------------------------------------------------------------------");
            sb.AppendLine("");
            sb.AppendLine(indent + "Import-DscResource -ModuleName xWebAdministration");

            return(sb.ToString());
        }
        public override string GetChildCode(int baseIndentDepth)
        {
            string baseIndent = CodeGenHelpers.GetIndentString(baseIndentDepth);

            string code = "";

            code += CodeGenHelpers.GenerateChildListCode("BindingInfo", this.Bindings.ToList <DesiredStateBase>(), baseIndentDepth, baseIndent);

            if (AuthenticationInfo != null)
            {
                code += baseIndent + "AuthenticationInfo = \n" + this.AuthenticationInfo.GetCode(baseIndentDepth + 2, CodeGenType.SingleChild);
            }

            return(code);
        }
        private string GenerateSitesAndPools(IEnumerable <SiteDesiredState> siteList
                                             , IEnumerable <PoolDesiredState> poolList)
        {
            string        code        = "";
            int           poolCounter = 0;
            StringBuilder sb          = new StringBuilder();

            List <PoolDesiredState> poolsLeftToGenerate = new List <PoolDesiredState>(poolList);

            siteList = siteList.OrderBy(s => s.Name);

            foreach (SiteDesiredState site in siteList)
            {
                code = GetSiteHeader(site);
                sb.Append(code);

                foreach (string poolName in site.GetPoolsReferenced())
                {
                    var poolToGenerate = poolsLeftToGenerate.FirstOrDefault(p => p.Name == poolName);

                    if (poolToGenerate != null)
                    {
                        code = GeneratePool(poolToGenerate, poolCounter);
                        poolCounter++;
                        sb.AppendLine(code);

                        poolsLeftToGenerate.Remove(poolToGenerate);
                    }
                    else
                    {
                        code = CodeGenHelpers.GetIndentString(2)
                               + string.Format("# Pool '{0}' was generated with an earlier site\n", poolName);

                        sb.Append(code);
                    }
                }

                sb.AppendLine("");
                sb.Append(GenerateSite(site));
            }

            return(sb.ToString());
        }