本文整理汇总了C#中CompositionContract.ChangeType方法的典型用法代码示例。如果您正苦于以下问题:C# CompositionContract.ChangeType方法的具体用法?C# CompositionContract.ChangeType怎么用?C# CompositionContract.ChangeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompositionContract
的用法示例。
在下文中一共展示了CompositionContract.ChangeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangingTheTypeOfAContractPreservesTheContractName
public void ChangingTheTypeOfAContractPreservesTheContractName()
{
var name = "a";
var c = new CompositionContract(typeof(object), name);
var d = c.ChangeType(typeof(AType));
Assert.Equal(name, d.ContractName);
}
示例2: ChangingTheTypeOfAContractChangesTheContractType
public void ChangingTheTypeOfAContractChangesTheContractType()
{
var c = new CompositionContract(typeof(object));
var d = c.ChangeType(typeof(AType));
Assert.Equal(typeof(AType), d.ContractType);
}
示例3: DiscoverGenericParts
// If the contract is a closed generic, look for open generics
// that close it.
private void DiscoverGenericParts(CompositionContract contract)
{
if (!contract.ContractType.IsConstructedGenericType)
return;
var gtd = contract.ContractType.GetGenericTypeDefinition();
var openGenericContract = contract.ChangeType(gtd);
ICollection<DiscoveredExport> openGenericParts;
if (!_discoveredParts.TryGetValue(openGenericContract, out openGenericParts))
return;
var typeArguments = contract.ContractType.GenericTypeArguments;
foreach (var open in openGenericParts)
{
DiscoveredPart closed;
if (open.Part.TryCloseGenericPart(typeArguments, out closed))
AddDiscoveredPart(closed);
}
}