public override string GetValueCodePHP(MethodInfoPointer owner, UInt32 branchId) { ParameterInfo[] ps = owner.Info; SubMethodParameterInfo p = (SubMethodParameterInfo)ps[1]; return(codeName2(p.CodeName, branchId)); }
public override CodeStatement GetIncrementalStatement(MethodInfoPointer owner, ILimnorCodeCompiler compiler, IMethodCompile methodToCompile, CodeMemberMethod method, CodeStatementCollection statements, UInt32 branchId) { ParameterInfo[] ps = owner.Info; SubMethodParameterInfo p = (SubMethodParameterInfo)ps[0]; CodeExpressionStatement incr = new CodeExpressionStatement(new CodeSnippetExpression(codeName2(p.CodeName, branchId) + "++")); return(incr); }
public override CodeStatement GetInitStatement(MethodInfoPointer owner, ILimnorCodeCompiler compiler, IMethodCompile methodToCompile, CodeMemberMethod method, CodeStatementCollection statements, UInt32 branchId) { ParameterInfo[] ps = owner.Info; SubMethodParameterInfo p = (SubMethodParameterInfo)ps[0]; CodeVariableDeclarationStatement vd = new CodeVariableDeclarationStatement(typeof(int), codeName2(p.CodeName, branchId), new CodePrimitiveExpression(0)); return(vd); }
public override string GetTestExpressionPhp(MethodInfoPointer owner, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data, UInt32 branchId) { ParameterInfo[] ps = owner.Info; SubMethodParameterInfo p = (SubMethodParameterInfo)ps[0]; string bin = string.Format(CultureInfo.InvariantCulture, "{0} < count({1});", codeName2(p.CodeName, branchId), owner.Owner.GetPhpScriptReferenceCode(jsCode)); return(bin); }
public override string[] GetIndexCodesPhp(MethodInfoPointer owner, JsMethodCompiler data, UInt32 branchId) { ParameterInfo[] ps = owner.Info; SubMethodParameterInfo p = (SubMethodParameterInfo)ps[0]; string[] pss = new string[1]; pss[0] = codeName2(p.CodeName, branchId); return(pss); }
/// <summary> /// indices for accessing array item /// </summary> /// <param name="owner"></param> /// <param name="method"></param> /// <returns></returns> public override CodeExpression[] GetIndexCodes(MethodInfoPointer owner, IMethodCompile method, UInt32 branchId) { ParameterInfo[] ps = owner.Info; SubMethodParameterInfo p = (SubMethodParameterInfo)ps[0]; CodeExpression[] pss = new CodeExpression[1]; pss[0] = new CodeVariableReferenceExpression(codeName2(p.CodeName, branchId)); return(pss); }
public override string GetIncrementalStatementPhp(MethodInfoPointer owner, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data, UInt32 branchId) { ParameterInfo[] ps = owner.Info; SubMethodParameterInfo p = (SubMethodParameterInfo)ps[0]; string incr = string.Format(CultureInfo.InvariantCulture, "{0}++", codeName2(p.CodeName, branchId)); return(incr); }
public override CodeExpression GetTestExpression(MethodInfoPointer owner, ILimnorCodeCompiler compiler, IMethodCompile methodToCompile, CodeMemberMethod method, CodeStatementCollection statements, UInt32 branchId) { ParameterInfo[] ps = owner.Info; SubMethodParameterInfo p = (SubMethodParameterInfo)ps[0]; CodeBinaryOperatorExpression bin = new CodeBinaryOperatorExpression( new CodeVariableReferenceExpression(codeName2(p.CodeName, branchId)), CodeBinaryOperatorType.LessThan, new CodePropertyReferenceExpression(owner.Owner.GetReferenceCode(methodToCompile, statements, true), "Length")); return(bin); }
public void LoadData(LimnorContextMenuCollection menus) { _menus = menus; List <MenuItemDataMethod> pms = _menus.PrimaryMethods; if (pms != null && pms.Count > 0) { foreach (MenuItemDataMethod m in pms) { lstP.Items.Add(m); } } List <MenuItemDataMethod> sms = _menus.SecondaryMethods; if (sms != null && sms.Count > 0) { foreach (MenuItemDataMethod m in sms) { lstS.Items.Add(m); } } SortedDictionary <string, IMethod> all = _menus.GetAllMethods(); SortedDictionary <string, TreeNode> customNodes = new SortedDictionary <string, TreeNode>(); foreach (KeyValuePair <string, IMethod> kv in all) { MethodInfoPointer mi = kv.Value as MethodInfoPointer; if (mi != null) { treeViewAll.Nodes.Add(new TreeNodeMethod(false, mi)); } else { MethodClass mc = kv.Value as MethodClass; if (mc != null) { //use 0 as the scope because method selection does not need scope TreeNodeCustomMethod tnc = new TreeNodeCustomMethod(treeViewAll, mc.IsStatic, mc, menus.Pointer, 0); customNodes.Add(tnc.Text, tnc); } } } int i = 0; foreach (KeyValuePair <string, TreeNode> kv in customNodes) { treeViewAll.Nodes.Insert(i++, kv.Value); } }
public static MenuItemDataMethod CreateMenuItem(IMethod p, LimnorContextMenuCollection menus) { MethodInfoPointer ip = p as MethodInfoPointer; if (ip != null) { return(new MethodItem(p.MethodSignature, menus.Owner, ip.MethodInformation)); } MethodClass mc = p as MethodClass; if (mc != null) { return(new MethodItemClassPointer(p.MethodSignature, menus.Owner, mc)); } IMethodWrapper w = p as IMethodWrapper; if (w != null) { return(new MethodItemWrapper(p.MethodSignature, menus.Owner, w)); } throw new DesignerException("Unsupported method type {0} for CreateMenuItem", p.GetType()); }
private MethodInfoPointer createPointer(MultiPanes viewersHolder, XmlNode rootNode) { MethodInfoPointer mp; if (_val is SubMethodInfo) { mp = new SubMethodInfoPointer(); } else { mp = new MethodInfoPointer(); } mp.Owner = Owner; mp.MemberName = _val.Name; ParameterInfo[] pifs = null; IDynamicMethodParameters dmp = Owner.ObjectInstance as IDynamicMethodParameters; if (dmp != null) { pifs = dmp.GetDynamicMethodParameters(_val.Name, null); } if (pifs == null) { pifs = _val.GetParameters(); } if (pifs != null && pifs.Length > 0) { Type[] ts = new Type[pifs.Length]; for (int i = 0; i < ts.Length; i++) { ts[i] = pifs[i].ParameterType; } mp.ParameterTypes = ts; } mp.SetMethodInfo(_val); return(mp); }
public bool IsWebServerValue() { if (_methodPointer != null) { MethodClass mc = _methodPointer.MethodPointed as MethodClass; if (mc != null) { if (mc.RunAt == EnumWebRunAt.Server) { return(true); } } else { if (_methodPointer.MethodPointed != null) { MethodInfoPointer mifp = _methodPointer.MethodPointed as MethodInfoPointer; if (mifp != null && mifp.MethodInfo != null) { object[] vs = mifp.MethodInfo.GetCustomAttributes(typeof(WebServerMemberAttribute), true); if (vs != null && vs.Length > 0) { return(true); } vs = mifp.MethodInfo.GetCustomAttributes(typeof(WebClientMemberAttribute), true); if (vs != null && vs.Length > 0) { return(false); } return(DesignUtil.IsWebServerObject(mifp)); } } } } return(false); }
public override IAction CreateMethodAction(ILimnorDesignPane designPane, IClass holder, IMethod scopeMethod, IActionsHolder actsHolder) { MethodInfoPointer mp = createPointer(designPane.PaneHolder, designPane.RootXmlNode); return(DesignUtil.OnCreateAction(holder, mp, scopeMethod, actsHolder, designPane.PaneHolder, designPane.RootXmlNode)); }
public abstract CodeExpression[] GetIndexCodes(MethodInfoPointer owner, IMethodCompile method, UInt32 branchId);
public override bool ExecuteMenuCommand(LimnorProject project, IClass holder, XmlNode node, MultiPanes pane, IMethod scopeMethod, IActionsHolder actsHolder) { MethodInfoPointer mp = createPointer(pane, node); return(DesignUtil.OnCreateAction(holder, mp, scopeMethod, actsHolder, pane, node) != null); }
public override CodeStatement GetIncrementalStatement(MethodInfoPointer owner, ILimnorCodeCompiler compiler, IMethodCompile methodToCompile, CodeMemberMethod method, CodeStatementCollection statements, UInt32 branchId) { return(null); }
public override string GetIncrementalStatementPhp(MethodInfoPointer owner, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data, UInt32 branchId) { return(null); }
public abstract string GetTestExpressionPhp(MethodInfoPointer owner, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data, UInt32 branchId);
public override string GetTestExpressionPhp(MethodInfoPointer owner, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data, UInt32 branchId) { return(null); }
public override string GetIndexCodeJS(MethodInfoPointer owner, UInt32 branchId) { return(null); }
public override string[] GetIndexCodesPhp(MethodInfoPointer owner, JsMethodCompiler data, UInt32 branchId) { return(null); }
public static bool CheckAction(IAction act, Form caller) { if (act == null) { return(true); } if (!act.IsValid || act.ActionMethod == null) { MessageBox.Show(caller, string.Format(System.Globalization.CultureInfo.InvariantCulture, "The action is invalid. [{0}]", act.ActionName), "Select action", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (IsWebPage) { DataTypePointer dtp = act.MethodOwner as DataTypePointer; if (dtp != null) { return(true); } TypePointer tp = act.MethodOwner as TypePointer; if (tp != null) { return(true); } MethodInfoPointer mip = act.ActionMethod as MethodInfoPointer; if (mip != null) { if (mip.MethodDef != null) { object[] vs = mip.MethodDef.GetCustomAttributes(typeof(StandaloneOnlyActionAttribute), true); if (vs != null && vs.Length > 0) { MessageBox.Show(caller, string.Format(System.Globalization.CultureInfo.InvariantCulture, "Action [{0}] cannot be used inside a method. Consider assigning it directly to an event.", act.ActionName), "Select action", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } } if (UseClientExecuterOnly) { if (act.ActionMethod.RunAt == EnumWebRunAt.Server) { MessageBox.Show(caller, string.Format(System.Globalization.CultureInfo.InvariantCulture, "Cannot use action executed by server object. Action:[{0}]", act.ActionName), "Select action", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } if (UseServerExecuterOnly) { if (act.ActionMethod.RunAt == EnumWebRunAt.Client) { MessageBox.Show(caller, string.Format(System.Globalization.CultureInfo.InvariantCulture, "Cannot use an action executed by client object. [{0}]", act.ActionName), "Select action", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } if (UseClientPropertyOnly) { IList <ISourceValuePointer> lst0 = act.GetServerProperties(0); if (lst0 != null && lst0.Count > 0) { List <ISourceValuePointer> lst = new List <ISourceValuePointer>(); foreach (ISourceValuePointer v in lst0) { if (v.IsWebServerValue()) { lst.Add(v); } } if (lst.Count > 0) { StringBuilder sb = new StringBuilder(lst[0].ToString()); for (int i = 1; i < lst.Count; i++) { sb.Append(","); sb.Append(lst[i].ToString()); } MessageBox.Show(caller, string.Format(System.Globalization.CultureInfo.InvariantCulture, "Cannot use an action involving server values. Action:[{0}] Server value(s):{1}", act.ActionName, sb.ToString()), "Select action", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } } if (UseServerPropertyOnly) { IList <ISourceValuePointer> lst0 = act.GetClientProperties(0); if (lst0 != null && lst0.Count > 0) { List <ISourceValuePointer> lst = new List <ISourceValuePointer>(); foreach (ISourceValuePointer v in lst0) { if (v.IsWebClientValue()) { lst.Add(v); } } if (lst.Count > 0) { StringBuilder sb = new StringBuilder(lst[0].ToString()); for (int i = 1; i < lst.Count; i++) { sb.Append(","); sb.Append(lst[i].ToString()); } MessageBox.Show(caller, string.Format(System.Globalization.CultureInfo.InvariantCulture, "Cannot use an action involving client values. Action:[{0}] Client value(s):{1}", act.ActionName, sb.ToString()), "Select action", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } } } return(true); }
/// <summary> /// indices for accessing array item /// </summary> /// <param name="owner"></param> /// <param name="method"></param> /// <returns></returns> public override CodeExpression[] GetIndexCodes(MethodInfoPointer owner, IMethodCompile method, UInt32 branchId) { return(null); }
public override void LoadNextLevel(TreeViewObjectExplorer tv, TreeNodeObject parentNode) { if (tv != null && tv.RootId != null && parentNode != null && parentNode.OwnerPointer != null && parentNode.OwnerPointer.RootPointer != null) { if (tv.Project != null && (tv.Project.ProjectType == EnumProjectType.WebAppPhp || tv.Project.ProjectType == EnumProjectType.WebAppAspx)) { if (tv.RootId.ClassId != parentNode.OwnerPointer.RootPointer.ClassId) { return; } } } IObjectPointer objRef = parentNode.OwnerPointer; TreeNodeClassRoot topClass = parentNode.TopLevelRootClassNode; bool forPhp = false; if (tv.Project != null) { forPhp = (tv.Project.ProjectType == EnumProjectType.WebAppPhp); } Dictionary <UInt32, IAction> actions = null; if (topClass != null) { if (!topClass.StaticScope) { actions = topClass.GetActions(); } } else { TreeNodeClassType rootType = parentNode.TopLevelNode as TreeNodeClassType; if (rootType != null) { actions = rootType.GetActions(); } } SortedList <string, TreeNode> newNodes = new SortedList <string, TreeNode>(); HtmlElement_BodyBase heb = (HtmlElement_BodyBase)parentNode.OwnerIdentity; MethodInfo[] mifs = heb.GetType().GetMethods(); if (mifs != null) { for (int i = 0; i < mifs.Length; i++) { if (parentNode.SelectionTarget == EnumObjectSelectType.Object) { if (mifs[i].ReturnType.Equals(typeof(void))) { continue; } ParameterInfo[] ps = mifs[i].GetParameters(); if (ps != null && ps.Length > 0) { continue; } } if (VPLUtil.IsNotForProgramming(mifs[i])) { continue; } if (!WebClientMemberAttribute.IsClientMethod(mifs[i]) && !WebServerMemberAttribute.IsServerMethod(mifs[i])) { continue; } MethodInfoPointer mp = new MethodInfoPointer(); mp.Owner = objRef; mp.SetMethodInfo(mifs[i]); int c; TreeNodeMethod nodeMethod = new TreeNodeMethod(ForStatic, mp); string key = mp.GetMethodSignature(out c); TreeNode nodeExist; if (newNodes.TryGetValue(key, out nodeExist)) { TreeNodeMethod mnd = (TreeNodeMethod)nodeExist; if (mnd.MethodInformation.DeclaringType.Equals(mnd.MethodInformation.ReflectedType)) { key = key + " - " + mifs[i].DeclaringType.Name; newNodes.Add(key, nodeMethod); } else { if (mifs[i].DeclaringType.Equals(mifs[i].ReflectedType)) { newNodes[key] = nodeMethod; key = key + " - " + mnd.MethodInformation.DeclaringType.Name; newNodes.Add(key, mnd); } else { key = key + " - " + mifs[i].DeclaringType.Name; newNodes.Add(key, nodeMethod); } } } else { newNodes.Add(key, nodeMethod); } //load actions if (actions != null) { bool bHasActions = false; foreach (IAction a in actions.Values) { ActionClass ac = a as ActionClass; if (ac != null) { MethodPointer mp0 = ac.ActionMethod as MethodPointer; if (mp0 != null) { if (mp0.IsSameObjectRef(mp)) { bHasActions = true; break; } } } } if (bHasActions) { nodeMethod.ShowActionIcon(); } } } parentNode.AddSortedNodes(newNodes); } }
public abstract string GetIndexCodeJS(MethodInfoPointer owner, UInt32 branchId);
public abstract string GetIncrementalStatementPhp(MethodInfoPointer owner, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data, UInt32 branchId);
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)); } }
public override string GetValueCodePHP(MethodInfoPointer owner, UInt32 branchId) { return(null); }
public abstract string[] GetIndexCodesPhp(MethodInfoPointer owner, JsMethodCompiler data, UInt32 branchId);
public abstract string GetValueCodePHP(MethodInfoPointer owner, UInt32 branchId);