Beispiel #1
0
        /// <summary>
        /// Create an instance and injects its dependencies via a constructor.
        /// </summary>
        /// <typeparam name="T">The type of the instance.</typeparam>
        /// <returns>Created instance.</returns>
        public static T Create <[MeansImplicitUse] T>() where T : class
        {
            var type = typeof(T);

            if (type.IsAbstract)
            {
                throw new ArgumentException($"{type} is abstract and thus cannot be instantiated.");
            }
            return((T)PocoInjection.CreateInstance(type, TryResolveGlobally));
        }
Beispiel #2
0
 private object CreateInstance(Type type) => PocoInjection.CreateInstance(type, _resolutionFunction);