示例#1
0
文件: Elements.cs 项目: kevtham/twin
 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;
 }
示例#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)));
        }
示例#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);
 }
示例#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;
 }
示例#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;
 }
示例#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);
        }
示例#7
0
文件: Elements.cs 项目: kevtham/twin
 public static object GetFocused(SessionRequest request) {
     return PersistedObject.Get(Element.Create(AutomationElement.FocusedElement, request.Session.Process.Id), request.Session);
 }
示例#8
0
 protected override Element GetTargetElement(SessionRequest basic)
 {
     return(Desktop.GetInstance(basic.Session.Process.Id));
 }
示例#9
0
        protected virtual Element GetTargetElement(SessionRequest basic)
        {
            string targetId = (string)basic.Parameters["target"];

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