本文整理汇总了C#中PType.ToBuiltIn方法的典型用法代码示例。如果您正苦于以下问题:C# PType.ToBuiltIn方法的具体用法?C# PType.ToBuiltIn怎么用?C# PType.ToBuiltIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PType
的用法示例。
在下文中一共展示了PType.ToBuiltIn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalConvertTo
protected override bool InternalConvertTo(
StackContext sctx,
PValue subject,
PType target,
bool useExplicit,
out PValue result)
{
result = null;
var s = (string) subject.Value;
var builtInT = target.ToBuiltIn();
if (useExplicit)
{
switch (builtInT)
{
case BuiltIn.List:
var lst = _toPCharList(s);
result = (PValue) lst;
break;
}
}
if (result == null)
{
switch (builtInT)
{
case BuiltIn.Object:
var clrType = ((ObjectPType) target).ClrType;
var typeC = Type.GetTypeCode(clrType);
switch (typeC)
{
case TypeCode.String:
result = CreateObject(s);
break;
case TypeCode.Object:
if (clrType == typeof (IEnumerable<PValue>))
result = (PValue) _toPCharList(s);
else if (clrType == typeof (char[]) ||
clrType == typeof (IEnumerable<char>) ||
clrType == typeof (ICollection<char>) ||
clrType == typeof (IList<char>))
result = new PValue(s.ToCharArray(), target);
break;
}
break;
}
}
return result != null;
}
示例2: InternalConvertTo
protected override bool InternalConvertTo(
StackContext sctx,
PValue subject,
PType target,
bool useExplicit,
out PValue result)
{
result = null;
switch (target.ToBuiltIn())
{
case BuiltIn.Real:
result = Real.CreatePValue(0.0);
break;
case BuiltIn.Int:
result = Int.CreatePValue(0);
break;
case BuiltIn.String:
result = String.CreatePValue("");
break;
case BuiltIn.Bool:
result = Bool.CreatePValue(false);
break;
}
return result != null;
}
示例3: InternalConvertTo
protected override bool InternalConvertTo(
StackContext sctx, PValue subject, PType target, bool useExplicit, out PValue result)
{
if (sctx == null)
throw new ArgumentNullException("sctx");
if (subject == null || subject.IsNull)
throw new ArgumentNullException("subject");
if ((object) target == null)
throw new ArgumentNullException("target");
result = null;
var c = (char) subject.Value;
var bi = target.ToBuiltIn();
if (useExplicit)
{
switch (bi)
{
case BuiltIn.Object:
var clrType = ((ObjectPType) target).ClrType;
switch (Type.GetTypeCode(clrType))
{
case TypeCode.Byte:
result = new PValue(Convert.ToByte(c), target);
break;
}
break;
}
}
if (result == null)
{
switch (bi)
{
case BuiltIn.Int:
result = (int) c;
break;
case BuiltIn.String:
result = c.ToString();
break;
case BuiltIn.Object:
var clrType = ((ObjectPType) target).ClrType;
switch (Type.GetTypeCode(clrType))
{
case TypeCode.Char:
result = new PValue(c, target);
break;
case TypeCode.Int32:
result = new PValue((Int32) c, target);
break;
}
break;
}
}
return result != null;
}
示例4: InternalConvertTo
protected override bool InternalConvertTo(
StackContext sctx,
PValue subject,
PType target,
bool useExplicit,
out PValue result)
{
result = null;
var obj = subject.Value as SymbolTable<Member>;
if (obj == null)
return false;
switch (target.ToBuiltIn())
{
case BuiltIn.String:
normalString:
if (
!TryDynamicCall(sctx, subject, new PValue[] {}, PCall.Get, "ToString",
out result))
result = null;
break;
case BuiltIn.Object:
var clrType = ((ObjectPType) target).ClrType;
var tc = Type.GetTypeCode(clrType);
switch (tc)
{
case TypeCode.String:
goto normalString;
}
break;
}
return result != null;
}