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


C# IDependencyResolver.GetService方法代码示例

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


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

示例1: RootRoute

 public RootRoute(bool blogAggregationEnabled, IRouteHandler normalRouteHandler, IRouteHandler aggRouteHandler,
     IDependencyResolver serviceLocator)
 {
     BlogAggregationEnabled = blogAggregationEnabled;
     NormalRouteHandler = normalRouteHandler ??
                          new PageRouteHandler("~/aspx/Dtp.aspx", serviceLocator.GetService<ISubtextPageBuilder>(), serviceLocator);
     AggregateRouteHandler = aggRouteHandler ??
                             new PageRouteHandler("~/aspx/AggDefault.aspx", serviceLocator.GetService<ISubtextPageBuilder>(), serviceLocator);
 }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:9,代码来源:RootRoute.cs

示例2: Register

    public static void Register(IDependencyResolver container)
    {
// Setup global sitemap loader
        MvcSiteMapProvider.SiteMaps.Loader = container.GetService<ISiteMapLoader>();

// Check all configured .sitemap files to ensure they follow the XSD for MvcSiteMapProvider
        var validator = container.GetService<ISiteMapXmlValidator>();
        validator.ValidateXml(HostingEnvironment.MapPath("~/Store.sitemap"));

// Register the Sitemaps routes for search engines
        XmlSiteMapController.RegisterRoutes(RouteTable.Routes);
    }
开发者ID:Wdovin,项目名称:vc-community,代码行数:12,代码来源:MvcSiteMapProviderConfig.cs

示例3: IncludeDependencyResolver

 public static PocketContainer IncludeDependencyResolver(
     this PocketContainer container,
     IDependencyResolver dependencyResolver)
 {
     return container.AddStrategy(type =>
     {
         if (dependencyResolver.GetService(type) != null)
         {
             return c => dependencyResolver.GetService(type);
         }
         return null;
     });
 }
开发者ID:gitter-badger,项目名称:PocketContainer,代码行数:13,代码来源:PocketContainerDependencyResolverStrategy.cs

示例4: Configure

        public static void Configure(IDependencyResolver dependencyResolver)
        {
            var list = new List<IEventSubscriber>
            {
                (IEventSubscriber)dependencyResolver.GetService(typeof (WatchingSubscriber)),
                (IEventSubscriber)dependencyResolver.GetService(typeof (UserRegistrationSubscriber)),
                (IEventSubscriber)dependencyResolver.GetService(typeof (UserLoginSubscriber))
            };

            foreach (IEventSubscriber eventSubscriber in list)
            {
                eventSubscriber.SubscribeEvent().Wait();
            }
        }
开发者ID:GusLab,项目名称:video-portal,代码行数:14,代码来源:EventAggregatorConfig.cs

示例5: CreateFilter

 private static Filter CreateFilter(FilterAttributeMetadata filterMetadata,
     IDependencyResolver dependencyResolver)
 {
     var filter = dependencyResolver.GetService(filterMetadata.Attribute.FilterType);
     filterMetadata.Attribute.InitializeFilter(filter);
     return new Filter(filter, filterMetadata.Scope, GetFilterOrder(filter));
 }
开发者ID:skalinets,项目名称:aspmvc_vs_fubumvc,代码行数:7,代码来源:FilterAttributeProvider.cs

示例6: CreateRavenDbTarget

        private static Target CreateRavenDbTarget(IDependencyResolver dependencyResolver, LoggingConfiguration loggingConfiguration)
        {
            var documentStore = (IDocumentStore)dependencyResolver.GetService(typeof(IDocumentStore));
            var ravenDbTarget = new RavenDbTarget(documentStore);
            var asyncWrapper = new AsyncTargetWrapper(ravenDbTarget, 1000, AsyncTargetWrapperOverflowAction.Discard);
            loggingConfiguration.AddTarget("ravenDb", asyncWrapper);

            return asyncWrapper;
        }
开发者ID:jaredrussell,项目名称:Amikiri,代码行数:9,代码来源:NLogConfig.cs

示例7: CompetentAuthorityEmailAddressAttributeTests

 public CompetentAuthorityEmailAddressAttributeTests()
 {
     dependencyResolver = A.Fake<IDependencyResolver>();
     A.CallTo(() => dependencyResolver.GetService(typeof(AppConfiguration))).Returns(
         new AppConfiguration()
         {
             Environment = "LIVE"
         });
     DependencyResolver.SetResolver(dependencyResolver);
     viewModel = new TestViewModel();
 }
开发者ID:EnvironmentAgency,项目名称:prsd-iws,代码行数:11,代码来源:CompetentAuthorityEmailAddressAttributeTests.cs

