private void FillInvokeTab() { Assembly proxyAssembly = wsdl.ProxyAssembly; if (proxyAssembly != null) { treeMethods.Nodes.Clear(); foreach (System.Type type in proxyAssembly.GetTypes()) { if (TreeNodeProperty.IsWebService(type)) { TreeNode node = treeMethods.Nodes.Add(type.Name, type.Name); HttpWebClientProtocol proxy = (HttpWebClientProtocol)Activator.CreateInstance(type); ProxyProperty property = new ProxyProperty(proxy); property.RecreateSubtree(null); node.Tag = property.TreeNode; proxy.Credentials = CredentialCache.DefaultCredentials; SoapHttpClientProtocol protocol2 = proxy as SoapHttpClientProtocol; if (protocol2 != null) { protocol2.CookieContainer = new CookieContainer(); protocol2.AllowAutoRedirect = true; } foreach (MethodInfo info in type.GetMethods()) { if (TreeNodeProperty.IsWebMethod(info)) { node.Nodes.Add(info.Name, info.Name).Tag = info; } } } } this.treeMethods.ExpandAll(); } }
private void ClearAllTabs() { buttonSaveAll.Enabled = false; buttonFind.Enabled = false; textBoxFind.Enabled = false; buttonCopy.Enabled = false; buttonPaste.Enabled = false; buttonOutputCopy.Enabled = false; richWsdl.Clear(); richWsdl.Font = Configuration.MasterConfig.UiSettings.WsdlFont; treeWsdl.Nodes.Clear(); richMessage.Clear(); richMessage.Font = Configuration.MasterConfig.UiSettings.MessageFont; richRequest.Clear(); richRequest.Font = Configuration.MasterConfig.UiSettings.ReqRespFont; richResponse.Clear(); richResponse.Font = Configuration.MasterConfig.UiSettings.ReqRespFont; treeMethods.Nodes.Clear(); toolStripButtonSort.Enabled = false; toolStripButtonSearch.Enabled = false; textBoxSearch.Enabled = false; TreeNodeProperty.ClearIncludedTypes(); treeInput.Nodes.Clear(); treeOutput.Nodes.Clear(); propInput.SelectedObject = null; propOutput.SelectedObject = null; if (Configuration.MasterConfig.WsdlSettings.BypassCertificateValidation == true) { ServicePointManager.ServerCertificateValidationCallback = delegate(Object sender1, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return(true); }; } }
private bool IsValidPasteNode(TreeNodeProperty tnp) { IDataObject dataObject = Clipboard.GetDataObject(); if ((dataObject == null) || (dataObject.GetData(DataFormats.Text) == null)) { return(false); } return(this.IsValidCopyNode(tnp)); }
private void propInput_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { TreeNodeProperty selectedObject = this.propInput.SelectedObject as TreeNodeProperty; if ((selectedObject != null) && ((e.ChangedItem.Label == "Type") && (e.OldValue != selectedObject.Type))) { TreeNodeProperty property2 = TreeNodeProperty.CreateTreeNodeProperty(selectedObject); property2.TreeNode = selectedObject.TreeNode; property2.RecreateSubtree(null); this.treeInput.SelectedNode = property2.TreeNode; } }
internal void macroPlaySetInput(string method, string field, string value, MacroPlayer.MacroCallbackType macroCallbackType) { macroCallback = macroCallbackType; if (macroPlaySelectNode(method, treeMethods.Nodes, treeMethods) != null) { TreeNode body = treeInput.Nodes.Find("Body", true)[0]; foreach (TreeNode tn in body.Nodes) { TreeNodeProperty tnp = (tn.Tag as TreeNodeProperty); if (tnp != null) { if (string.Compare(field, tnp.Name, StringComparison.InvariantCultureIgnoreCase) == 0) { treeInput.SelectedNode = tn; object ovalue = value; if (!tnp.Type.Equals(typeof(String))) { if (tnp.Type.Equals(typeof(DateTime)) && value.Equals("TODAY")) { value = DateTime.Now.ToString("yyyy-MM-dd"); } MethodInfo[] mi = tnp.Type.GetMethods(); foreach (MethodInfo m in mi) { if ("Parse".Equals(m.Name)) { ParameterInfo[] pi = m.GetParameters(); if ((pi.Length == 1) && (pi[0].ParameterType.Equals(typeof(String)))) { ovalue = m.Invoke(m, new object[] { value }); break; } } } } TreeNodeProperty property2 = TreeNodeProperty.CreateTreeNodeProperty(tnp, ovalue); property2.TreeNode = tnp.TreeNode; property2.RecreateSubtree(null); this.treeInput.SelectedNode = property2.TreeNode; macroCallback.Invoke(); } } } } }
private void CopyToClipboard(TreeNodeProperty tnp) { if (!IsValidCopyNode(tnp)) { throw new Exception("Cannot copy from here"); } object o = tnp.ReadChildren(); if (o != null) { StringWriter writer = new StringWriter(); System.Type[] extraTypes = new System.Type[] { o.GetType() }; System.Type type = (o is DataSet) ? typeof(DataSet) : typeof(object); new XmlSerializer(type, extraTypes).Serialize((TextWriter)writer, o); Clipboard.SetDataObject(writer.ToString()); } }
internal string macroPlayGetValue(string output, string field, TreeNodeCollection trc, ref int counter) { string s = string.Empty; foreach (TreeNode tn in trc) { TreeNodeProperty tnp = (tn.Tag as TreeNodeProperty); if (tnp != null) { if (string.Compare(field, tnp.Name, StringComparison.InvariantCultureIgnoreCase) == 0) { if (counter > 1) { counter--; continue; } treeOutput.SelectedNode = tn; ClassProperty cp = tn.Tag as ClassProperty; if (cp != null) { return(cp.InternalValue.ToString()); } PrimitiveProperty pp = tn.Tag as PrimitiveProperty; if (pp != null) { return(pp.Value.ToString()); } throw new ApplicationException("Unsupported type in macroPlayGetValue"); } } s = macroPlayGetValue(output, field, tn.Nodes, ref counter); if (!string.IsNullOrEmpty(s)) { break; } } return(s); }
private void treeViewAll_AfterSelect(object sender, TreeViewEventArgs e) { btOK.Enabled = false; if (e.Node != null) { TreeNodeProperty tnp = e.Node as TreeNodeProperty; if (tnp != null) { btOK.Enabled = !tnp.Property.IsReadOnly; } else { TreeNodeCustomProperty tncp = e.Node as TreeNodeCustomProperty; if (tncp != null) { btOK.Enabled = tncp.Property.CanWrite; } } } }
private void buttonPaste_Click(object sender, EventArgs e) { TreeNodeProperty tag = this.treeInput.SelectedNode.Tag as TreeNodeProperty; if (tag is MethodProperty) { throw new Exception("Paste not valid on method"); } System.Type[] typeList = tag.GetTypeList(); System.Type type = typeof(DataSet).IsAssignableFrom(typeList[0]) ? typeof(DataSet) : typeof(object); XmlSerializer serializer = new XmlSerializer(type, typeList); StringReader textReader = new StringReader((string)Clipboard.GetDataObject().GetData(DataFormats.Text)); object val = serializer.Deserialize(textReader); if ((val == null) || !typeList[0].IsAssignableFrom(val.GetType())) { throw new Exception("Invalid Type pasted"); } TreeNodeProperty property2 = TreeNodeProperty.CreateTreeNodeProperty(tag, val); property2.TreeNode = tag.TreeNode; property2.RecreateSubtree(null); this.treeInput.SelectedNode = property2.TreeNode; }
private bool IsValidPasteNode(TreeNodeProperty tnp) { IDataObject dataObject = Clipboard.GetDataObject(); if ((dataObject == null) || (dataObject.GetData(DataFormats.Text) == null)) { return false; } return this.IsValidCopyNode(tnp); }
private bool IsValidCopyNode(TreeNodeProperty tnp) { return (((tnp != null) && (tnp.TreeNode.Parent != null)) && (tnp.GetType() != typeof(TreeNodeProperty))); }
private bool IsValidCopyNode(TreeNodeProperty tnp) { return(((tnp != null) && (tnp.TreeNode.Parent != null)) && (tnp.GetType() != typeof(TreeNodeProperty))); }
public static void ApplyConfig(TreeNode treeNode, string currentxpath, XmlDocument xmlDocument, Assembly proxyAssembly) { if (treeNode.Tag != null) { string nodeType = treeNode.Tag.GetType().ToString(); XmlNode currentNode = null; switch (nodeType) { case "WebServiceStudio.MethodProperty": currentxpath += ((MethodProperty)treeNode.Tag).Name; //((MethodProperty)treeNode.Tag). = xmlDocument.SelectSingleNode(currentxpath); break; case "WebServiceStudio.ClassProperty": currentxpath += "/" + ((ClassProperty)treeNode.Tag).Name; currentNode = xmlDocument.SelectSingleNode(currentxpath); if (currentNode != null) { if (currentNode.Attributes["isNull"] != null) { ((ClassProperty)treeNode.Tag).IsNull = Convert.ToBoolean(currentNode.Attributes["isNull"].Value); } else { if (currentNode.Attributes["type"] != null) { if (Type.GetType(currentNode.Attributes["type"].Value) != ((ClassProperty)treeNode.Tag).Type) { ((ClassProperty)treeNode.Tag).Type = Type.GetType(currentNode.Attributes["type"].Value); TreeNodeProperty property1 = treeNode.Tag as TreeNodeProperty; TreeNodeProperty property2 = TreeNodeProperty.CreateTreeNodeProperty(property1); property2.TreeNode = property1.TreeNode; property2.RecreateSubtree(null); treeNode = property2.TreeNode; if (currentNode.Attributes["value"] != null) { Type type = Type.GetType(currentNode.Attributes["type"].Value); if (type == null) { type = proxyAssembly.GetType(currentNode.Attributes["type"].Value); } if (type.IsEnum) { ((NullablePrimitiveProperty)treeNode.Tag).Value = Enum.Parse(type, currentNode.Attributes["value"].Value); } else { ((NullablePrimitiveProperty)treeNode.Tag).Value = Convert.ChangeType(currentNode.Attributes["value"].Value, type); } } } } ((ClassProperty)treeNode.Tag).IsNull = false; } } break; case "WebServiceStudio.PrimitiveProperty": currentxpath += "/" + ((PrimitiveProperty)treeNode.Tag).Name; currentNode = xmlDocument.SelectSingleNode(currentxpath); if (currentNode != null) { Type type = Type.GetType(currentNode.Attributes["type"].Value); if (type == null) { type = proxyAssembly.GetType(currentNode.Attributes["type"].Value); } if (type.IsEnum) { ((PrimitiveProperty)treeNode.Tag).Value = Enum.Parse(type, currentNode.Attributes["value"].Value); } else { ((PrimitiveProperty)treeNode.Tag).Value = Convert.ChangeType(currentNode.Attributes["value"].Value, type); } } break; case "WebServiceStudio.NullablePrimitiveProperty": currentxpath += "/" + ((NullablePrimitiveProperty)treeNode.Tag).Name; currentNode = xmlDocument.SelectSingleNode(currentxpath); if (currentNode != null) { if (currentNode.Attributes["isNull"] != null) { ((NullablePrimitiveProperty)treeNode.Tag).IsNull = Convert.ToBoolean(currentNode.Attributes["isNull"].Value); } else { ((NullablePrimitiveProperty)treeNode.Tag).IsNull = false; } //if (currentNode.Attributes["type"] != null) //{ Type type = Type.GetType(currentNode.Attributes["type"].Value); if (type == null) { type = proxyAssembly.GetType(currentNode.Attributes["type"].Value); } if (type.IsEnum) { if (currentNode.Attributes["value"] != null) { ((NullablePrimitiveProperty)treeNode.Tag).Value = Enum.Parse(type, currentNode.Attributes["value"].Value); } } else { if (currentNode.Attributes["value"] != null) { ((NullablePrimitiveProperty)treeNode.Tag).Value = Convert.ChangeType(currentNode.Attributes["value"].Value, type); } } //} } break; case "WebServiceStudio.ArrayProperty": currentxpath += "/" + ((ArrayProperty)treeNode.Tag).Name; currentNode = xmlDocument.SelectSingleNode(currentxpath); if (currentNode.Attributes["isNull"] != null) { ((ArrayProperty)treeNode.Tag).IsNull = Convert.ToBoolean(currentNode.Attributes["isNull"].Value); } else { ((ArrayProperty)treeNode.Tag).IsNull = false; } ((ArrayProperty)treeNode.Tag).Length = Convert.ToInt32( currentNode.Attributes["length"].Value); break; default: throw new NotSupportedException("Not Supported Property:" + nodeType); } } else { currentxpath += "/" + treeNode.Text; } foreach (TreeNode childTreeNode in treeNode.Nodes) { ApplyConfig(childTreeNode, currentxpath, xmlDocument, proxyAssembly); } }
public override void LoadNextLevel(TreeViewObjectExplorer tv, TreeNodeObject parentNode) { UInt32 scopeId = parentNode.ScopeMethodId; SortedList <string, TreeNode> newNodes = new SortedList <string, TreeNode>(); HtmlElement_BodyBase heb = (HtmlElement_BodyBase)parentNode.OwnerIdentity; PropertyDescriptorCollection pifs = TypeDescriptor.GetProperties(heb.GetType()); TreeNodeClassRoot topClass = parentNode.TopLevelRootClassNode; Dictionary <UInt32, IAction> actions = null; if (topClass != null) { if (!topClass.StaticScope) { actions = topClass.GetActions(); } } else { if (tv != null) { if (tv.RootClassNode != null) { actions = tv.RootClassNode.GetActions(); } } if (actions == null) { TreeNodeClassType rootType = parentNode.TopLevelNode as TreeNodeClassType; if (rootType != null) { actions = rootType.GetActions(); } } } for (int i = 0; i < pifs.Count; i++) { if (NotForProgrammingAttribute.IsNotForProgramming(pifs[i])) { continue; } if (!WebClientMemberAttribute.IsClientProperty(pifs[i]) && !WebServerMemberAttribute.IsServerProperty(pifs[i])) { continue; } TreeNodeProperty nodeProperty; PropertyPointer pp; pp = new PropertyPointer(); pp.Owner = new HtmlElementPointer(heb); pp.SetPropertyInfo(pifs[i]); if (!newNodes.ContainsKey(pp.Name)) { nodeProperty = new TreeNodeProperty(ForStatic, pp); try { newNodes.Add(pp.Name, nodeProperty); } catch (Exception err) { MathNode.Log(tv != null ? tv.FindForm() : null, err); } //load actions bool bHasActions = false; if (string.CompareOrdinal(pp.Name, "Cursor") == 0) { bHasActions = false; } if (actions != null) { foreach (IAction a in actions.Values) { if (a != null && a.IsStatic == parentNode.IsStatic) { if (nodeProperty.IncludeAction(a, tv, scopeId, false)) { bHasActions = true; break; } } } if (bHasActions) { nodeProperty.OnShowActionIcon(); } } } } parentNode.AddSortedNodes(newNodes); }