コード例 #1
0
        private void UpdateInitialisedAdapters(IComponentRegistration registration)
        {
            var adapterServices = _serviceInfo
                                  .Where(si => si.Value.ShouldRecalculateAdaptersOn(registration))
                                  .Select(si => si.Key)
                                  .ToArray();

            if (adapterServices.Length == 0)
            {
                return;
            }

            Debug.WriteLine(
                string.Format(
                    CultureInfo.InvariantCulture,
                    "[Autofac] Component '{0}' provides services that have already been adapted. Consider refactoring to ContainerBuilder.Build() rather than Update().",
                    registration));

            var adaptationSandbox = new AdaptationSandbox(
                _dynamicRegistrationSources.Where(rs => rs.IsAdapterForIndividualComponents),
                registration,
                adapterServices);

            // Adapter registrations come from sources, so they are added with originatedFromSource: true
            var adapters = adaptationSandbox.GetAdapters();

            foreach (var adapter in adapters)
            {
                AddRegistration(adapter, true, true);
            }
        }
コード例 #2
0
 private void UpdateInitialisedAdapters(IComponentRegistration registration)
 {
     Service[] adapterServices = (from si in this._serviceInfo
                                  where si.Value.ShouldRecalculateAdaptersOn(registration)
                                  select si.Key).ToArray <Service>();
     if (adapterServices.Length != 0)
     {
         AdaptationSandbox sandbox = new AdaptationSandbox(from rs in this._dynamicRegistrationSources
                                                           where rs.IsAdapterForIndividualComponents
                                                           select rs, registration, adapterServices);
         foreach (IComponentRegistration registration2 in sandbox.GetAdapters())
         {
             this.AddRegistration(registration2, true);
         }
     }
 }
コード例 #3
0
        void UpdateInitialisedAdapters(IComponentRegistration registration)
        {
            var adapterServices = _serviceInfo
                .Where(si => si.Value.ShouldRecalculateAdaptersOn(registration))
                .Select(si => si.Key)
                .ToArray();

            if (adapterServices.Length == 0)
                return;

            Debug.WriteLine(string.Format(CultureInfo.InvariantCulture,
                "[Autofac] Component '{0}' provides services that have already been adapted. Consider refactoring to ContainerBuilder.Build() rather than Update().",
                registration));

            var adaptationSandbox = new AdaptationSandbox(
                _dynamicRegistrationSources.Where(rs => rs.IsAdapterForIndividualComponents),
                registration,
                adapterServices);

            var adapters = adaptationSandbox.GetAdapters();
            foreach (var adapter in adapters)
                AddRegistration(adapter, true);
        }