public static InitializerContext IocInitialize(this InitializerContext context, Action <IocInitializer> configure = null, ITypeFinder typeFinder = null) { var initializer = new IocInitializer(); initializer.Builder = new ContainerBuilder(); initializer.Builder.RegisterType <Configs>().As <ISettings>().SingleInstance(); initializer.Builder.RegisterType <Configs>().SingleInstance(); initializer.Builder.RegisterType <MemoryCacheManager>().As <ICacheProvider>().SingleInstance(); if (typeFinder == null) { typeFinder = new AppDomainTypeFinder(); } initializer.Builder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance(); initializer.Builder.RegisterType <EventPublisher>().As <IEventPublisher>().SingleInstance(); var drInstancees = typeFinder.CreateInstanceOnFoundType <IDependencyRegistrar>(); drInstancees = drInstancees.AsQueryable().OrderBy(t => t.Order).ToList(); foreach (var dependencyRegistrar in drInstancees) { dependencyRegistrar.Register(initializer.Builder, typeFinder); } if (configure != null) { configure.Invoke(initializer); } context.Initialzer.Add(initializer); return(context); }
public static InitializerContext EnableLog4Net(this InitializerContext context, Action <LogInitializer> configure = null) { var logInitialzer = new LogInitializer(); if (configure != null) { configure.Invoke(logInitialzer); } context.Initialzer.Add(logInitialzer); return(context); }
private Action <T>[] GetInstanceInitializersFor <T>(Type type, Registration registration) { if (this.instanceInitializers.Count == 0) { return(Helpers.Array <Action <T> > .Empty); } var context = new InitializerContext(registration); return(( from instanceInitializer in this.instanceInitializers where instanceInitializer.AppliesTo(type, context) select instanceInitializer.CreateAction <T>(context)) .ToArray()); }
public Action <T> CreateAction <T>(InitializerContext context) => instance => this.instanceInitializer(new InstanceInitializationData(context, instance !));
public bool AppliesTo(Type implementationType, InitializerContext context) => this.predicate(context);
public Action <T> CreateAction <T>(InitializerContext context) => Helpers.CreateAction <T>(this.instanceInitializer);
public bool AppliesTo(Type implementationType, InitializerContext context) => Types.GetTypeHierarchyFor(implementationType).Contains(this.serviceType);
public bool AppliesTo(Type implementationType, InitializerContext context) { var typeHierarchy = Types.GetTypeHierarchyFor(implementationType); return(typeHierarchy.Contains(this.serviceType)); }
private static bool ShouldApplyInitializer(InitializerContext context) => context.Registration is IDisposableRegistration;
public Action <T> CreateAction <T>(InitializerContext context) { return(instance => this.instanceInitializer(new InstanceInitializationData(context, instance))); }
public Action <T> CreateAction <T>(InitializerContext context) { return(Helpers.CreateAction <T>(this.instanceInitializer)); }
public static InitializerContext DisableLog4Net(this InitializerContext context) { LogProvider.SetLogType("EmptyLog"); return(context); }
private static bool Always(InitializerContext context) => true;
public static InitializerContext MouduleInitialize(this InitializerContext context) { var initializer = new ModuleInitializer(); context.Initialzer.Add(initializer); return context; }
public InitializerContext initializer() { InitializerContext _localctx = new InitializerContext(_ctx, State); EnterRule(_localctx, 172, RULE_initializer); int _la; try { int _alt; State = 993; switch (_input.La(1)) { case ENCODE: case PROTOCOL: case SELECTOR: case SUPER: case SELF: case SIZEOF: case LPAREN: case LBRACK: case AT: case BANG: case TILDE: case INC: case DEC: case SUB: case MUL: case BITAND: case CARET: case IDENTIFIER: case CHARACTER_LITERAL: case STRING_LITERAL: case HEX_LITERAL: case DECIMAL_LITERAL: case OCTAL_LITERAL: case FLOATING_POINT_LITERAL: EnterOuterAlt(_localctx, 1); { State = 978; assignment_expression(); } break; case LBRACE: EnterOuterAlt(_localctx, 2); { State = 979; Match(LBRACE); State = 980; initializer(); State = 985; _errHandler.Sync(this); _alt = Interpreter.AdaptivePredict(_input,107,_ctx); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber ) { if ( _alt==1 ) { { { State = 981; Match(COMMA); State = 982; initializer(); } } } State = 987; _errHandler.Sync(this); _alt = Interpreter.AdaptivePredict(_input,107,_ctx); } State = 989; _la = _input.La(1); if (_la==COMMA) { { State = 988; Match(COMMA); } } State = 991; Match(RBRACE); } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return _localctx; }