public T GetActivityArguments <T>(JsonTypeConverter <T> converter) where T : class { try { var itineraryToken = _messageToken["itinerary"]; if (itineraryToken == null) { throw new ArgumentException("Itinerary not found in the routing slip"); } var activityToken = itineraryToken is JArray ? itineraryToken[0] : itineraryToken; if (activityToken == null) { throw new ArgumentException("Activity not found in the routing slip"); } var token = _variablesToken.Merge(activityToken["arguments"]); return(converter.Convert(token)); } catch (Exception ex) { throw new RoutingSlipArgumentException("The activity arguments could not be read", ex); } }
public static void AssertColumns(DataColumnCollection expectedColumns, DataColumnCollection actualColumns, bool useClrTypes = false) { for (int i = 0; i < expectedColumns.Count; i++) { DataColumn expectedColumn = expectedColumns[i]; DataColumn actualColumn = actualColumns[i]; Assert.Equal(expectedColumn.ColumnName, actualColumn.ColumnName); if (!useClrTypes && JsonTypeConverter.IsNumeric(expectedColumn.DataType)) { Assert.Equal(typeof(double), actualColumn.DataType); } else { Assert.Equal(expectedColumn.DataType, actualColumn.DataType); } } }
public static void AssertRows(DataTable expected, DataTable actual, bool useClrTypes = false) { for (int i = 0; i < expected.Rows.Count; i++) { DataRow expectedRow = expected.Rows[i]; DataRow actualRow = actual.Rows[i]; foreach (DataColumn expectedColumn in expected.Columns) { var expectedColumnValue = expectedRow[expectedColumn.ColumnName]; var actualColumnValue = actualRow[expectedColumn.ColumnName]; if (!useClrTypes && JsonTypeConverter.IsNumeric(expectedColumn.DataType) && expectedColumnValue != DBNull.Value && actualColumnValue != DBNull.Value) { Assert.Equal(Convert.ToDecimal(expectedColumnValue), Convert.ToDecimal(actualColumnValue)); } else { Assert.Equal(expectedColumnValue, actualColumnValue); } } } }
public void RegisterTypeConverter(Type objectType, JsonTypeConverter typeConverter) { typeConverters[objectType] = typeConverter; }
public JsonTypeConverterWrapper(JsonTypeConverter typeConverter, JsonConverter jsonConverter) { this.typeConverter = typeConverter; this.jsonConverter = jsonConverter; }