/// <summary> /// Initializes a new instance of the <see cref="ExecutableCommandRegistration{TValue}"/> class. /// </summary> /// <typeparam name="TValue">The type of value expected to be handled by the execution action.</typeparam> /// <param name="name">The name of the command to be registered.</param> /// <param name="executionAction">The action to be invoked when the command is triggered.</param> /// <param name="objectConverterFactory">A factory used to create requested object converters.</param> /// <exception cref="ArgumentException">Thrown when the given name is an invalid string.</exception> /// <exception cref="ArgumentNullException">Thrown when the given or execution action object converter factory is null.</exception> internal ExecutableCommandRegistration(string name, Action <TValue> executionAction, ObjectConverterFactory objectConverterFactory) { VerificationProvider.VerifyValidString(name, "name"); VerificationProvider.VerifyNotNull(executionAction, "executionAction"); VerificationProvider.VerifyNotNull(objectConverterFactory, "objectConverterFactory"); mName = name; mExecutionAction = executionAction; mObjectConverterFactory = objectConverterFactory; }
private void SetPropertyOnObject <T>(PropertyInfo typeProperty, T newItem) where T : new() { if (TableConstants.ReservedPropertyNames.Contains(typeProperty.Name)) { return; } IObjectToTypeConverter objectConverter = ObjectConverterFactory.GetConverterFor(typeProperty.PropertyType); typeProperty.SetValue(newItem, objectConverter.ConvertToValue(_properties[typeProperty.Name], typeProperty), null); }
private static Dictionary <string, EntityProperty> GetProperties(Dictionary <string, Tuple <object, Type> > properties) { var entityProperties = new Dictionary <string, EntityProperty>(); foreach (KeyValuePair <string, Tuple <object, Type> > property in properties) { Type propertyType = property.Value.Item2; IObjectToTypeConverter converter = ObjectConverterFactory.GetConverterFor(propertyType); entityProperties[property.Key] = converter.ConvertToEntityProperty(property.Value.Item1, propertyType); } return(entityProperties); }
/// <summary> /// Initializes a new instance of the <see cref="CommandResultSet"/> class. /// </summary> /// <param name="objectConverterFactory">A factory used to create requested object converters.</param> /// <param name="commands">A collection of commands to add to the set.</param> /// <exception cref="ArgumentNullException">Thrown when the given object converter factory or collection of commands is null.</exception> internal CommandResultSet(ObjectConverterFactory objectConverterFactory, IEnumerable <CommandResult> commands) { VerificationProvider.VerifyNotNull(objectConverterFactory, "objectConverterFactory"); VerificationProvider.VerifyNotNull(commands, "commands"); mObjectConverterFactory = objectConverterFactory; mCommands = commands; // Extract all commands that have a key value foreach (var command in commands) { mKeyedCommands[command.Key] = command; } }
/// <summary> /// Initializes a new instance of the <see cref="ExecutableCommandRegistrar"/> class. /// </summary> /// <param name="objectConverterFactory">A factory used to create requested object converters.</param> /// <exception cref="ArgumentNullException">Thrown when the given object converter factory is null.</exception> internal ExecutableCommandRegistrar(ObjectConverterFactory objectConverterFactory) { VerificationProvider.VerifyNotNull(objectConverterFactory, "objectConverterFactory"); mObjectConverterFactory = objectConverterFactory; }