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


C# Type.GetTypeReferenceName方法代码示例

本文整理汇总了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;
        }
    }
开发者ID:atsushieno,项目名称:md-typescript,代码行数:19,代码来源:TS2CSImplementor.cs

示例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;
        }
    }
开发者ID:atsushieno,项目名称:md-typescript,代码行数:15,代码来源:TS2CSImplementor.cs

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

示例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}");
    }
开发者ID:atsushieno,项目名称:md-typescript,代码行数:25,代码来源:TS2CSImplementor.cs

示例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}");
 }
开发者ID:atsushieno,项目名称:md-typescript,代码行数:8,代码来源:TS2CSImplementor.cs

示例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}");
    }
开发者ID:atsushieno,项目名称:md-typescript,代码行数:37,代码来源:TS2CSImplementor.cs


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