Example #1
0
        private static void ProvidePopIndentMethod(CodeTypeMemberCollection members, CodeMemberField currentIndent, CodeMemberProperty indentLengths)
        {
            CodeVariableReferenceExpression codeVariableReferenceExpression  = new CodeVariableReferenceExpression("indentLength");
            CodeVariableReferenceExpression codeVariableReferenceExpression2 = new CodeVariableReferenceExpression("returnValue");
            CodeMemberMethod value = CodeDomHelpers.CreateMethod(typeof(string), "PopIndent", "Remove the last indent that was added with PushIndent", (MemberAttributes)24578, new CodeVariableDeclarationStatement(typeof(string), codeVariableReferenceExpression2.VariableName, string.Empty.Prim()), new CodeConditionStatement(indentLengths.Ref().Prop("Count").Gt(0.Prim()), new CodeVariableDeclarationStatement(typeof(int), codeVariableReferenceExpression.VariableName, indentLengths.Ref().Index(indentLengths.Ref().Prop("Count").Subtract(1.Prim()))), indentLengths.Ref().CallS("RemoveAt", indentLengths.Ref().Prop("Count").Subtract(1.Prim())), new CodeConditionStatement(codeVariableReferenceExpression.Gt(0.Prim()), codeVariableReferenceExpression2.Assign(currentIndent.Ref().Call("Substring", currentIndent.Ref().Prop("Length").Subtract(codeVariableReferenceExpression))), currentIndent.Ref().Assign(currentIndent.Ref().Call("Remove", currentIndent.Ref().Prop("Length").Subtract(codeVariableReferenceExpression))))), new CodeMethodReturnStatement(codeVariableReferenceExpression2));

            members.Add(value);
        }
        private static void ProvidePopIndentMethod(CodeTypeMemberCollection members, CodeMemberField currentIndent, CodeMemberProperty indentLengths)
        {
            CodeVariableReferenceExpression lhs         = new CodeVariableReferenceExpression("indentLength");
            CodeVariableReferenceExpression expression2 = new CodeVariableReferenceExpression("returnValue");
            CodeMemberMethod method = CodeDomHelpers.CreateMethod(typeof(string), "PopIndent", "Remove the last indent that was added with PushIndent", MemberAttributes.Public | MemberAttributes.Final, new CodeObject[] { new CodeVariableDeclarationStatement(typeof(string), expression2.VariableName, string.Empty.Prim()), new CodeConditionStatement(indentLengths.Ref().Prop("Count").Gt(0.Prim()), new CodeStatement[] { new CodeVariableDeclarationStatement(typeof(int), lhs.VariableName, indentLengths.Ref().Index(new CodeExpression[] { indentLengths.Ref().Prop("Count").Subtract(1.Prim()) })), indentLengths.Ref().CallS("RemoveAt", new CodeExpression[] { indentLengths.Ref().Prop("Count").Subtract(1.Prim()) }), new CodeConditionStatement(lhs.Gt(0.Prim()), new CodeStatement[] { expression2.Assign(currentIndent.Ref().Call("Substring", new CodeExpression[] { currentIndent.Ref().Prop("Length").Subtract(lhs) })), currentIndent.Ref().Assign(currentIndent.Ref().Call("Remove", new CodeExpression[] { currentIndent.Ref().Prop("Length").Subtract(lhs) })) }) }), new CodeMethodReturnStatement(expression2) });

            members.Add(method);
        }