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


C# IType.GetEntityType方法代码示例

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


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

示例1: EntityTypeRefToMember

 public static JsExpression EntityTypeRefToMember(IType typeRef, bool isGenericArgument)
 {
     if (typeRef == null)
         return null;
     if (typeRef.Kind == TypeKind.Anonymous)
         return Js.Null();
     if (isGenericArgument)
     {
         var code = Sk.GetGenericArugmentJsCode(typeRef.GetEntityType());
         if (code != null)
             return Js.CodeExpression(code);
     }
     var name = GetEntityJsName(typeRef);
     if (Sk.IsJsonMode(typeRef.GetEntityType()))
         return Js.String(name);
     var member = Js.Members(name);
     if (typeRef.IsGenericTypeParameter())
     {
         if (member.PreviousMember == null)
             member.PreviousMember = Js.This();
         else
             throw new Exception();
     }
     var def = typeRef.GetDefinitionOrArrayType();
     if (def != null && Sk.IsClrType(def))
     {
         member = member.Member("ctor");
     }
     return member;
 }
开发者ID:benbon,项目名称:SharpKit,代码行数:30,代码来源:SkJs.cs

示例2: GetValueTypeInitializer

 public static ResolveResult GetValueTypeInitializer(IType ce, NProject Project)
 {
     var fullName = SkJs.GetEntityJsName(ce);
     if (ce.FullName == "System.Nullable")
         return Cs.Null();
     if (ce is ITypeDefinition)
     {
         var def = (ITypeDefinition)ce;
         if (def.KnownTypeCode != KnownTypeCode.None)
         {
             if (def.KnownTypeCode == KnownTypeCode.Boolean)
             {
                 return Cs.Value(false, Project);
             }
             else if (def.KnownTypeCode == KnownTypeCode.Char)
             {
                 return Cs.Value('\0', Project);
             }
             else if (def.KnownTypeCode == KnownTypeCode.SByte ||
                 def.KnownTypeCode == KnownTypeCode.Int16 ||
                 def.KnownTypeCode == KnownTypeCode.Int32 ||
                 def.KnownTypeCode == KnownTypeCode.Int64 ||
                 def.KnownTypeCode == KnownTypeCode.UInt16 ||
                 def.KnownTypeCode == KnownTypeCode.UInt32 ||
                 def.KnownTypeCode == KnownTypeCode.UInt64 ||
                 def.KnownTypeCode == KnownTypeCode.Byte ||
                 def.KnownTypeCode == KnownTypeCode.Decimal ||
                 def.KnownTypeCode == KnownTypeCode.Double ||
                 def.KnownTypeCode == KnownTypeCode.Single
                 )
             {
                 return Cs.Value(0, Project);
             }
         }
     }
     if (ce.Kind == TypeKind.Enum)
     {
         var en = ce;
         var enumMembers = en.GetFields();
         var defaultEnumMember = enumMembers.Where(t => (t.ConstantValue is int) && (int)t.ConstantValue == 0).FirstOrDefault() ?? enumMembers.FirstOrDefault();
         if (defaultEnumMember != null)
             return defaultEnumMember.AccessSelf();//.Access().Member(c.CreateTypeRef(en), defaultEnumMember);
         else
             return null;
     }
     else if (ce.GetEntityType().FullName == "System.DateTime")
     {
         var minDateFe = ce.GetFields(t => t.Name == "MinValue").First();
         return minDateFe.AccessSelf();// c.Member(c.Class(c.DateTimeType), minDateFe);
     }
     else
     {
         return Cs.New(ce);
     }
 }
开发者ID:benbon,项目名称:SharpKit,代码行数:55,代码来源:MemberConverter.cs

示例3: GetEntityJsName

 public static string GetEntityJsName(IType ceref)
 {
     if (ceref is ITypeDefinition)
         return GetEntityJsName((ITypeDefinition)ceref);
     var includeGenericArgs = !Sk.IgnoreTypeArguments(ceref.GetEntityType());
     return ceref.GetEntityJsName(false, includeGenericArgs);
 }
开发者ID:benbon,项目名称:SharpKit,代码行数:7,代码来源:SkJs.cs


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