private IKeyInfoHelper GetKeyInfoHelper(Type keyType)
        {
            IKeyInfoService service = null;

            if (this.Database != null)
            {
                service = this
                          .Database
                          .DatabaseEngine
                          .ServiceProvider
                          .GetService <IKeyInfoService>();
            }

            if (service == null)
            {
                // Should we really fall back?
                // Tests would fail without this, add injection?
                service = DefaultServiceConfigurations.CreateDefaultKeyInfoService();
            }

            IKeyInfoHelper result;

            service.TryCreateKeyInfoHelper(keyType, out result);

            return(result);
        }
Example #2
0
        public KeyInfoService(IKeyInfoService keyInfoService)
        {
            _keyInfoService = keyInfoService;
            Post["/api/keyinfo/add", runAsync : true] = async(_, ct) => await Add();

            Post["/api/keyinfo/delete", runAsync : true] = async(_, ct) => await DeleteKey();

            Get["/api/keyinfo", runAsync : true] = async(_, ct) => await GetAll();
        }
Example #3
0
        private IKeyInfoService Combine(
            IKeyInfoService existing,
            IKeyInfoService addition)
        {
            if (!(existing is CombinedKeyInfoService combined))
            {
                combined = CombinedKeyInfoService.Empty.Add(existing);
            }

            return(combined.Add(addition));
        }
        private CombinedKeyInfoService(
            CombinedKeyInfoService existing,
            IKeyInfoService addition)
        {
            int length = existing.factories.Length;

            this.factories = new IKeyInfoService[length + 1];

            Array.Copy(existing.factories, this.factories, length);
            this.factories[length] = addition;
        }
        public ModularKeyInfoFactory(IDatabase database)
        {
            this.service = database
                           .DatabaseEngine
                           .ServiceProvider
                           .GetService <IKeyInfoService>();

            if (this.service == null)
            {
                // Fallback
                this.service = DefaultServiceConfigurations.CreateDefaultKeyInfoService();
            }
        }
Example #6
0
        private IKeyInfoService Combine(
            IKeyInfoService existing,
            IKeyInfoService addition)
        {
            var combined = existing as CombinedKeyInfoService;

            if (combined == null)
            {
                combined = CombinedKeyInfoService.Empty.Add(existing);
            }

            return(combined.Add(addition));
        }
 protected ModularKeyInfoFactory(IKeyInfoService service)
 {
     this.service = service;
 }
 public CombinedKeyInfoService Add(IKeyInfoService factory)
 {
     return(new CombinedKeyInfoService(this, factory));
 }