Beispiel #1
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #6
0
        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));
            }
        }
Beispiel #8
0
 public ClassRelation(string name, IXmlElement element = null, IParseLocationInfo parseLocation = null)
     : base(name, nameof(ClassRelation), null, element, parseLocation)
 {
 }
Beispiel #9
0
 /// <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));
 }
Beispiel #10
0
 /// <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));
 }
Beispiel #11
0
 public ClassModel(string name, string type, INamespace ns, IXmlElement element = null, IParseLocationInfo parseLocation = null)
     : base(name, type, ns, element, parseLocation)
 {
 }
Beispiel #12
0
 public ClassRelationReference(string name, IParseLocationInfo parseLocation) : base(name, null, "relation", parseLocation)
 {
 }
Beispiel #13
0
 public ParseException(IParseLocationInfo locationInfo, string message)
     : base(FormatMessage(locationInfo, message))
 {
 }
Beispiel #14
0
 public EntityRelation(string name, IXmlElement element, IParseLocationInfo parseLocation) : base(name, element, parseLocation)
 {
 }
Beispiel #15
0
        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));
        }
Beispiel #16
0
 public XmlElement(ISchemaElement definition, IXmlElement parentElement, IParseLocationInfo parseLocation)
 {
     this.Definition    = definition;
     this.ParentElement = parentElement;
     this.ParseLocation = parseLocation;
 }
Beispiel #17
0
 public ReferenceBase(string name, string type, IParseLocationInfo parseLocation)
 {
     Name          = name;
     Type          = type;
     ParseLocation = parseLocation;
 }
Beispiel #18
0
        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);
            }
        }
Beispiel #19
0
        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);
        }
Beispiel #20
0
 public static ClassRelationReference CreateRelationReference(this IClassModel classModel, string relationName, IParseLocationInfo parseLocation)
 {
     return(new ClassRelationReference(relationName, parseLocation));
 }
Beispiel #21
0
 public XmlAttribute(ISchemaElementAttribute definition, string value, IParseLocationInfo parseLocation)
 {
     this.Definition    = definition;
     this.Value         = value;
     this.ParseLocation = parseLocation;
 }
Beispiel #22
0
 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;
 }
Beispiel #24
0
 public ParseException(IParseLocationInfo locationInfo, string message, Exception innerException)
     : base(FormatMessage(locationInfo, message), innerException)
 {
 }
Beispiel #25
0
        public static ClassAttributeReference CreateAttributeReference(this IClassModel classModel, string attributeName, IParseLocationInfo parseLocation = null)
        {
            var designModel = (IDesignModel)classModel;

            return(new ClassAttributeReference(attributeName, parseLocation ?? designModel.ParseLocation));
        }
Beispiel #26
0
 protected override IClassAttribute CreateAttribute(string name, IDataType type, IXmlElement element, IParseLocationInfo parseLocation)
 {
     return(new EntityAttribute(name, type, element, parseLocation));
 }
Beispiel #27
0
 public static ClassAttributeReference CreateRelationAttributeReference(this IClassRelation classRelation, string attributeName, IParseLocationInfo parseLocation)
 {
     return(new ClassAttributeReference(attributeName, parseLocation));
 }
Beispiel #28
0
 public ClassAttributeReference(string name, IParseLocationInfo parseLocation) : base(name, null, nameof(IClassAttribute), parseLocation)
 {
 }
Beispiel #29
0
        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);
        }
Beispiel #30
0
 public ClassModelReference(string name, INamespace ns, string type, IParseLocationInfo parseLocation = null) : base(name, ns, type, parseLocation)
 {
 }