当前位置: 首页>>代码示例>>C#>>正文


C# IContext.GetInstance方法代码示例

本文整理汇总了C#中IContext.GetInstance方法的典型用法代码示例。如果您正苦于以下问题:C# IContext.GetInstance方法的具体用法?C# IContext.GetInstance怎么用?C# IContext.GetInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IContext的用法示例。


在下文中一共展示了IContext.GetInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildUserSession

 private static UserSession BuildUserSession(IContext context)
 {
     var request = context.GetInstance<HttpRequest>();
       if (!request.Cookies.AllKeys.Contains(UserSession.CookieName))
     return null;
       // ReSharper disable once PossibleNullReferenceException
       var userSessionId = Guid.Parse(request.Cookies[UserSession.CookieName].Value);
       var authenticationDao = context.GetInstance<AuthenticationDao>();
       return authenticationDao.LoadUserSession(userSessionId);
 }
开发者ID:adamrmoss,项目名称:MillionSteps,代码行数:10,代码来源:WebRegistry.cs

示例2: OpenSession

        static IDocumentSession OpenSession(IContext ctx)
        {
            var bus = ctx.GetInstance<IBus>();
            string environmentId = null;

            if (bus.CurrentMessageContext != null && bus.CurrentMessageContext.Headers.ContainsKey("EnvironmentId"))
                environmentId = bus.CurrentMessageContext.Headers["EnvironmentId"];

            var store = ctx.GetInstance<IDocumentStore>();

            return RavenSession.OpenSession(environmentId, store);
        }
开发者ID:northshoreab,项目名称:Hygia,代码行数:12,代码来源:RavenRegistry.cs

示例3: Process

        public object Process(object target, IContext context)
        {
            var clockedElement = (IClockedElement)target;
            context.GetInstance<IClock>().Subscribe(clockedElement);

            return target;
        }
开发者ID:caiokf,项目名称:senoc,代码行数:7,代码来源:ClockedElementInterceptor.cs

示例4: CreateBus

 private IServiceBus CreateBus(IContext context)
 {
     return ServiceBusFactory.New(sbc =>
                                      {
                                          sbc.UseRabbitMq();
                                          sbc.ReceiveFrom("rabbitmq://localhost/" + QueueName);
                                          sbc.UseRabbitMqRouting();
                                          sbc.Subscribe(c => c.LoadFrom(context.GetInstance<IContainer>()));
                                      });
 }
开发者ID:WalkingDisaster,项目名称:Messaging-POC,代码行数:10,代码来源:BusRegistry.cs

示例5: CreateFluentConfiguration

        private FluentConfiguration CreateFluentConfiguration(IContext context)
        {
            var databaseProvider = context.GetInstance<IDatabaseAdapter>();

            //// TODO: get list of mappings assembly
            return Fluently
                .Configure()
                .ExposeConfiguration(x => x.SetProperty("cache.use_second_level_cache", "true"))
                .ExposeConfiguration(x => x.SetProperty("cache.use_query_cache", "true"))
                .ExposeConfiguration(x => x.SetProperty("cache.provider_class", typeof(FeliceCacheProvider).AssemblyQualifiedName))
                .Database(databaseProvider.GetHibernateDriver(AppSettings.ConnectionString))
                .Mappings(ConfigureMappings);
        }
开发者ID:joaofx,项目名称:felice,代码行数:13,代码来源:NHibernateRegistry.cs

示例6: GetCurrentUser

        private string GetCurrentUser(IContext context)
        {
            try
            {
                var httpContext = context.GetInstance<HttpContextBase>();
                if (httpContext == null) return null;
                if (httpContext.User == null) return null;
                var user = httpContext.User;
                if (!user.Identity.IsAuthenticated) return null;

                return user.Identity.Name;
            }
            catch (Exception ex)
            {
                throw new Exception("Error trying to determine the current user.", ex);
            }
        }
开发者ID:var-renu,项目名称:justdoit,代码行数:17,代码来源:DefaultRegistry.cs

示例7: BuildCryptographer

        static ICryptographer BuildCryptographer(IContext context)
        {
            var processName = Process.GetCurrentProcess()
                                     .ProcessName.ToLower();
            if (processName.Contains("w3wp") || processName.Contains("aspnet_wp") || processName.Contains("iisexpress"))
                return new WebCryptographer();

            var cryptoConfig = context.GetInstance<ICryptoConfigurationProvider>();
            var encryptionAlgorithm = cryptoConfig.EncryptionAlgorithm;
            var hashAlgorithm = cryptoConfig.HashAlgorithm;
            var encryptionKey = cryptoConfig.EncryptionKey;
            var hmacKey = cryptoConfig.HmacKey;
            var generic = typeof (Cryptographer<,>);
            var specific = generic.MakeGenericType(new[] {encryptionAlgorithm, hashAlgorithm});
            var ci = specific.GetConstructor(new[] {typeof (byte[]), typeof (byte[])});
            var o = ci.Invoke(new object[] {encryptionKey, hmacKey});
            return o.As<ICryptographer>();
        }
开发者ID:alanstevens,项目名称:Contrive,代码行数:18,代码来源:AuthRegistry.cs

示例8: BuildRestClient

 private static RestClient BuildRestClient(IContext context)
 {
     var settings = context.GetInstance<Settings>();
       return new RestClient(settings.ApiUrl.OriginalString);
 }
开发者ID:adamrmoss,项目名称:MillionSteps,代码行数:5,代码来源:CoreRegistry.cs

示例9: Process

        public object Process(object target, IContext context)
        {
            context.GetInstance<IEventAggregator>().Subscribe(target);

            return target;
        }
开发者ID:alanstevens,项目名称:Contrive,代码行数:6,代码来源:SubscriptionInterceptor.cs

示例10: Process

 public object Process(object target, IContext context)
 {
     var eventPublisher = context.GetInstance<IEventPublisher>();
     eventPublisher.Subscribe(target);
     return target;
 }
开发者ID:himmelreich-it,项目名称:opencbs,代码行数:6,代码来源:EventAggregatorInterceptor.cs

示例11: Process

 public object Process(object target, IContext context)
 {
     context.GetInstance<IEventAggregator>().AddListener(target);
     return target;
 }
开发者ID:thedersen,项目名称:DDDCourse,代码行数:5,代码来源:EventAggregatorInterceptor.cs

示例12: Process

 public object Process(object target, IContext context)
 {
     context.GetInstance<IDistributor>().AddListener(target);
     return target;
 }
开发者ID:caiokf,项目名称:senoc,代码行数:5,代码来源:DistribuitionListenerInterceptor.cs

示例13: CreateSessionFactory

 private ISessionFactory CreateSessionFactory(IContext context)
 {
     return context.GetInstance<FluentConfiguration>().BuildSessionFactory();
 }
开发者ID:joaofx,项目名称:felice,代码行数:4,代码来源:NHibernateRegistry.cs

示例14: CreateSession

 private static ISession CreateSession(IContext x)
 {
     var session = x.GetInstance<ISessionFactory>().OpenSession();
     session.FlushMode = FlushMode.Commit;
     return session;
 }
开发者ID:joaofx,项目名称:felice,代码行数:6,代码来源:NHibernateRegistry.cs

示例15: CreateBus

 private static IBus CreateBus(IContext context)
 {
     return new MassTransitPublisher(context.GetInstance<IServiceBus>());
 }
开发者ID:CumpsD,项目名称:CC.Cumps,代码行数:4,代码来源:BusRegistry.cs


注:本文中的IContext.GetInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。