当前位置: 首页>>代码示例>>C#>>正文


C# ITypeDefinition.GetAllBaseTypes方法代码示例

本文整理汇总了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;
				}
			);
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:31,代码来源:OverrideEqualsGetHashCodeMethodsDialog.xaml.cs

示例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;
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:28,代码来源:Compiler.cs

示例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;
		}
开发者ID:pdavis68,项目名称:SaltarelleCompiler,代码行数:30,代码来源:Compiler.cs

示例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;
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:25,代码来源:CannotRemoveBaseTypeOrInterface.cs

示例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;
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:23,代码来源:MembersMustExist.cs

示例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;
        }
开发者ID:jack128,项目名称:SaltarelleCompiler,代码行数:33,代码来源:Compiler.cs

示例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);
			}
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:14,代码来源:MetadataImporter.cs


注:本文中的ITypeDefinition.GetAllBaseTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。