Exemplo n.º 1
0
        public string GetCode(int baseIndentDepth, CodeGenType codeGenType = CodeGenType.Parent)
        {
            var baseIndent = CodeGenHelpers.GetIndentString(baseIndentDepth);

            string scriptPrefix      = "";
            string scriptSuffix      = "";
            string blockvariableName = "";

            var sb = new StringBuilder();

            if (codeGenType == CodeGenType.Parent)  // The parent needs to have a variable name
            {
                blockvariableName = this.Key;
            }

            string objectDescriptionComment = (this.ObjectDescription.Trim() == "") ? "" : "  # " + this.ObjectDescription;

            sb.AppendLine(baseIndent + scriptPrefix + DscObjectType + " " + blockvariableName + objectDescriptionComment);
            sb.AppendLine(baseIndent + "{");

            foreach (var a in this.Attributes)
            {
                sb.AppendLine(baseIndent + CodeGenHelpers.Indent + a.Code + a.Comment);
            }

            sb.Append(this.GetChildCode(baseIndentDepth + 1));

            sb.AppendLine(baseIndent + "}" + scriptSuffix);
            return(sb.ToString());
        }
Exemplo n.º 2
0
        public void AddAttributeWithOverrideValue(string paramName, string value, string sourceServerValue)
        {
            var comment = CodeGenHelpers.GetCommentOnOverride(value, sourceServerValue);


            CreateAttribute(paramName, value, comment);
        }
Exemplo n.º 3
0
        private void CreateAttribute(string paramName, string value, string comment)
        {
            string code = CodeGenHelpers.FormatAttributeCode(paramName, value);

            var attrib = new Attribute(paramName, code, comment);

            this.Attributes.Add(attrib);

            if (CodeGenHelpers.AreEqualCI(paramName, "name"))
            {
                this.Name = value;
            }
        }
Exemplo n.º 4
0
        private void CreateAttribute(string paramName, object value, string comment)
        {
            string code = CodeGenHelpers.FormatAttributeCode(paramName, value);

            var attrib = new Attribute(paramName, code, comment);

            this.Attributes.Add(attrib);

            // TODO this is messy, review
            if (CodeGenHelpers.AreEqualCI(paramName, "name"))
            {
                this.Name = value.ToString();
            }
        }