private static string typeNameJustDefined; //used to check reference to itself /// <summary> /// Internal validator to validate the BinX grammar and usage. It is used after opening and saving a BinX document. A error window /// is popped up with error and warning messages listed for reference. /// </summary> /// <param name="defset"></param> /// <param name="dataset"></param> public static void validate(DefinitionsNode defset, DatasetNode dataset) { ArrayList report = new ArrayList(); Hashtable defs = new Hashtable(); //check definition section foreach (DefineTypeNode dt in defset.getDefinitions()) { string sTypeName = dt.getTypeName(); //check duplicate type definitions if (defs.Contains(sTypeName)) { report.Add("Error: duplicate type name '" + sTypeName + "' at '" + dt.toNodeText() + "'."); } else { defs.Add(sTypeName, sTypeName); } //check defineType content typeNameJustDefined = sTypeName; checkComplexType(dt.getBaseType(), defs, report); } typeNameJustDefined = null; if (dataset != null) { //check dataset section if (dataset.getBinaryFileName() == null || dataset.getBinaryFileName().Length < 1) { report.Add("Warning: dataset has no binary file attached."); } if (dataset.getDataset().Count <= 0) { report.Add("Warning: dataset has no element."); } Hashtable varNames = new Hashtable(); foreach (AbstractNode an in dataset.getDataset()) { //check for duplicate varNames checkVarNames(an, varNames, report); checkUseType(an, defs, report); } } //show report if any if (report.Count > 0) { formErrors = new FormErrors(); formErrors.addMessages(report); formErrors.Show(); } }
private static string typeNameJustDefined; //used to check reference to itself #endregion Fields #region Methods /// <summary> /// Internal validator to validate the BinX grammar and usage. It is used after opening and saving a BinX document. A error window /// is popped up with error and warning messages listed for reference. /// </summary> /// <param name="defset"></param> /// <param name="dataset"></param> public static void validate(DefinitionsNode defset, DatasetNode dataset) { ArrayList report = new ArrayList(); Hashtable defs = new Hashtable(); //check definition section foreach (DefineTypeNode dt in defset.getDefinitions()) { string sTypeName = dt.getTypeName(); //check duplicate type definitions if (defs.Contains(sTypeName)) { report.Add("Error: duplicate type name '" + sTypeName + "' at '" + dt.toNodeText() + "'."); } else { defs.Add(sTypeName, sTypeName); } //check defineType content typeNameJustDefined = sTypeName; checkComplexType(dt.getBaseType(), defs, report); } typeNameJustDefined = null; if (dataset != null) { //check dataset section if (dataset.getBinaryFileName() == null || dataset.getBinaryFileName().Length < 1) { report.Add("Warning: dataset has no binary file attached."); } if (dataset.getDataset().Count <= 0) { report.Add("Warning: dataset has no element."); } Hashtable varNames = new Hashtable(); foreach (AbstractNode an in dataset.getDataset()) { //check for duplicate varNames checkVarNames(an, varNames, report); checkUseType(an, defs, report); } } //show report if any if (report.Count > 0) { formErrors = new FormErrors(); formErrors.addMessages(report); formErrors.Show(); } }