private IMessageHandler CreateMessageHandler(IBrokeredMessage message) { var messageType = message.Properties[MessageProperties.MessageType].ToString(); var messageHandlerType = _messageHandlerRegistry.GetMessageTypeHandler(messageType); return((IMessageHandler)_typeCreator.Create(messageHandlerType)); }
public GenericType(Type type, ICFType[] genericArgs) : this(ITypeCreator.Create(type), genericArgs) { }
public TypeFieldInfo(Type type, string name, string dmName) : this(ITypeCreator.Create(type), name, dmName) { }
public TypeInfo(string name, string dcNamespace, string dcName, TypeFieldInfo[] fieldInfos) : this(ITypeCreator.Create(typeof(object)), name, dcNamespace, dcName, fieldInfos) { }
public ListType(Type type) : this(ITypeCreator.Create(type)) { }
public ListType(string type) : this(ITypeCreator.Create(type)) { }
private object CreateInstance( ITypeCreator typeCreator, Type type, string referenceName, LinkedList<object> buildChain, object[] args) { object item; if (args?.Length > 0) { // We have arguments so will just let the type creator do the work here item = typeCreator.Create(type, referenceName, buildChain, args); } else if (typeCreator.AutoDetectConstructor) { // Use constructor detection to figure out how to create this instance var constructor = Configuration.ConstructorResolver.Resolve(type, args); var parameterInfos = constructor.GetParameters(); if (parameterInfos.Length == 0) { item = typeCreator.Create(type, referenceName, buildChain); } else { // Get values for each of the constructor parameters var parameters = new Collection<object>(); foreach (var parameterInfo in parameterInfos) { var context = buildChain.Last?.Value; Log.CreateParameter(type, parameterInfo.ParameterType, parameterInfo.Name, context); // Recurse to build this parameter value var parameterValue = Build(parameterInfo.ParameterType, parameterInfo.Name, null); parameters.Add(parameterValue); } item = typeCreator.Create(type, referenceName, buildChain, parameters.ToArray()); } } else { // The type creator is going to be solely responsible for creating this instance item = typeCreator.Create(type, referenceName, buildChain); } return item; }