internal static Node AddNode(Node node) { if (!entries.ContainsKey(node.Name)) { entries.Add(node.Name, node); return(node); } else { PssgSchema.SetNodeDataTypeIfNull(entries[node.Name], node.DataType); foreach (Attribute attrEntry in node.Attributes) { bool add = true; for (int i = 0; i < entries[node.Name].Attributes.Count; i++) { if (entries[node.Name].Attributes[i].Name == attrEntry.Name) { add = false; PssgSchema.SetAttributeDataTypeIfNull(entries[node.Name].Attributes[i], attrEntry.DataType); break; } } if (add) { entries[node.Name].Attributes.Add(attrEntry); } } return(entries[node.Name]); } }
public static Attribute AddAttribute(string nodeName, string attributeName, Type attrType) { Node node = PssgSchema.AddNode(nodeName); if (attrType != null) { bool add = true; for (int i = 0; i < node.Attributes.Count; i++) { if (node.Attributes[i].Name == attributeName) { add = false; // Allow overwrite if current data type is null PssgSchema.SetAttributeDataTypeIfNull(node.Attributes[i], attrType); return(node.Attributes[i]); } } if (add) { PssgSchema.Attribute attr = new Attribute(attributeName, attrType); node.Attributes.Add(attr); return(attr); } } return(null); }
public PssgAttribute(XAttribute xAttr, PssgFile file, PssgNode node) { this.file = file; this.ParentNode = node; //this.id = PssgSchema.GetAttributeId(ParentNode.Name, xAttr.Name.LocalName); string attrName = xAttr.Name.LocalName.StartsWith("___") ? xAttr.Name.LocalName.Substring(3) : xAttr.Name.LocalName; this.AttributeInfo = PssgSchema.AddAttribute(this.ParentNode.Name, attrName);// PssgSchema.GetAttribute(this.ParentNode.Name, xAttr.Name.LocalName); this.data = this.FromString(xAttr.Value); PssgSchema.SetAttributeDataTypeIfNull(this.AttributeInfo, this.ValueType); }
public static void AddAttribute(string nodeName, Attribute attribute) { Node node = PssgSchema.AddNode(nodeName); bool add = true; for (int i = 0; i < node.Attributes.Count; i++) { if (node.Attributes[i].Name == attribute.Name) { add = false; // Allow overwrite if current data type is null PssgSchema.SetAttributeDataTypeIfNull(node.Attributes[i], attribute.DataType); break; } } if (add) { node.Attributes.Add(attribute); } }