<commit_before>﻿using System.Collections.Generic;
using Thinktecture.IdentityServer.Core.Models;
using Thinktecture.IdentityServer.Core.Services;
using Thinktecture.IdentityServer.Core.Services.InMemory;

namespace Thinktecture.IdentityServer.Core.Configuration
{
    public static class InMemoryFactory
    {
        public static IdentityServerServiceFactory Create(
            IEnumerable<InMemoryUser> users,
            IEnumerable<Client> clients,
            IEnumerable<Scope> scopes)
        {
            var userService = new InMemoryUserService(users);
            var scopeService = new InMemoryScopeService(scopes);
            var clientService = new InMemoryClientService(clients);

            var factory = new IdentityServerServiceFactory
            {
                UserService = Registration.RegisterFactory<IUserService>(() => userService),
                ScopeService = Registration.RegisterFactory<IScopeService>(() => scopeService),
                ClientService = Registration.RegisterFactory<IClientService>(() => clientService)
            };

            return factory;
        }
    }
}<commit_msg>Made services optional at inmem factory<commit_after>﻿using System.Collections.Generic;
using Thinktecture.IdentityServer.Core.Models;
using Thinktecture.IdentityServer.Core.Services;
using Thinktecture.IdentityServer.Core.Services.InMemory;

namespace Thinktecture.IdentityServer.Core.Configuration
{
    public static class InMemoryFactory
    {
        public static IdentityServerServiceFactory Create(
            IEnumerable<InMemoryUser> users = null,
            IEnumerable<Client> clients = null,
            IEnumerable<Scope> scopes = null)
        {
            var factory = new IdentityServerServiceFactory();
            
            if (users != null)
            {
                var userService = new InMemoryUserService(users);
                factory.UserService = Registration.RegisterFactory<IUserService>(() => userService);
            }

            if (clients != null)
            {
                var clientService = new InMemoryClientService(clients);
                factory.ClientService = Registration.RegisterFactory<IClientService>(() => clientService);
            }

            if (scopes != null)
            {
                var scopeService = new InMemoryScopeService(scopes);
                factory.ScopeService = Registration.RegisterFactory<IScopeService>(() => scopeService);
            }

            return factory;
        }
    }
}
{'fraction_non_alphanumeric': 0.07982525814138205, 'fraction_numerical': 0.0, 'mean_word_length': 2.4649243466299864, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6977214', 'n_tokens_mistral': 604, 'n_tokens_neox': 584, 'n_words': 119}