本文整理汇总了C#中DependencyInjectionContainer.TryResolve方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyInjectionContainer.TryResolve方法的具体用法?C# DependencyInjectionContainer.TryResolve怎么用?C# DependencyInjectionContainer.TryResolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DependencyInjectionContainer
的用法示例。
在下文中一共展示了DependencyInjectionContainer.TryResolve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureDependencies
public static void ConfigureDependencies(DependencyInjectionContainer container)
{
ILinqToAstoriaQueryEvaluationStrategy strategy;
if (!container.TryResolve<ILinqToAstoriaQueryEvaluationStrategy>(out strategy))
{
container.Register<ILinqToAstoriaQueryEvaluationStrategy, LinqToAstoriaClrQueryEvaluationStrategy>();
container.Register<IPrimitiveDataTypeResolver, NullPrimitiveDataTypeResolver>();
}
container.Register<IQueryDataSetBuilder, AstoriaQueryDataSetBuilder>();
container.Register<IQueryRepositoryBuilder, AstoriaQueryRepositoryBuilderBase>();
container.Register<IQueryExpressionEvaluator, LinqToAstoriaEvaluator>();
container.Register<ILinqToAstoriaQueryResolver, LinqToAstoriaQueryResolver>();
container.Register<ILinqToAstoriaQuerySpanGenerator, LinqToAstoriaQuerySpanGenerator>();
container.Register<IClientQueryResultComparer, ClientQueryResultComparer>();
container.Register<IOracleBasedDataSynchronizer, QueryDataSetSynchronizer>();
container.Register<ILinqResultComparerContextAdapter, LinqResultComparerDataServiceContextAdapter>();
container.Register<IQueryValueDeepCopyingVisitor, AstoriaQueryValueDeepCopyingVisitor>();
container.Register<ISpatialClrTypeResolver, SpatialClrTypeResolver>();
container.Register<ISpatialDataTypeDefinitionResolver, SpatialDataTypeDefinitionResolver>();
container.RegisterCustomResolver(
typeof(QueryRepository),
resolver =>
{
var workspace = container.Resolve<AstoriaWorkspace>();
if (workspace.CurrentQueryRepository == null)
{
var queryTypeLibrary = container.Resolve<QueryTypeLibrary>();
var queryRepositoryBuilder = container.Resolve<IQueryRepositoryBuilder>();
var queryRepository = queryRepositoryBuilder.CreateQueryRepository(workspace.ConceptualModel, queryTypeLibrary, workspace.DownloadedEntityContainerData);
workspace.CurrentQueryRepository = queryRepository;
}
return workspace.CurrentQueryRepository;
});
container.RegisterCustomResolver(
typeof(IQueryDataSet),
resolver =>
{
var queryRepository = container.Resolve<QueryRepository>();
return queryRepository.DataSet;
});
container.RegisterServiceReference<IDataOracleService>(
() =>
{
var workspace = container.Resolve<AstoriaWorkspace>();
return workspace.OracleServiceUri;
});
container.RegisterCustomResolver(
typeof(IEntitySetResolver),
esResolver =>
{
var workspace = container.Resolve<AstoriaWorkspace>();
return workspace.EntitySetResolver;
});
container.RegisterCustomResolver(
typeof(IQueryTypeLibraryBuilder),
queryTypeLibBuilderResolver =>
{
var queryEvaluationStrategy = container.Resolve<ILinqToAstoriaQueryEvaluationStrategy>();
var primitiveTypeResolver = container.Resolve<IPrimitiveDataTypeResolver>();
var edmDataTypeResolver = container.Resolve<EdmDataTypeResolver>();
return new AstoriaQueryTypeLibraryBuilder(queryEvaluationStrategy, primitiveTypeResolver, edmDataTypeResolver);
});
container.RegisterCustomResolver(
typeof(QueryTypeLibrary),
queryTypeLib =>
{
var workspace = container.Resolve<AstoriaWorkspace>();
if (workspace.CurrentQueryRepository == null)
{
var queryTypeLibraryBuilder = container.Resolve<IQueryTypeLibraryBuilder>();
var queryTypeLibrary = queryTypeLibraryBuilder.BuildLibraryWithoutClrTypeMapping(workspace.ConceptualModel);
queryTypeLibrary.UpdateClrTypeMapping(workspace.Assemblies.Select(ac => ac.Contents).ToArray());
return queryTypeLibrary;
}
else
{
return workspace.CurrentQueryRepository.TypeLibrary;
}
});
container.RegisterCustomResolver(
typeof(IEntityModelConceptualDataServices),
t =>
{
var workspace = container.Resolve<AstoriaWorkspace>();
// Add data generation hints before creating structural data services
ResolveDataGenerationHints(workspace.ConceptualModel, container);
var builder = container.Resolve<IEntityModelConceptualDataServicesFactory>();
var services = builder.CreateConceptualDataServices(workspace.ConceptualModel);
ExceptionUtilities.CheckObjectNotNull(services, "Structural data services builder returned null unexpectedly");
//.........这里部分代码省略.........