//Extensions for UAOOI internal static XML.Parameter ExportArgument(this Parameter argument, Action <TraceMessage> traceEvent) { bool _ValueRankSpecified = false; XML.ValueRank _ValueRank = argument.ValueRank.GetValueRank(x => _ValueRankSpecified = x, traceEvent); return(new XML.Parameter() { DataType = argument.DataType, Description = argument.Descriptions == null || argument.Descriptions.Count == 0 ? null : new XML.LocalizedText() { Key = argument.Descriptions[0].Locale, Value = argument.Descriptions[0].Text }, Identifier = 0, IdentifierSpecified = false, Name = argument.Name, ValueRank = _ValueRank, }); }
/// <summary> /// Gets the value rank. /// </summary> /// <param name="valueRank">The value rank.</param> /// <param name="specified">if set to <c>true</c> the parameter is specified.</param> /// <param name="traceEvent">An <see cref="Action"/> delegate is used to trace event as the <see cref="TraceMessage"/>.</param> /// <returns>Returns value of <see cref="XML.ValueRank" />.</returns> internal static XML.ValueRank GetValueRank(this int?valueRank, Action <bool> specified, Action <TraceMessage> traceEvent) { XML.ValueRank _vr = XML.ValueRank.Scalar; if (!valueRank.HasValue) { specified(false); return(_vr); } specified(true); if (valueRank < -2) { traceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.WrongValueRank, String.Format("The value {0} is not supported", valueRank))); } else if (valueRank == -3) { traceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.WrongValueRank, String.Format("The value {0} is not supported", valueRank))); } //_vr = ModelDesign.ValueRank.ScalarOrOneDimension; else if (valueRank == -2) { _vr = XML.ValueRank.ScalarOrArray; } else if (valueRank == -1) { _vr = XML.ValueRank.Scalar; specified(false); } else if (valueRank == 0) { _vr = XML.ValueRank.OneOrMoreDimensions; } else if (valueRank == 1) { _vr = XML.ValueRank.Array; } else { _vr = XML.ValueRank.OneOrMoreDimensions; } return(_vr); }