Clone() public method

public Clone ( ) : CacheRequest
return CacheRequest
示例#1
0
        public AutomationElement GetUpdatedCache(CacheRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var updated = SourceManager.GetOrCreateAutomationElement(sourceElement);

            if (request == CacheRequest.DefaultRequest)
            {
                return(updated);
            }

            if ((request.TreeScope & TreeScope.Element) == TreeScope.Element)
            {
                foreach (var property in request.CachedProperties)
                {
                    updated.propertyCache [property.Id] =
                        new CachedValue(updated.GetCurrentPropertyValue(property),
                                        updated.sourceElement.SupportsProperty(property));
                }
                updated.mode         = request.AutomationElementMode;
                updated.CacheRequest = request.Clone();
            }

            if ((request.TreeScope & TreeScope.Children) == TreeScope.Children ||
                (request.TreeScope & TreeScope.Descendants) == TreeScope.Descendants)
            {
                // Modify scope to make sure children include
                // themselves, and only include their own
                // children if specified by original scope
                var childRequest = request.Clone();
                childRequest.TreeScope |= TreeScope.Element;
                if ((request.TreeScope & TreeScope.Descendants) != TreeScope.Descendants)
                {
                    childRequest.TreeScope ^= TreeScope.Children;
                }

                updated.cachedChildren = new List <AutomationElement> ();
                var child = TreeWalker.RawViewWalker.GetFirstChild(updated, childRequest);
                while (child != null)
                {
                    if (childRequest.TreeFilter.AppliesTo(child))
                    {
                        child.cachedParent = updated;
                        updated.cachedChildren.Add(child);
                    }
                    child = TreeWalker.RawViewWalker.GetNextSibling(child, childRequest);
                }
            }

            return(updated);
        }
示例#2
0
 public void CloneTest()
 {
     CacheRequest target = new CacheRequest();
     target.TreeScope = TreeScope.Subtree;
     CacheRequest actual;
     actual = target.Clone();
     Assert.AreEqual(target.TreeScope, actual.TreeScope);
 }
示例#3
0
		public AutomationElement GetUpdatedCache (CacheRequest request)
		{
			if (request == null)
				throw new ArgumentNullException ("request");

			var updated = SourceManager.GetOrCreateAutomationElement (sourceElement);
			if (request == CacheRequest.DefaultRequest)
				return updated;

			if ((request.TreeScope & TreeScope.Element) == TreeScope.Element) {
				foreach (var property in request.CachedProperties) {
					updated.propertyCache [property.Id ] =
						new CachedValue (updated.GetCurrentPropertyValue (property),
						                 updated.sourceElement.SupportsProperty (property));
				}
				updated.mode = request.AutomationElementMode;
				updated.CacheRequest = request.Clone ();
			}

			if ((request.TreeScope & TreeScope.Children) == TreeScope.Children ||
			    (request.TreeScope & TreeScope.Descendants) == TreeScope.Descendants) {
				// Modify scope to make sure children include
				// themselves, and only include their own
				// children if specified by original scope
				var childRequest = request.Clone ();
				childRequest.TreeScope |= TreeScope.Element;
				if ((request.TreeScope & TreeScope.Descendants) != TreeScope.Descendants)
					childRequest.TreeScope ^= TreeScope.Children;

				updated.cachedChildren = new List<AutomationElement> ();
				var child = TreeWalker.RawViewWalker.GetFirstChild (updated, childRequest);
				while (child != null) {
					if (childRequest.TreeFilter.AppliesTo (child)) {
						child.cachedParent = updated;
						updated.cachedChildren.Add (child);
					}
					child = TreeWalker.RawViewWalker.GetNextSibling (child, childRequest);
				}
			}

			return updated;
		}