public static new DataElement PitParser(PitParser context, XmlNode node, DataElementContainer parent) { string name = node.getAttr("name", null); string refName = node.getAttr("ref", null); DataModel dataModel = null; if (refName != null) { var refObj = context.getReference(refName, parent) as DataModel; if (refObj == null) throw new PeachException("Error, DataModel {0}could not resolve ref '{1}'. XML:\n{2}".Fmt( name == null ? "" : "'" + name + "' ", refName, node.OuterXml)); if (string.IsNullOrEmpty(name)) name = refName; dataModel = refObj.Clone(name) as DataModel; dataModel.isReference = true; dataModel.referenceName = refName; } else { if (string.IsNullOrEmpty(name)) throw new PeachException("Error, DataModel missing required 'name' attribute."); dataModel = new DataModel(name); } context.handleCommonDataElementAttributes(node, dataModel); context.handleCommonDataElementChildren(node, dataModel); context.handleDataElementContainer(node, dataModel); return dataModel; }
public static DataElement PitParser(PitParser context, XmlNode node, DataElementContainer parent) { if (node.Name != "Block") { return(null); } Block block = null; if (node.hasAttr("ref")) { string name = node.getAttr("name", null); string refName = node.getAttrString("ref"); DataElement refObj = context.getReference(refName, parent); if (refObj == null) { throw new PeachException("Error, Block {0}could not resolve ref '{1}'. XML:\n{2}".Fmt( name == null ? "" : "'" + name + "' ", refName, node.OuterXml)); } if (!(refObj is Block)) { throw new PeachException("Error, Block {0}resolved ref '{1}' to unsupported element {2}. XML:\n{3}".Fmt( name == null ? "" : "'" + name + "' ", refName, refObj.debugName, node.OuterXml)); } if (string.IsNullOrEmpty(name)) { name = new Block().name; } block = refObj.Clone(name) as Block; block.parent = parent; block.isReference = true; block.referenceName = refName; } else { block = DataElement.Generate <Block>(node); block.parent = parent; } context.handleCommonDataElementAttributes(node, block); context.handleCommonDataElementChildren(node, block); context.handleDataElementContainer(node, block); return(block); }