本文整理汇总了C#中ITypeDefinition.GetAllBaseTypes方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeDefinition.GetAllBaseTypes方法的具体用法?C# ITypeDefinition.GetAllBaseTypes怎么用?C# ITypeDefinition.GetAllBaseTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeDefinition
的用法示例。
在下文中一共展示了ITypeDefinition.GetAllBaseTypes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OverrideEqualsGetHashCodeMethodsDialog
public OverrideEqualsGetHashCodeMethodsDialog(InsertionContext context, ITextEditor editor, ITextAnchor endAnchor,
ITextAnchor insertionPosition, ITypeDefinition selectedClass, IMethod selectedMethod, AstNode baseCallNode)
: base(context, editor, insertionPosition)
{
if (selectedClass == null)
throw new ArgumentNullException("selectedClass");
InitializeComponent();
this.selectedClass = selectedClass;
this.insertionEndAnchor = endAnchor;
this.selectedMethod = selectedMethod;
this.baseCallNode = baseCallNode;
addIEquatable.Content = string.Format(StringParser.Parse("${res:AddIns.SharpRefactoring.OverrideEqualsGetHashCodeMethods.AddInterface}"),
"IEquatable<" + selectedClass.Name + ">");
string otherMethod = selectedMethod.Name == "Equals" ? "GetHashCode" : "Equals";
addOtherMethod.Content = StringParser.Parse("${res:AddIns.SharpRefactoring.OverrideEqualsGetHashCodeMethods.AddOtherMethod}", new StringTagPair("otherMethod", otherMethod));
addIEquatable.IsEnabled = !selectedClass.GetAllBaseTypes().Any(
type => {
if (!type.IsParameterized || (type.TypeParameterCount != 1))
return false;
if (type.FullName != "System.IEquatable")
return false;
return type.TypeArguments.First().FullName == selectedClass.FullName;
}
);
}
示例2: GetJsClass
private JsClass GetJsClass(ITypeDefinition typeDefinition) {
JsClass result;
if (!_types.TryGetValue(typeDefinition, out result)) {
var semantics = _metadataImporter.GetTypeSemantics(typeDefinition);
if (semantics.GenerateCode) {
var errors = Utils.FindTypeUsageErrors(typeDefinition.GetAllBaseTypes(), _metadataImporter);
if (errors.HasErrors) {
var oldRegion = _errorReporter.Region;
try {
_errorReporter.Region = typeDefinition.Region;
foreach (var ut in errors.UsedUnusableTypes)
_errorReporter.Message(Messages._7500, ut.FullName, typeDefinition.FullName);
foreach (var t in errors.MutableValueTypesBoundToTypeArguments)
_errorReporter.Message(Messages._7539, t.FullName);
}
finally {
_errorReporter.Region = oldRegion;
}
}
result = new JsClass(typeDefinition);
}
else {
result = null;
}
_types[typeDefinition] = result;
}
return result;
}
示例3: GetJsClass
private JsClass GetJsClass(ITypeDefinition typeDefinition) {
JsClass result;
if (!_types.TryGetValue(typeDefinition, out result)) {
if (typeDefinition.Kind == TypeKind.Struct && !_allowUserDefinedStructs) {
var oldRegion = _errorReporter.Region;
_errorReporter.Region = typeDefinition.Region;
_errorReporter.Message(Messages._7998, "user-defined value type (struct)");
_errorReporter.Region = oldRegion;
}
var semantics = _metadataImporter.GetTypeSemantics(typeDefinition);
if (semantics.GenerateCode) {
var unusableTypes = Utils.FindUsedUnusableTypes(typeDefinition.GetAllBaseTypes(), _metadataImporter).ToList();
if (unusableTypes.Count > 0) {
foreach (var ut in unusableTypes) {
var oldRegion = _errorReporter.Region;
_errorReporter.Region = typeDefinition.Region;
_errorReporter.Message(Messages._7500, ut.FullName, typeDefinition.FullName);
_errorReporter.Region = oldRegion;
}
}
result = new JsClass(typeDefinition);
}
else {
result = null;
}
_types[typeDefinition] = result;
}
return result;
}
示例4: AddedBaseType
private bool AddedBaseType(IDifferences differences, ITypeDefinition impl, ITypeDefinition contract)
{
// For interfaces we rely only on the AddedInterface check
if (impl.IsInterface || contract.IsInterface)
return false;
// Base types must be in the same order so we have to compare them in order
List<ITypeReference> implBaseTypes = new List<ITypeReference>(impl.GetAllBaseTypes());
int lastIndex = 0;
foreach (var contractBaseType in contract.GetAllBaseTypes())
{
lastIndex = implBaseTypes.FindIndex(lastIndex, item1BaseType => _typeComparer.Equals(item1BaseType, contractBaseType));
if (lastIndex < 0)
{
differences.AddIncompatibleDifference(this,
"Type '{0}' does not inherit from base type '{1}' in the implementation but it does in the contract.",
contract.FullName(), contractBaseType.FullName());
return true;
}
}
return false;
}
示例5: FindMatchingBase
private FindMethodResult FindMatchingBase(ITypeDefinition type, IMethodDefinition method, out IMethodDefinition resultMethod)
{
resultMethod = null;
if (type == null || method.IsConstructor)
{
return FindMethodResult.NotFound;
}
bool foundMethodWithDifferentReturnType = false;
foreach (var baseType in type.GetAllBaseTypes())
{
FindMethodResult found = FindMethodInCollection(method, baseType.Methods, out resultMethod, false);
if (found == FindMethodResult.Found)
return found;
if (found == FindMethodResult.ReturnTypeChanged)
foundMethodWithDifferentReturnType = true;
}
if (foundMethodWithDifferentReturnType)
return FindMethodResult.ReturnTypeChanged;
return FindMethodResult.NotFound;
}
示例6: GetJsClass
private JsClass GetJsClass(ITypeDefinition typeDefinition)
{
JsClass result;
if (!_types.TryGetValue(typeDefinition, out result)) {
var semantics = _metadataImporter.GetTypeSemantics(typeDefinition);
if (semantics.GenerateCode) {
var unusableTypes = Utils.FindUsedUnusableTypes(typeDefinition.GetAllBaseTypes(), _metadataImporter).ToList();
if (unusableTypes.Count > 0) {
foreach (var ut in unusableTypes) {
var oldRegion = _errorReporter.Region;
_errorReporter.Region = typeDefinition.Region;
_errorReporter.Message(7500, ut.FullName, typeDefinition.FullName);
_errorReporter.Region = oldRegion;
}
result = new JsClass(typeDefinition, "X", ConvertClassType(typeDefinition.Kind), new string[0], null, null);
}
else {
var baseTypes = typeDefinition.GetAllBaseTypes().Where(t => _runtimeLibrary.GetScriptType(t, TypeContext.GenericArgument) != null).ToList();
var baseClass = typeDefinition.Kind != TypeKind.Interface ? _runtimeLibrary.GetScriptType(baseTypes.Last(t => !t.GetDefinition().Equals(typeDefinition) && t.Kind == TypeKind.Class), TypeContext.Inheritance) : null; // NRefactory bug/feature: Interfaces are reported as having System.Object as their base type.
var interfaces = baseTypes.Where(t => !t.GetDefinition().Equals(typeDefinition) && t.Kind == TypeKind.Interface).Select(t => _runtimeLibrary.GetScriptType(t, TypeContext.Inheritance)).Where(t => t != null).ToList();
var typeArgNames = semantics.IgnoreGenericArguments ? null : typeDefinition.TypeParameters.Select(a => _namer.GetTypeParameterName(a)).ToList();
result = new JsClass(typeDefinition, semantics.Name, ConvertClassType(typeDefinition.Kind), typeArgNames, baseClass, interfaces);
}
}
else {
result = null;
}
_types[typeDefinition] = result;
}
return result;
}
示例7: GetBackingFieldName
private string GetBackingFieldName(ITypeDefinition declaringTypeDefinition, string memberName) {
int inheritanceDepth = declaringTypeDefinition.GetAllBaseTypes().Count(b => b.Kind != TypeKind.Interface) - 1;
if (_minimizeNames) {
int count;
_backingFieldCountPerType.TryGetValue(declaringTypeDefinition, out count);
count++;
_backingFieldCountPerType[declaringTypeDefinition] = count;
return string.Format(CultureInfo.InvariantCulture, "${0}${1}", inheritanceDepth, count);
}
else {
return string.Format(CultureInfo.InvariantCulture, "${0}${1}Field", inheritanceDepth, memberName);
}
}