/// <summary> /// Gets whether or not the structure objects are of the same type /// </summary> /// <param name="other">The structure object definition to compare to</param> /// <returns>True if the objects are of the same type. False otherwise</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 04/22/13 RCG 2.80.22 N/A Created public bool Equals(StructureObjectDefinition other) { bool IsEqual = true; // We already know it's a structure type but we need to make sure that all // of the objects in the structure definition are the same if (StructureDefinition.Count == other.StructureDefinition.Count) { for (int iIndex = 0; iIndex < StructureDefinition.Count; iIndex++) { if (StructureDefinition[iIndex].Equals(other.StructureDefinition[iIndex]) == false) { // The structures don't match IsEqual = false; break; } } } else { IsEqual = false; } return(IsEqual); }
/// <summary> /// Gets whether or not the objects are of the same type /// </summary> /// <param name="other">The object definition to compare to</param> /// <returns>True if the objects are of the same type. False otherwise</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 04/22/13 RCG 2.80.22 N/A Created public override bool Equals(ObjectDefinition other) { bool IsEqual = false; StructureObjectDefinition StructureObject = other as StructureObjectDefinition; // Check to see if other is a structure object if (StructureObject != null) { // It is so lets call the more specific Equals operator IsEqual = Equals(StructureObject); } return(IsEqual); }
/// <summary> /// Creates an object definition from a COSEM Data object /// </summary> /// <param name="itemName">The name of the item</param> /// <param name="data">The COSEM Data object to create the definition from</param> /// <returns>The created object definition</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 05/07/13 RCG 2.80.27 N/A Created public static ObjectDefinition CreateFromCOSEMData(string itemName, COSEMData data) { ObjectDefinition Definition = null; if (data != null) { switch (data.DataType) { case COSEMDataTypes.Array: { COSEMData[] ArrayData = data.Value as COSEMData[]; ArrayObjectDefinition ArrayDefinition = null; if (ArrayData != null && ArrayData.Count() > 0) { ArrayDefinition = new ArrayObjectDefinition(itemName, CreateFromCOSEMData("Element Type", ArrayData[0])); for (int iIndex = 0; iIndex < ArrayData.Count(); iIndex++) { ArrayDefinition.Elements.Add(CreateFromCOSEMData("[" + iIndex.ToString() + "]", ArrayData[iIndex])); } } else if (ArrayData != null) { // The current count is 0 so we don't actually know the data type ArrayDefinition = new ArrayObjectDefinition(itemName, null); } Definition = ArrayDefinition; break; } case COSEMDataTypes.Structure: { COSEMData[] StructureData = data.Value as COSEMData[]; StructureObjectDefinition StructureDefinition = new StructureObjectDefinition(itemName); if (StructureData != null) { for (int iIndex = 0; iIndex < StructureData.Count(); iIndex++) { StructureDefinition.StructureDefinition.Add(CreateFromCOSEMData("Element " + iIndex.ToString(), StructureData[iIndex])); } } Definition = StructureDefinition; break; } case COSEMDataTypes.Enum: { // We won't really know if there is an actual enumeration associated so we should treat this as a byte value EnumObjectDefinition EnumDefinition = new EnumObjectDefinition(itemName, typeof(byte)); EnumDefinition.Value = data.Value; Definition = EnumDefinition; break; } default: { Definition = new ObjectDefinition(itemName, data.DataType); Definition.Value = data.Value; break; } } } return(Definition); }