本文整理汇总了C#中System.ComponentModel.Composition.Primitives.ComposablePartDefinition类的典型用法代码示例。如果您正苦于以下问题:C# ComposablePartDefinition类的具体用法?C# ComposablePartDefinition怎么用?C# ComposablePartDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComposablePartDefinition类属于System.ComponentModel.Composition.Primitives命名空间,在下文中一共展示了ComposablePartDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CatalogExport
public CatalogExport(CatalogExportProvider catalogExportProvider,
ComposablePartDefinition partDefinition, ExportDefinition definition)
{
this._catalogExportProvider = catalogExportProvider;
this._partDefinition = partDefinition;
this._definition = definition;
}
开发者ID:JackFong,项目名称:FreeRadical,代码行数:7,代码来源:CatalogExportProvider.CatalogExport.cs
示例2: WriteImportDefinition
public static IDictionary<string, object> WriteImportDefinition(ComposablePartDefinition owner, ContractBasedImportDefinition importDefinition)
{
Assumes.NotNull(owner);
Assumes.NotNull(importDefinition);
Lazy<Type> partType = ReflectionModelServices.GetPartType(owner);
IDictionary<string, object> cache = new Dictionary<string, object>();
cache.WriteContractName(importDefinition.ContractName);
cache.WriteValue(AttributedCacheServices.CacheKeys.RequiredTypeIdentity, importDefinition.RequiredTypeIdentity, null);
cache.WriteRequiredMetadata(importDefinition.RequiredMetadata);
cache.WriteValue(AttributedCacheServices.CacheKeys.RequiredCreationPolicy, importDefinition.RequiredCreationPolicy, CreationPolicy.Any);
cache.WriteValue(AttributedCacheServices.CacheKeys.Cardinality, importDefinition.Cardinality, ImportCardinality.ExactlyOne);
if (ReflectionModelServices.IsImportingParameter(importDefinition))
{
cache.WriteValue(AttributedCacheServices.CacheKeys.ImportType, AttributedCacheServices.ImportTypes.Parameter);
cache.WriteLazyParameter(
ReflectionModelServices.GetImportingParameter(importDefinition),
partType);
}
else
{
// don't write anything for import type - member assumed
LazyMemberInfo importingMemberInfo = ReflectionModelServices.GetImportingMember(importDefinition);
cache.WriteValue(AttributedCacheServices.CacheKeys.IsRecomposable, importDefinition.IsRecomposable, false);
cache.WriteValue(AttributedCacheServices.CacheKeys.MemberType, importingMemberInfo.MemberType , MemberTypes.Property);
cache.WriteLazyAccessors(
importingMemberInfo.GetAccessors(),
partType);
}
return cache;
}
开发者ID:JackFong,项目名称:FreeRadical,代码行数:33,代码来源:CompositionCacheServices.cs
示例3: CheckName
private void CheckName(ComposablePartDefinition def)
{
if (!def.Metadata.ContainsKey(Keys.PluginId))
{
var msg = string.Format("There's a plugin without id. Check you've set the attribute Metadata to the plugin with the key '{0}'", Keys.PluginId);
#if DEBUG
throw new NotImplementedException(msg);
#else
Logger.Warn(msg);
#endif
}
else
{
Guid id;
if (!(Guid.TryParse(def.Metadata[Keys.PluginId].ToString(), out id)))
{
throw new Exception(string.Format(
"The plugin doen't have a valid id. Check you've set the attribute Metadata to the plugin with the key '{0}'", Keys.PluginId));
}
if (this.IdCollection.Contains(id))
{
throw new Exception(string.Format(
"A plugin with the same id already exist in the repository [id: {0}]", id.ToString()));
}
}
}
开发者ID:seniorOtaka,项目名称:ndoctor,代码行数:26,代码来源:MefPluginLoader.cs
示例4: PartCreatorExport
public PartCreatorExport(CatalogExportProvider catalogExportProvider, ComposablePartDefinition partDefinition, ExportDefinition exportDefinition)
{
this._catalogExportProvider = catalogExportProvider;
this._partDefinition = partDefinition;
this._exportDefinition = exportDefinition;
this._partCreatorExportDefinition = new PartCreatorExportDefinition(this._exportDefinition);
}
开发者ID:grothag,项目名称:pocketmef,代码行数:7,代码来源:CatalogExportProvider.PartCreatorExport.cs
示例5: AddInComposablePartDefinition
public AddInComposablePartDefinition(AddInCatalog catalog, ComposablePartDefinition composablePartDefinition)
{
this._composablePartDefinition = composablePartDefinition;
List<KeyValuePair<string, object>> injectedMetadata = new List<KeyValuePair<string, object>>();
injectedMetadata.Add(new KeyValuePair<string, object>(AddInCatalog.PackageIdMetadataName, catalog.PackageId));
injectedMetadata.Add(new KeyValuePair<string, object>(AddInCatalog.PackageVersionMetadataName,
catalog.PackageVersion));
List<ExportDefinition> interceptedExports = new List<ExportDefinition>();
foreach (ExportDefinition export in composablePartDefinition.ExportDefinitions)
{
ICompositionElement compositionElement = export as ICompositionElement;
if (compositionElement == null)
throw new InvalidOperationException("ExportDefinition doesn't implement ICompositionElement");
Dictionary<string, object> metadata = injectedMetadata.Concat(export.Metadata)
.ToDictionary(kvp => kvp.Key,
kvp => kvp.Value);
// TODO this will fail if export isn't a ReflectionMemberExportDefinition (Internal, so I can't check)
LazyMemberInfo lazyMember = ReflectionModelServices.GetExportingMember(export);
ExportDefinition interceptedExport =
ReflectionModelServices.CreateExportDefinition(lazyMember,
export.ContractName,
new Lazy<IDictionary<string, object>>(() => metadata),
compositionElement.Origin);
interceptedExports.Add(interceptedExport);
}
this._exportDefinitions = interceptedExports.ToArray();
}
开发者ID:ppittle,项目名称:LBi.LostDoc,代码行数:34,代码来源:AddInComposablePartDefinition.cs
示例6: CacheImportDefinition
public IDictionary<string, object> CacheImportDefinition(ComposablePartDefinition owner, ImportDefinition importDefinition)
{
ContractBasedImportDefinition contractBasedImport = importDefinition as ContractBasedImportDefinition;
Assumes.NotNull(contractBasedImport);
return CompositionCacheServices.WriteImportDefinition(owner, contractBasedImport);
}
开发者ID:ibratoev,项目名称:MEF.NET35,代码行数:7,代码来源:AttributedComposablePartCatalogSite.cs
示例7: TranslateImport
private static ImportDefinition TranslateImport(ImportDefinition import, ComposablePartDefinition part)
{
ContractBasedImportDefinition contractBasedImport = import as ContractBasedImportDefinition;
if (contractBasedImport == null)
{
return import;
}
int[] importParametersOrder = contractBasedImport.Metadata.GetValue<int[]>(CompositionConstants.GenericImportParametersOrderMetadataName);
if (importParametersOrder == null)
{
return import;
}
int partArity = part.Metadata.GetValue<int>(CompositionConstants.GenericPartArityMetadataName);
if (partArity == 0)
{
return import;
}
string contractName = GenericServices.GetGenericName(contractBasedImport.ContractName, importParametersOrder, partArity);
string requiredTypeIdentity = GenericServices.GetGenericName(contractBasedImport.RequiredTypeIdentity, importParametersOrder, partArity);
return new ContractBasedImportDefinition(
contractName,
requiredTypeIdentity,
contractBasedImport.RequiredMetadata,
contractBasedImport.Cardinality,
contractBasedImport.IsRecomposable,
false,
contractBasedImport.RequiredCreationPolicy,
contractBasedImport.Metadata);
}
开发者ID:nlhepler,项目名称:mono,代码行数:32,代码来源:PrimitivesServices.cs
示例8: Filter
/// <summary>
/// Decides whether given part satisfies a filter.
/// </summary>
/// <param name="part"><see cref="ComposablePartDefinition"/> being filtered.</param>
/// <returns>True if a given <see cref="ComposablePartDefinition"/> satisfies the filter.
/// False otherwise.</returns>
public bool Filter(ComposablePartDefinition part)
{
// Fetch all metadata
Dictionary<string, object> metadata = new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase);
foreach (var md in part.Metadata)
{
metadata.Add(md.Key, md.Value);
}
var additionalMetadata = from ed in part.ExportDefinitions
from md in ed.Metadata
select md;
foreach (var md in additionalMetadata)
{
if (!metadata.ContainsKey(md.Key))
{
metadata.Add(md.Key, md.Value);
}
}
// Fetch "Scope"
var key = "Scope";
if (metadata.ContainsKey(key))
{
PartCreationScope scope = PartCreationScope.Default;
Enum.TryParse(metadata[key].ToString(), out scope);
return scope == _partCreationScope;
}
else if (_partCreationScope == PartCreationScope.Default)
{
return true;
}
return false;
}
开发者ID:doublekill,项目名称:MefContrib,代码行数:40,代码来源:HasPartCreationScope.cs
示例9: GetAllWithinAppScope
private static bool GetAllWithinAppScope(ComposablePartDefinition def)
{
return def.ExportDefinitions.
Any(ed =>
!ed.Metadata.ContainsKey(ModeKey) ||
(ed.Metadata.ContainsKey(ModeKey) && ((WebScopeMode)ed.Metadata[ModeKey]) == WebScopeMode.Application));
}
开发者ID:femiosinowo,项目名称:sssadl,代码行数:7,代码来源:ScopedContainerHttpModule.cs
示例10: PartDefinitionInfo
/// <summary>
/// Create a PartDefinitionInfo representing partDefinition.
/// </summary>
/// <param name="partDefinition">The part to be analyzed.</param>
public PartDefinitionInfo(ComposablePartDefinition partDefinition)
{
PartDefinition = partDefinition;
ImportDefinitions = Enumerable.Empty<ImportDefinitionInfo>();
_isRejected = new Lazy<bool>(() => ImportDefinitions
.Any(idi => idi.Exception is ImportCardinalityMismatchException));
}
开发者ID:JackFong,项目名称:FreeRadical,代码行数:11,代码来源:PartDefinitionInfo.cs
示例11: TryTraverse
public bool TryTraverse(ComposablePartDefinition part, out IEnumerable<ComposablePartDefinition> reachableParts)
{
reachableParts = null;
List<ComposablePartDefinition> reachablePartList = null;
// Go through all part exports
foreach (ExportDefinition export in part.ExportDefinitions)
{
// Find all parts that we know will import each export
List<ComposablePartDefinition> candidateReachableParts = null;
if (this._importersIndex.TryGetValue(export.ContractName, out candidateReachableParts))
{
// find if they actually match
foreach (var candidateReachablePart in candidateReachableParts)
{
foreach (ImportDefinition import in candidateReachablePart.ImportDefinitions.Where(this._importFilter))
{
if (import.IsImportDependentOnPart(part, export, part.IsGeneric() != candidateReachablePart.IsGeneric()))
{
if (reachablePartList == null)
{
reachablePartList = new List<ComposablePartDefinition>();
}
reachablePartList.Add(candidateReachablePart);
}
}
}
}
}
reachableParts = reachablePartList;
return (reachableParts != null);
}
开发者ID:nlhepler,项目名称:mono,代码行数:33,代码来源:FilteredCatalog.DependentsTraversal.cs
示例12: IsMatch
protected override bool IsMatch(ComposablePartDefinition composablePartDefinition)
{
var element = composablePartDefinition as ICompositionElement;
if (element == null)
return true;
return element.DisplayName.StartsWith("Raven.Database") == false;
}
开发者ID:925coder,项目名称:ravendb,代码行数:7,代码来源:BuiltinFilteringCatalog.cs
示例13: DecoratedExport
/// <summary>
/// Initializes the context from a part and the export.
/// </summary>
internal DecoratedExport(ComposablePartDefinition part, ExportDefinition export)
{
this.ExportDefinition = export;
this.ExportingMember = ReflectionModelServices.GetExportingMember(export);
this.ExportingType = ReflectionModelServices.GetPartType(part);
this.NewMetadata = new Dictionary<string, object>(export.Metadata);
}
开发者ID:NuPattern,项目名称:NuPattern,代码行数:10,代码来源:DecoratingReflectionCatalog.cs
示例14: CreatePart
public static ReflectionComposablePart CreatePart(ComposablePartDefinition partDefinition, object attributedPart)
{
Assumes.NotNull(partDefinition);
Assumes.NotNull(attributedPart);
return new ReflectionComposablePart((ReflectionComposablePartDefinition)partDefinition, attributedPart);
}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:AttributedModelDiscovery.cs
示例15: Filter
/// <summary>
/// Decides whether given part satisfies a filter.
/// </summary>
/// <param name="part"><see cref="ComposablePartDefinition"/> being filtered.</param>
/// <returns>True if a given <see cref="ComposablePartDefinition"/> satisfies the filter.
/// False otherwise.</returns>
public bool Filter(ComposablePartDefinition part)
{
if (creationPolicy == CreationPolicy.Any && !part.Metadata.ContainsKey(CompositionConstants.PartCreationPolicyMetadataName))
return true;
return part.Metadata.ContainsKey(CompositionConstants.PartCreationPolicyMetadataName) &&
((CreationPolicy)part.Metadata[CompositionConstants.PartCreationPolicyMetadataName]) == creationPolicy;
}
开发者ID:doublekill,项目名称:MefContrib,代码行数:14,代码来源:CommonFilters.cs
示例16: InterceptingComposablePartDefinition
public InterceptingComposablePartDefinition(ComposablePartDefinition interceptedPartDefinition, IExportedValueInterceptor valueInterceptor)
{
if (interceptedPartDefinition == null) throw new ArgumentNullException("interceptedPartDefinition");
if (valueInterceptor == null) throw new ArgumentNullException("valueInterceptor");
InterceptedPartDefinition = interceptedPartDefinition;
this.valueInterceptor = valueInterceptor;
}
开发者ID:damonrpayne,项目名称:MefContrib,代码行数:8,代码来源:InterceptingComposablePartDefinition.cs
示例17: InterceptingComposablePartDefinition
public InterceptingComposablePartDefinition(ComposablePartDefinition interceptedPartDefinition, IExportedValueInterceptor valueInterceptor)
{
interceptedPartDefinition.ShouldNotBeNull("interceptedPartDefinition");
valueInterceptor.ShouldNotBeNull("valueInterceptor");
InterceptedPartDefinition = interceptedPartDefinition;
_valueInterceptor = valueInterceptor;
}
开发者ID:glennblock,项目名称:MefContrib,代码行数:8,代码来源:InterceptingComposablePartDefinition.cs
示例18: When_calling_create_part_it_should_create_a_disposable_intercepting_part
public void When_calling_create_part_it_should_create_a_disposable_intercepting_part()
{
var mockInterceptor = new Mock<IExportedValueInterceptor>();
interceptedPartDefinition = AttributedModelServices.CreatePartDefinition(typeof(DisposablePart), null);
interceptingPartDefinition = new InterceptingComposablePartDefinition(interceptedPartDefinition, mockInterceptor.Object);
var part = interceptingPartDefinition.CreatePart();
part.ShouldBeOfType<DisposableInterceptingComposablePart>();
}
开发者ID:doublekill,项目名称:MefContrib,代码行数:8,代码来源:InterceptingComposablePartDefinitionTests.cs
示例19: CachePartDefinition
public IDictionary<string, object> CachePartDefinition(ComposablePartDefinition partDefinition)
{
ComposablePartDefinition reflectionPartDefition = partDefinition as ComposablePartDefinition;
Assumes.NotNull(reflectionPartDefition);
IDictionary<string, object> cache = CompositionCacheServices.WritePartDefinition(reflectionPartDefition, this.WriteAssemblyForTypes);
return cache;
}
开发者ID:ibratoev,项目名称:MEF.NET35,代码行数:8,代码来源:AttributedComposablePartCatalogSite.cs
示例20: GetPartType
public static Lazy<Type> GetPartType(ComposablePartDefinition partDefinition)
{
AddInComposablePartDefinition addinPartDef = partDefinition as AddInComposablePartDefinition;
if (addinPartDef == null)
throw new ArgumentException("Must be of type AddInComposablePartDefinition", "partDefinition");
return ReflectionModelServices.GetPartType(addinPartDef.Definition);
}
开发者ID:ppittle,项目名称:LBi.LostDoc,代码行数:9,代码来源:AddInModelServices.cs
注:本文中的System.ComponentModel.Composition.Primitives.ComposablePartDefinition类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论