本文整理汇总了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;
}
示例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);
}
}
示例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);
}