internal SoalTypeBuilder GetReplacementType(SoalTypeBuilder original) { SoalTypeBuilder result = null; this.replacementTypes.TryGetValue(original, out result); return(result); }
internal void AddRootType(SoalTypeBuilder type) { if (type == null) { return; } this.rootTypes.Add(type); }
internal SoalTypeBuilder ResolveXsdReplacementType(SoalTypeBuilder type) { while (true) { SoalTypeBuilder replacementType = null; if (type != null && this.replacementTypes.TryGetValue(type, out replacementType)) { type = replacementType; } if (replacementType == null) { return(type); } } }
internal void RegisterOriginalType(ISymbol obj, SoalTypeBuilder type) { if (obj == null) { return; } if (type == null) { return; } if (!originalTypes.ContainsKey(obj)) { this.originalTypes.Add(obj, type); } }
public static SoalTypeBuilder GetCoreType(this SoalTypeBuilder type) { if (type == null) { return(null); } if (type is NullableTypeBuilder) { return(((NullableTypeBuilder)type).InnerType.GetCoreType()); } if (type is ArrayTypeBuilder) { return(((ArrayTypeBuilder)type).InnerType.GetCoreType()); } return(type); }
public static bool IsArrayType(this SoalTypeBuilder type) { if (type == null) { return(false); } if (type is NullableTypeBuilder) { return(((NullableTypeBuilder)type).InnerType.IsArrayType()); } if (type is ArrayTypeBuilder) { return(true); } return(false); }
internal void RegisterReplacementType(SoalTypeBuilder from, SoalTypeBuilder to) { if (from == null) { return; } if (to == null) { return; } if (!replacementTypes.ContainsKey(from)) { this.replacementTypes.Add(from, to); this.typesToRemove.Add(from); } }
internal void Reference(SoalTypeBuilder type) { if (type == null) { return; } int count = 0; if (this.referenceCounter.TryGetValue(type, out count)) { ++count; } else { count = 1; } this.referenceCounter[type] = count; }
private void CheckXsdTypes() { var types = this.Model.Symbols.OfType <StructBuilder>().ToList(); foreach (var type in types) { foreach (var prop in type.Properties) { if (prop.Type == null || prop.Type.GetCoreType() == null) { XElement elem = this.XsdTypes.GetX(type); string uri = ""; if (elem != null) { uri = elem.BaseUri; } this.AddError("The property '" + type.Name + "." + prop.Name + "' has no type.", uri, SoalImporter.GetLinePositionSpan(elem)); } else { SoalTypeBuilder originalType = null; if (this.originalTypes.TryGetValue((ISymbol)prop, out originalType)) { if (originalType is AnnotatedElementBuilder && ((AnnotatedElementBuilder)originalType).HasAnnotation(SoalAnnotations.Restriction)) { SoalImporter.CopyAnnotation(SoalAnnotations.Restriction, ((AnnotatedElementBuilder)originalType), prop); } if (originalType is StructBuilder) { object wrapped = ((StructBuilder)originalType).GetAnnotationPropertyValue(SoalAnnotations.Type, SoalAnnotationProperties.Wrapped) ?? false; if ((bool)wrapped) { SoalImporter.CopyAnnotationProperty(SoalAnnotations.Type, SoalAnnotationProperties.Wrapped, ((AnnotatedElementBuilder)originalType), SoalAnnotations.Element, SoalAnnotationProperties.Wrapped, prop); SoalImporter.CopyAnnotationProperty(SoalAnnotations.Type, SoalAnnotationProperties.Items, ((AnnotatedElementBuilder)originalType), SoalAnnotations.Element, SoalAnnotationProperties.Items, prop); SoalImporter.CopyAnnotationProperty(SoalAnnotations.Type, SoalAnnotationProperties.Sap, ((AnnotatedElementBuilder)originalType), SoalAnnotations.Element, SoalAnnotationProperties.Sap, prop); } } } } } } }
internal SoalTypeBuilder ResolveXsdType(XName name) { SoalTypeBuilder result = null; if (name.NamespaceName == XsdReader.XsdNamespace) { result = this.ResolveXsdPrimitiveType(name); if (result != null) { return(result); } } NamespaceBuilder ns = this.GetNamespace(name.NamespaceName); if (ns != null) { SoalTypeBuilder type = ns.Declarations.FirstOrDefault(d => d.Name == name.LocalName) as SoalTypeBuilder; return(this.ResolveXsdReplacementType(type)); } return(null); }
internal SoalTypeBuilder ResolveXsdPrimitiveType(XName name) { if (name.NamespaceName == XsdReader.XsdNamespace) { SoalType result = null; SoalTypeBuilder resultAsBuilder = null; switch (name.LocalName) { case "any": result = SoalInstance.Object; break; case "anySimpleType": result = SoalInstance.Object; break; case "string": result = SoalInstance.String; break; case "anyURI": result = SoalInstance.String; break; case "QName": result = SoalInstance.String; break; case "NOTATION": result = SoalInstance.String; break; case "normalizedString": result = SoalInstance.String; break; case "token": result = SoalInstance.String; break; case "language": result = SoalInstance.String; break; case "Name": result = SoalInstance.String; break; case "NCName": result = SoalInstance.String; break; case "NMTOKEN": result = SoalInstance.String; break; case "NMTOKENS": result = SoalInstance.String; break; case "ID": result = SoalInstance.String; break; case "IDREF": result = SoalInstance.String; break; case "IDREFS": result = SoalInstance.String; break; case "ENTITY": result = SoalInstance.String; break; case "ENTITIES": result = SoalInstance.String; break; case "integer": result = SoalInstance.Int; break; case "nonPositiveInteger": result = SoalInstance.Int; break; case "negativeInteger": result = SoalInstance.Int; break; case "int": result = SoalInstance.Int; break; case "short": result = SoalInstance.Int; break; case "nonNegativeInteger": result = SoalInstance.Int; break; case "positiveInteger": result = SoalInstance.Int; break; case "unsignedInt": result = SoalInstance.Int; break; case "unsignedShort": result = SoalInstance.Int; break; case "long": result = SoalInstance.Long; break; case "unsignedLong": result = SoalInstance.Int; break; case "float": result = SoalInstance.Float; break; case "double": result = SoalInstance.Double; break; case "decimal": result = SoalInstance.Double; break; case "byte": result = SoalInstance.Byte; break; case "unsignedByte": result = SoalInstance.Byte; break; case "base64Binary": resultAsBuilder = this.byteArray; break; case "hexBinary": resultAsBuilder = this.byteArray; break; case "bool": result = SoalInstance.Bool; break; case "boolean": result = SoalInstance.Bool; break; case "time": result = SoalInstance.Time; break; case "date": result = SoalInstance.Date; break; case "dateTime": result = SoalInstance.DateTime; break; case "duration": result = SoalInstance.TimeSpan; break; case "gDay": result = SoalInstance.Date; break; case "gMonth": result = SoalInstance.Date; break; case "gMonthDay": result = SoalInstance.Date; break; case "gYear": result = SoalInstance.Date; break; case "gYearMonth": result = SoalInstance.Date; break; default: break; } if (resultAsBuilder == null && result != null) { resultAsBuilder = result.ToMutable(); } return(resultAsBuilder); } return(null); }
internal void RemoveType(SoalTypeBuilder type) { this.typesToRemove.Add(type); }