示例8: GetCurrentUserJson

        //TODO Need to be removed
        public static string GetCurrentUserJson(IDependencyResolver resolver)
        {
            var result = new LoggedUserModel();
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
                result.IsAuthenticated = false;
            else
            {
                var userManager = resolver.GetService<IUserManager>();
                var permissionsRspManager = resolver.GetService<IRolePermissionRspManager>();
                var permissionsManager = resolver.GetService<IPermissionManager>();

                var user = userManager.GetByLogin(HttpContext.Current.User.Identity.Name);

                result.IsAuthenticated = true;
                result.Name = user.Name;

                var userPermissions = permissionsRspManager.GetEntities().Where(e => !e.DeleteDate.HasValue && user.RoleId == e.RoleId).ToList();

                result.Permissions = userPermissions.Where(o => o.Key == StringHelper.GetMD5Hash(String.Format("{0}_{1}", o.RoleId, o.PermissionId))).
                    Select(o => o.Permission.Name).ToList();
            }

            return JsonConvert.SerializeObject(result, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });
        }
开发者ID:HedinRakot,项目名称:Zierer,代码行数:25,代码来源:JsonHelper.cs

示例9: FindLoggingRules

 private static IEnumerable<InternalLoggingRule> FindLoggingRules(IDependencyResolver dependencyResolver)
 {
     var documentStore = (IDocumentStore)dependencyResolver.GetService(typeof(IDocumentStore));
     using (var session = documentStore.OpenSession())
     {
         var configuration = session.Load<Amikiri.Core.Models.NLogConfiguration>(Amikiri.Core.Models.NLogConfiguration.DocumentId);
         if(configuration == null)
         {
             configuration = CreateDefaultLoggingConfiguration();
             session.Store(configuration);
             session.SaveChanges();
             return configuration.LoggingRules;
         }
         else
         {
             return configuration.LoggingRules;
         }
     }
 }
开发者ID:jaredrussell,项目名称:Amikiri,代码行数:19,代码来源:NLogConfig.cs

示例10: CreateWorker

        //internal for testing 
        internal SmartActionWorker CreateWorker(Controller ctrl,Func<dynamic> modelId, ICustomAttributeProvider action,IDependencyResolver solver)
        {
            if (ctrl == null) throw new NotSupportedException("This attribute works only with Controller");

            var ipFactory = solver.GetService<IValidationFailedPolicyFactory>();
            if (ipFactory == null)
            {
                ipFactory=new ValidationFailedPolicyActivator(solver);
            }
            
            var facade = new SmartContextFacade(ctrl,modelId,ValidationFailedPolicy??DefaultPolicy, ipFactory);
            
            
            CheckOverridePolicy(action,facade);
            var worker = new SmartActionWorker(facade);
            return worker;
        }
开发者ID:Deson621,项目名称:MvcPowerTools,代码行数:18,代码来源:ValidModelOnlyAttribute.cs

示例11: GameItemViewModel

        public GameItemViewModel(Game game, IDependencyResolver resolver)
        {
            Game = game;

            _logger = resolver.GetService<ILogger>();
            _vpdbClient = resolver.GetService<IVpdbClient>();
            _gameManager = resolver.GetService<IGameManager>();
            _messageManager = resolver.GetService<IMessageManager>();
            var threadManager = resolver.GetService<IThreadManager>();

            // release identify
            IdentifyRelease = ReactiveCommand.CreateAsyncObservable(_ => _vpdbClient.Api.GetReleasesBySize(Game.FileSize, MatchThreshold).SubscribeOn(threadManager.WorkerScheduler));
            IdentifyRelease.Select(releases => releases
                .Select(release => new {release, release.Versions})
                .SelectMany(x => x.Versions.Select(version => new {x.release, version, version.Files}))
                .SelectMany(x => x.Files.Select(file => new GameResultItemViewModel(game, x.release, x.version, file, CloseResults)))
            ).Subscribe(x => {

                var releases = x as GameResultItemViewModel[] ?? x.ToArray();
                var numMatches = 0;
                _logger.Info("Found {0} releases for game to identify.", releases.Length);
                GameResultItemViewModel match = null;
                foreach (var vm in releases) {
                    if (game.Filename == vm.TableFile.Reference.Name && game.FileSize == vm.TableFile.Reference.Bytes) {
                        numMatches++;
                        match = vm;
                    }
                }
                _logger.Info("Found {0} identical match(es).", numMatches);

                // if file name and file size are identical, directly match.
                if (numMatches == 1 && match != null) {
                    _logger.Info("File name and size are equal to local release, linking.");
                    _gameManager.LinkRelease(match.Game, match.Release, match.TableFile.Reference.Id);
                    _messageManager.LogReleaseLinked(match.Game, match.Release, match.TableFile.Reference.Id);

                } else {
                    _logger.Info("View model updated with identified releases.");
                    IdentifiedReleases = releases;
                    HasExecuted = true;
                }
            }, exception => _vpdbClient.HandleApiError(exception, "identifying a game by file size"));

            //SyncToggled
            //	.Where(_ => Game.IsSynced && Game.HasRelease)
            //	.Subscribe(_ => { GameManager.Sync(Game); });

            // handle errors
            IdentifyRelease.ThrownExceptions.Subscribe(e => { _logger.Error(e, "Error matching game."); });

            // spinner
            IdentifyRelease.IsExecuting.ToProperty(this, vm => vm.IsExecuting, out _isExecuting);

            // result switch
            IdentifyRelease.Select(r => r.Count > 0).Subscribe(hasResults => { HasResults = hasResults; });

            // close button
            CloseResults.Subscribe(_ => { HasExecuted = false; });

            // identify button visibility
            this.WhenAny(
                vm => vm.HasExecuted,
                vm => vm.Game.HasRelease,
                vm => vm.IsExecuting,
                (hasExecuted, hasRelease, isExecuting) => !hasExecuted.Value && !hasRelease.Value && !isExecuting.Value
            ).ToProperty(this, vm => vm.ShowIdentifyButton, out _showIdentifyButton);
        }
