/// <summary> /// Gets whether or not the objects are of the same type /// </summary> /// <param name="other">The array 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; ArrayObjectDefinition Definition = other as ArrayObjectDefinition; if (Definition != null) { IsEqual = this.Equals(Definition); } 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); }
/// <summary> /// Gets whether or not the objects are of the same type /// </summary> /// <param name="other">The array 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(ArrayObjectDefinition other) { // We already know that it's an array so we just need to make sure the element definition matches return(ElementDefinition.Equals(other.ElementDefinition)); }