Exemplo n.º 1
0
        public AutomationElement GetPreviousSibling(AutomationElement element, ICacheRequest cacheRequest = null)
        {
            var child = cacheRequest == null?
                        NativeTreeWalker.GetPreviousSibling(element.ToNative()) :
                            NativeTreeWalker.GetPreviousSibling(element.ToNative(), cacheRequest.ToNative());

            return(Automation.WrapNativeElement(child));
        }
Exemplo n.º 2
0
        public AutomationElement GetParent(AutomationElement element, ICacheRequest cacheRequest = null)
        {
            var parent = cacheRequest == null?
                         NativeTreeWalker.GetParent(element.ToNative()) :
                             NativeTreeWalker.GetParent(element.ToNative(), cacheRequest.ToNative());

            return(Automation.WrapNativeElement(parent));
        }
Exemplo n.º 3
0
        public AutomationElement GetLastChild(AutomationElement element, ICacheRequest cacheRequest = null)
        {
            var child = cacheRequest == null?
                        NativeTreeWalker.GetLastChildElement(element.ToNative()) :
                            NativeTreeWalker.GetLastChildElementBuildCache(element.ToNative(), cacheRequest.ToNative());

            return(Automation.WrapNativeElement(child));
        }
Exemplo n.º 4
0
        public void HandleDeivce(Object obj)
        {
            TcpClient client = (TcpClient)obj;
            var       stream = client.GetStream();

            Byte[] bytes = new Byte[2048];
            int    i;

            try
            {
                while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
                {
                    BinaryFormatter binaryFormatter = new BinaryFormatter();
                    ICacheResponse  response;
                    using (MemoryStream ms = new MemoryStream(bytes))
                    {
                        ICacheRequest cacheRequest = (ICacheRequest)binaryFormatter.Deserialize(ms);
                        if (cacheRequest is ISetCacheRequest setCacheRequest)
                        {
                            _cachingProvider.Set(setCacheRequest.Key, setCacheRequest.Value, new TimeSpan(0, 0, setCacheRequest.ExpiresIn));
                            response = new SetCacheResponse(true);
                        }
                        else if (cacheRequest is IGetCacheRequest getCacheRequest)
                        {
                            response = _cachingProvider.Get(getCacheRequest.Key);
                        }
                        else
                        {
                            throw new InvalidOperationException("Unknown action!");
                        }
                    }

                    using (MemoryStream responseMs = new MemoryStream())
                    {
                        binaryFormatter.Serialize(responseMs, response);
                        byte[] outputBytes = responseMs.ToArray();
                        stream.Write(outputBytes, 0, outputBytes.Length);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: {0}", e.ToString());
                client.Close();
            }
        }
Exemplo n.º 5
0
 public static UIA.CacheRequest ToNative(this ICacheRequest cacheRequest)
 {
     return(((UIA2CacheRequest)cacheRequest)?.NativeCacheRequest);
 }
Exemplo n.º 6
0
 public static UIA.IUIAutomationCacheRequest ToNative(this ICacheRequest cacheRequest)
 {
     return(((UIA3CacheRequest)cacheRequest)?.NativeCacheRequest);
 }