protected SymbolEntry AddSymbol(XmlQualifiedName qname, XmlSchemaObject schemaObject, string suffix) { SymbolEntry symbol = new SymbolEntry() { xsdNamespace = qname.Namespace, clrNamespace = this.configSettings.GetClrNamespace(qname.Namespace), symbolName = qname.Name }; string identifierName = NameGenerator.MakeValidIdentifier(symbol.symbolName, this.configSettings.NameMangler2); symbol.identifierName = identifierName; int id = 0; if (this.symbols.ContainsKey(symbol)) { identifierName = string.Concat(identifierName, suffix); symbol.identifierName = identifierName; while (this.symbols.ContainsKey(symbol)) { id++; symbol.identifierName = string.Concat(identifierName, id.ToString(CultureInfo.InvariantCulture.NumberFormat)); } } if (symbol.isNameFixed()) { this.nFixedNames++; } this.symbols.Add(symbol, symbol); this.schemaNameToIdentifiers.Add(schemaObject, symbol.identifierName); return(symbol); }
protected SymbolEntry AddSymbol( XmlQualifiedName qname, XmlSchemaObject schemaObject, string suffix) { var symbol = new SymbolEntry(); symbol.xsdNamespace = qname.Namespace; symbol.clrNamespace = configSettings.GetClrNamespace(qname.Namespace); symbol.symbolName = qname.Name; var identifierName = NameGenerator.MakeValidIdentifier( symbol.symbolName, this.configSettings.NameMangler2); symbol.identifierName = identifierName; int id = 0; if (symbols.ContainsKey(symbol)) { identifierName = identifierName + suffix; symbol.identifierName = identifierName; while (symbols.ContainsKey(symbol)) { id++; symbol.identifierName = identifierName + id.ToString(CultureInfo.InvariantCulture.NumberFormat); } } if (symbol.isNameFixed()) { nFixedNames++; } symbols.Add(symbol, symbol); // Type vs typeName schemaNameToIdentifiers.Add(schemaObject, symbol.identifierName); return(symbol); }
public static string MakeValidCLRNamespace(string xsdNamespace, bool nameMangler2) { if (xsdNamespace == null || xsdNamespace == string.Empty) { return(string.Empty); } xsdNamespace = xsdNamespace.Replace("http://", string.Empty); if (xsdNamespace == string.Empty) { return(string.Empty); } if (nameMangler2) { xsdNamespace = xsdNamespace.Replace('.', '_').Replace('-', '_'); } string[] pieces = xsdNamespace.Split(new char[] { '/', '.', ':', '-' }); string clrNS = NameGenerator.MakeValidIdentifier(pieces[0], nameMangler2); for (int i = 1; i < pieces.Length; i++) { if (pieces[i] != string.Empty) { clrNS += "." + NameGenerator.MakeValidIdentifier(pieces[i], nameMangler2); } } return(clrNS); }
public static string MakeValidCLRNamespace(string xsdNamespace, bool nameMangler2) { string empty; if ((xsdNamespace == null ? false : !(xsdNamespace == string.Empty))) { xsdNamespace = xsdNamespace.Replace("http://", string.Empty); if (!(xsdNamespace == string.Empty)) { if (nameMangler2) { xsdNamespace = xsdNamespace.Replace('.', '\u005F').Replace('-', '\u005F'); } string[] pieces = xsdNamespace.Split(new char[] { '/', '.', ':', '-' }); string clrNS = NameGenerator.MakeValidIdentifier(pieces[0], nameMangler2); for (int i = 1; i < (int)pieces.Length; i++) { if (pieces[i] != string.Empty) { clrNS = string.Concat(clrNS, ".", NameGenerator.MakeValidIdentifier(pieces[i], nameMangler2)); } } empty = clrNS; } else { empty = string.Empty; } } else { empty = string.Empty; } return(empty); }
public string AddAttribute(XmlSchemaAttribute attribute) { string identifierName = NameGenerator.MakeValidIdentifier(attribute.QualifiedName.Name); identifierName = getSymbol(identifierName, Constants.LocalAttributeConflictSuffix); symbolToQName.Add(identifierName.ToUpper(CultureInfo.InvariantCulture), attribute.QualifiedName); return(identifierName); }
public string AddAttribute(XmlSchemaAttribute attribute) { string identifierName = NameGenerator.MakeValidIdentifier(attribute.QualifiedName.Name, this.ConfigSettings.NameMangler2); identifierName = this.getSymbol(identifierName, ""); this.symbolToQName.Add(identifierName.ToUpper(CultureInfo.InvariantCulture), attribute.QualifiedName); return(identifierName); }
public void AddComplexRestrictedContentType(XmlSchemaComplexType wrappingType, ClrTypeReference wrappingTypeRef) { string identifier = NameGenerator.MakeValidIdentifier(wrappingType.Name); AnonymousType at = new AnonymousType(); at.identifier = identifier; at.typeRefence = wrappingTypeRef; at.wrappingType = wrappingType; anonymousTypes.Add(at); }
public void AddComplexRestrictedContentType(XmlSchemaComplexType wrappingType, ClrTypeReference wrappingTypeRef) { string identifier = NameGenerator.MakeValidIdentifier(wrappingType.Name, this.ConfigSettings.NameMangler2); AnonymousType at = new AnonymousType() { identifier = identifier, typeRefence = wrappingTypeRef, wrappingType = wrappingType }; this.anonymousTypes.Add(at); }
public string AddLocalElement(XmlSchemaElement element) { string identifierName = (string)qNameToSymbol[element.QualifiedName]; if (identifierName != null) { return(identifierName); } identifierName = NameGenerator.MakeValidIdentifier(element.QualifiedName.Name); identifierName = getSymbol(identifierName, Constants.LocalElementConflictSuffix); symbolToQName.Add(identifierName.ToUpper(CultureInfo.InvariantCulture), element.QualifiedName); qNameToSymbol.Add(element.QualifiedName, identifierName); return(identifierName); }
public string AddLocalElement(XmlSchemaElement element) { string str; string identifierName = (string)this.qNameToSymbol[element.QualifiedName]; if (identifierName == null) { identifierName = NameGenerator.MakeValidIdentifier(element.QualifiedName.Name, this.ConfigSettings.NameMangler2); identifierName = this.getSymbol(identifierName, ""); this.symbolToQName.Add(identifierName.ToUpper(CultureInfo.InvariantCulture), element.QualifiedName); this.qNameToSymbol.Add(element.QualifiedName, identifierName); str = identifierName; } else { str = identifierName; } return(str); }