public static CodeSnippetTypeMember CreateCast(string typeT, string typeT1, bool useAutoTyping) { CodeSnippetTypeMember castMember = new CodeSnippetTypeMember(); if (useAutoTyping) { castMember.Text = String.Concat(" public static explicit operator ", typeT, "(XElement xe) { ", "return (", typeT, ")", Constants.XTypedServices, ".ToXTypedElement(xe,", NameGenerator.GetServicesClassName(), ".Instance as ILinqToXsdTypeManager); }"); } else { castMember.Text = String.Concat(" public static explicit operator ", typeT, "(XElement xe) { return ", Constants.XTypedServices, ".ToXTypedElement<", GetInnerType(typeT, typeT1), ">(xe,", NameGenerator.GetServicesClassName(), ".Instance as ILinqToXsdTypeManager); }"); } return(castMember); }
private void ImplementIXmlSerializable() { string interfaceName = "IXmlSerializable"; string typeManagerName = NameGenerator.GetServicesClassName(); string methodName = string.Concat(this.clrTypeInfo.clrtypeName, "SchemaProvider"); CodeMemberMethod schemaProviderMethod = CodeDomHelper.CreateMethod(methodName, MemberAttributes.Abstract | MemberAttributes.Final | MemberAttributes.Static | MemberAttributes.FamilyAndAssembly | MemberAttributes.FamilyOrAssembly | MemberAttributes.Public, null); schemaProviderMethod.Parameters.Add(new CodeParameterDeclarationExpression("XmlSchemaSet", "schemas")); CodeStatementCollection statements = schemaProviderMethod.Statements; CodeTypeReferenceExpression codeTypeReferenceExpression = new CodeTypeReferenceExpression(typeManagerName); CodeExpression[] codeVariableReferenceExpression = new CodeExpression[] { new CodeVariableReferenceExpression("schemas") }; statements.Add(CodeDomHelper.CreateMethodCall(codeTypeReferenceExpression, "AddSchemas", codeVariableReferenceExpression)); codeVariableReferenceExpression = new CodeExpression[] { new CodePrimitiveExpression(this.clrTypeInfo.schemaName), new CodePrimitiveExpression(this.clrTypeInfo.schemaNs) }; CodeExpression qNameExp = new CodeObjectCreateExpression("XmlQualifiedName", codeVariableReferenceExpression); if (this.clrTypeInfo.typeOrigin != SchemaOrigin.Element) { schemaProviderMethod.ReturnType = new CodeTypeReference("XmlQualifiedName"); schemaProviderMethod.Statements.Add(new CodeMethodReturnStatement(qNameExp)); } else { CodeStatementCollection codeStatementCollection = schemaProviderMethod.Statements; CodePropertyReferenceExpression codePropertyReferenceExpression = new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("schemas"), "GlobalElements"); codeVariableReferenceExpression = new CodeExpression[] { qNameExp }; codeStatementCollection.Add(new CodeVariableDeclarationStatement("XmlSchemaElement", "element", new CodeCastExpression("XmlSchemaElement", new CodeIndexerExpression(codePropertyReferenceExpression, codeVariableReferenceExpression)))); CodeStatementCollection statements1 = schemaProviderMethod.Statements; CodeBinaryOperatorExpression codeBinaryOperatorExpression = new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("element"), CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null)); CodeStatement[] codeMethodReturnStatement = new CodeStatement[] { new CodeMethodReturnStatement(new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("element"), "ElementSchemaType")) }; statements1.Add(new CodeConditionStatement(codeBinaryOperatorExpression, codeMethodReturnStatement)); schemaProviderMethod.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null))); schemaProviderMethod.ReturnType = new CodeTypeReference("XmlSchemaType"); } this.decl.CustomAttributes.Add(CodeDomHelper.SchemaProviderAttribute(this.clrTypeInfo.clrtypeName)); this.decl.BaseTypes.Add(interfaceName); this.decl.Members.Add(schemaProviderMethod); }
internal virtual void InsertDefaultFixedValueInDefaultCtor(CodeConstructor ctor) { if (this.FixedValue != null) { ctor.Statements.Add(new CodeAssignStatement(CodeDomHelper.CreateFieldReference(null, this.propertyName), CodeDomHelper.CreateFieldReference(null, NameGenerator.ChangeClrName(this.propertyName, NameOptions.MakeFixedValueField)))); } else if (this.DefaultValue != null) { ctor.Statements.Add(new CodeAssignStatement(CodeDomHelper.CreateFieldReference(null, this.propertyName), CodeDomHelper.CreateFieldReference(null, NameGenerator.ChangeClrName(this.propertyName, NameOptions.MakeDefaultValueField)))); } }
private CodeExpression[] GetListParameters(bool set, bool constructor) { CodeExpression[] listParameters = null; int paramCount = 2; CodeExpression typeParam = null; CodeExpression nameOrValue = null; if (set) { paramCount++; if (!constructor) { nameOrValue = CodeDomHelper.SetValue(); } else { nameOrValue = new CodeVariableReferenceExpression(this.propertyName); } } if (!this.IsSubstitutionHead) { paramCount++; if (!this.typeRef.IsSimpleType) { typeParam = CodeDomHelper.SingletonTypeManager(); } else { typeParam = this.GetSchemaDatatypeExpression(); if (this.fixedDefaultValue != null) { paramCount++; } } } else { paramCount += this.substitutionMembers.Count; typeParam = CodeDomHelper.SingletonTypeManager(); } listParameters = new CodeExpression[paramCount]; int paramIndex = 0; int num = paramIndex; paramIndex = num + 1; listParameters[num] = CodeDomHelper.This(); int num1 = paramIndex; paramIndex = num1 + 1; listParameters[num1] = typeParam; if (nameOrValue != null) { int num2 = paramIndex; paramIndex = num2 + 1; listParameters[num2] = nameOrValue; } if (!this.IsSubstitutionHead) { int num3 = paramIndex; paramIndex = num3 + 1; listParameters[num3] = this.xNameGetExpression; } else { foreach (XmlSchemaElement elem in this.substitutionMembers) { int num4 = paramIndex; paramIndex = num4 + 1; listParameters[num4] = CodeDomHelper.XNameGetExpression(elem.QualifiedName.Name, elem.QualifiedName.Namespace); } } if (this.fixedDefaultValue != null) { if (this.FixedValue == null) { int num5 = paramIndex; paramIndex = num5 + 1; listParameters[num5] = new CodeFieldReferenceExpression(null, NameGenerator.ChangeClrName(this.propertyName, NameOptions.MakeDefaultValueField)); } else { int num6 = paramIndex; paramIndex = num6 + 1; listParameters[num6] = new CodeFieldReferenceExpression(null, NameGenerator.ChangeClrName(this.propertyName, NameOptions.MakeFixedValueField)); } } return(listParameters); }
protected void CreateFixedDefaultValue(CodeTypeDeclaration typeDecl) { if (this.fixedDefaultValue != null) { CodeMemberField fixedOrDefaultField = null; CodeTypeReference returnType = this.ReturnType; if (this.unionDefaultType != null) { returnType = new CodeTypeReference(this.unionDefaultType.ToString()); } fixedOrDefaultField = (this.FixedValue == null ? new CodeMemberField(returnType, NameGenerator.ChangeClrName(base.PropertyName, NameOptions.MakeDefaultValueField)) : new CodeMemberField(returnType, NameGenerator.ChangeClrName(base.PropertyName, NameOptions.MakeFixedValueField))); CodeDomHelper.AddBrowseNever(fixedOrDefaultField); fixedOrDefaultField.Attributes = fixedOrDefaultField.Attributes & (MemberAttributes.Abstract | MemberAttributes.Final | MemberAttributes.Static | MemberAttributes.Override | MemberAttributes.Const | MemberAttributes.New | MemberAttributes.Overloaded | MemberAttributes.ScopeMask | MemberAttributes.VTableMask) & (MemberAttributes.New | MemberAttributes.Overloaded | MemberAttributes.Assembly | MemberAttributes.FamilyAndAssembly | MemberAttributes.Family | MemberAttributes.FamilyOrAssembly | MemberAttributes.Private | MemberAttributes.Public | MemberAttributes.AccessMask | MemberAttributes.VTableMask) | MemberAttributes.Private | MemberAttributes.Static; fixedOrDefaultField.InitExpression = SimpleTypeCodeDomHelper.CreateFixedDefaultValueExpression(returnType, this.fixedDefaultValue); typeDecl.Members.Add(fixedOrDefaultField); } }
private CodeStatement CreateDefaultValueAssignStmt(object value) { CodeStatement codeAssignStatement = new CodeAssignStatement(CodeDomHelper.CreateFieldReference(null, this.propertyName), CodeDomHelper.CreateFieldReference(null, NameGenerator.ChangeClrName(this.propertyName, NameOptions.MakeDefaultValueField))); return(codeAssignStatement); }
internal override void AddToConstructor(CodeConstructor functionalConstructor) { if (!this.IsList) { functionalConstructor.Parameters.Add(new CodeParameterDeclarationExpression(this.ReturnType, this.propertyName)); if (!this.FromBaseType) { functionalConstructor.Statements.Add(new CodeAssignStatement(CodeDomHelper.CreateFieldReference("this", this.propertyName), new CodeVariableReferenceExpression(this.propertyName))); } else { functionalConstructor.BaseConstructorArgs.Add(new CodeVariableReferenceExpression(this.propertyName)); } } else { CodeParameterDeclarationExpressionCollection parameters = functionalConstructor.Parameters; CodeTypeReference[] codeTypeReference = new CodeTypeReference[] { new CodeTypeReference(this.clrTypeName) }; parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference("IEnumerable", codeTypeReference), this.propertyName)); if (!this.FromBaseType) { CodeTypeReference listType = this.GetListType(); functionalConstructor.Statements.Add(new CodeAssignStatement(CodeDomHelper.CreateFieldReference("this", NameGenerator.ChangeClrName(this.propertyName, NameOptions.MakeField)), new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(listType), "Initialize", this.GetListParameters(true, true)))); } else { functionalConstructor.BaseConstructorArgs.Add(new CodeVariableReferenceExpression(this.propertyName)); } } }
private void AddListGetStatements(CodeStatementCollection getStatements, CodeTypeReference listType, string listName) { if (this.FixedValue == null) { CodeBinaryOperatorExpression codeBinaryOperatorExpression = new CodeBinaryOperatorExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), listName), CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(null)); CodeStatement[] codeAssignStatement = new CodeStatement[] { new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), listName), new CodeObjectCreateExpression(listType, this.GetListParameters(false, false))) }; getStatements.Add(new CodeConditionStatement(codeBinaryOperatorExpression, codeAssignStatement)); getStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), listName))); } else { getStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(null, NameGenerator.ChangeClrName(this.propertyName, NameOptions.MakeFixedValueField)))); } }
private void AddGetStatements(CodeStatementCollection getStatements) { CodeExpression[] simpleTypeClassExpression; if (!this.IsSubstitutionHead) { CodeExpression returnExp = null; if (this.FixedValue == null) { getStatements.Add(this.GetValueMethodCall()); this.CheckOccurrence(getStatements); CodeVariableReferenceExpression returnValueExp = new CodeVariableReferenceExpression("x"); if ((this.IsRef ? true : !this.typeRef.IsSimpleType)) { returnExp = new CodeCastExpression(this.ReturnType, returnValueExp); } else { CodeTypeReference parseType = this.ReturnType; if ((!this.typeRef.IsValueType ? false : this.IsNullable)) { parseType = new CodeTypeReference(this.clrTypeName); } if (!this.IsUnion) { string parseMethodName = null; CodeExpression simpleTypeExpression = this.GetSchemaDatatypeExpression(); if (!this.IsSchemaList) { parseMethodName = "ParseValue"; } else { parseMethodName = "ParseListValue"; parseType = new CodeTypeReference(this.clrTypeName); } CodeTypeReferenceExpression codeTypeReferenceExpression = CodeDomHelper.CreateTypeReferenceExp("XTypedServices"); simpleTypeClassExpression = new CodeExpression[] { returnValueExp, simpleTypeExpression }; returnExp = CodeDomHelper.CreateGenericMethodCall(codeTypeReferenceExpression, parseMethodName, parseType, simpleTypeClassExpression); if (this.DefaultValue != null) { ((CodeMethodInvokeExpression)returnExp).Parameters.Add(new CodeFieldReferenceExpression(null, NameGenerator.ChangeClrName(this.propertyName, NameOptions.MakeDefaultValueField))); } } else { CodeTypeReferenceExpression codeTypeReferenceExpression1 = CodeDomHelper.CreateTypeReferenceExp("XTypedServices"); simpleTypeClassExpression = new CodeExpression[] { returnValueExp, this.GetSimpleTypeClassExpression() }; returnExp = CodeDomHelper.CreateMethodCall(codeTypeReferenceExpression1, "ParseUnionValue", simpleTypeClassExpression); } } getStatements.Add(new CodeMethodReturnStatement(returnExp)); } else { getStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(null, NameGenerator.ChangeClrName(this.propertyName, NameOptions.MakeFixedValueField)))); } } else { this.AddSubstGetStatements(getStatements); } }
protected void AddFixedValueChecking(CodeStatementCollection setStatements) { if (this.FixedValue != null) { CodeExpression fixedValueExpr = new CodeFieldReferenceExpression(null, NameGenerator.ChangeClrName(this.propertyName, NameOptions.MakeFixedValueField)); CodePropertySetValueReferenceExpression codePropertySetValueReferenceExpression = new CodePropertySetValueReferenceExpression(); CodeExpression[] codeExpressionArray = new CodeExpression[] { fixedValueExpr }; CodeMethodInvokeExpression codeMethodInvokeExpression = CodeDomHelper.CreateMethodCall(codePropertySetValueReferenceExpression, "Equals", codeExpressionArray); CodeStatement[] codeStatementArray = new CodeStatement[0]; CodeStatement[] codeThrowExceptionStatement = new CodeStatement[1]; Type type = typeof(LinqToXsdFixedValueException); codeExpressionArray = new CodeExpression[] { new CodePropertySetValueReferenceExpression(), fixedValueExpr }; codeThrowExceptionStatement[0] = new CodeThrowExceptionStatement(new CodeObjectCreateExpression(type, codeExpressionArray)); setStatements.Add(new CodeConditionStatement(codeMethodInvokeExpression, codeStatementArray, codeThrowExceptionStatement)); } }
public static CodePropertyReferenceExpression SingletonTypeManager() { return(new CodePropertyReferenceExpression( new CodeTypeReferenceExpression(NameGenerator.GetServicesClassName()), Constants.TypeManagerInstance)); }
public static CodeSnippetTypeMember CreateCast(string typeT, string typeT1, bool useAutoTyping) { string[] strArrays; CodeSnippetTypeMember castMember = new CodeSnippetTypeMember(); if (!useAutoTyping) { strArrays = new string[] { " public static explicit operator ", typeT, "(XElement xe) { return ", "XTypedServices", ".ToXTypedElement<", CodeDomHelper.GetInnerType(typeT, typeT1), ">(xe,", NameGenerator.GetServicesClassName(), ".Instance as ILinqToXsdTypeManager); }" }; castMember.Text = string.Concat(strArrays); } else { strArrays = new string[] { " public static explicit operator ", typeT, "(XElement xe) { ", "return (", typeT, ")", "XTypedServices", ".ToXTypedElement(xe,", NameGenerator.GetServicesClassName(), ".Instance as ILinqToXsdTypeManager); }" }; castMember.Text = string.Concat(strArrays); } return(castMember); }
internal static CodeTypeDeclaration CreateTypeManager(XmlQualifiedName rootElementName, bool enableServiceReference, CodeStatementCollection typeDictionaryStatements, CodeStatementCollection elementDictionaryStatements, CodeStatementCollection wrapperDictionaryStatements) { string servicesClassName = NameGenerator.GetServicesClassName(); CodeTypeDeclaration servicesTypeDecl = new CodeTypeDeclaration(servicesClassName) { Attributes = MemberAttributes.Public }; CodeMemberField singletonField = CodeDomHelper.CreateMemberField("typeManagerSingleton", servicesClassName, MemberAttributes.Static, true); CodeMemberProperty singletonProperty = CodeDomHelper.CreateProperty("Instance", null, singletonField, MemberAttributes.Abstract | MemberAttributes.Final | MemberAttributes.Static | MemberAttributes.FamilyAndAssembly | MemberAttributes.FamilyOrAssembly | MemberAttributes.Public, false); MemberAttributes privateStatic = MemberAttributes.Abstract | MemberAttributes.Final | MemberAttributes.Static | MemberAttributes.Assembly | MemberAttributes.FamilyOrAssembly | MemberAttributes.Private; CodeTypeConstructor staticServicesConstructor = new CodeTypeConstructor(); CodeTypeReference returnType = CodeDomHelper.CreateDictionaryType("XName", "System.Type"); CodeTypeReference wrapperReturnType = CodeDomHelper.CreateDictionaryType("System.Type", "System.Type"); CodeMemberProperty typeDictProperty = null; if (typeDictionaryStatements.Count <= 0) { typeDictProperty = CodeDomHelper.CreateInterfaceImplProperty("GlobalTypeDictionary", "ILinqToXsdTypeManager", returnType); typeDictProperty.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("XTypedServices"), "EmptyDictionary"))); } else { typeDictProperty = CodeDomHelper.CreateInterfaceImplProperty("GlobalTypeDictionary", "ILinqToXsdTypeManager", returnType, "typeDictionary"); CodeMemberField staticTypeDictionary = CodeDomHelper.CreateDictionaryField("typeDictionary", "XName", "System.Type"); CodeMemberMethod buildTypeDictionary = CodeDomHelper.CreateMethod("BuildTypeDictionary", privateStatic, null); buildTypeDictionary.Statements.AddRange(typeDictionaryStatements); staticServicesConstructor.Statements.Add(CodeDomHelper.CreateMethodCall(null, "BuildTypeDictionary", new CodeExpression[0])); servicesTypeDecl.Members.Add(staticTypeDictionary); servicesTypeDecl.Members.Add(buildTypeDictionary); } CodeMemberProperty elementDictProperty = null; if (elementDictionaryStatements.Count <= 0) { elementDictProperty = CodeDomHelper.CreateInterfaceImplProperty("GlobalElementDictionary", "ILinqToXsdTypeManager", returnType); elementDictProperty.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("XTypedServices"), "EmptyDictionary"))); } else { elementDictProperty = CodeDomHelper.CreateInterfaceImplProperty("GlobalElementDictionary", "ILinqToXsdTypeManager", returnType, "elementDictionary"); CodeMemberField staticElementDictionary = CodeDomHelper.CreateDictionaryField("elementDictionary", "XName", "System.Type"); CodeMemberMethod buildElementDictionary = CodeDomHelper.CreateMethod("BuildElementDictionary", privateStatic, null); buildElementDictionary.Statements.AddRange(elementDictionaryStatements); staticServicesConstructor.Statements.Add(CodeDomHelper.CreateMethodCall(null, "BuildElementDictionary", new CodeExpression[0])); servicesTypeDecl.Members.Add(staticElementDictionary); servicesTypeDecl.Members.Add(buildElementDictionary); } CodeMemberProperty wrapperDictProperty = null; if (wrapperDictionaryStatements.Count <= 0) { wrapperDictProperty = CodeDomHelper.CreateInterfaceImplProperty("RootContentTypeMapping", "ILinqToXsdTypeManager", wrapperReturnType); wrapperDictProperty.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("XTypedServices"), "EmptyTypeMappingDictionary"))); } else { wrapperDictProperty = CodeDomHelper.CreateInterfaceImplProperty("RootContentTypeMapping", "ILinqToXsdTypeManager", wrapperReturnType, "wrapperDictionary"); CodeMemberField staticWrapperDictionary = CodeDomHelper.CreateDictionaryField("wrapperDictionary", "System.Type", "System.Type"); CodeMemberMethod buildWrapperDictionary = CodeDomHelper.CreateMethod("BuildWrapperDictionary", privateStatic, null); buildWrapperDictionary.Statements.AddRange(wrapperDictionaryStatements); staticServicesConstructor.Statements.Add(CodeDomHelper.CreateMethodCall(null, "BuildWrapperDictionary", new CodeExpression[0])); servicesTypeDecl.Members.Add(staticWrapperDictionary); servicesTypeDecl.Members.Add(buildWrapperDictionary); } string schemaSetFieldName = "schemaSet"; CodeTypeReference schemaSetType = new CodeTypeReference("XmlSchemaSet"); CodeMemberField schemaSetField = new CodeMemberField(schemaSetType, schemaSetFieldName) { Attributes = MemberAttributes.Abstract | MemberAttributes.Final | MemberAttributes.Static | MemberAttributes.Assembly | MemberAttributes.FamilyOrAssembly | MemberAttributes.Private }; CodeMemberMethod addSchemasMethod = CodeDomHelper.CreateMethod("AddSchemas", MemberAttributes.Abstract | MemberAttributes.Final | MemberAttributes.Static | MemberAttributes.FamilyOrAssembly, null); addSchemasMethod.Parameters.Add(new CodeParameterDeclarationExpression("XmlSchemaSet", "schemas")); CodeStatementCollection statements = addSchemasMethod.Statements; CodeVariableReferenceExpression codeVariableReferenceExpression = new CodeVariableReferenceExpression("schemas"); CodeExpression[] codeFieldReferenceExpression = new CodeExpression[] { new CodeFieldReferenceExpression(null, schemaSetFieldName) }; statements.Add(CodeDomHelper.CreateMethodCall(codeVariableReferenceExpression, "Add", codeFieldReferenceExpression)); CodeTypeReferenceExpression interLockedType = new CodeTypeReferenceExpression("System.Threading.Interlocked"); CodeMemberProperty schemaSetProperty = CodeDomHelper.CreateInterfaceImplProperty("Schemas", "ILinqToXsdTypeManager", schemaSetType); CodeFieldReferenceExpression schemaSetFieldRef = new CodeFieldReferenceExpression(null, schemaSetFieldName); CodeDirectionExpression schemaSetParam = new CodeDirectionExpression(FieldDirection.Ref, schemaSetFieldRef); CodeStatementCollection getStatements = schemaSetProperty.GetStatements; CodeBinaryOperatorExpression codeBinaryOperatorExpression = new CodeBinaryOperatorExpression(schemaSetFieldRef, CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(null)); CodeStatement[] codeVariableDeclarationStatement = new CodeStatement[] { new CodeVariableDeclarationStatement(schemaSetType, "tempSet", new CodeObjectCreateExpression(schemaSetType, new CodeExpression[0])), null }; codeFieldReferenceExpression = new CodeExpression[] { schemaSetParam, new CodeVariableReferenceExpression("tempSet"), new CodePrimitiveExpression(null) }; codeVariableDeclarationStatement[1] = new CodeExpressionStatement(CodeDomHelper.CreateMethodCall(interLockedType, "CompareExchange", codeFieldReferenceExpression)); getStatements.Add(new CodeConditionStatement(codeBinaryOperatorExpression, codeVariableDeclarationStatement)); schemaSetProperty.GetStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression(schemaSetFieldName))); schemaSetProperty.SetStatements.Add(new CodeAssignStatement(schemaSetFieldRef, new CodePropertySetValueReferenceExpression())); servicesTypeDecl.Members.Add(schemaSetField); servicesTypeDecl.Members.Add(schemaSetProperty); servicesTypeDecl.Members.Add(addSchemasMethod); servicesTypeDecl.Members.Add(typeDictProperty); servicesTypeDecl.Members.Add(elementDictProperty); servicesTypeDecl.Members.Add(wrapperDictProperty); servicesTypeDecl.BaseTypes.Add("ILinqToXsdTypeManager"); CodeMemberMethod getRootType = new CodeMemberMethod() { Attributes = MemberAttributes.Abstract | MemberAttributes.Final | MemberAttributes.Static | MemberAttributes.FamilyAndAssembly | MemberAttributes.FamilyOrAssembly | MemberAttributes.Public, Name = "GetRootType", ReturnType = new CodeTypeReference("System.Type") }; if (!rootElementName.IsEmpty) { CodeStatementCollection codeStatementCollection = getRootType.Statements; CodeFieldReferenceExpression codeFieldReferenceExpression1 = CodeDomHelper.CreateFieldReference(null, "elementDictionary"); codeFieldReferenceExpression = new CodeExpression[] { CodeDomHelper.XNameGetExpression(rootElementName.Name, rootElementName.Namespace) }; codeStatementCollection.Add(new CodeMethodReturnStatement(new CodeIndexerExpression(codeFieldReferenceExpression1, codeFieldReferenceExpression))); } else { getRootType.Statements.Add(new CodeMethodReturnStatement(CodeDomHelper.Typeof("Xml.Schema.Linq.XTypedElement"))); } servicesTypeDecl.Members.Add(staticServicesConstructor); servicesTypeDecl.Members.Add(getRootType); servicesTypeDecl.Members.Add(singletonField); servicesTypeDecl.Members.Add(singletonProperty); return(servicesTypeDecl); }