/// <summary> /// Check useType node for defined-type reference, or call checkComplexType for complex node. /// </summary> /// <remarks> /// This check should apply to the following scenarios: /// <list> /// Wherever a useType element is found (in struct, array, union, dataset), /// Empty typeName attribute is given for a useType element /// The typeName given by the useType element is not already defined before this reference in the definitions section /// </list> /// </remarks> /// <param name="aNode"></param> /// <param name="defs"></param> /// <param name="report"></param> private static void checkUseType(AbstractNode aNode, Hashtable defs, ArrayList report) { if (aNode.GetType().Equals(typeof(UseTypeNode))) { string sTypeName = aNode.getTypeName(); if (sTypeName == null || sTypeName.Length < 1) { report.Add("Error: invalid type name at '" + aNode.toNodeText() + "'."); } else if (sTypeName.Equals(typeNameJustDefined)) { report.Add("Error: recursively referencing the type for '" + aNode.toNodeText() + "'."); } else { if (!defs.Contains(sTypeName)) { report.Add("Error: type '" + sTypeName + "' used before defined at '" + aNode.toNodeText() + "'."); } } } else if (aNode.isComplex()) { checkComplexType((ComplexNode)aNode, defs, report); } }
/// <summary> /// Add cases to a union node in the treeview from loaded document. /// </summary> /// <remarks> /// The TypeNode for UnionCase object node has null reference for DataNode. /// TODO: union containing arrays not supported here /// </remarks> /// <param name="node"></param> /// <param name="t"></param> protected void addUnionNode(TreeNode node, UnionNode t) { foreach (CaseNode c in t.getCases()) { DataNode dt = new DataNode(c); node.Nodes.Add(dt); //node.LastNode.Text = c.toNodeText(); AbstractNode caseBody = c.getCaseBody(); TreeNode caseNode = node.LastNode; caseNode.Nodes.Add(new DataNode(caseBody)); if (caseBody.isComplex()) { if (caseBody.GetType().Equals(typeof(StructNode))) { addStructNode(caseNode.LastNode, (StructNode)caseBody); } else if (caseBody.GetType().Equals(typeof(UnionNode))) { addUnionNode(caseNode.LastNode, (UnionNode)caseBody); } else if (caseBody.GetType().Equals(typeof(ArrayNode))) { addArrayNode(caseNode.LastNode, (ArrayNode)caseBody); } } } }
public bool isComplex() { return((dataNode_ == null)?false:dataNode_.isComplex()); }
/// <summary> /// Check useType node for defined-type reference, or call checkComplexType for complex node. /// </summary> /// <remarks> /// This check should apply to the following scenarios: /// <list> /// Wherever a useType element is found (in struct, array, union, dataset), /// Empty typeName attribute is given for a useType element /// The typeName given by the useType element is not already defined before this reference in the definitions section /// </list> /// </remarks> /// <param name="aNode"></param> /// <param name="defs"></param> /// <param name="report"></param> private static void checkUseType(AbstractNode aNode, Hashtable defs, ArrayList report) { if (aNode.GetType().Equals(typeof(UseTypeNode))) { string sTypeName = aNode.getTypeName(); if (sTypeName==null || sTypeName.Length < 1) { report.Add("Error: invalid type name at '" + aNode.toNodeText() + "'."); } else if (sTypeName.Equals(typeNameJustDefined)) { report.Add("Error: recursively referencing the type for '" + aNode.toNodeText() + "'."); } else { if (!defs.Contains(sTypeName)) { report.Add("Error: type '" + sTypeName + "' used before defined at '" + aNode.toNodeText() + "'."); } } } else if (aNode.isComplex()) { checkComplexType((ComplexNode)aNode, defs, report); } }