本文整理汇总了C#中IKVM.Reflection.Type.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Type.ToString方法的具体用法?C# Type.ToString怎么用?C# Type.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKVM.Reflection.Type
的用法示例。
在下文中一共展示了Type.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportType
TypeSpec ImportType (MetaType type, DynamicTypeReader dtype)
{
if (type.HasElementType) {
var element = type.GetElementType ();
++dtype.Position;
var spec = ImportType (element, dtype);
if (type.IsArray)
return ArrayContainer.MakeType (module, spec, type.GetArrayRank ());
if (type.IsByRef)
return ReferenceContainer.MakeType (module, spec);
if (type.IsPointer)
return PointerContainer.MakeType (module, spec);
throw new NotImplementedException ("Unknown element type " + type.ToString ());
}
TypeSpec compiled_type;
if (compiled_types.TryGetValue (type, out compiled_type)) {
if (compiled_type.BuiltinType == BuiltinTypeSpec.Type.Object && dtype.IsDynamicObject ())
return module.Compiler.BuiltinTypes.Dynamic;
return compiled_type;
}
return CreateType (type, dtype, true);
}
示例2: ImportType
TypeSpec ImportType (MetaType type, DynamicTypeReader dtype)
{
if (type.HasElementType) {
var element = type.GetElementType ();
++dtype.Position;
var spec = ImportType (element, dtype);
if (type.IsArray)
return ArrayContainer.MakeType (module, spec, type.GetArrayRank ());
if (type.IsByRef)
return ReferenceContainer.MakeType (module, spec);
if (type.IsPointer)
return PointerContainer.MakeType (module, spec);
throw new NotImplementedException ("Unknown element type " + type.ToString ());
}
return CreateType (type, dtype, true);
}
示例3: FormatType
// TODO: fine tune this so that our output is less verbose. We need to figure
// out a way to do this while not making things confusing.
string FormatType (Type t)
{
if (t == null)
return "";
string type = GetFullName (t);
if (type == null)
return t.ToString ();
if (!type.StartsWith ("System.")) {
if (type.IndexOf (".") == -1)
return type;
if (t.GetNamespace () == this.t.GetNamespace ())
return t.Name;
return type;
}
if (t.HasElementType) {
Type et = t.GetElementType ();
if (t.IsArray)
return FormatType (et) + " []";
if (t.IsPointer)
return FormatType (et) + " *";
if (t.IsByRef)
return "ref " + FormatType (et);
}
switch (type) {
case "System.Byte": return "byte";
case "System.SByte": return "sbyte";
case "System.Int16": return "short";
case "System.Int32": return "int";
case "System.Int64": return "long";
case "System.UInt16": return "ushort";
case "System.UInt32": return "uint";
case "System.UInt64": return "ulong";
case "System.Single": return "float";
case "System.Double": return "double";
case "System.Decimal": return "decimal";
case "System.Boolean": return "bool";
case "System.Char": return "char";
case "System.String": return "string";
case "System.Object": return "object";
case "System.Void": return "void";
}
if (type.LastIndexOf(".") == 6)
return type.Substring(7);
//
// If the namespace of the type is the namespace of what
// we are printing (or is a member of one if its children
// don't print it. This basically means that in C# we would
// automatically get the namespace imported by virtue of the
// namespace {} block.
//
if (this.t.Namespace.StartsWith (t.Namespace + ".") || t.Namespace == this.t.Namespace)
return type.Substring (t.Namespace.Length + 1);
return type;
}