/// <summary> /// Reads a new attribute definition by file name. /// </summary> /// <param name="fileName">The file name</param> /// <returns>An attribute definition</returns> public static AttributeDefinition ByFileName(string fileName) { return(new AttributeDefinition { FileName = fileName, DefinitionCollection = AttributeDefinitionCollection.ReadFrom(fileName) }); }
public void TestAttributeDefinitionCollectionLocal_de() { Assert.IsTrue(File.Exists("AttributeDefinitionCollectionLocal_de.xml")); var def1 = AttributeDefinitionCollection.ReadFrom("AttributeDefinitionCollectionLocal_de.xml"); Assert.IsNotNull(def1); def1.SaveTo("Cloned_AttributeDefinitionCollectionLocal_de.xml"); Assert.IsTrue(File.Exists("Cloned_AttributeDefinitionCollectionLocal_de.xml")); var def2 = AttributeDefinitionCollection.ReadFrom("Cloned_AttributeDefinitionCollectionLocal_de.xml"); for (int i = 0; i < def1.AttributeDefinition.Count; i++) { Assert.AreEqual(def1.AttributeDefinition[i], def2.AttributeDefinition[i], $"Definition #{i} is equal"); } }
/// <summary> /// Finishes construction of the object by populating properties of the object from /// the XML node /// </summary> /// <param name="theNode"></param> /// <param name="theManager"></param> public override void FinishConstruction(XElement theNode, DictionaryManager theManager) { try { if (theNode.Element("ByteSize") != null) { SetByteSize(theNode.Element("ByteSize").Value); } IsTlvStructure = false; // Parse each of the attribute nodes in turn - this may well get recursive m_AttributeDefinitions = new AttributeDefinitionCollection(Name); foreach (var attributeNode in theNode.Elements("Attribute")) { AttributeDefinition theAttribute = new AttributeDefinition(attributeNode, theManager, this); m_AttributeDefinitions.Add(theAttribute); if (theAttribute.HasDiscriminator && theAttribute.HasLengthIndicator) { IsTlvStructure = true; m_TlvControlAttribute = theAttribute; } } // Check the name. If it's null then make one up if (theNode.Element("Name") == null) { Name = String.Format("XXStruct_{0}", Ref); } } catch (DataDictionaryException ex) { throw new DataDictionaryException("Error constructing definition for Struct. XML:\n{0}\nException: {1}", theNode, ex.Message); } catch (XmlException ex) { throw new DataDictionaryException("Error constructing definition for Struct. XML:\n{0}\nException: {1}", theNode, ex.Message); } }
public void GetCollectionBlockAndAttribute() { if (BlockTableRecordCollection == null) { BlockTableRecordCollection = new string[] { "a", "b", "c" }; AttributeDefinitionCollection = new string[3, 5]; AttributeDefinitionCollection[1, 0] = "2"; AttributeDefinitionCollection[1, 1] = "3"; AttributeDefinitionCollection[2, 0] = "7"; AttributeDefinitionCollection[2, 1] = "8"; AttributeDefinitionCollection[2, 2] = "9"; } cbbBlkTblRec.Items.Clear(); cbbAttDef.Items.Clear(); foreach (string BlockTableRecord in BlockTableRecordCollection) { cbbBlkTblRec.Items.Add(BlockTableRecord); } cbbBlkTblRec.SelectedIndex = BlockTableRecordSet; for (int i = 0; i < AttributeDefinitionCollection.GetLength(1); i++) { if (!string.IsNullOrEmpty(AttributeDefinitionCollection[BlockTableRecordSet, i])) { cbbAttDef.Items.Add(AttributeDefinitionCollection[BlockTableRecordSet, i]); } } if (cbbAttDef.Items.Count != 0) { cbbAttDef.SelectedIndex = 0; } else { cbbAttDef.Text = null; } }