Ejemplo n.º 1
0
        internal static CodeTypeDeclaration ProvideBaseClass(string name)
        {
            CodeTypeDeclaration codeTypeDeclaration = new CodeTypeDeclaration(name);

            codeTypeDeclaration.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "Base class"));
            codeTypeDeclaration.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "Base class"));
            codeTypeDeclaration.IsPartial = false;
            codeTypeDeclaration.IsClass   = true;
            codeTypeDeclaration.AddSummaryComment("Base class for this transformation");
            if (baseClassMembers == null)
            {
                baseClassMembers = ProvideBaseClassMembers();
            }
            codeTypeDeclaration.Members.AddRange(baseClassMembers);
            return(codeTypeDeclaration);
        }
Ejemplo n.º 2
0
        private static CodeTypeDeclaration ProvideNestedClass(CultureInfo formatProvider, CodeTypeMemberCollection members)
        {
            CodeTypeDeclaration member = new CodeTypeDeclaration("ToStringInstanceHelper")
            {
                IsClass = true
            };

            member.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "ToString Helpers"));
            member.Attributes = MemberAttributes.Public;
            member.AddSummaryComment("Utility class to produce culture-oriented representation of an object as a string.");
            CodeMemberField field = ProvideNestedFormatProviderField(member, formatProvider);
            CodeFieldReferenceExpression formatProviderFieldRef = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), field.Name);

            ProvideNestedFormatProviderProperty(member, formatProviderFieldRef);
            ProvideNestedToStringWithCultureMethod(member, formatProviderFieldRef);
            members.Add(member);
            return(member);
        }