Exemple #1
0
        /// <summary>
        /// Merge in variable type design
        /// </summary>
        /// <param name="mergedInstance"></param>
        /// <param name="variableType"></param>
        private static void MergeIn(this InstanceDesign mergedInstance, VariableTypeDesign variableType)
        {
            if (!(mergedInstance is VariableDesign mergedVariable))
            {
                throw new ArgumentException(nameof(mergedInstance));
            }
            mergedVariable.TypeDefinition     = variableType.SymbolicId;
            mergedVariable.TypeDefinitionNode = variableType;

            if (variableType.DecodedValue != null)
            {
                mergedVariable.DecodedValue = variableType.DecodedValue;
            }
            if (variableType.DataType != null &&
                variableType.DataType != Constants.BaseDataType)
            {
                mergedVariable.DataType     = variableType.DataType;
                mergedVariable.DataTypeNode = variableType.DataTypeNode;
            }
            if (variableType.ValueRankSpecified)
            {
                mergedVariable.ValueRank          = variableType.ValueRank;
                mergedVariable.ValueRankSpecified = true;
            }
            if (!string.IsNullOrEmpty(variableType.ArrayDimensions))
            {
                mergedVariable.ArrayDimensions = variableType.ArrayDimensions;
            }
            if (variableType.AccessLevelSpecified)
            {
                mergedVariable.AccessLevel          = variableType.AccessLevel;
                mergedVariable.AccessLevelSpecified = true;
            }
            if (variableType.MinimumSamplingIntervalSpecified)
            {
                mergedVariable.MinimumSamplingInterval          = variableType.MinimumSamplingInterval;
                mergedVariable.MinimumSamplingIntervalSpecified = true;
            }
            if (variableType.HistorizingSpecified)
            {
                mergedVariable.Historizing          = variableType.Historizing;
                mergedVariable.HistorizingSpecified = true;
            }
        }
 /// <summary>
 /// Merge in another veriable type design
 /// </summary>
 /// <param name="type"></param>
 /// <param name="merge"></param>
 private static void MergeIn(this TypeDesign type, VariableTypeDesign merge)
 {
     if (!(type is VariableTypeDesign varType))
     {
         throw new FormatException(nameof(merge));
     }
     if (merge.DecodedValue != null)
     {
         varType.DecodedValue = merge.DecodedValue;
     }
     if (merge.DataType != null &&
         merge.DataType != Constants.BaseDataType)
     {
         varType.DataType     = merge.DataType;
         varType.DataTypeNode = merge.DataTypeNode;
     }
     if (merge.ValueRankSpecified)
     {
         varType.ValueRank          = merge.ValueRank;
         varType.ValueRankSpecified = true;
     }
     if (!string.IsNullOrEmpty(merge.ArrayDimensions))
     {
         varType.ArrayDimensions = merge.ArrayDimensions;
     }
     if (merge.AccessLevelSpecified)
     {
         varType.AccessLevel          = merge.AccessLevel;
         varType.AccessLevelSpecified = true;
     }
     if (merge.MinimumSamplingIntervalSpecified)
     {
         varType.MinimumSamplingInterval          = merge.MinimumSamplingInterval;
         varType.MinimumSamplingIntervalSpecified = true;
     }
     if (merge.HistorizingSpecified)
     {
         varType.Historizing          = merge.Historizing;
         varType.HistorizingSpecified = true;
     }
 }