Пример #1
0
        public override IEnumerable <IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
        {
            IExpressionStatement parentExpression = GetParentExpressionStatemenmt(registrationRootElement);

            if (parentExpression == null)
            {
                yield break;
            }

            IStructuralMatchResult match = Match(registrationRootElement);

            if (match.Matched)
            {
                var arguments = match.GetMatchedElementList("assemblies").Cast <ICSharpArgument>();

                IEnumerable <IModule> modules = arguments.SelectNotNull(argument => ModuleExtractor.GetTargetModule(argument.Value));

                IEnumerable <FilteredRegistrationBase> basedOnRegistrations = basedOnPatterns.SelectMany(
                    basedOnPattern => basedOnPattern.GetBasedOnRegistrations(parentExpression.Expression)).ToList();

                foreach (IModule module in modules)
                {
                    // todo blech, fix this
                    yield return(new CompositeRegistration(registrationRootElement, basedOnRegistrations.Union(
                                                               new ComponentRegistrationBase[]
                    {
                        new DefaultScanAssemblyRegistration(registrationRootElement),
                        new ModuleBasedOnRegistration(registrationRootElement, module)
                    })));
                }
            }
        }
Пример #2
0
 protected override IModule GetTargetModule(IStructuralMatchResult match)
 {
     return(ModuleExtractor.GetTargetModule(match.GetMatchedType("type")));
 }
Пример #3
0
        protected override IModule GetTargetModule(IStructuralMatchResult match)
        {
            var argument = (ICSharpArgument)match.GetMatchedElement("assemblyName");

            return(ModuleExtractor.GetTargetModule(argument.Value));
        }
Пример #4
0
 public RegisterAssemblyTypes([ImportMany] IEnumerable <IBasedOnPattern> basedOnPatterns)
     : base(pattern)
 {
     this.basedOnPatterns = basedOnPatterns;
     ModuleExtractor.AddExtractor(new CallingAssemblyExtractor("Autofac.Module", "ThisAssembly"));
 }
 public AutofacContainerInfo()
 {
     ModuleExtractor.AddExtractor(new CallingAssemblyExtractor("Autofac.Module", "ThisAssembly"));
 }
Пример #6
0
 public RegisterAssemblyTypes([ImportMany] params IBasedOnPattern[] basedOnPatterns)
     : base(pattern, basedOnPatterns)
 {
     ModuleExtractor.AddExtractor(new AutofacModuleThisAssemblyExtractor());
 }