Beispiel #1
0
 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;
 }
Beispiel #2
0
        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)));
        }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 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;
 }
Beispiel #5
0
 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;
 }
Beispiel #6
0
        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);
        }
Beispiel #7
0
 public static object GetFocused(SessionRequest request) {
     return PersistedObject.Get(Element.Create(AutomationElement.FocusedElement, request.Session.Process.Id), request.Session);
 }
Beispiel #8
0
 protected override Element GetTargetElement(SessionRequest basic)
 {
     return(Desktop.GetInstance(basic.Session.Process.Id));
 }
Beispiel #9
0
        protected virtual Element GetTargetElement(SessionRequest basic)
        {
            string targetId = (string)basic.Parameters["target"];

            return((Element)basic.Session[new Guid(targetId)]);
        }
Beispiel #10
0
 public ElementRequest(SessionRequest basic, Element target) : base(basic) {
     Target = target;
 }
Beispiel #11
0
 public ElementRequest(SessionRequest basic, Element target) : base(basic)
 {
     Target = target;
 }
Beispiel #12
0
		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;
		}
Beispiel #13
0
 public virtual object Respond(SessionRequest request)
 {
     return(handler(request));
 }
Beispiel #14
0
		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));
		}
Beispiel #15
0
 public static object Delete(SessionRequest request) {
     Attachment attachment = (Attachment)request.Session[new Guid(request.Parameters["attachment"])];
     request.Session.Release(attachment);
     attachment.Dispose();
     return null;
 }
Beispiel #16
0
 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);
 }
Beispiel #17
0
 protected virtual Element GetTargetElement(SessionRequest basic) {
     string targetId = (string)basic.Parameters["target"];
     return (Element)basic.Session[new Guid(targetId)];
 }
Beispiel #18
0
 protected override Element GetTargetElement(SessionRequest basic) {
     return Desktop.GetInstance(basic.Session.Process.Id);
 }
Beispiel #19
0
 public static object Clear(SessionRequest request) {
     Clipboard.Empty = true;
     return null;
 }
Beispiel #20
0
		public virtual object Respond(SessionRequest request) {
			return handler(request);
		}