FormatMultivaluedList now accepts all null values.

DateTimeAdd now accepts null value for timespan parameter.
ConvertStringToGuid returns Empty Guid if the input is a null/empty string.
ConvertFromBase64 returns null if the input is a null/empty string.
ConvertToBase64 returns null if the input is a null/empty string.
ConvertToNumber returns 0 if the input is a null/empty string.
SplitString returns null if the input is a null/empty string.
RemoveDuplicates returns null if the input is a null list.
This commit is contained in:
NileshGhodekar 2018-11-10 18:38:56 +00:00
Родитель 96eea308cd
Коммит 9bb6e90222
1 изменённых файлов: 94 добавлений и 104 удалений

Просмотреть файл

@ -726,13 +726,13 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
object parameter = this.parameters[0];
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionDivideInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionDivideInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[1];
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionDivideInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionDivideInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
long result;
@ -1738,13 +1738,13 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
object parameter = this.parameters[0];
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionAddInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionAddInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[1];
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionAddInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionAddInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
long result;
@ -1788,13 +1788,13 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
object parameter = this.parameters[0];
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionSubtractInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionSubtractInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[1];
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionSubtractInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionSubtractInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
long result;
@ -1914,6 +1914,8 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionFormatMultivaluedListNullFunctionParameterError, new InvalidFunctionFormatException(Messages.ExpressionFunction_NullFunctionParameterError, this.function, 1));
}
// Change to accept nulls
/*
// At least one argument to format string function should not be null
bool allArgsNull = true;
for (int i = 1; i < this.parameters.Count; ++i)
@ -1930,6 +1932,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionFormatMultivaluedListNullFunctionParameterError, new InvalidFunctionFormatException(Messages.ExpressionFunction_NullFunctionParameterError2, this.function, 2));
}
*/
object result = null;
@ -1938,12 +1941,16 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
var maxListItemCount = 0;
for (int i = 1; i < this.parameters.Count; ++i)
{
Type paramType = this.parameters[i].GetType();
if (paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof(List<>))
parameter = this.parameters[i];
if (parameter != null)
{
var listItemCount = ((IEnumerable)this.parameters[i]).Cast<object>().ToList().Count;
Type paramType = parameter.GetType();
if (paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof(List<>))
{
var listItemCount = ((IEnumerable)parameter).Cast<object>().ToList().Count;
maxListItemCount = listItemCount > maxListItemCount ? listItemCount : maxListItemCount;
maxListItemCount = listItemCount > maxListItemCount ? listItemCount : maxListItemCount;
}
}
}
@ -1953,14 +1960,15 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
var args = new object[this.parameters.Count - 1];
for (int i = 1; i < this.parameters.Count; ++i)
{
Type paramType = this.parameters[i].GetType();
if (paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof(List<>))
parameter = this.parameters[i];
args[i - 1] = parameter;
if (parameter != null)
{
args[i - 1] = null;
}
else
{
args[i - 1] = this.parameters[i];
Type paramType = parameter.GetType();
if (paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof(List<>))
{
args[i - 1] = null;
}
}
}
@ -1976,16 +1984,17 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
{
for (int i = 1; i < this.parameters.Count; ++i)
{
Type paramType = this.parameters[i].GetType();
if (paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof(List<>))
parameter = this.parameters[i];
args[i - 1] = parameter;
if (parameter != null)
{
List<object> list = ((IEnumerable)this.parameters[i]).Cast<object>().ToList();
Type paramType = parameter.GetType();
if (paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof(List<>))
{
List<object> list = ((IEnumerable)parameter).Cast<object>().ToList();
args[i - 1] = list.Count > n ? list[n] : null;
}
else
{
args[i - 1] = this.parameters[i];
args[i - 1] = list.Count > n ? list[n] : null;
}
}
}
@ -2133,11 +2142,6 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionDateTimeAddInvalidFunctionParameterCountError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFunctionParameterCountError, this.function, 2, this.parameters.Count));
}
if (this.parameters[1] == null)
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionDateTimeAddNullFunctionParameterError, new InvalidFunctionFormatException(Messages.ExpressionFunction_NullFunctionParameterError, this.function, 2));
}
Type parameterType = typeof(DateTime);
object parameter = this.parameters[0];
if (!this.VerifyType(parameter, parameterType))
@ -2150,7 +2154,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
parameter = this.parameters[1];
if (!this.VerifyType(parameter, parameterType) && !this.VerifyType(parameter, parameterType2))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionDateTimeAddInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError3, this.function, parameterType.Name, parameterType2.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionDateTimeAddInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError3, this.function, parameterType.Name, parameterType2.Name, parameter == null ? "null" : parameter.GetType().Name));
}
object result;
@ -2163,22 +2167,26 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
}
else
{
if (parameter is TimeSpan)
parameter = this.parameters[1];
if (parameter == null)
{
result = ((DateTime)this.parameters[0]).Add((TimeSpan)this.parameters[1]);
result = (DateTime)this.parameters[0];
}
else if (parameter is TimeSpan)
{
result = ((DateTime)this.parameters[0]).Add((TimeSpan)parameter);
}
else
{
// do additional parameter validation check during execution as it may be a lookup expression than a design-time value.
parameterType = typeof(TimeSpan);
parameter = this.parameters[1];
TimeSpan parseTimeSpan;
if (!TimeSpan.TryParse(parameter as string, out parseTimeSpan))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionDateTimeAddInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError2, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name, parameter));
}
result = ((DateTime)this.parameters[0]).Add(TimeSpan.Parse(this.parameters[1].ToString()));
result = ((DateTime)this.parameters[0]).Add(TimeSpan.Parse(parameter.ToString()));
}
}
@ -2814,7 +2822,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionLeftInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionLeftInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
string result;
@ -2864,7 +2872,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionLeftPadInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionLeftPadInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[2];
@ -3053,7 +3061,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionMidInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionMidInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[2];
@ -3064,7 +3072,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionMidInvalidThirdFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidThirdFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionMidInvalidThirdFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidThirdFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
string result;
@ -3126,13 +3134,13 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
object parameter = this.parameters[0];
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionModInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionModInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[1];
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionModInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionModInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
long result;
@ -3183,13 +3191,13 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
object parameter = this.parameters[0];
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionMultiplyInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionMultiplyInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[1];
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionMultiplyInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionMultiplyInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
long result;
@ -3439,7 +3447,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRandomNumberInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRandomNumberInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[1];
@ -3450,7 +3458,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRandomNumberInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRandomNumberInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
int result;
@ -3654,7 +3662,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRightInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRightInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
string result;
@ -3715,7 +3723,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRightPadInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRightPadInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[2];
@ -3958,7 +3966,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionValueByIndexInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionValueByIndexInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
object result;
@ -4041,7 +4049,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionValueByKeyInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionValueByKeyInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
object result = null;
@ -4068,7 +4076,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
}
else
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionValueByKeyInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionValueByKeyInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
}
@ -4155,7 +4163,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionWordInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionWordInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[2];
@ -4167,7 +4175,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
parameterType = typeof(char);
if (parameter.ToString().ToCharArray().Length != 1)
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionWordInvalidThirdFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidThirdFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionWordInvalidThirdFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidThirdFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
string result;
@ -4262,7 +4270,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionBitAndInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionBitAndInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[1];
@ -4273,7 +4281,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionBitAndInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionBitAndInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
long result;
@ -4365,7 +4373,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionBitOrInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionBitOrInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
parameter = this.parameters[1];
@ -4376,7 +4384,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionBitOrInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionBitOrInvalidSecondFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidSecondFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
long result;
@ -4470,21 +4478,17 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
Type parameterType = typeof(string);
object parameter = this.parameters[0];
if (parameter == null)
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertStringToGuidNullFunctionParameterError, new InvalidFunctionFormatException(Messages.ExpressionFunction_NullFunctionParameterError, this.function, 1));
}
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertStringToGuidInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertStringToGuidInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
byte[] result;
if (this.mode != EvaluationMode.Parse)
{
result = (new Guid((string)parameter)).ToByteArray();
var input = parameter as string;
result = string.IsNullOrEmpty(input) ? Guid.Empty.ToByteArray() : (new Guid(input)).ToByteArray();
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionConvertStringToGuid, "ConvertStringToGuid('{0}') returned '{1}'.", this.parameters[0], result);
}
@ -4519,21 +4523,17 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
Type parameterType = typeof(string);
object parameter = this.parameters[0];
if (parameter == null)
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertFromBase64NullFunctionParameterError, new InvalidFunctionFormatException(Messages.ExpressionFunction_NullFunctionParameterError, this.function, 1));
}
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertFromBase64InvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertFromBase64InvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
byte[] result;
if (this.mode != EvaluationMode.Parse)
{
result = Convert.FromBase64String((string)parameter);
var input = parameter as string;
result = string.IsNullOrEmpty(input) ? null : Convert.FromBase64String(input);
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionConvertFromBase64, "ConvertFromBase64('{0}') returned '{1}'.", this.parameters[0], result);
}
@ -4571,7 +4571,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertNumberToListInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertNumberToListInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
List<int> result = null;
@ -4624,7 +4624,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertSidToStringInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertSidToStringInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
string result;
@ -4667,21 +4667,16 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
Type parameterType = typeof(byte[]);
object parameter = this.parameters[0];
if (parameter == null)
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertToBase64NullFunctionParameterError, new InvalidFunctionFormatException(Messages.ExpressionFunction_NullFunctionParameterError, this.function, 1));
}
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertToBase64InvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertToBase64InvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
string result;
if (this.mode != EvaluationMode.Parse)
{
result = Convert.ToBase64String((byte[])parameter);
result = parameter == null ? null : Convert.ToBase64String((byte[])parameter);
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionConvertToBase64, "ConvertToBase64('{0}') returned '{1}'.", this.parameters[0], result);
}
@ -4755,21 +4750,16 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
Type parameterType = typeof(string);
Type parameterType2 = typeof(bool);
object parameter = this.parameters[0];
if (parameter == null)
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertToNumberNullFunctionParameterError, new InvalidFunctionFormatException(Messages.ExpressionFunction_NullFunctionParameterError, this.function, 1));
}
if (!this.VerifyType(parameter, parameterType) && !this.VerifyType(parameter, parameterType2) && !this.VerifyType(parameter, typeof(long)))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertToNumberInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError2, this.function, parameterType.Name, parameterType2.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionConvertToNumberInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError2, this.function, parameterType.Name, parameterType2.Name, parameter == null ? "null" : parameter.GetType().Name));
}
long result;
if (this.mode != EvaluationMode.Parse)
{
result = Convert.ToInt64(parameter, CultureInfo.InvariantCulture);
result = parameter == null ? 0 : Convert.ToInt64(parameter, CultureInfo.InvariantCulture);
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionConvertToNumber, "ConvertToNumber('{0}') returned '{1}'.", this.parameters[0], result);
}
else
@ -4895,7 +4885,7 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionEscapeDNComponentInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionEscapeDNComponentInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
string result;
@ -4981,11 +4971,6 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
Type parameterType = typeof(string);
object parameter = this.parameters[0];
if (parameter == null)
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionSplitStringNullFunctionParameterError, new InvalidFunctionFormatException(Messages.ExpressionFunction_NullFunctionParameterError, this.function, 1));
}
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionSplitStringInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFunctionParameterTypeError, this.function, 1, parameterType.Name, parameter.GetType().Name));
@ -5022,9 +5007,9 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
List<string> result;
if (this.mode != EvaluationMode.Parse)
{
result = !string.IsNullOrEmpty(separator) ? input.Split(new string[] { separator }, count, StringSplitOptions.RemoveEmptyEntries).ToList() : input.Split(default(string[]), count, StringSplitOptions.RemoveEmptyEntries).ToList();
result = string.IsNullOrEmpty(input) ? null : !string.IsNullOrEmpty(separator) ? input.Split(new string[] { separator }, count, StringSplitOptions.RemoveEmptyEntries).ToList() : input.Split(default(string[]), count, StringSplitOptions.RemoveEmptyEntries).ToList();
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionSplitString, "SplitString('{0}', '{1}', '{2}') returned a list with '{3}' items.", input, separator, count, result.Count);
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionSplitString, "SplitString('{0}', '{1}', '{2}') returned a list with '{3}' items.", input, separator, count, result == null ? 0 : result.Count);
}
else
{
@ -5057,14 +5042,9 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
Type parameterType = typeof(List<string>);
object parameter = this.parameters[0];
if (parameter == null)
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRemoveDuplicatesNullFunctionParameterError, new InvalidFunctionFormatException(Messages.ExpressionFunction_NullFunctionParameterError, this.function, 1));
}
if (!this.VerifyType(parameter, parameterType))
{
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRemoveDuplicatesInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter.GetType().Name));
throw Logger.Instance.ReportError(EventIdentifier.ExpressionFunctionRemoveDuplicatesInvalidFirstFunctionParameterTypeError, new InvalidFunctionFormatException(Messages.ExpressionFunction_InvalidFirstFunctionParameterTypeError, this.function, parameterType.Name, parameter == null ? "null" : parameter.GetType().Name));
}
List<string> result;
@ -5072,14 +5052,24 @@ namespace MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Common
if (this.mode != EvaluationMode.Parse)
{
List<string> input = (List<string>)parameter;
result = new List<string>(input.Count);
foreach (string item in input.Where(item => !result.Contains(item, StringComparer.OrdinalIgnoreCase)))
if (input != null)
{
result.Add(item);
result = new List<string>(input.Count);
foreach (string item in input.Where(item => !result.Contains(item, StringComparer.OrdinalIgnoreCase)))
{
result.Add(item);
}
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionRemoveDuplicates, "RemoveDuplicates('{0}') returned a list with '{1}' items removed.", this.parameters[0], input.Count - result.Count);
}
else
{
result = null;
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionRemoveDuplicates, "RemoveDuplicates('{0}') returned null.", this.parameters[0]);
}
Logger.Instance.WriteVerbose(EventIdentifier.ExpressionFunctionRemoveDuplicates, "RemoveDuplicates('{0}') returned a list with '{1}' items removed.", this.parameters[0], input.Count - result.Count);
}
else
{