本文整理汇总了C#中CompositionContract.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# CompositionContract.Equals方法的具体用法?C# CompositionContract.Equals怎么用?C# CompositionContract.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompositionContract
的用法示例。
在下文中一共展示了CompositionContract.Equals方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetExportDescriptors
public override IEnumerable<ExportDescriptorPromise> GetExportDescriptors(CompositionContract contract, DependencyAccessor descriptorAccessor)
{
if (!contract.Equals(_supportedContract))
return NoExportDescriptors;
var implementations = descriptorAccessor.ResolveDependencies("test for existing", contract, false);
if (implementations.Any())
return NoExportDescriptors;
return new[] { new ExportDescriptorPromise(contract, "test metadataProvider", false, NoDependencies, _ => ExportDescriptor.Create((c, o) => DefaultObject, NoMetadata)) };
}
示例2: GetExportDescriptors
public override IEnumerable<ExportDescriptorPromise> GetExportDescriptors(CompositionContract contract, DependencyAccessor definitionAccessor)
{
if (!contract.Equals(s_currentScopeContract))
return NoExportDescriptors;
return new[] { new ExportDescriptorPromise(
contract,
typeof(CompositionContext).Name,
true,
NoDependencies,
_ => ExportDescriptor.Create((c, o) => c, NoMetadata)) };
}
示例3: IsSupportedContract
protected bool IsSupportedContract(CompositionContract contract)
{
if (contract.ContractType != contractType || contract.ContractName != contractName)
return false;
if (contract.MetadataConstraints != null) {
var subsetOfConstraints = contract.MetadataConstraints.Where(c => metadata.ContainsKey(c.Key)).ToDictionary(c => c.Key, c => metadata[c.Key]);
var constrainedSubset = new CompositionContract(contract.ContractType, contract.ContractName,
subsetOfConstraints.Count == 0 ? null : subsetOfConstraints);
if (!contract.Equals(constrainedSubset))
return false;
}
return true;
}
示例4: AContractWithConstraintIsNotEqualToAContractWithoutConstraint
public void AContractWithConstraintIsNotEqualToAContractWithoutConstraint()
{
var first = new CompositionContract(typeof(string), null, new Dictionary<string, object> { { "A", 1 } });
var second = new CompositionContract(typeof(string));
Assert.False(first.Equals(second));
}
示例5: ConstraintsWithEquivalentKeysAndValuesAreEqual
public void ConstraintsWithEquivalentKeysAndValuesAreEqual()
{
var mcd1 = new CompositionContract(s_defaultContractType, null, new Dictionary<string, object> { { "A", new[] { "B" } } });
var mcd2 = new CompositionContract(s_defaultContractType, null, new Dictionary<string, object> { { "A", new[] { "B" } } });
Assert.True(mcd1.Equals(mcd2));
}
示例6: DiscoverConstrainedParts
// If the contract has metadata constraints, look for exports with matching metadata.
private void DiscoverConstrainedParts(CompositionContract contract)
{
if (contract.MetadataConstraints != null)
{
var unconstrained = new CompositionContract(contract.ContractType, contract.ContractName);
DiscoverGenericParts(unconstrained);
ICollection<DiscoveredExport> forKey;
if (_discoveredParts.TryGetValue(unconstrained, out forKey))
{
foreach (var export in forKey)
{
var subsettedConstraints = contract.MetadataConstraints.Where(c => export.Metadata.ContainsKey(c.Key)).ToDictionary(c => c.Key, c => export.Metadata[c.Key]);
if (subsettedConstraints.Count != 0)
{
var constrainedSubset = new CompositionContract(unconstrained.ContractType, unconstrained.ContractName, subsettedConstraints);
if (constrainedSubset.Equals(contract))
AddDiscoveredExport(export, contract);
}
}
}
}
}