public AppHelperFactory(string configFile) { XmlDocument doc = new XmlDocument(); doc.Load(configFile); foreach (XmlNode appHelperNode in doc.SelectNodes("//AppHelper")) { string name = appHelperNode.Attributes["name"].Value; string className = appHelperNode.Attributes["class"].Value; Type appHelperType = Type.GetType(className); if (appHelperType != null) { System.Diagnostics.Debug.WriteLine(string.Format("AppHelperFactory: loaded type: {0}", appHelperType.ToString())); appHelpers[name] = (IAppHelper)Activator.CreateInstance(appHelperType); contexts[name] = new SimpleAppHelperContext(); List <string> inputFieldNames = new List <string>(); foreach (XmlNode inputField in appHelperNode.SelectNodes("inputFields/inputField")) { inputFieldNames.Add(inputField.Attributes["name"].Value); } contexts[name].InputFields = inputFieldNames.ToArray(); List <string> outputFieldNames = new List <string>(); foreach (XmlNode outputField in appHelperNode.SelectNodes("outputFields/outputField")) { outputFieldNames.Add(outputField.Attributes["name"].Value); } contexts[name].OutputFields = outputFieldNames.ToArray(); } } }
public AppHelperFactory(string configFile) { XmlDocument doc = new XmlDocument(); doc.Load(configFile); foreach (XmlNode appHelperNode in doc.SelectNodes("//AppHelper")) { string name = appHelperNode.Attributes["name"].Value; string className = appHelperNode.Attributes["class"].Value; Type appHelperType = Type.GetType(className); if (appHelperType != null) { System.Diagnostics.Debug.WriteLine(string.Format("AppHelperFactory: loaded type: {0}", appHelperType.ToString())); appHelpers[name] = (IAppHelper)Activator.CreateInstance(appHelperType); contexts[name] = new SimpleAppHelperContext(); List<string> inputFieldNames = new List<string>(); foreach (XmlNode inputField in appHelperNode.SelectNodes("inputFields/inputField")) { inputFieldNames.Add(inputField.Attributes["name"].Value); } contexts[name].InputFields = inputFieldNames.ToArray(); List<string> outputFieldNames = new List<string>(); foreach (XmlNode outputField in appHelperNode.SelectNodes("outputFields/outputField")) { outputFieldNames.Add(outputField.Attributes["name"].Value); } contexts[name].OutputFields = outputFieldNames.ToArray(); } } }
private void DoSearch(IAppHelper helper) { statusLabel.Text = "Performing Search. Please Wait..."; this.Cursor = Cursors.WaitCursor; // use an app helper to locate information //helper = appHelperFactory.GetAppHelper(appHelper); AppHelperContext context = new SimpleAppHelperContext(); context["title"] = txtMovieName.Text; AppHelperItem[] items = helper.LocateItems(context); statusLabel.Text = null; this.Cursor = Cursors.Default; switch (items.Length) { case 0: MessageBox.Show("No Match Found for: " + txtMovieName.Text); break; case 1: AppHelperItemSelected(helper, items[0]); break; default: AppHelperResultSelector resultSelector = new AppHelperResultSelector(helper); resultSelector.ItemSelectedEvent += new AppHelperItemSelected(AppHelperItemSelected); resultSelector.Items = items; resultSelector.Show(); break; } }
private void AppHelperItemSelected(IAppHelper helper, AppHelperItem item) { System.Diagnostics.Debug.WriteLine(string.Format("got selected item. name: {0}. value: {1}", item.Name, item.Value)); AppHelperContext context = new SimpleAppHelperContext(); if (helper.LoadItem(item, context)) { // if (context["title"] != null) // this.txtMovieName.Text = (string)context["title"]; MediaItem.ReadFrom(context); UpdateDisplay(); } }