本文整理汇总了C#中System.ComponentModel.Composition.Primitives.ExportDefinition类的典型用法代码示例。如果您正苦于以下问题:C# ExportDefinition类的具体用法?C# ExportDefinition怎么用?C# ExportDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExportDefinition类属于System.ComponentModel.Composition.Primitives命名空间,在下文中一共展示了ExportDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CatalogExport
public CatalogExport(CatalogExportProvider catalogExportProvider,
ComposablePartDefinition partDefinition, ExportDefinition definition)
{
this._catalogExportProvider = catalogExportProvider;
this._partDefinition = partDefinition;
this._definition = definition;
}
示例2: PartCreatorExport
public PartCreatorExport(CatalogExportProvider catalogExportProvider, ComposablePartDefinition partDefinition, ExportDefinition exportDefinition)
{
this._catalogExportProvider = catalogExportProvider;
this._partDefinition = partDefinition;
this._exportDefinition = exportDefinition;
this._partCreatorExportDefinition = new PartCreatorExportDefinition(this._exportDefinition);
}
示例3: ExportingMember
public ExportingMember(ExportDefinition definition, ReflectionMember member)
{
Assumes.NotNull(definition, member);
this._definition = definition;
this._member = member;
}
示例4: IsMatch
protected bool IsMatch(ExportDefinition exportDefinition)
{
// If the feature is not enabled don't allow it
if (exportDefinition.Metadata.ContainsKey("EnabledFeatures"))
{
if (!EnabledFeatures.IsEnabled((string)exportDefinition.Metadata["EnabledFeatures"]))
{
return false;
}
}
// If the feature is turned off in the options don't allow it
if (exportDefinition.Metadata.ContainsKey("FeatureEnabled"))
{
if (!OptionApi.GetBool((string)exportDefinition.Metadata["FeatureEnabled"]))
{
return false;
}
}
if (exportDefinition.Metadata.ContainsKey("SupportedApplication"))
{
var applicationType = ((ApplicationType)exportDefinition.Metadata["SupportedApplication"]);
return applicationType.HasFlag(_applicationType);
}
return false;
}
示例5: XElementExportProvider
/// <summary>
/// Initializes a new instance of the <see cref="XElementExportProvider"/> class.
/// Includes *.xml and *.config by default.
/// </summary>
/// <param name="path">The path. Defaults to Directory.GetCurrentDirectory()</param>
/// <param name="filters">A list of additional file filters to include.</param>
public XElementExportProvider(string path = null, IEnumerable<string> filters = null)
{
if (path == null)
{
path = Directory.GetCurrentDirectory();
}
List<string> include = new List<string>(new[] { "*.xml", "*.config" });
if (filters != null)
{
foreach (string filter in filters.Where(filter => !string.IsNullOrWhiteSpace(filter)).Where(filter => !include.Contains(filter)))
{
include.Add(filter);
}
}
List<string> xmlFiles = new List<string>(include.SelectMany(ext => Directory.GetFiles(path, ext)));
_exportsDictionary = xmlFiles.Select(filePath => new FileInfo(filePath)).ToDictionary(
fileInfo => fileInfo.Name,
fileInfo =>
{
ExportDefinition def = new ExportDefinition(fileInfo.Name, null);
Export e = new Export(def, () => XElement.Load(fileInfo.FullName));
return e;
});
}
示例6: CreateCannotGetExportedValue
public static CompositionException CreateCannotGetExportedValue(ComposablePart part, ExportDefinition definition, Exception innerException)
{
Assumes.NotNull(part, definition, innerException);
return new CompositionException(
ErrorBuilder.CreateCannotGetExportedValue(part, definition, innerException));
}
示例7: WebScopedComposablePart
protected WebScopedComposablePart(ComposablePart composablePart)
{
_composablePart = composablePart;
_exportDef = composablePart.ExportDefinitions.First();
_key = ((string)_exportDef.Metadata["ExportTypeIdentity"]).Replace('.', '_');
}
示例8: 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);
}
示例9: IsConstraintSatisfiedBy
public override bool IsConstraintSatisfiedBy(ExportDefinition exportDefinition)
{
if (!base.IsConstraintSatisfiedBy(exportDefinition))
{
return false;
}
return PartCreatorExportDefinition.IsProductConstraintSatisfiedBy(this._productImportDefinition, exportDefinition);
}
示例10: GetExportedObject
public override object GetExportedObject(ExportDefinition definition)
{
Guard.Against(!definition.Equals(_export.Definition),
Resources.Error_PartDoesNotContainAnExportForContract,
definition.ContractName);
return _export.GetExportedObject();
}
示例11: ReflectionMemberExportDefinition
public ReflectionMemberExportDefinition(LazyMemberInfo member, ExportDefinition exportDefinition, ICompositionElement origin)
{
Assumes.NotNull(exportDefinition);
this._member = member;
this._exportDefinition = exportDefinition;
this._origin = origin;
}
示例12: GetExportedObject_Guards_Against_Non_Matching_ExportDefinition
public void GetExportedObject_Guards_Against_Non_Matching_ExportDefinition()
{
object expected = new object();
Export export = new Export("Foo", new Dictionary<string, object>(), () => expected);
ExportDefinition nonMatching = new ExportDefinition("Bar", new Dictionary<string, object>());
ExceptionAssert.Guards(() => new SingleExportComposablePart(export).GetExportedObject(nonMatching),
TargetResources.Error_PartDoesNotContainAnExportForContract, nonMatching.ContractName);
}
示例13: Constructor2_NullAsMetadataArgument_ShouldSetMetadataPropertyToReadOnlyDictionary
public void Constructor2_NullAsMetadataArgument_ShouldSetMetadataPropertyToReadOnlyDictionary()
{
var definition = new ExportDefinition("Contract", (IDictionary<string, object>)null);
ExceptionAssert.Throws<NotSupportedException>(() =>
{
definition.Metadata["Value"] = "Value";
});
}
示例14: GetExportedValue
public override object GetExportedValue(ExportDefinition definition)
{
Requires.NotNull(definition, "definition");
if (definition != _export.Definition)
{
throw ExceptionBuilder.CreateExportDefinitionNotOnThisComposablePart("definition");
}
return _export.Value;
}
示例15: GetExportedValue
public override object GetExportedValue(ExportDefinition definition)
{
if (definition == null)
throw new ArgumentNullException("definition");
var rdef = (RubyExportDefinition)definition;
var instance = GetOrCreateInstance();
return rdef.GetExportedObject(instance);
}