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


C# IType.ToString方法代码示例

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


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

示例1: AssertToStringGoesThroughEntityFormatter

        protected static void AssertToStringGoesThroughEntityFormatter(IType entity)
        {
            var mock = new Mock<EntityFormatter>();
            new ClosedEnvironment(mock.Object).Run(() =>
             	{
             		mock.Setup(formatter => formatter.FormatType(entity))
             			.Returns("")
             			.AtMostOnce();

             		entity.ToString();

             		mock.VerifyAll();
             	});
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:14,代码来源:EntityFormatterTestBase.cs

示例2: ResloveExpression

        public static List<Error> ResloveExpression(Node root, Expression expr, out IType type)
        {
            var errors = new List<Error>();

            var list = ExpressionBuilder.Build(expr);

            foreach (var exprNode in list.Where(exprNode => exprNode.ExprType == ExprType.Var))
            {
                errors.AddRange(IdentifierResolver.ResloveIdentifierType(root, exprNode.Tokens, out type));
                exprNode.Type = type;
            }

            type = list.First().Type;
            foreach (var node in list)
            {
                if ((node.Type != null) && (node.Type.ToString() != type.ToString()))
                {
                    errors.Add(new Error(root.GetSourceIdentifier(), node.Tokens.First(),
                                         string.Format(ErrorMessages.TypeMismatch, node.Type.ToString(), type.ToString())));
                }
            }

            return errors;
        }
开发者ID:BooMWax,项目名称:ifmo,代码行数:24,代码来源:ExpressionResolver.cs

示例3: AppendReturnType

		void AppendReturnType (StringBuilder result, CodeGenerationOptions options, IType type)
		{
			if (type == null)
				throw new ArgumentNullException ("type");
			var implementingType = options.Part;
			var loc = implementingType.Region.End;
			
			var pf = implementingType.ParsedFile;
			var file = pf as CSharpParsedFile;
			var resolved = type;
			if (resolved.Kind == TypeKind.Unknown) {
				result.Append (type.ToString ());
				return;
			}
			var def = type.GetDefinition ();
			if (def != null) {
				using (var stringWriter = new System.IO.StringWriter ()) {
					var formatter = new TextWriterOutputFormatter (stringWriter);
					stringWriter.NewLine = EolMarker; 
					var visitor = new CSharpOutputVisitor (formatter, FormattingOptionsFactory.CreateMono ());
					var shortType = CreateShortType (def.Compilation, file, loc, resolved);
					shortType.AcceptVisitor (visitor);
					
					var typeString = stringWriter.ToString ();
					if (typeString.StartsWith ("global::"))
						typeString = typeString.Substring ("global::".Length);
					result.Append (typeString);
				}
			} else {
				result.Append (new ICSharpCode.NRefactory.CSharp.CSharpAmbience ().ConvertType (type));
			}
		}
开发者ID:sparek,项目名称:monodevelop,代码行数:32,代码来源:CSharpCodeGenerator.cs

示例4: MakeString

 private static string MakeString(IType type)
 {
     switch (type.GetTypeInfo())
     {
         case TypeInfo.Integer:
             return "int";
         case TypeInfo.Real:
             return "double";
         case TypeInfo.Ref:
             return type.ToString();
         default:
             return "";
     }
 }
开发者ID:BooMWax,项目名称:ifmo,代码行数:14,代码来源:CSharpEmitter.cs

示例5: GetCorrectConstructor

        IConstructor GetCorrectConstructor(Node sourceNode, IType type, ExpressionCollection arguments)
        {
            IConstructor[] constructors = type.GetConstructors().ToArray();
            if (null != constructors && constructors.Length > 0)
                return (IConstructor)GetCorrectCallableReference(sourceNode, arguments, constructors);

            if (!IsError(type))
            {
                if (null == (type as IGenericParameter))
                {
                    Error(CompilerErrorFactory.NoApropriateConstructorFound(sourceNode, type.ToString(), GetSignature(arguments)));
                }
                else
                {
                    Error(CompilerErrorFactory.CannotCreateAnInstanceOfGenericParameterWithoutDefaultConstructorConstraint(sourceNode, type.ToString()));
                }
            }
            return null;
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:19,代码来源:ProcessMethodBodies.cs

示例6: CheckGeneratorReturnType

        void CheckGeneratorReturnType(Method method, IType returnType)
        {
            bool validReturnType =
                (TypeSystemServices.IEnumerableType == returnType ||
                 TypeSystemServices.IEnumeratorType == returnType ||
                 TypeSystemServices.IsSystemObject(returnType) ||
                 TypeSystemServices.IsGenericGeneratorReturnType(returnType));

            if (!validReturnType)
            {
                Error(CompilerErrorFactory.InvalidGeneratorReturnType(method.ReturnType, returnType.ToString()));
            }
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:13,代码来源:ProcessMethodBodies.cs

示例7: AssertTypeCompatibility

        bool AssertTypeCompatibility(Node sourceNode, IType expectedType, IType actualType)
        {
            if (IsError(expectedType) || IsError(actualType))
                return false;

            if (expectedType.IsPointer && actualType.IsPointer)
                return true; //if both types are unmanaged pointers casting is always possible

            if (TypeSystemServices.IsNullable(expectedType) && Null.Default == actualType)
                return true;

            if (!CanBeReachedFrom(sourceNode, expectedType, actualType))
            {
                Error(CompilerErrorFactory.IncompatibleExpressionType(sourceNode, expectedType.ToString(), actualType.ToString()));
                return false;
            }

            return true;
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:19,代码来源:ProcessMethodBodies.cs

示例8: AssertCanCreateInstance

 bool AssertCanCreateInstance(Node sourceNode, IType type)
 {
     if (type.IsInterface)
     {
         Error(CompilerErrorFactory.CantCreateInstanceOfInterface(sourceNode, type.ToString()));
         return false;
     }
     if (type.IsEnum)
     {
         Error(CompilerErrorFactory.CantCreateInstanceOfEnum(sourceNode, type.ToString()));
         return false;
     }
     if (type.IsAbstract)
     {
         Error(CompilerErrorFactory.CantCreateInstanceOfAbstractType(sourceNode, type.ToString()));
         return false;
     }
     if (!(type is GenericConstructedType)
         &&
           ((type.GenericInfo != null
            && type.GenericInfo.GenericParameters.Length > 0)
        || (type.ConstructedInfo != null
            && !type.ConstructedInfo.FullyConstructed))
        )
     {
         Error(CompilerErrorFactory.GenericTypesMustBeConstructedToBeInstantiated(sourceNode));
         return false;
     }
     return true;
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:30,代码来源:ProcessMethodBodies.cs

示例9: NamedArgumentNotFound

 protected virtual void NamedArgumentNotFound(IType type, ReferenceExpression name)
 {
     Error(name, CompilerErrorFactory.NotAPublicFieldOrProperty(name, type.ToString(), name.Name));
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:4,代码来源:ProcessMethodBodies.cs

示例10: SyntheticType

        public SyntheticType(IType baseType)
        {
            if (!ShouldBeSyntheticType(baseType))
            {
                throw new ArgumentException("{0} is not a valid type for SyntheticType", baseType.ToString());
            }

            // gosdk: Ensure the generated name does not collide with existing type names
            BaseType = baseType;

            IType elementType = getElementType(baseType);

            if (elementType is PrimaryType)
            {
                var type = (elementType as PrimaryType).Type;
                if (type == KnownPrimaryType.Boolean)
                {
                    Name += "Bool";
                }
                else if (type == KnownPrimaryType.ByteArray)
                {
                    Name += "ByteArray";
                }
                else if (type == KnownPrimaryType.Double)
                {
                    Name += "Float64";
                }
                else if (type == KnownPrimaryType.Int)
                {
                    Name += "Int32";
                }
                else if (type == KnownPrimaryType.Long)
                {
                    Name += "Int64";
                }
                else if (type == KnownPrimaryType.Stream)
                {
                    Name += "ReadCloser";
                }
                else if (type == KnownPrimaryType.String)
                {
                    Name += "String";
                }
                else if (type == KnownPrimaryType.TimeSpan)
                {
                    Name += "TimeSpan";
                }
                else if (type == KnownPrimaryType.Base64Url)
                {
                    Name += "Base64Url";
                }
                else if (type == KnownPrimaryType.UnixTime)
                {
                    Name += "UnixTime";
                }
            }
            else if (elementType is InterfaceType)
            {
                Name += "Object";
            }
            else if (elementType is PackageType)
            {
                Name += (elementType as PackageType).Member;
            }
            else if (elementType is EnumType)
            {
                Name += "String";
            }
            else
            {
                Name += elementType.Name;
            }

            Property p = new Property();
            p.SerializedName = "value";
            p.Name = "Value";
            p.Type = baseType;
            Properties.Add(p);
        }
开发者ID:jhancock93,项目名称:autorest,代码行数:79,代码来源:SyntheticType.cs

示例11: GetScriptType

 public JsExpression GetScriptType(IType type, TypeContext context)
 {
     if (type.Kind == TypeKind.Delegate) {
         return _createTypeReferenceExpression(KnownTypeReference.Delegate);
     }
     else if (type.TypeParameterCount > 0 && !(type is ParameterizedType) && context == TypeContext.TypeOf) {
         // This handles open generic types ( typeof(C<,>) )
         return _createTypeReferenceExpression(type.GetDefinition().ToTypeReference());
     }
     else if (type.Kind == TypeKind.Enum && (context == TypeContext.CastTarget || context == TypeContext.InvokeConstructor)) {
         var def = type.GetDefinition();
         return _createTypeReferenceExpression(def.EnumUnderlyingType.ToTypeReference());
     }
     else if (type.Kind == TypeKind.Array) {
         return _createTypeReferenceExpression(KnownTypeReference.Array);
     }
     else if (type is ITypeParameter) {
         return JsExpression.Identifier(_getTypeParameterName((ITypeParameter)type));
     }
     else if (type is ParameterizedType) {
         var pt = (ParameterizedType)type;
         var def = pt.GetDefinition();
         var sem = _metadataImporter.GetTypeSemantics(def);
         if (sem.Type == TypeScriptSemantics.ImplType.NormalType && !sem.IgnoreGenericArguments)
             return JsExpression.Invocation(JsExpression.Member(_createTypeReferenceExpression(KnownTypeReference.Type), "makeGenericType"), _createTypeReferenceExpression(type.GetDefinition().ToTypeReference()), JsExpression.ArrayLiteral(pt.TypeArguments.Select(a => GetScriptType(a, TypeContext.GenericArgument))));
         else
             return GetScriptType(def, context);
     }
     else if (type is ITypeDefinition) {
         var td = (ITypeDefinition)type;
         if (_metadataImporter.IsSerializable(td) && (context == TypeContext.CastTarget || context == TypeContext.Inheritance)) {
             return null;
         }
         else if (context != TypeContext.UseStaticMember && context != TypeContext.InvokeConstructor && !_metadataImporter.IsRealType(td)) {
             if (context == TypeContext.CastTarget || context == TypeContext.Inheritance)
                 return null;
             else
                 return _createTypeReferenceExpression(KnownTypeReference.Object);
         }
         else {
             var sem = _metadataImporter.GetTypeSemantics(td);
             var jsref = _createTypeReferenceExpression(td.ToTypeReference());
             if (td.TypeParameterCount > 0 && !sem.IgnoreGenericArguments) {
                 // This handles the case of resolving the current type, eg. to access a static member.
                 return JsExpression.Invocation(JsExpression.Member(_createTypeReferenceExpression(KnownTypeReference.Type), "makeGenericType"), _createTypeReferenceExpression(type.GetDefinition().ToTypeReference()), JsExpression.ArrayLiteral(td.TypeParameters.Select(a => GetScriptType(a, TypeContext.GenericArgument))));
             }
             else {
                 return jsref;
             }
         }
     }
     else if (type.Kind == TypeKind.Anonymous || type.Kind == TypeKind.Null || type.Kind == TypeKind.Dynamic) {
         return _createTypeReferenceExpression(KnownTypeReference.Object);
     }
     else {
         throw new InvalidOperationException("Could not determine the script type for " + type.ToString() + ", context " + context);
     }
 }
开发者ID:koczkatamas,项目名称:SaltarelleCompiler,代码行数:58,代码来源:ScriptSharpRuntimeLibrary.cs

示例12: TypeWriter

 public static void TypeWriter(StringWriter writer, IType iType)
 {
     writer.Write(iType.ToString());
 }
开发者ID:lzybkr,项目名称:CppCliReflector,代码行数:4,代码来源:Helper.cs

示例13: GetType

 private static Type GetType(IType type)
 {
     switch (type.GetTypeInfo())
     {
         case TypeInfo.Integer:
             return typeof (int);
         case TypeInfo.Real:
             return typeof (double);
         case TypeInfo.Ref:
             //return Type.GetType(type.ToString());
             var key = RecSym.Keys.First(x => x.Name.Text == type.ToString());
             return RecSym[key]; //.UnderlyingSystemType;
         default:
             return null;
     }
 }
开发者ID:BooMWax,项目名称:ifmo,代码行数:16,代码来源:Emitter.cs

示例14: AssertTypeCompatibility

        bool AssertTypeCompatibility(Node sourceNode, IType expectedType, IType actualType)
        {
            if (TypeSystemServices.IsError(expectedType)
                || TypeSystemServices.IsError(actualType))
            {
                return false;
            }

            if (!TypeSystemServices.AreTypesRelated(expectedType, actualType))
            {
                Error(CompilerErrorFactory.IncompatibleExpressionType(sourceNode, expectedType.ToString(), actualType.ToString()));
                return false;
            }
            return true;
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:15,代码来源:ProcessMethodBodies.cs

示例15: GetTypeReferenceString

 protected override string GetTypeReferenceString(IType reference, OutputSettings settings)
 {
     return reference.ToString ();
 }
开发者ID:Kalnor,项目名称:monodevelop,代码行数:4,代码来源:NetAmbience.cs


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