public static object SetFocused(SessionRequest request) { Dictionary<string,object> element = (Dictionary<string,object>)request.Body["focusedElement"]; Guid guid = new Guid((string)element["uuid"]); Element elt = (Element)request.Session[guid]; elt.Focus(); return null; }
public override object Respond(SessionRequest request) { Element element = GetTargetElement(request); if (!optional && !element.Exists) { throw new ElementNotAvailableException("Element no longer exists"); } return(Respond(new ElementRequest(request, element))); }
public static object Create(SessionRequest request) { string extension = null; if (request.Body.ContainsKey("name")) { string name = (string)request.Body["name"]; if (name != null && name.Contains(".")) extension = name.Substring(name.LastIndexOf(".") + 1); } Attachment attachment = (extension == null) ? new Attachment() : new Attachment(extension); UpdateAttachment(attachment, request.Body); return PersistedObject.Get(attachment, request.Session); }
public static object SetContent(SessionRequest request) { switch((string)request.Body["type"]) { case null: Clipboard.Empty = true; break; case "text": Clipboard.Text = (string)request.Body["text"]; break; default: throw new TwinException("Unknown clipboard data type "+request.Body["type"]); } return null; }
public static object GetContent(SessionRequest request) { Dictionary<string,object> data = new Dictionary<string,object>(); if(Clipboard.Empty) { data["type"]=null; } else { string text = Clipboard.Text; if(text == null) data["type"] = "other"; else { data["type"] = "text"; data["text"] = text; } } return data; }
public override JSONResponse Respond(JSONRequest request) { SessionRequest sessionRequest = new SessionRequest(request); object value = Respond(sessionRequest); if (value is JSONResponse) { return((JSONResponse)value); } JSONResponse response = new JSONResponse(); response.Body = new Dictionary <string, object>(); response.Body["sessionId"] = sessionRequest.Session.ToString(); response.Body["status"] = (int)ResponseStatus.Success; response.Body["value"] = value; return(response); }
public static object GetFocused(SessionRequest request) { return PersistedObject.Get(Element.Create(AutomationElement.FocusedElement, request.Session.Process.Id), request.Session); }
protected override Element GetTargetElement(SessionRequest basic) { return(Desktop.GetInstance(basic.Session.Process.Id)); }
protected virtual Element GetTargetElement(SessionRequest basic) { string targetId = (string)basic.Parameters["target"]; return((Element)basic.Session[new Guid(targetId)]); }
public ElementRequest(SessionRequest basic, Element target) : base(basic) { Target = target; }
public override JSONResponse Respond(JSONRequest request) { SessionRequest sessionRequest = new SessionRequest(request); object value = Respond(sessionRequest); if (value is JSONResponse) return (JSONResponse)value; JSONResponse response = new JSONResponse(); response.Body = new Dictionary<string, object>(); response.Body["sessionId"] = sessionRequest.Session.ToString(); response.Body["status"] = (int)ResponseStatus.Success; response.Body["value"] = value; return response; }
public virtual object Respond(SessionRequest request) { return(handler(request)); }
public override object Respond(SessionRequest request) { Element element = GetTargetElement(request); if(!optional && !element.Exists) throw new ElementNotAvailableException("Element no longer exists"); return Respond(new ElementRequest(request, element)); }
public static object Delete(SessionRequest request) { Attachment attachment = (Attachment)request.Session[new Guid(request.Parameters["attachment"])]; request.Session.Release(attachment); attachment.Dispose(); return null; }
public static object Update(SessionRequest request) { Attachment attachment = (Attachment)request.Session[new Guid(request.Parameters["attachment"])]; UpdateAttachment(attachment, request.Body); return PersistedObject.GetNoCreate(attachment, request.Session); }
protected virtual Element GetTargetElement(SessionRequest basic) { string targetId = (string)basic.Parameters["target"]; return (Element)basic.Session[new Guid(targetId)]; }
protected override Element GetTargetElement(SessionRequest basic) { return Desktop.GetInstance(basic.Session.Process.Id); }
public static object Clear(SessionRequest request) { Clipboard.Empty = true; return null; }
public virtual object Respond(SessionRequest request) { return handler(request); }