本文整理汇总了C#中Type.GetTypeReferenceName方法的典型用法代码示例。如果您正苦于以下问题:C# Type.GetTypeReferenceName方法的具体用法?C# Type.GetTypeReferenceName怎么用?C# Type.GetTypeReferenceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type.GetTypeReferenceName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnumerateProperties
IEnumerable<PropertyInfo> EnumerateProperties(Type type)
{
foreach (var p in type.GetProperties (flags)) {
// TextEditInfo has case-conflicting properties (e.g. position and Position). Do not generate member-collision.
if (Char.IsUpper (p.Name [0]) && type.GetProperty (Char.ToLower (p.Name [0]) + p.Name.Substring (1)) != null)
continue;
// It is not really doable or at least very easy to support
// callbacks. So, ignore them so far.
if (IsCallType (p.PropertyType))
continue;
// FIXME: in this type, there are complicated variable between object and call (Action/Func), so I disabled all members at all.
if (type.GetTypeReferenceName () == "AstWalkerDetailCallback")
continue;
yield return p;
}
}
示例2: EnumerateMethods
IEnumerable<MethodInfo> EnumerateMethods(Type type)
{
foreach (var m in type.GetMethods (flags)) {
// It is not really doable or at least very easy to support
// callbacks. So, ignore them so far.
if (IsCallType (m.ReturnType) || m.GetParameters ().Select (p => p.ParameterType).Any (t => IsCallType (t)))
continue;
// FIXME: in this type, there are complicated variable between object and call (Action/Func), so I disabled all members at all.
if (type.GetTypeReferenceName () == "AstWalkerDetailCallback")
continue;
yield return m;
}
}
示例3: GetImplementedType
string GetImplementedType(Type type, bool addImpl = false)
{
if (type == typeof (void))
return "void";
if (type == typeof (string))
return "string";
if (type == typeof (bool))
return "bool";
if (type == typeof (double))
return "double";
if (type.IsArray)
return "TypeScriptArray<" + GetImplementedType (type.GetElementType ()) + ">";
if (type.IsGenericParameter)
return type.Name;
switch (type.GetTypeReferenceName ()) {
case "any":
return "object";
}
// FIXME: we cannot support callback yet. So, just return object
if (IsCallType (type))
return "object";
string suffix = type.IsInterface && addImpl ? "_Impl" : string.Empty;
bool isSystem = (type.Namespace ?? "").StartsWith ("System");
if (type.IsGenericType)
return (isSystem ? "" : "TypeScriptServiceBridge.") +
type.Namespace + "." + type.GetTypeReferenceName (suffix);
if (!isSystem)
return "TypeScriptServiceBridge." + type.FullName + suffix;
return type.FullName + suffix;
}
示例4: GenerateInterface
void GenerateInterface(Type type)
{
output.WriteLine ("\tpublic interface {0} : ITypeScriptObject", type.GetTypeReferenceName ());
GenerateImplements (type);
output.WriteLine ("\t{");
foreach (var p in EnumerateProperties (type)) {
GenerateFieldSignature (type, p, null);
output.WriteLine (" { get; set; }");
}
foreach (var m in EnumerateMethods (type)) {
GenerateMethodSignature (type, m, null);
output.WriteLine (";");
}
output.WriteLine ("\t}");
output.WriteLine ("\tpublic class {0} : TypeScriptObject, {1}", type.GetTypeReferenceName ("_Impl"), type.GetTypeReferenceName ());
output.WriteLine ("\t{");
output.WriteLine ("\t\tpublic {0}_Impl (ObjectInstance instance) : base (instance) {{}}", type.GetPrimaryName ());
ImplementProperties (type);
ImplementMethods (type);
output.WriteLine ("\t}");
}
示例5: GenerateEnum
void GenerateEnum(Type type)
{
output.WriteLine ("\tpublic enum " + type.GetTypeReferenceName ());
output.WriteLine ("\t{");
foreach (var n in Enum.GetNames (type))
output.WriteLine ("\t\t{0} = {1},", n, ((IConvertible) Enum.Parse (type, n)).ToInt32 (null));
output.WriteLine ("\t}");
}
示例6: GenerateClass
void GenerateClass(Type type)
{
output.Write ("\tpublic class " + type.GetTypeReferenceName () + " : ");
string baseType = GetBaseTypeFromAttribute (type);
if (baseType == null)
output.WriteLine ("TypeScriptObject");
else
output.WriteLine (baseType);
GenerateImplements (type);
output.WriteLine ("\t{");
output.WriteLine ("\t\tpublic {0} (ObjectInstance instance) : base (instance) {{}}", type.GetPrimaryName ());
foreach (var c in type.GetConstructors (flags)) {
if (!c.IsPublic)
continue;
// FIXME: they are workarounds for conflict betweeen
// ctor(Object regex) and ctor(object instance)...
if (type.GetTypeReferenceName () == "RegexLiteral" || type.GetTypeReferenceName () == "RegularExpressionLiteralToken")
continue;
output.WriteLine ("\t\tpublic {0} ({1})", type.GetPrimaryName (), GetArgumentsSignature (c));
var args = GetMarshaledCallArguments (c);
output.WriteLine ("\t\t\t : base (CallConstructor (\"{0}\", \"{1}\"{2}))", type.Namespace, type.GetTypeReferenceName (), args);
output.WriteLine ("\t\t{");
output.WriteLine ("\t\t}");
}
ImplementProperties (type);
ImplementMethods (type);
ImplementInterfaces (type);
output.WriteLine ("\t}");
}