Пример #1
0
        private void LoadAlertSinks(TinyIoC.TinyIoCContainer container)
        {
            var alertSinkInstances =
                from t in GetType().Assembly.GetTypes()
                where t.GetInterfaces().Any(x => x.Name == typeof(IAlertSink).Name)
                select(IAlertSink) container.Resolve(t);

            foreach (var alertSink in alertSinkInstances)
            {
                logger.Log(string.Format("Loaded IAlertSink {0}", alertSink.GetType()));
                alertSinks.Add(alertSink);
            }
        }
        public static IConfigurationValueResolver GetResolverFor(this TinyIoC.TinyIoCContainer ioc,
                                                                 IConfigurationValue value)
        {
            var resolverType = typeof(IConfigurationValueResolver <>).MakeGenericType(value.GetType());

            try
            {
                var resolver = ioc.Resolve(resolverType);
                return((IConfigurationValueResolver)resolver);
            }
            catch (TinyIoCResolutionException e)
            {
                Console.WriteLine(e);
                return(null);

                throw;
            }
        }
Пример #3
0
        protected override void RequestStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
        {
            base.RequestStartup(container, pipelines, context);

            // At request startup we modify the request pipelines to
            // include forms authentication - passing in our now request
            // scoped user name mapper.
            //
            // The pipelines passed in here are specific to this request,
            // so we can add/remove/update items in them as we please.
            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration()
            {
                RedirectUrl = "~/account/logon",
                UserMapper  = container.Resolve <IUserMapper>(),
            };

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
        }
Пример #4
0
 public static T Resolve <T>() where T : class
 {
     return(_container.Resolve <T>());
 }