// Overrides the ConvertFrom method of TypeConverter. public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { MathNodeRoot r = new MathNodeRoot(); MathNodeStringValue mv = new MathNodeStringValue(r); mv.Value = (string)value; r[1] = mv; return(r); } return(base.ConvertFrom(context, culture, value)); }
public override string CreateJavaScript(StringCollection method) { MathNode.Trace("{0}.CreateJavaScript", this.GetType().Name); if (this.IsWebClientValue()) { if (_methodPointer == null) { MathNode.Trace("Warning: method pointer is null"); return(null); } if (method == null) { throw new DesignerException("Calling {0}.CreateJavaScript with null method", this.GetType().Name); } MethodParameterJsCodeAttribute jsCodeAttr = null; MethodInfoPointer mip = _methodPointer as MethodInfoPointer; if (mip != null) { MethodBase mb = mip.MethodDef; if (mb != null) { object[] vs = mb.GetCustomAttributes(typeof(MethodParameterJsCodeAttribute), true); if (vs != null && vs.Length > 0) { jsCodeAttr = vs[0] as MethodParameterJsCodeAttribute; } } } int n = ChildNodeCount; string[] ps; if (n > 0) { IList <IParameter> pList = _methodPointer.MethodPointed.MethodParameterTypes;; ps = new string[n]; for (int i = 0; i < n; i++) { this[i].CompileDataType = new RaisDataType(pList[i].ParameterLibType); if (jsCodeAttr != null && jsCodeAttr.IsJsCode(pList[i].Name)) { MathNodeValue mv = this[i] as MathNodeValue; if (mv != null) { if (mv.Value != null) { ps[i] = mv.Value.ToString(); } else { ps[i] = string.Empty; } continue; } else { MathNodeStringValue msv = this[i] as MathNodeStringValue; if (msv != null) { if (msv.Value != null) { ps[i] = msv.Value; } else { ps[i] = string.Empty; } continue; } } } ps[i] = this[i].CreateJavaScript(method); } } else { ps = new string[] { }; } _methodPointer.SetParameterJS(ps); string ce = _methodPointer.GetJavaScriptReferenceCode(method); return(ce); } else { return(string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.values.{0}", DataPassingCodeName)); } }