Пример #1
0
        private void BuildServiceInfos()
        {
            _serviceInfos.Clear();

            CloudFoundryApplicationOptions appOpts = new CloudFoundryApplicationOptions();
            var aopSection = _config.GetSection(CloudFoundryApplicationOptions.CONFIGURATION_PREFIX);

            aopSection.Bind(appOpts);

            ApplicationInstanceInfo appInfo = new ApplicationInstanceInfo(appOpts);
            var serviceSection = _config.GetSection(CloudFoundryServicesOptions.CONFIGURATION_PREFIX);
            CloudFoundryServicesOptions serviceOpts = new CloudFoundryServicesOptions();

            serviceSection.Bind(serviceOpts);

            foreach (KeyValuePair <string, Service[]> serviceopt in serviceOpts.Services)
            {
                foreach (Service s in serviceopt.Value)
                {
                    IServiceInfoFactory factory = FindFactory(s);
                    if (factory != null)
                    {
                        if (factory.Create(s) is ServiceInfo info)
                        {
                            info.ApplicationInfo = appInfo;
                            _serviceInfos.Add(info);
                        }
                    }
                }
            }
        }
        private void BuildServiceInfos()
        {
            _serviceInfos.Clear();

            CloudFoundryApplicationOptions appOpts = new CloudFoundryApplicationOptions();

            _config.Bind(appOpts);
            ApplicationInstanceInfo appInfo = new ApplicationInstanceInfo(appOpts);

            CloudFoundryServicesOptions serviceOpts = new CloudFoundryServicesOptions();

            _config.Bind(serviceOpts);

            foreach (Service s in serviceOpts.Services)
            {
                IServiceInfoFactory factory = FindFactory(s);
                if (factory != null)
                {
                    var info = factory.Create(s) as ServiceInfo;
                    if (info != null)
                    {
                        info.ApplicationInfo = appInfo;
                        _serviceInfos.Add(info);
                    }
                }
            }
        }
Пример #3
0
        private IServiceInfoFactory CreateServiceInfoFactory(IEnumerable <ConstructorInfo> declaredConstructors)
        {
            IServiceInfoFactory result = null;

            foreach (ConstructorInfo ci in declaredConstructors)
            {
                if (ci.GetParameters().Length == 0 && ci.IsPublic && !ci.IsStatic)
                {
                    result = ci.Invoke(null) as IServiceInfoFactory;
                    break;
                }
            }

            return(result);
        }
Пример #4
0
        internal void BuildServiceInfoFactories()
        {
            _factories.Clear();

            var assembly = GetType().GetTypeInfo().Assembly;
            var types    = assembly.DefinedTypes;

            foreach (var type in types)
            {
                if (type.IsDefined(typeof(ServiceInfoFactoryAttribute)))
                {
                    IServiceInfoFactory instance = CreateServiceInfoFactory(type.DeclaredConstructors);
                    if (instance != null)
                    {
                        _factories.Add(instance);
                    }
                }
            }
        }