public static Exception TryResolve <T>(this IObjectResolver resolver, IObjectCollectionObserver <T> observer, out T[] instances)
 {
     try
     {
         instances = ResolveAll(resolver, observer);
         return(null);
     }
     catch (Exception ex)
     {
         instances = null;
         return(ex);
     }
 }
        public static T[] ResolveAll <T>(this IObjectResolver resolver, IObjectCollectionObserver <T> observer)
        {
            var builders = observer.ObjectBuilders;

            if (builders == null)
            {
                throw new ObsoleteObjectBuilderException(GetObsoleteObjectBuilderErrorMessage(observer.ContractType));
            }
            var result = new T[builders.Length];

            for (int i = 0; i < builders.Length; i++)
            {
                result[i] = resolver.Resolve(builders[i], null);
            }
            return(result);
        }
        public bool TryGet <T>(Type contract, out IObjectCollectionObserver <T> observer)
        {
            Requires.NotNull(contract, "contract");
            ObjectBuilderGroup        group;
            List <ObjectBuilder <T> > builders;

            if (!TryGetCore(contract, out group, out builders))
            {
                observer = null;
                return(false);
            }
            var obs = new ObjectCollectionObserverImpl <T>(group, contract, builders);

            group.AddObserver(obs);
            observer = obs;
            return(true);
        }
 public static bool TryGetObserver <T>(this IObjectResolver resolver, out IObjectCollectionObserver <T> observer)
 {
     return(resolver.Kernel.TryGet(typeof(T), out observer));
 }
 public static bool TryGetObserver(this IObjectResolver resolver, Type contractType, out IObjectCollectionObserver observer)
 {
     return(resolver.Kernel.TryGet(contractType, out observer));
 }
Example #6
0
 public bool TryGet <T>(Type contract, out IObjectCollectionObserver <T> observer)
 {
     return(_registry.TryGet(contract, out observer));
 }