public override QsValue ExclamationOperator(QsValue key) { if (key.ToString().Equals("TypeName", StringComparison.OrdinalIgnoreCase)) { return(new QsText(InstanceType.Name)); } if (key.ToString().Equals("Properties", StringComparison.OrdinalIgnoreCase)) { QsFlowingTuple f = new QsFlowingTuple(); var mms = InstanceType.GetProperties(BindingFlags.Public | BindingFlags.Instance); QsTupleValue[] fefe = new QsTupleValue[mms.Length]; for (int ix = 0; ix < mms.Length; ix++) { fefe[ix].Name = (string)mms[ix].Name; fefe[ix].Value = new QsText(mms[ix].PropertyType.Name); } if (fefe.Length == 0) { return(new QsFlowingTuple()); } return(new QsFlowingTuple(fefe)); } if (key.ToString().Equals("Methods", StringComparison.OrdinalIgnoreCase)) { QsFlowingTuple f = new QsFlowingTuple(); var mms = from m in InstanceType.GetMethods(BindingFlags.Public | BindingFlags.Instance) where m.IsSpecialName == false select m; QsTupleValue[] fefe = new QsTupleValue[mms.Count()]; for (int ix = 0; ix < mms.Count(); ix++) { fefe[ix].Name = (string)mms.ElementAt(ix).Name; fefe[ix].Value = new QsText(mms.ElementAt(ix).ReturnType.Name); } if (fefe.Length == 0) { return(new QsFlowingTuple()); } return(new QsFlowingTuple(fefe)); } if (key.ToString().Equals("Type", StringComparison.OrdinalIgnoreCase)) { return(new QsObject(InstanceType)); } return(new QsText("Unknown Command")); }
public override string ToString() { return(VariableName + ": " + ContentValue.ToString()); }
public override QsValue DivideOperation(QsValue value) { /* * DynamicMethod dm = GetOperationMethod(Operator.Divide, value); * * if (dm != null) * { * var result = dm.Invoke(null, new object[] { this.ThisObject, ((QsObject)value).ThisObject }); * return QsObject.CreateNativeObject(result); * * } */ var o = value as QsObject; if (o != null) { var expr = Expression.Divide(Expression.Constant(_NativeObject), Expression.Constant(o._NativeObject)); // Construct Lambda function which return one object. Expression <Func <object> > cq = Expression.Lambda <Func <object> >(expr); // compile the function Func <object> aqf = cq.Compile(); // execute the function object result = aqf(); // return the result return(new QsObject(result)); } else { throw new NotImplementedException("Operation between " + this.ToString() + " and " + value.ToString() + " is not supported"); } }
public override QsValue AddOperation(QsValue value) { QsText t = new QsText(Text + value.ToString()); return(t); }