Ejemplo n.º 1
0
        private static T GetOrCreate <T>(
            string key,
            IDataLoaderRegistry registry,
            Action <IDataLoaderRegistry> register)
            where T : IDataLoader
        {
            if (registry == null)
            {
                throw new InvalidOperationException(TypeResources
                                                    .DataLoaderResolverContextExtensions_RegistryIsNull);
            }

            if (!registry.TryGet(key, out T dataLoader))
            {
                register(registry);

                if (!registry.TryGet(key, out dataLoader))
                {
                    throw new InvalidOperationException(TypeResources
                                                        .DataLoaderResolverContextExtensions_UnableToRegister);
                }
            }

            return(dataLoader);
        }
Ejemplo n.º 2
0
        private static T GetOrCreate <T>(
            string key,
            IDataLoaderRegistry registry,
            Action <IDataLoaderRegistry> register)
            where T : IDataLoader
        {
            if (registry == null)
            {
                // TODO : resources
                throw new InvalidOperationException(
                          "No DataLoader registry was registerd with your " +
                          "dependency injection.");
            }

            if (!registry.TryGet(key, out T dataLoader))
            {
                register(registry);

                if (!registry.TryGet(key, out dataLoader))
                {
                    // TODO : resources
                    throw new InvalidOperationException(
                              "Unable to register a DataLoader with your " +
                              "DataLoader registry.");
                }
            }

            return(dataLoader);
        }