本文整理汇总了C#中IResolver类的典型用法代码示例。如果您正苦于以下问题:C# IResolver类的具体用法?C# IResolver怎么用?C# IResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IResolver类属于命名空间,在下文中一共展示了IResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInstance
public override object GetInstance(IInstanceFactory factory, IResolver resolver)
{
if (!_threadLocalInstance.IsValueCreated)
_threadLocalInstance.Value = factory.CreateInstance(resolver);
return _threadLocalInstance.Value;
}
示例2: ModelMetadataProviders
internal ModelMetadataProviders(IResolver<ModelMetadataProvider> resolver = null)
{
_resolver = resolver ?? new SingleServiceResolver<ModelMetadataProvider>(
() => _currentProvider,
new CachedDataAnnotationsModelMetadataProvider(),
"ModelMetadataProviders.Current");
}
示例3: DefaultControllerFactory
internal DefaultControllerFactory(IControllerActivator controllerActivator, IResolver<IControllerActivator> activatorResolver, IDependencyResolver dependencyResolver)
{
if (controllerActivator != null)
this._controllerActivator = controllerActivator;
else
this._activatorResolver = activatorResolver ?? (IResolver<IControllerActivator>) new SingleServiceResolver<IControllerActivator>((Func<IControllerActivator>) (() => (IControllerActivator) null), (IControllerActivator) new DefaultControllerFactory.DefaultControllerActivator(dependencyResolver), "DefaultControllerFactory constructor");
}
示例4: IndicatorUpdateCoordinator
public IndicatorUpdateCoordinator(ILog log, Repository<IIndicatorConfiguration> indicatorConfigurationRepository, Repository<IIndicatorState> indicatorStateRepository, IResolver resolver)
{
_log = log;
_indicatorConfigurationRepository = indicatorConfigurationRepository;
_indicatorStateRepository = indicatorStateRepository;
_resolver = resolver;
}
示例5: ControllerBuilder
internal ControllerBuilder(IResolver<IControllerFactory> serviceResolver) {
_serviceResolver = serviceResolver ?? new SingleServiceResolver<IControllerFactory>(
() => _factoryThunk(),
new DefaultControllerFactory { ControllerBuilder = this },
"ControllerBuilder.GetControllerFactory"
);
}
示例6: DispatchToEventSubscribers
public DispatchToEventSubscribers(
ILog log,
IResolver resolver)
{
_log = log;
_resolver = resolver;
}
示例7: CSSAssetsFileHasher
public CSSAssetsFileHasher(string hashQueryStringKeyName, IResolver fileResolver, IHasher hasher, IPathTranslator pathTranslator)
{
HashQueryStringKeyName = hashQueryStringKeyName;
FileSystemResolver = fileResolver;
Hasher = hasher;
this.pathTranslator = pathTranslator;
}
示例8: ExecuteAsync
public async Task ExecuteAsync(IResolver resolver, CancellationToken cancellationToken)
{
var queryProcessor = resolver.Resolve<IQueryProcessor>();
var updateItineraryService = resolver.Resolve<IUpdateItineraryService>();
var commandBus = resolver.Resolve<ICommandBus>();
var routingService = resolver.Resolve<IRoutingService>();
var cargo = (await queryProcessor.ProcessAsync(new GetCargosQuery(CargoId), cancellationToken).ConfigureAwait(false)).Single();
var updatedItinerary = await updateItineraryService.UpdateItineraryAsync(cargo.Itinerary, cancellationToken).ConfigureAwait(false);
if (cargo.Route.Specification().IsSatisfiedBy(updatedItinerary))
{
await commandBus.PublishAsync(new CargoSetItineraryCommand(cargo.Id, updatedItinerary), cancellationToken).ConfigureAwait(false);
return;
}
var newItineraries = await routingService.CalculateItinerariesAsync(cargo.Route, cancellationToken).ConfigureAwait(false);
var newItinerary = newItineraries.FirstOrDefault();
if (newItinerary == null)
{
// TODO: Tell domain that a new itinerary could not be found
throw DomainError.With("Could not find itinerary");
}
await commandBus.PublishAsync(new CargoSetItineraryCommand(cargo.Id, newItinerary), cancellationToken).ConfigureAwait(false);
}
示例9: SelectDatabaseStep
///<summary>
/// Initializes a new instance of <see cref="SelectDatabaseStep"/>.
///</summary>
///<param name="serviceProvider">The service provider to use for service location.</param>
///<param name="sourceModel">The <see cref="ConfigurationSourceModel"/> to update on <see cref="WizardStep.Execute"/></param>
///<param name="validatorFactory">The factory creating new <see cref="Validator"/> instances.</param>
///<param name="elementLookup">The service for locating registered elements.</param>
public SelectDatabaseStep(IServiceProvider serviceProvider,
ConfigurationSourceModel sourceModel,
IResolver<Validator> validatorFactory,
ElementLookup elementLookup
)
: base(serviceProvider, validatorFactory, elementLookup)
{
this.sourceModel = sourceModel;
var name = AddReflectedProperty(wizardData, propertyName);
PropertyList.Add(new AssociatedWizardProperty(serviceProvider,
wizardData,
TypeDescriptor.GetProperties(wizardData)[propertyConnectionString],
validatorFactory,
elementLookup,
name));
PropertyList.Add(new AssociatedWizardProperty(serviceProvider,
wizardData,
TypeDescriptor.GetProperties(wizardData)[propertyProviderName],
validatorFactory,
elementLookup,
name));
SetDefaultDatabase(elementLookup);
}
示例10: ServiceProviderAdapter
public ServiceProviderAdapter(IResolver resolver)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
_resolver = resolver;
}
示例11: BuildManagerViewEngine
internal BuildManagerViewEngine(IViewPageActivator viewPageActivator, IResolver<IViewPageActivator> activatorResolver,
IDependencyResolver dependencyResolver, VirtualPathProvider pathProvider)
{
if (viewPageActivator != null)
{
_viewPageActivator = viewPageActivator;
}
else
{
_activatorResolver = activatorResolver ?? new SingleServiceResolver<IViewPageActivator>(
() => null,
new DefaultViewPageActivator(dependencyResolver),
"BuildManagerViewEngine constructor");
}
if (pathProvider != null)
{
Func<VirtualPathProvider> providerFunc = () => pathProvider;
_fileExistsCache = new FileExistenceCache(providerFunc);
VirtualPathProviderFunc = providerFunc;
}
else
{
if (_sharedFileExistsCache == null)
{
// Startup initialization race is OK providing service remains read-only
_sharedFileExistsCache = new FileExistenceCache(() => HostingEnvironment.VirtualPathProvider);
}
_fileExistsCache = _sharedFileExistsCache;
}
}
示例12: CreateStartInfo
private ProcessStartInfo CreateStartInfo(Benchmark benchmark, string exeName, string args, string workingDirectory, IResolver resolver)
{
var start = new ProcessStartInfo
{
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
WorkingDirectory = workingDirectory
};
var runtime = benchmark.Job.Env.HasValue(EnvMode.RuntimeCharacteristic)
? benchmark.Job.Env.Runtime
: RuntimeInformation.GetCurrentRuntime();
// TODO: use resolver
switch (runtime)
{
case Runtime.Clr:
case Runtime.Core:
start.FileName = exeName;
start.Arguments = args;
break;
case Runtime.Mono:
start.FileName = "mono";
start.Arguments = GetMonoArguments(benchmark.Job, exeName, args, resolver);
break;
default:
throw new NotSupportedException("Runtime = " + runtime);
}
return start;
}
示例13: TryGetConstructor
public bool TryGetConstructor(Type type, IResolver resolver, out ConstructorInfo constructor)
{
if (type.IsAbstract)
{
constructor = null;
return false;
}
var rankedConstructors =
type.GetConstructors()
.SelectMany(GetVirtualContructors)
.Where(v => v.CanResolve(resolver))
.GroupBy(v => v.GetScore())
.OrderByDescending(g => g.Key);
var enumerator = rankedConstructors.GetEnumerator();
if (!enumerator.MoveNext())
{
constructor = null;
return false;
}
if (enumerator.Current.Count() > 1)
{
constructor = null;
return false;
}
constructor = enumerator.Current.Single().Constructor;
return true;
}
示例14: Build
/// <summary>
/// generates project.lock.json that tells compiler where to take dlls and source from
/// and builds executable and copies all required dll's
/// </summary>
public BuildResult Build(GenerateResult generateResult, ILogger logger, Benchmark benchmark, IResolver resolver)
{
if (!DotNetCliCommandExecutor.ExecuteCommand(
RestoreCommand,
generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath,
logger,
DefaultTimeout))
{
return BuildResult.Failure(generateResult, new Exception("dotnet restore has failed"));
}
if (!DotNetCliCommandExecutor.ExecuteCommand(
GetBuildCommand(TargetFrameworkMoniker),
generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath,
logger,
DefaultTimeout))
{
// dotnet cli could have succesfully builded the program, but returned 1 as exit code because it had some warnings
// so we need to check whether the exe exists or not, if it does then it is OK
if (File.Exists(generateResult.ArtifactsPaths.ExecutablePath))
{
return BuildResult.Success(generateResult);
}
return BuildResult.Failure(generateResult);
}
return BuildResult.Success(generateResult);
}
示例15: SizesModel
public SizesModel(IResolver resolver, IReadOnlyCollection<ImageInfo> images, string id)
{
this.ServiceName = resolver.ServiceName;
this.Images = images;
this.ServiceId = resolver.ServiceId;
this.Id = id;
}