public void DefineAndSet(string name, TypeBridge type, CQ_Value value) { if (values == null) { values = new Dictionary <string, CQ_Value>(); } else if (values.ContainsKey(name)) { throw new Exception(name + "已经定义过"); } CQ_Value v = new CQ_Value(); if (type.type != null) { v.m_type = type.type; } else if (type.stype != null) { v.m_stype = type.stype; } v.UsingValue(value); values[name] = v; int newdepth = tvalueDepth.Pop() + 1; tvalueDepth.Push(newdepth); tvalues.Push(name); }
public object ConvertTo(object src, TypeBridge targetType) { Type_Action dele = CQuark.AppDomain.GetITypeByCQType(targetType) as Type_Action; return(dele.CreateDelegate(src as DeleFunction)); //throw new NotImplementedException(); }
public object ConvertTo(TypeBridge targetType) { if (!_isNum && _obj == null) { return(_obj); } if (_isNum) { if (targetType.type == typeof(bool)) { return(_num == 1); } else if (NumberUtil.IsNumberType(targetType.type)) { return(NumberUtil.Double2TargetType(targetType.type, _num)); } } if (m_type == targetType.type && m_stype == targetType.stype) { return(_obj); } //TODO 这个流程太长了,最好简化 if (m_type != null) { return(AppDomain.GetITypeByType(m_type).ConvertTo(_obj, targetType)); } else if (m_stype != null) { return(AppDomain.GetITypeByClassCQ(m_stype).ConvertTo(_obj, targetType)); } return(null); }
public override object ConvertTo(object src, TypeBridge targetType) { if (NumberUtil.IsNumberType(_type) && NumberUtil.IsNumberType(targetType.type)) { double srcValue = NumberUtil.GetDouble(_type, src); return(NumberUtil.Double2TargetType(targetType, srcValue)); } else { return(base.ConvertTo(src, targetType)); } }
public static IType GetITypeByCQType(TypeBridge typeBridge) { if (typeBridge.type != null) { return(GetITypeByType(typeBridge.type)); } else if (typeBridge.stype != null) { return(GetITypeByClassCQ(typeBridge.stype)); } return(null); }
public object ConvertTo(object src, TypeBridge targetType) { var type = CQuark.AppDomain.GetITypeByCQType(targetType); if (this.typeBridge == type || (Type)targetType == typeof(object)) { return(src); } if (this.types.Contains(type)) { return(src); } throw new NotImplementedException(); }
public void SetObject(TypeBridge cqType, object obj) { if (cqType.type != null) { SetObject(cqType.type, obj); } else if (cqType.stype != null) { SetObject(cqType.stype, obj); } else { SetNoneTypeObject(obj); } }
public object ConvertTo(object src, TypeBridge 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); }
public virtual object ConvertTo(object src, TypeBridge targetType) { throw new NotImplementedException(); }
public virtual object ConvertTo(object src, TypeBridge targetType) { Type targettype = (Type)targetType; if (this._type == targettype) { return(src); } if (_type.IsEnum) { if (targettype == typeof(int)) { return(System.Convert.ToInt32(src)); } else if (targettype == typeof(uint)) { return(System.Convert.ToUInt32(src)); } else if (targettype == typeof(short)) { return(System.Convert.ToInt16(src)); } else if (targettype == typeof(ushort)) { return(System.Convert.ToUInt16(src)); } else { return(System.Convert.ToInt32(src)); } } else if (targettype != null && targettype.IsEnum) { return(Enum.ToObject(targettype, src)); } MethodInfo[] ms = _type.GetMethods(); foreach (MethodInfo m in ms) { if ((m.Name == "op_Implicit" || m.Name == "op_Explicit") && m.ReturnType == targettype) { return(m.Invoke(null, new object[] { src })); } } if (targettype != null) { if (targettype.IsAssignableFrom(_type)) { return(src); } if (src != null && targettype.IsInstanceOfType(src)) { return(src); } } else { return(src); } return(null); }
public static object ConvertTo(object obj, TypeBridge targetType) { return(GetITypeByType(obj.GetType()).ConvertTo(obj, targetType)); }
public object ConvertTo(object src, TypeBridge targetType) { return(null); }