public ITypeProcessor GetCollectionProcessorFor(string collectionKind, string dataTypeName, string value) { //Console.WriteLine($"*** GetCollectionProcessorFor(<{collectionKind}>, <{dataTypeName}>, <{(value == null ? "NULL" : value)}>)"); if (string.IsNullOrEmpty(collectionKind)) { return(GetCollectionProcessorFor(dataTypeName, value)); } if (string.IsNullOrEmpty(dataTypeName)) { return(GetCollectionProcessorForValue(collectionKind, value)); } IValueProcessor elementProcessor = GetProcessorForDataType(dataTypeName) as IValueProcessor; if (elementProcessor == null) { ThrowMissingTypeName(dataTypeName); } ITypeProcessor processor = GetCollectionProcessorFor(collectionKind, elementProcessor); if (value != null) { processor.SetValue(value); } return(processor); }
private ITypeProcessor GetProcessorFor(object instance, PropertyInfo prop, FieldInfo field) { Type propFieldType = prop?.PropertyType ?? field?.FieldType; ITypeProcessor processor = _manager.GetProcessorFor(propFieldType); CheckProcessorExists(propFieldType, processor); object value = prop != null?prop.GetValue(instance) : field.GetValue(instance); processor.SetValue(value); return(processor); }
private void PropertySetImpl(string propName, string keyOrTypeName, string keyOrValue, bool isValue) { //Console.WriteLine($"***** PropertySet: propName: <{propName}>, keyOrTypeName: <{keyOrTypeName}>, keyOrValue: <{keyOrValue}>"); GetPropertyOrFieldData(propName, keyOrTypeName, out object instance, out PropertyInfo prop, out FieldInfo field); var setValue = prop != null ? (Action <object, object>)prop.SetValue : field.SetValue; if (!isValue) { setValue(instance, _scenario.GetEx <object>(keyOrValue)); return; } ITypeProcessor processor = _manager.GetProcessorFor(prop.PropertyType); CheckProcessorExists(prop.PropertyType, processor); processor.SetValue(keyOrValue); setValue(instance, processor.Value); }
private void PropertyTestImpl( string propNameOrValueKey, string keyOrTypeName, string keyOrValue, string stepText, bool isValue, string propName2 = null, string keyOrTypeName2 = null) { string compareText = GetCompareText(stepText); CompareOp compareOp = ToCompareOp(compareText); //Console.WriteLine($"***** PropertyTest: propName: <{propNameOrValueKey}>, keyOrTypeName: <{keyOrTypeName}>, keyOrValue: <{keyOrValue}>, compare: <{compareOp}>, propName2: <{propName2}>, keyOrTypeName2: <{keyOrTypeName2}>"); GetPropertyOrFieldData(propNameOrValueKey, keyOrTypeName, out object instance, out PropertyInfo prop, out FieldInfo field); GetPropertyOrFieldData(propName2, keyOrTypeName2, out object instance2, out PropertyInfo prop2, out FieldInfo field2); ITypeProcessor actual = GetProcessorFor(propNameOrValueKey, instance, prop, field); ITypeProcessor expected = null; if (!IsSingleCompareOp(compareOp)) { if (isValue) { expected = actual.Clone(); expected.SetValue(keyOrValue); } else { expected = GetProcessorFor(keyOrValue, instance2, prop2, field2); } } if (expected == null) { expected = new ObjectProcessor(_scenario); expected.PostCurrentValue(); } DoCompare(actual, expected, compareOp); }
public ITypeProcessor GetCollectionProcessorFor(string dataTypeName, string value) { if (string.IsNullOrEmpty(dataTypeName)) { return(GetCollectionProcessorForValue(null, value)); } IValueProcessor elementProcessor = GetProcessorForDataType(dataTypeName) as IValueProcessor; if (elementProcessor == null) { ThrowMissingTypeName(dataTypeName); } ITypeProcessor processor = GetCollectionProcessorFor(null, elementProcessor); if (value != null) { processor.SetValue(value); } return(processor); }