本文整理汇总了C#中CSLE.CLType类的典型用法代码示例。如果您正苦于以下问题:C# CLType类的具体用法?C# CLType怎么用?C# CLType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CLType类属于CSLE命名空间,在下文中一共展示了CLType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:60,代码来源:CLS_Type_Double.cs
示例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);
}
开发者ID:wpszz,项目名称:CSLightForUnity,代码行数:31,代码来源:CLS_Type_Long.cs
示例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;
}
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:31,代码来源:RegHelper_Type.cs
示例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);
}
开发者ID:wpszz,项目名称:CSLightForUnity,代码行数:26,代码来源:RegHelper_Dele.cs
示例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);
}
开发者ID:wpszz,项目名称:CSLightForUnity,代码行数:28,代码来源:ToCSLightVector3.cs
示例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();
}
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:60,代码来源:CLS_Type_Float.cs
示例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();
}
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:8,代码来源:CLS_Type_String.cs
示例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();
}
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:9,代码来源:CLS_Type_String.cs
示例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();
}
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:9,代码来源:CLS_Type_Class.cs
示例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);
}
开发者ID:lightszero,项目名称:cslightcore,代码行数:10,代码来源:CLS_Type_Byte.cs
示例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();
}
开发者ID:qq1792,项目名称:CSLightStudio,代码行数:10,代码来源:CLS_Type_Null.cs
示例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);
}
开发者ID:lightszero,项目名称:cslightcore,代码行数:10,代码来源:CLS_Type_Byte.cs
示例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];
}
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:10,代码来源:CLS_Environment.cs
示例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;
}
开发者ID:wpszz,项目名称:CSLightForUnity,代码行数:12,代码来源:RegHelper_Type.cs
示例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;
}
开发者ID:qq1792,项目名称:CSLightStudio,代码行数:14,代码来源:CLS_Type_String.cs
示例16: Math2Value
public virtual object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returnType)
{
if (code == '+')
{
returnType = typeof(string);
if (left == null)
return "null" + right.value;
if (right.value == null)
return left.ToString() + "null";
return left.ToString() + right.value;
}
throw new NotImplementedException("未实现算术运算: " + code);
}
开发者ID:wpszz,项目名称:CSLightForUnity,代码行数:17,代码来源:RegHelper_Type.cs
示例17: 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 Quaternion)
{
returntype = typeof(Quaternion);
return ((Quaternion)left) * ((Quaternion)right.value);
}
if (right.value is Vector3)
{
returntype = typeof(Vector3);
return ((Quaternion)left) * ((Vector3)right.value);
}
}
return base.Math2Value(content, code, left, right, out returntype);
}
开发者ID:wpszz,项目名称:CSLightForUnity,代码行数:18,代码来源:ToCSLightQuaternion.cs
示例18: ConvertTo
public override object ConvertTo(CLS_Content env, object src, CLType targetType)
{
if ((Type)targetType == typeof(uint))
{
return (uint)(byte)src;
}
else if ((Type)targetType == typeof(int))
{
return (int)(byte)src;
}
else if ((Type)targetType == typeof(double))
{
return (double)(byte)src;
}
else if ((Type)targetType == typeof(float))
{
return (float)(byte)src;
}
else if ((Type)targetType == typeof(ushort))
{
return (ushort)(byte)src;
}
else if ((Type)targetType == typeof(byte))
{
return (byte)(byte)src;
}
else if ((Type)targetType == typeof(char))
{
return (char)(byte)src;
}
else if ((Type)targetType == typeof(ushort))
{
return (ushort)(byte)src;
}
else if ((Type)targetType == typeof(sbyte))
{
return (sbyte)(byte)src;
}
else if ((Type)targetType == typeof(short))
{
return (short)(byte)src;
}
return base.ConvertTo(env, src, targetType);
}
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:44,代码来源:CLS_Type_Byte.cs
示例19: Math2Value
public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
{
returntype = null;
if (left is DeleEvent)
{
DeleEvent info = left as DeleEvent;
Delegate calldele = null;
if (right.value is DeleFunction) calldele = CreateDelegate(env.environment, right.value as DeleFunction);
else if (right.value is DeleLambda) calldele = CreateDelegate(env.environment, right.value as DeleLambda);
else if (right.value is Delegate) calldele = right.value as Delegate;
if (code == '+')
{
info._event.AddEventHandler(info.source, calldele);
return null;
}
else if (code == '-')
{
info._event.AddEventHandler(info.source, calldele);
return null;
}
}
else if(left is Delegate)
{
Delegate info = left as Delegate;
Delegate calldele = null;
if (right.value is DeleFunction) calldele = CreateDelegate(env.environment, right.value as DeleFunction);
else if (right.value is DeleLambda) calldele = CreateDelegate(env.environment, right.value as DeleLambda);
else if (right.value is Delegate) calldele = right.value as Delegate;
if (code == '+')
{
Delegate.Combine(info, calldele);
return null;
}
else if (code == '-')
{
Delegate.Remove(info, calldele);
}
}
return new NotSupportedException();
}
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:43,代码来源:RegHelper_DeleAction.cs
示例20: ConvertTo
public object ConvertTo(CLS_Content env, object src, CLType targetType)
{
if ((Type)targetType == typeof(int))
{
return (int)(float)src;
}
else if ((Type)targetType == typeof(uint))
{
return (uint)(float)src;
}
else if ((Type)targetType == typeof(double))
{
return (double)(float)src;
}
else if ((Type)targetType == typeof(float))
{
return (float)src;
}
throw new NotImplementedException();
}
开发者ID:GraphicGame,项目名称:CSLightStudio,代码行数:20,代码来源:CLS_Type_Float.cs
注:本文中的CSLE.CLType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论