本文整理汇总了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);
}
示例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);
}
示例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;
});
}
示例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();
}
}
示例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));
}
示例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;
}
示例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();
}
示例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() });
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例12: CatalogService
public CatalogService(IDependencyResolver container)
{
m_ContreteCatalogService = container.GetService<ICatalogService>();
}
示例13: UnknownTypeMessageHandler
public UnknownTypeMessageHandler(IDependencyResolver resolver)
{
_handler = (IPoisonMessageHandler)resolver
.GetService(typeof(IPoisonMessageHandler));
}
示例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);
}
示例15: DirectoryRoute
public DirectoryRoute(string directoryName, IDependencyResolver serviceLocator)
: base(directoryName + "/{*pathInfo}", new DirectoryRouteHandler(serviceLocator.GetService<ISubtextPageBuilder>(), serviceLocator))
{
DirectoryName = directoryName;
}