Beispiel #1
0
 /// <summary>
 /// Finds all dependency runtime types (instantiable types) which matches the criteria
 /// </summary>
 /// <param name="runtimeTypes">Types</param>
 /// <param name="typeParser">Parset</param>
 /// <param name="typeId">Id</param>
 /// <param name="args">Values</param>
 /// <returns></returns>
 public static IRuntimeType[] GetRuntimeTypes(this IEnumerable <IRuntimeType> runtimeTypes, ITypeParser typeParser, string typeId, string[] args) =>
 typeParser.FindRuntimeTypes(typeId, Format.GetNames(args), runtimeTypes.Where((p) => p.Attribute is IDependencyAttribute)).ToArray();
Beispiel #2
0
        /// <summary>
        /// Creates the instance.
        /// </summary>
        /// <param name="type">The identifier.</param>
        /// <param name="args">The arguments.</param>
        /// <returns></returns>
        /// <exception cref="TypeInstantiationException"></exception>
        IRuntimeType GetRuntimeType(Type type, object[] args)
        {
            var runtimeTypes = Types.Values.Where((p) => p.ActivatorType == type && p.Count == args.Length && p.RuntimeTypes.IsAssignableFrom(Format.GetTypes(args))).ToArray();
            var runtimeType  = runtimeTypes.Length == 1 ? runtimeTypes[0] : Parser.FindRuntimeTypes(type.ToString(), Format.GetNames(args), Types.Values).FirstOrDefault();

            if (runtimeType == null)
            {
                throw new TypeRegistrationException(string.Format("{0} is not registered (parameter type mismatch)", type));
            }
            return(runtimeType);
        }
Beispiel #3
0
 /// <summary>
 /// Finds all dependency runtime types (instantiable types) which matches the criteria
 /// </summary>
 /// <param name="runtimeTypes">Types</param>
 /// <param name="typeParser">Parset</param>
 /// <param name="runtimeType">Id</param>
 /// <param name="args">Values</param>
 /// <returns></returns>
 public static IRuntimeType[] FindRuntimeTypes(this IEnumerable <IRuntimeType> runtimeTypes, ITypeParser typeParser, IRuntimeType runtimeType, object[] args) =>
 typeParser.FindRuntimeTypes(runtimeType.TypeFullName, Format.GetNames(args), runtimeTypes.Where((p) => p.Attribute is IDependencyAttribute)).Where((p) => p.ActivatorType == runtimeType.ActivatorType).ToArray();