public static ClassModelReference CreateClassModelReference(this IDesignModelCollection designModelCollection, INamespace ns, IParseLocationInfo parseLocation, string name, string type = null) { var pos = name.IndexOf(':'); if (pos != -1) { name = name.Substring(0, pos); type = name.Substring(pos + 1); } pos = name.LastIndexOf('.'); if (pos == -1) { return(new ClassModelReference(name, ns, type, parseLocation)); } var nsName = name.Substring(0, pos); name = name.Substring(pos + 1); ns = designModelCollection.GetNamespace(nsName); return(new ClassModelReference(name, ns, type, parseLocation)); }
public DesignModelProperty(string name, IDataType type, object value, ISchemaElementAttribute definition = null, IParseLocationInfo parseLocation = null) { Name = name; Type = type; Value = value; ParseLocation = parseLocation; Definition = definition; }
public IDesignModelProperty GetProperty(string name, IParseLocationInfo parseLocation = null) { if (!_propertyMap.TryGetValue(name, out var property) && parseLocation != null) { throw new ParseException(parseLocation, $"Property '{name}' not found in design model '{FullyQualifiedName}'"); } return(property); }
private static string FormatMessage(IParseLocationInfo locationInfo, string message) { var buf = new StringBuilder(512); buf.Append(message); buf.Append(" (").Append(locationInfo).Append(")"); return(buf.ToString()); }
public INamespace GetNamespace(string name, IParseLocationInfo parseLocation = null) { if (!_namespaceMap.TryGetValue(name, out var res)) { if (parseLocation != null) { throw new ParseException(parseLocation, $"Namespace '{name}' not found"); } } return(res); }
private static string FormatMessage(XName xmlName, IParseLocationInfo parseLocation, string message) { var buf = new StringBuilder(512); buf.Append("Error in "); buf.Append(xmlName.LocalName); buf.Append(": "); buf.Append(message); buf.Append(" (").Append(parseLocation).Append(")"); return(buf.ToString()); }
public virtual void CopyPropertiesFrom(IDesignModel source, IParseLocationInfo parseLocation = null) { var propertiesToCopy = source.Properties.Join( Element.Definition.Attributes, x => x.Name, x => x.Name.LocalName, (x, y) => new { x.Name, y.Type, x.Value, Definition = y } ); foreach (var entry in propertiesToCopy.Where(x => !_propertyMap.ContainsKey(x.Name))) { AddProperty(new DesignModelProperty(entry.Name, entry.Type, entry.Value, entry.Definition, parseLocation)); } }
public ClassRelation(string name, IXmlElement element = null, IParseLocationInfo parseLocation = null) : base(name, nameof(ClassRelation), null, element, parseLocation) { }
/// <summary> /// Creates a relation. Subclasses can override to use specific types. /// </summary> /// <param name="name"></param> /// <param name="element"></param> /// <param name="parseLocation"></param> /// <returns></returns> protected virtual IClassRelation CreateRelation(string name, IXmlElement element, IParseLocationInfo parseLocation) { return(new ClassRelation(name, element, parseLocation)); }
/// <summary> /// Creates an attribute. Subclasses can override to use specific types. /// </summary> /// <param name="name"></param> /// <param name="type"></param> /// <param name="element"></param> /// <param name="parseLocation"></param> /// <returns></returns> protected virtual IClassAttribute CreateAttribute(string name, IDataType type, IXmlElement element, IParseLocationInfo parseLocation) { return(new ClassAttribute(name, type, element, parseLocation)); }
public ClassModel(string name, string type, INamespace ns, IXmlElement element = null, IParseLocationInfo parseLocation = null) : base(name, type, ns, element, parseLocation) { }
public ClassRelationReference(string name, IParseLocationInfo parseLocation) : base(name, null, "relation", parseLocation) { }
public ParseException(IParseLocationInfo locationInfo, string message) : base(FormatMessage(locationInfo, message)) { }
public EntityRelation(string name, IXmlElement element, IParseLocationInfo parseLocation) : base(name, element, parseLocation) { }
public static ClassModelReference CreateClassModelReference(this IClassModel classModel, IParseLocationInfo parseLocation = null) { var designModel = (IDesignModel)classModel; return(new ClassModelReference(designModel.Name, designModel.Namespace, designModel.DesignModelType, parseLocation ?? designModel.ParseLocation)); }
public XmlElement(ISchemaElement definition, IXmlElement parentElement, IParseLocationInfo parseLocation) { this.Definition = definition; this.ParentElement = parentElement; this.ParseLocation = parseLocation; }
public ReferenceBase(string name, string type, IParseLocationInfo parseLocation) { Name = name; Type = type; ParseLocation = parseLocation; }
public DesignModelBase(string name, string type, INamespace ns, IXmlElement element = null, IParseLocationInfo parseLocation = null) { Name = name; DesignModelType = type; Element = element; ParseLocation = parseLocation ?? element?.ParseLocation; Namespace = ns; if (ns != null) { OutputConfiguration = new OutputConfiguration.OutputConfiguration(ns.OutputConfiguration); } }
public virtual IClassAttribute CloneAttribute(IClassAttribute sourceAttribute, IParseLocationInfo parseLocation) { var attribute = new ClassAttribute(sourceAttribute.Name, sourceAttribute.Type, null, parseLocation: parseLocation); attribute.CopyPropertiesFrom(sourceAttribute, parseLocation); AddAttribute(attribute); return(attribute); }
public static ClassRelationReference CreateRelationReference(this IClassModel classModel, string relationName, IParseLocationInfo parseLocation) { return(new ClassRelationReference(relationName, parseLocation)); }
public XmlAttribute(ISchemaElementAttribute definition, string value, IParseLocationInfo parseLocation) { this.Definition = definition; this.Value = value; this.ParseLocation = parseLocation; }
public ClassAttribute(string name, IDataType type, IXmlElement element = null, IParseLocationInfo parseLocation = null) : base(name, nameof(ClassAttribute), null, element, parseLocation) { Type = type; }
public DesignModelReference(string name, INamespace ns, string type, IParseLocationInfo parseLocation = null) : base($"{ns.Name}.{name}", type, parseLocation) { LocalName = name; Namespace = ns; }
public ParseException(IParseLocationInfo locationInfo, string message, Exception innerException) : base(FormatMessage(locationInfo, message), innerException) { }
public static ClassAttributeReference CreateAttributeReference(this IClassModel classModel, string attributeName, IParseLocationInfo parseLocation = null) { var designModel = (IDesignModel)classModel; return(new ClassAttributeReference(attributeName, parseLocation ?? designModel.ParseLocation)); }
protected override IClassAttribute CreateAttribute(string name, IDataType type, IXmlElement element, IParseLocationInfo parseLocation) { return(new EntityAttribute(name, type, element, parseLocation)); }
public static ClassAttributeReference CreateRelationAttributeReference(this IClassRelation classRelation, string attributeName, IParseLocationInfo parseLocation) { return(new ClassAttributeReference(attributeName, parseLocation)); }
public ClassAttributeReference(string name, IParseLocationInfo parseLocation) : base(name, null, nameof(IClassAttribute), parseLocation) { }
public virtual IClassRelation CloneRelation(IClassRelation sourceRelation, IClassModel destinationClassModel, IParseLocationInfo parseLocation) { var relation = new ClassRelation(sourceRelation.Name, parseLocation: parseLocation); relation.CopyPropertiesFrom(sourceRelation, parseLocation); relation.Destination = destinationClassModel; AddOutgoingRelation(relation); destinationClassModel.AddIncomingRelation(relation); return(relation); }
public ClassModelReference(string name, INamespace ns, string type, IParseLocationInfo parseLocation = null) : base(name, ns, type, parseLocation) { }