开发者ID:freezy,项目名称:vpdb-agent,代码行数:67,代码来源:GameItemViewModel.cs

示例12: CatalogService

 public CatalogService(IDependencyResolver container)
 {
     m_ContreteCatalogService = container.GetService<ICatalogService>();
 }
开发者ID:hhariri,项目名称:ReSharper8Demo,代码行数:4,代码来源:CatalogService.cs

示例13: UnknownTypeMessageHandler

 public UnknownTypeMessageHandler(IDependencyResolver resolver)
 {
     _handler = (IPoisonMessageHandler)resolver
         .GetService(typeof(IPoisonMessageHandler));
 }
开发者ID:smartpcr,项目名称:data-pipeline,代码行数:5,代码来源:UnknownTypeMessageHandler.cs

示例14: TopLevel

        /// <summary>
        /// Initializes a new instance of the <see cref="TopLevel"/> class.
        /// </summary>
        /// <param name="impl">The platform-specific window implementation.</param>
        /// <param name="dependencyResolver">
        /// The dependency resolver to use. If null the default dependency resolver will be used.
        /// </param>
        public TopLevel(ITopLevelImpl impl, IDependencyResolver dependencyResolver)
        {
            dependencyResolver = dependencyResolver ?? Locator.Current;

            IPlatformRenderInterface renderInterface = dependencyResolver.GetService<IPlatformRenderInterface>();

            this.PlatformImpl = impl;
            this.accessKeyHandler = dependencyResolver.GetService<IAccessKeyHandler>();
            this.inputManager = dependencyResolver.GetService<IInputManager>();
            this.keyboardNavigationHandler = dependencyResolver.GetService<IKeyboardNavigationHandler>();
            this.LayoutManager = dependencyResolver.GetService<ILayoutManager>();
            this.renderManager = dependencyResolver.GetService<IRenderManager>();

            if (renderInterface == null)
            {
                throw new InvalidOperationException(
                    "Could not create an interface to the rendering subsystem: maybe no rendering subsystem was initialized?");
            }

            if (this.PlatformImpl == null)
            {
                throw new InvalidOperationException(
                    "Could not create window implementation: maybe no windowing subsystem was initialized?");
            }

            if (this.inputManager == null)
            {
                throw new InvalidOperationException(
                    "Could not create input manager: maybe Application.RegisterServices() wasn't called?");
            }

            if (this.LayoutManager == null)
            {
                throw new InvalidOperationException(
                    "Could not create layout manager: maybe Application.RegisterServices() wasn't called?");
            }

            if (this.renderManager == null)
            {
                throw new InvalidOperationException(
                    "Could not create render manager: maybe Application.RegisterServices() wasn't called?");
            }

            if (this.accessKeyHandler != null)
            {
                this.accessKeyHandler.SetOwner(this);
            }

            if (this.keyboardNavigationHandler != null)
            {
                this.keyboardNavigationHandler.SetOwner(this);
            }

            this.PlatformImpl.SetOwner(this);
            this.PlatformImpl.Activated = this.HandleActivated;
            this.PlatformImpl.Deactivated = this.HandleDeactivated;
            this.PlatformImpl.Closed = this.HandleClosed;
            this.PlatformImpl.Input = this.HandleInput;
            this.PlatformImpl.Paint = this.HandlePaint;
            this.PlatformImpl.Resized = this.HandleResized;

            Size clientSize = this.ClientSize = this.PlatformImpl.ClientSize;

            this.dispatcher = Dispatcher.UIThread;
            this.renderer = renderInterface.CreateRenderer(this.PlatformImpl.Handle, clientSize.Width, clientSize.Height);

            this.LayoutManager.Root = this;
            this.LayoutManager.LayoutNeeded.Subscribe(_ => this.HandleLayoutNeeded());
            this.LayoutManager.LayoutCompleted.Subscribe(_ => this.HandleLayoutCompleted());
            this.renderManager.RenderNeeded.Subscribe(_ => this.HandleRenderNeeded());

            IStyler styler = dependencyResolver.GetService<IStyler>();
            styler.ApplyStyles(this);

            this.GetObservable(ClientSizeProperty).Skip(1).Subscribe(x => this.PlatformImpl.ClientSize = x);
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:83,代码来源:TopLevel.cs

示例15: DirectoryRoute

 public DirectoryRoute(string directoryName, IDependencyResolver serviceLocator)
     : base(directoryName + "/{*pathInfo}", new DirectoryRouteHandler(serviceLocator.GetService<ISubtextPageBuilder>(), serviceLocator))
 {
     DirectoryName = directoryName;
 }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:5,代码来源:DirectoryRoute.cs


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