internal static ValueObjectWrapper GetValueObjects(object instance, SqlParserConfig config) { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } var type = instance.GetType(); var valueObjects = new Dictionary <string, ValueObject>(); var propertyValues = new Dictionary <string, ValueWrapper>(); var properties = GetPropertyInfoCaches(type); foreach (var propertyInfo in properties) { var vo = new ValueObject(propertyInfo, config, propertyInfo.Name, propertyInfo.GetValue(instance), propertyInfo.PropertyType); vo.Initialize(); valueObjects.Add(propertyInfo.Name, vo); var wrapper = new ValueWrapper { Name = propertyInfo.Name, Value = vo.Value, Type = propertyInfo.PropertyType }; propertyValues.Add(propertyInfo.Name, wrapper); } var result = new ValueObjectWrapper(propertyValues, valueObjects); return(result); }
// for unit test internal static ValueObjectWrapper GetValueObjects(List <ParameterEmulator> emulators, SqlParserConfig config) { if (emulators == null) { throw new ArgumentNullException(nameof(emulators)); } var valueObjects = new Dictionary <string, ValueObject>(); var propertyValues = new Dictionary <string, ValueWrapper>(); foreach (var emulator in emulators) { var vo = new ValueObject(config, emulator.Name, emulator.ParameterValue, emulator.ParameterType); vo.Initialize(); valueObjects.Add(emulator.Name, vo); var wrapper = new ValueWrapper { Name = emulator.Name, Value = vo.Value, Type = emulator.ParameterType }; propertyValues.Add(wrapper.Name, wrapper); } var result = new ValueObjectWrapper(propertyValues, valueObjects); return(result); }