本文整理汇总了C#中System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValues方法的典型用法代码示例。如果您正苦于以下问题:C# ExportProvider.GetExportedValues方法的具体用法?C# ExportProvider.GetExportedValues怎么用?C# ExportProvider.GetExportedValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.Composition.Hosting.ExportProvider
的用法示例。
在下文中一共展示了ExportProvider.GetExportedValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateIndexes
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
/// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param>
/// <param name="documentStore">The document store.</param>
public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore)
{
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
task.Execute(documentStore);
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
task.Execute(documentStore);
}
}
示例2: CreateIndexes
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands, DocumentConvention conventions)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
try
{
var tasks = catalogToGetnIndexingTasksFrom
.GetExportedValues<AbstractIndexCreationTask>()
.ToList();
var indexesToAdd = tasks
.Select(x => new IndexToAdd
{
Definition = x.CreateIndexDefinition(),
Name = x.IndexName,
Priority = x.Priority ?? IndexingPriority.Normal
})
.ToArray();
databaseCommands.PutIndexes(indexesToAdd);
foreach (var task in tasks)
task.AfterExecute(databaseCommands, conventions);
}
// For old servers that don't have the new entrypoint for executing multiple indexes
catch (Exception)
{
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
task.Execute(databaseCommands, conventions);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e));
}
}
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
task.Execute(databaseCommands, conventions);
}
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}
示例3: CreateIndexesAsync
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
/// <param name="catalogToGetnIndexingTasksFrom">The catalog to getn indexing tasks from.</param>
/// <param name="documentStore">The document store.</param>
public static Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore)
{
var tasks = catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>();
Task[] array = tasks.Select(task => task.ExecuteAsync(documentStore)).ToArray();
var indexesAsync = new Task(() => Task.WaitAll(array));
indexesAsync.Start();
return indexesAsync;
}
示例4: CreateIndexesAsync
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
public static Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands asyncDatabaseCommands, DocumentConvention conventions)
{
var tasks = catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>();
Task[] array = tasks.Select(task => task.ExecuteAsync(asyncDatabaseCommands, conventions)).ToArray();
var indexesAsync = new Task(() => Task.WaitAll(array));
indexesAsync.Start();
return indexesAsync;
}
示例5: CreateIndexes
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
/// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param>
/// <param name="documentStore">The document store.</param>
public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
task.Execute(documentStore);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e));
}
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
task.Execute(documentStore);
}
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}
示例6: CreateIndexesAsync
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
public static async Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
await task.ExecuteAsync(databaseCommands, conventions);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e));
}
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
await task.ExecuteAsync(databaseCommands, conventions);
}
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}
示例7: GetCommandSettings
/// <summary>
/// This is all the command settings that are related to the file match element.
/// </summary>
/// <param name="container">The container for all the plugins.</param>
/// <param name="project">The project to get all the command settings for.</param>
/// <returns>Dictionary of command type/command </returns>
private Dictionary<string, List<string>> GetCommandSettings(ExportProvider container, ProjectElement project)
{
var currentConfigurationElementCollections = container.GetExportedValues<CurrentConfigurationElementCollection>()
.Where(x => !_excludedElements.Contains(x.Setting.ElementSettingName));
var commandSettings = new Dictionary<string, List<string>>();
foreach (var configurationElementCollection in currentConfigurationElementCollections)
{
var collectionSettingName = configurationElementCollection.Setting.ElementCollectionSettingName;
var configurationProperty = project.GetConfigurationProperty(collectionSettingName);
var commandElementCollection = project.GetElementCollection<CurrentConfigurationElementCollection>(configurationProperty);
var conversionType = commandElementCollection.Setting.ConversionType;
var commandSettingKeys = new List<string>();
for (var i = 0; i < commandElementCollection.Count; i++)
{
var commandElement = commandElementCollection[i];
commandSettingKeys.Add(commandElement.Name);
}
commandSettings.Add(conversionType, commandSettingKeys);
}
return commandSettings;
}
示例8: CreateIndexesAsync
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
public static async Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands asyncDatabaseCommands, DocumentConvention conventions)
{
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
await task.ExecuteAsync(asyncDatabaseCommands, conventions);
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
await task.ExecuteAsync(asyncDatabaseCommands, conventions);
}
}
示例9: SideBySideCreateIndexesAsync
/// <summary>
/// Creates the indexes found in the specified catalog in side-by-side mode.
/// </summary>
/// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param>
/// <param name="documentStore">The document store.</param>
public static async Task SideBySideCreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
await task.SideBySideExecuteAsync(documentStore, minimumEtagBeforeReplace, replaceTimeUtc).ConfigureAwait(false);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e));
}
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
await task.ExecuteAsync(documentStore).ConfigureAwait(false);
}
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}
示例10: CreateTransformersAsync
private static async Task CreateTransformersAsync(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore)
{
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
await task.ExecuteAsync(documentStore).ConfigureAwait(false);
}
}
示例11: SideBySideCreateIndexesAsync
/// <summary>
/// Creates the indexes found in the specified catalog in side-by-side mode.
/// </summary>
/// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param>
/// <param name="documentStore">The document store.</param>
/// <param name="minimumEtagBeforeReplace">Minimum last indexed etag after which index will be replaced (map indexes only)</param>
/// <param name="replaceTimeUtc"></param>
public static async Task SideBySideCreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
var failed = false;
try
{
var tasks = catalogToGetnIndexingTasksFrom
.GetExportedValues<AbstractIndexCreationTask>()
.ToList();
var indexesToAdd = CreateIndexesToAdd(tasks, documentStore.Conventions);
await documentStore.AsyncDatabaseCommands.PutSideBySideIndexesAsync(indexesToAdd, minimumEtagBeforeReplace, replaceTimeUtc).ConfigureAwait(false);
foreach (var task in tasks)
await task.AfterExecuteAsync(documentStore.AsyncDatabaseCommands, documentStore.Conventions).ConfigureAwait(false);
}
// For old servers that don't have the new endpoint for executing multiple indexes
catch (Exception)
{
failed = true;
}
if (failed)
{
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
await task.SideBySideExecuteAsync(documentStore, minimumEtagBeforeReplace, replaceTimeUtc).ConfigureAwait(false);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile side by side index name = " + task.IndexName, e));
}
}
}
await CreateTransformersAsync(catalogToGetnIndexingTasksFrom, documentStore).ConfigureAwait(false);
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more side by side indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}
示例12: SideBySideCreateIndexes
/// <summary>
/// Creates the indexes found in the specified catalog in side-by-side mode.
/// </summary>
/// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param>
/// <param name="documentStore">The document store.</param>
/// <param name="minimumEtagBeforeReplace">Minimum last indexed etag after which index will be replaced (map indexes only)</param>
/// <param name="replaceTimeUtc"></param>
public static void SideBySideCreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
try
{
var tasks = catalogToGetnIndexingTasksFrom
.GetExportedValues<AbstractIndexCreationTask>()
.ToList();
documentStore.SideBySideExecuteIndexes(tasks, minimumEtagBeforeReplace, replaceTimeUtc);
}
// For old servers that don't have the new endpoint for executing multiple indexes
catch (Exception ex)
{
Log.InfoException("Could not create side by side indexes in one shot (maybe using older version of RavenDB ?)", ex);
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
task.SideBySideExecute(documentStore, minimumEtagBeforeReplace, replaceTimeUtc);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile side by side index name = " + task.IndexName, e));
}
}
}
CreateTransformers(catalogToGetnIndexingTasksFrom, documentStore);
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more side by indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}
示例13: CreateIndexes
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
/// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param>
/// <param name="documentStore">The document store.</param>
public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDocumentStore documentStore)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
try
{
var tasks = catalogToGetnIndexingTasksFrom
.GetExportedValues<AbstractIndexCreationTask>()
.ToList();
documentStore.ExecuteIndexes(tasks);
}
// For old servers that don't have the new entrypoint for executing multiple indexes
catch (Exception ex)
{
Log.InfoException("Could not create indexes in one shot (maybe using older version of RavenDB ?)", ex);
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
task.Execute(documentStore);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e));
}
}
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
task.Execute(documentStore);
}
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}
示例14: SideBySideCreateIndexes
/// <summary>
/// Creates the indexes found in the specified catalog in side-by-side mode.
/// </summary>
public static void SideBySideCreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands, DocumentConvention conventions, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
task.SideBySideExecute(databaseCommands, conventions, minimumEtagBeforeReplace, replaceTimeUtc);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e));
}
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
task.Execute(databaseCommands, conventions);
}
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}
示例15: CreateIndexesAsync
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
public static async Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
bool failed = false;
try
{
var tasks = catalogToGetnIndexingTasksFrom
.GetExportedValues<AbstractIndexCreationTask>()
.ToList();
var indexesNames = tasks.Select(x => x.IndexName).ToArray();
var definitions = tasks.Select(x => x.CreateIndexDefinition()).ToArray();
var priorities = tasks.Select(x => x.Priority ?? IndexingPriority.Normal).ToArray();
await databaseCommands.PutIndexesAsync(indexesNames, definitions, priorities).ConfigureAwait(false);
foreach (var task in tasks)
await task.AfterExecuteAsync(databaseCommands, conventions).ConfigureAwait(false);
}
// For old servers that don't have the new entrypoint for executing multiple indexes
catch (Exception)
{
failed = true;
}
if (failed)
{
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
await task.ExecuteAsync(databaseCommands, conventions).ConfigureAwait(false);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e));
}
}
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
await task.ExecuteAsync(databaseCommands, conventions).ConfigureAwait(false);
}
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}