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


C# AstType.ToString方法代码示例

本文整理汇总了C#中AstType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# AstType.ToString方法的具体用法?C# AstType.ToString怎么用?C# AstType.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AstType的用法示例。


在下文中一共展示了AstType.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsSkipType

        /// <summary>
        /// Check if the type should be skipped to generate 'Contract.Ensures' and 'Contract.Requires' statemets.
        /// </summary>
        /// <param name="type">the type</param>
        /// <returns>true: skip type</returns>
        public static bool IsSkipType(AstType type)
        {
            string typeName = type.HasChildren ? type.FirstChild.ToString() : type.ToString();

            if (SkipTypes == null)
            {
                return false;
            }

            return SkipTypes.Any(s => s.ToUpper() == typeName.ToUpper());
        }
开发者ID:kenyamat,项目名称:ICGenerator,代码行数:16,代码来源:Generator.cs

示例2: AreTypesEqual

        /// <summary>
        /// Determines whether the types are equal.
        /// </summary>
        /// <param name="expectedType">The expected type.</param>
        /// <param name="typeReference">The type reference.</param>
        /// <returns><c>true</c> if parameters are equal, otherwise <c>false</c>.</returns>
        private static bool AreTypesEqual(string expectedType, AstType typeReference)
        {
            SimpleType simpleType = typeReference as SimpleType; // Generic types

            if (simpleType != null)
            {
                if (simpleType.TypeArguments.Count == 1)
                {
                    typeReference = simpleType.TypeArguments.First();
                }
                else if (simpleType.TypeArguments.Count >= 2)
                {
                    // This can't be handled correctly
                    return true;
                }
            }

            ComposedType composedType = typeReference as ComposedType; // Arrays

            if (composedType != null)
            {
                if (!expectedType.EndsWith("[]", StringComparison.Ordinal))
                {
                    return false;
                }
                else
                {
                    expectedType = expectedType.Replace("[]", string.Empty);
                    typeReference = composedType.BaseType;
                }
            }

            if (expectedType.StartsWith("ref ", StringComparison.Ordinal))
            {
                expectedType = expectedType.Replace("ref ", string.Empty);
            }

            string typeReplacement;
            if (TypeReplacements.TryGetValue(expectedType, out typeReplacement))
            {
                expectedType = typeReplacement;
            }

            // Validate
            string typeName = typeReference.ToString();
            if (expectedType.Equals(typeName, StringComparison.OrdinalIgnoreCase)
                || ("System." + expectedType).Equals(typeName, StringComparison.OrdinalIgnoreCase)
                || expectedType.Substring(expectedType.LastIndexOf('.') + 1).Equals(typeName, StringComparison.OrdinalIgnoreCase))
            {
                return true;
            }

            return false;
        }
开发者ID:tigerjibo,项目名称:ReportGenerator,代码行数:60,代码来源:PartCoverMethodElement.cs

示例3: ReplaceType

        void ReplaceType(AstType type)
        {
            int length = type.EndLocation.Column - type.StartLocation.Column;
            int offset = type.StartLocation.Column - 1;

            ReplaceType (type.ToString (), offset, length);
        }
开发者ID:0xb1dd1e,项目名称:debugger-libs,代码行数:7,代码来源:NRefactoryExpressionResolverVisitor.cs

示例4: CreateTypeCompletionData

		IEnumerable<ICompletionData> CreateTypeCompletionData(IType hintType, AstType hintTypeAst)
		{
			var wrapper = new CompletionDataWrapper(this);
			var state = GetState();
			Func<IType, IType> pred = null;
			if (hintType != null) {
				
				if (hintType.Kind != TypeKind.Unknown) {
					var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);
					pred = t => {
						// check if type is in inheritance tree.
						if (hintType.GetDefinition() != null && !t.GetDefinition().IsDerivedFrom(hintType.GetDefinition())) {
							return null;
						}
						if (t.Kind == TypeKind.Interface && hintType.Kind != TypeKind.Array) {
							return null;
						}
						// check for valid constructors
						if (t.GetConstructors().Count() > 0) {
							bool isProtectedAllowed = currentType != null ? currentType.Resolve(ctx).GetDefinition().IsDerivedFrom(t.GetDefinition()) : false;
							if (!t.GetConstructors().Any(m => lookup.IsAccessible(m, isProtectedAllowed)))
								return null;
						}

						var typeInference = new TypeInference(Compilation);
						typeInference.Algorithm = TypeInferenceAlgorithm.ImprovedReturnAllResults;
						var inferedType = typeInference.FindTypeInBounds(new [] { t }, new [] { hintType });
						wrapper.AddType(inferedType, amb.ConvertType(inferedType));
						return null;
					};
					if (!(hintType.Kind == TypeKind.Interface && hintType.Kind != TypeKind.Array)) {
						DefaultCompletionString = GetShortType(hintType, GetState());
						wrapper.AddType(hintType, DefaultCompletionString);
					}
					if (hintType is ParameterizedType && hintType.TypeParameterCount == 1 && hintType.FullName == "System.Collections.Generic.IEnumerable") {
						var arg = ((ParameterizedType)hintType).TypeArguments.FirstOrDefault();
						var array = new ArrayTypeReference(arg.ToTypeReference(), 1).Resolve(ctx);
						wrapper.AddType(array, amb.ConvertType(array));
					}
				} else {
					DefaultCompletionString = hintTypeAst.ToString();
					wrapper.AddType(hintType, DefaultCompletionString);
				}
			} 
			AddTypesAndNamespaces(wrapper, state, null, pred, m => false);
			if (hintType == null || hintType == SpecialType.UnknownType)
				AddKeywords(wrapper, primitiveTypesKeywords.Where(k => k != "void"));
			CloseOnSquareBrackets = true;
			AutoCompleteEmptyMatch = true;
			return wrapper.Result;
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:51,代码来源:CSharpCompletionEngine.cs

示例5: GenerateNamespaceString

 string GenerateNamespaceString(AstType astType)
 {
     return astType.ToString();
 }
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:4,代码来源:AstCsToJson.cs


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