/// <summary> /// Prepares scripts required by the specified control for /// registration on the client. This will not add the /// control to the Controls collection. /// </summary> /// <param name="control">The JavascriptControl to add</param> public void AddJsonControl(JsonControl control) { lock (addJsonControlLock) { if (wiring) { throw new JsonInvalidOperationException(string.Format("Can't add JsonControls during WireScriptsAndValidate phase.")); } if (jsonControls.ContainsKey(control.JsonId)) { return; } jsonControls.Add(control.JsonId, control); if (!jsonControlsByDomId.ContainsKey(control.DomId)) { jsonControlsByDomId.Add(control.DomId, control); } // commented this since this is an uninteresting event. When this happens the only thing that will be affected is // finding JsonControls by DomId. One should always use the JsonId to retrieve controls unless there is a specific // reason not to. //else if (jsonControlsByDomId[control.DomId] != control) //{ // LogManager.CurrentLog.AddEntry("Attempted to add JsonControl ({0}) but the control ({1}) has the same DomId.\r\n\r\n*** Stack Trace ***\r\n{2}", new string[] { control.ToString(), jsonControlsByDomId[control.DomId].ToString(), Environment.StackTrace }); //} //throw new JsonInvalidOperationException(string.Format("Attempted to add JsonControl ({0}) but the control ({1}) has the same DomId.", control.ToString(), jsonControlsByDomId[control.DomId].ToString())); } }
protected override void Render(HtmlTextWriter writer) { JsonControl.ApplyAttributesAndStyles(controlToRender, styles, attributes, CssClass); //if (this.UseWorking) //{ // SetupWorkingDiv(writer); //} controlToRender.TagName = "div"; controlToRender.Attributes.Add("id", this.DomId); controlToRender.Attributes.Add("jsonid", this.JsonId); if (!string.IsNullOrEmpty(this.Height)) { controlToRender.Style.Add(HtmlTextWriterStyle.Height, GetDimension(this.Height)); } if (!string.IsNullOrEmpty(this.Width)) { controlToRender.Style.Add(HtmlTextWriterStyle.Width, GetDimension(this.Width)); } controlToRender.RenderControl(writer); if (this.renderScripts) { this.RenderConglomerateScript(writer); } }
internal static void FillJsonControlDictionary(Page page, Dictionary <string, JsonControl> listToFill) { foreach (Control control in page.Controls) { if (control is JsonControl && !listToFill.ContainsValue((JsonControl)control)) { JsonControl toAdd = (JsonControl)control; listToFill.Add(toAdd.JsonId, toAdd); } } }
/// <inheritdoc/> public Selections Solve(Requirements requirements) { #region Sanity checks if (requirements == null) { throw new ArgumentNullException(nameof(requirements)); } if (requirements.InterfaceUri == null) { throw new ArgumentException(Resources.MissingInterfaceUri, nameof(requirements)); } #endregion Selections selections = null; _handler.RunTask(new SimpleTask(Resources.ExternalSolverRunning, () => { using (var control = new JsonControl(GetStartInfo()) { { "confirm", args => DoConfirm((string)args[0]) }, { "confirm-keys", args => DoConfirmKeys(new FeedUri((string)args[0]), args[1].ReparseAsJson <Dictionary <string, string[][]> >()) }, { "update-key-info", args => null } }) { control.Invoke(args => { if ((string)args[0] == "ok") { _feedManager.Stale = args[1].ReparseAsJson(new { stale = false }).stale; selections = XmlStorage.FromXmlString <Selections>((string)args[2]); } else { throw new SolverException(((string)args[1]).Replace("\n", Environment.NewLine)); } }, "select", GetEffectiveRequirements(requirements), _feedManager.Refresh); while (selections == null) { control.HandleStderr(); control.HandleNextChunk(); } control.HandleStderr(); } })); return(selections); }
public static List <JsonControl> GetAllJsonControls(Control parent) { List <JsonControl> results = new List <JsonControl>(); foreach (Control control in parent.Controls) { if (control is UserControl) { results.AddRange(GetAllJsonControls(control)); } if (control is JsonControl) { JsonControl jsonControl = (JsonControl)control; results.Add(jsonControl); } } return(results); }
public T FindJsonControlAs <T>(string jsonId) where T : JsonControl { T retVal = default(T); if (string.IsNullOrEmpty(jsonId)) { return(retVal); } if (jsonControls.ContainsKey(jsonId)) { retVal = jsonControls[jsonId] as T; if (retVal != null) { return(retVal); } } if (this.Master != null) { foreach (Control control in this.Master.Controls) { if (control is JsonControl) { JsonControl jsonControl = (JsonControl)control; if (jsonControl.JsonId.Equals(jsonId)) { retVal = jsonControl as T; if (retVal != null) { return(retVal); } } } } } return(retVal); }
private void SaveLogs() { JsonControl.WriteSerializedGzipFile("logs.gz", _controller.RigLogs); }
private void LoadLogs() { _controller = File.Exists("logs.gz") ? new RigController(JsonControl.GetSerializedGzipFile <BindingList <RigController.Rig> >("logs.gz")) : new RigController(); }
/// <inheritdoc/> public Selections Solve(Requirements requirements) { #region Sanity checks if (requirements == null) throw new ArgumentNullException(nameof(requirements)); if (requirements.InterfaceUri == null) throw new ArgumentException(Resources.MissingInterfaceUri, nameof(requirements)); #endregion Selections selections = null; _handler.RunTask(new SimpleTask(Resources.ExternalSolverRunning, () => { using (var control = new JsonControl(GetStartInfo()) { {"confirm", args => DoConfirm((string)args[0])}, {"confirm-keys", args => DoConfirmKeys(new FeedUri((string)args[0]), args[1].ReparseAsJson<Dictionary<string, string[][]>>())}, {"update-key-info", args => null} }) { control.Invoke(args => { if ((string)args[0] == "ok") { _feedManager.Stale = args[1].ReparseAsJson(new {stale = false}).stale; selections = XmlStorage.FromXmlString<Selections>((string)args[2]); } else throw new SolverException(((string)args[1]).Replace("\n", Environment.NewLine)); }, "select", GetEffectiveRequirements(requirements), _feedManager.Refresh); while (selections == null) { control.HandleStderr(); control.HandleNextChunk(); } control.HandleStderr(); } })); return selections; }
// Use this for initialization void Start() { _instance = this; }