本文整理汇总了C#中CSLE.CLType类的典型用法代码示例。如果您正苦于以下问题:C# CLType类的具体用法?C# CLType怎么用?C# CLType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CLType类属于CSLE命名空间,在下文中一共展示了CLType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Math2Value
public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
{
returntype = typeof(double);
if ((Type)right.type == typeof(int))
{
if (code == '+')
return (double)left + (double)(int)right.value;
else if (code == '-')
return (double)left - (double)(int)right.value;
else if (code == '*')
return (double)left * (double)(int)right.value;
else if (code == '/')
return (double)left / (double)(int)right.value;
else if (code == '%')
return (double)left % (double)(int)right.value;
}
else if ((Type)right.type == typeof(uint))
{
if (code == '+')
return (double)left + (double)(uint)right.value;
else if (code == '-')
return (double)left - (double)(uint)right.value;
else if (code == '*')
return (double)left * (double)(uint)right.value;
else if (code == '/')
return (double)left / (double)(uint)right.value;
else if (code == '%')
return (double)left % (double)(uint)right.value;
}
else if ((Type)right.type == typeof(double))
{
returntype = typeof(double);
if (code == '+')
return (double)left + (double)right.value;
else if (code == '-')
return (double)left - (double)right.value;
else if (code == '*')
return (double)left * (double)right.value;
else if (code == '/')
return (double)left / (double)right.value;
else if (code == '%')
return (double)left % (double)right.value;
}
else if ((Type)right.type == typeof(float))
{
returntype = typeof(double);
if (code == '+')
return (double)left + (double)(float)right.value;
else if (code == '-')
return (double)left - (double)(float)right.value;
else if (code == '*')
return (double)left * (double)(float)right.value;
else if (code == '/')
return (double)left / (double)(float)right.value;
else if (code == '%')
return (double)left % (double)(float)right.value;
}
return base.Math2Value(env, code, left, right, out returntype);
}
示例2: ConvertTo
public override object ConvertTo(CLS_Content env, object src, CLType targetType)
{
Type t = targetType;
if (t == typeof(double))
return (double)(long)(src);
if (t == typeof(float))
return (float)(long)(src);
if (t == typeof(long))
return src;
if (t == typeof(ulong))
return (ulong)(long)(src);
if (t == typeof(int))
return (int)(long)(src);
if (t == typeof(uint))
return (uint)(long)(src);
if (t == typeof(short))
return (short)(long)(src);
if (t == typeof(ushort))
return (ushort)(long)(src);
if (t == typeof(sbyte))
return (sbyte)(long)(src);
if (t == typeof(byte))
return (byte)(long)(src);
if (t == typeof(char))
return (char)(long)(src);
if (t == typeof(int?))
return (int?)(long)(src);
if (t == typeof(uint?))
return (uint?)(long)(src);
return base.ConvertTo(env, src, targetType);
}
示例3: ConvertTo
public virtual object ConvertTo(CLS_Content env, object src, CLType targetType)
{
//type.get
if (_type.IsEnum)
{
if ((Type)targetType == typeof(int))
return System.Convert.ToInt32(src);
else if ((Type)targetType == typeof(uint))
return System.Convert.ToUInt32(src);
else if ((Type)targetType == typeof(short))
return System.Convert.ToInt16(src);
else if ((Type)targetType == typeof(ushort))
return System.Convert.ToUInt16(src);
else
{
return System.Convert.ToInt32(src);
}
}
var ms = _type.GetMethods();
foreach (var m in ms)
{
if ((m.Name == "op_Implicit" || m.Name == "op_Explicit") && m.ReturnType == (Type)targetType)
{
return m.Invoke(null, new object[] { src });
}
}
return src;
}
示例4: Math2Value
public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
{
returntype = null;
Delegate rightDele = null;
if (right.value is DeleFunction)
rightDele = CreateDelegate(env.environment, right.value as DeleFunction);
else if (right.value is DeleLambda)
rightDele = CreateDelegate(env.environment, right.value as DeleLambda);
else if (right.value is Delegate)
rightDele = right.value as Delegate;
if (rightDele != null)
{
Delegate leftDele = left as Delegate;
if (left == null)
return rightDele;
if (code == '+')
return Delegate.Combine(leftDele, rightDele);
if (code == '-')
return Delegate.Remove(leftDele, rightDele);
}
throw new NotSupportedException("" + right.value);
}
示例5: Math2Value
public override object Math2Value(CLS_Content content, char code, object left, CLS_Content.Value right, out CLType returntype)
{
if (code == '+')
{
if (right.value is Vector3)
{
returntype = typeof(Vector3);
return ((Vector3)left) + ((Vector3)right.value);
}
}
if (code == '-')
{
returntype = typeof(Vector3);
return ((Vector3)left) - ((Vector3)right.value);
}
if (code == '*')
{
returntype = typeof(Vector3);
return ((Vector3)left) * Convert.ToSingle(right.value);
}
if (code == '/')
{
returntype = typeof(Vector3);
return ((Vector3)left) / Convert.ToSingle(right.value);
}
return base.Math2Value(content, code, left, right, out returntype);
}
示例6: Math2Value
public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
{
returntype = typeof(float);
if ((Type)right.type == typeof(int))
{
if (code == '+')
return (float)left + (float)(int)right.value;
else if (code == '-')
return (float)left - (float)(int)right.value;
else if (code == '*')
return (float)left * (float)(int)right.value;
else if (code == '/')
return (float)left / (float)(int)right.value;
else if (code == '%')
return (float)left % (float)(int)right.value;
}
else if ((Type)right.type == typeof(uint))
{
if (code == '+')
return (float)left + (float)(uint)right.value;
else if (code == '-')
return (float)left - (float)(uint)right.value;
else if (code == '*')
return (float)left * (float)(uint)right.value;
else if (code == '/')
return (float)left / (float)(uint)right.value;
else if (code == '%')
return (float)left % (float)(uint)right.value;
}
else if ((Type)right.type == typeof(double))
{
returntype = typeof(double);
if (code == '+')
return (double)(float)left + (double)right.value;
else if (code == '-')
return (double)(float)left - (double)right.value;
else if (code == '*')
return (double)(float)left * (double)right.value;
else if (code == '/')
return (double)(float)left / (double)right.value;
else if (code == '%')
return (double)(float)left % (double)right.value;
}
else if ((Type)right.type == typeof(float))
{
returntype = typeof(float);
if (code == '+')
return (float)left + (float)right.value;
else if (code == '-')
return (float)left - (float)right.value;
else if (code == '*')
return (float)left * (float)right.value;
else if (code == '/')
return (float)left / (float)right.value;
else if (code == '%')
return (float)left % (float)right.value;
}
throw new NotImplementedException();
}
示例7: Math2Value
public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
{
returntype = typeof(string);
if (code == '+')
return (string)left + right.value.ToString();
throw new NotImplementedException();
}
示例8: ConvertTo
public object ConvertTo(CLS_Content env, object src, CLType targetType)
{
if (targetType == type) return src;
if ((Type)targetType == typeof(void))
{
return null;
}
throw new NotImplementedException();
}
示例9: ConvertTo
public object ConvertTo(CLS_Content env, object src, CLType targetType)
{
var type = env.environment.GetType(targetType);
if (this.types.Contains(type))
{
return src;
}
throw new NotImplementedException();
}
示例10: Math2Value
public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
{
bool math2ValueSuccess = false;
object value = NumericTypeUtils.Math2Value<byte>(code, left, right, out returntype, out math2ValueSuccess);
if (math2ValueSuccess) {
return value;
}
return base.Math2Value(env, code, left, right, out returntype);
}
示例11: Math2Value
public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
{
if ((Type)right.type == typeof(string))
{
returntype = typeof(String);
return "null" + right.value;
}
throw new NotImplementedException();
}
示例12: ConvertTo
public override object ConvertTo(CLS_Content env, object src, CLType targetType)
{
bool convertSuccess = false;
object convertedObject = NumericTypeUtils.TryConvertTo<byte>(src, targetType, out convertSuccess);
if (convertSuccess) {
return convertedObject;
}
return base.ConvertTo(env, src, targetType);
}
示例13: GetType
public ICLS_Type GetType(CLType type)
{
if (type == null)
return typess["null"];
if (types.ContainsKey(type) == false)
{
logger.Log_Error("(CLScript)类型未注册:" + type.ToString());
}
return types[type];
}
示例14: ConvertTo
public virtual object ConvertTo(CLS_Content env, object src, CLType targetType)
{
Type targetSysType = (Type)targetType;
if (sysType == targetSysType)
return src;
if (targetSysType == null)
return src;
return src;
}
示例15: ConvertTo
public object ConvertTo(CLS_Content env, object src, CLType targetType)
{
if ((Type)targetType == typeof(string)) return src;
if ((Type)targetType == typeof(void))
{
return null;
}
if (((Type)targetType).IsAssignableFrom(typeof(string)))
//if((Type)targetType== typeof(object))
{
return src;
}
return null;
}