Exemple #1
0
//        internal static IUiEltCollection GetUiEltCollectionViaChildKerne(AutomationElementCollection elements, IChildKernel childKernel)
//        {
//            if (null == elements) {
//                return null;
//            }
//            try {
//                var manyElements = new ConstructorArgument("elements", elements);
//                  IUiEltCollection adapterCollection = childKernel.Get<IUiEltCollection>("AutomationElementCollection.NET", manyElements);
//                   return adapterCollection;
//            }
//            catch (Exception eFailedToIssueCollection) {
//                // TODO
//                // write error to error object!!!
//                // Console.WriteLine("Collection 01 via ChildKernel");
//                // Console.WriteLine(eFailedToIssueCollection.Message);
//                return null;
//            }
//        }

        internal static IUiEltCollection GetUiEltCollection(classic.AutomationElementCollection elements)
        {
            if (null == elements)
            {
                return(null);
            }
            try {
                var manyElements = new ConstructorArgument("elements", elements);
                // 20140122
                IUiEltCollection adapterCollection;   // = Kernel.Get<IUiEltCollection>("AutomationElementCollection.NET", manyElements);
//                  if (null != ChildKernel) {
//Console.WriteLine("child coll");
                // adapterCollection = ChildKernel.Get<IUiEltCollection>("AutomationElementCollection.NET", manyElements);
                // var childKernel = GetChildKernel();
                // adapterCollection = childKernel.Get<IUiEltCollection>("AutomationElementCollection.NET", manyElements);
                adapterCollection = ChildKernel.Get <IUiEltCollection>("AutomationElementCollection.NET", manyElements);
                // childKernel.Dispose();
//                  } else {
//                      adapterCollection = Kernel.Get<IUiEltCollection>("AutomationElementCollection.NET", manyElements);
//                  }
                return(adapterCollection);
            }
            catch (Exception) {
                // TODO
                // write error to error object!!!
                // Console.WriteLine("Collection 01");
                // Console.WriteLine(eFailedToIssueCollection.Message);
                return(null);
            }
        }
Exemple #2
0
 public UiEltCollection(classic.AutomationElementCollection elements)
 {
     foreach (classic.AutomationElement element in elements.Cast <classic.AutomationElement>().Where(element => null != element))
     {
         _collectionHolder.Add(AutomationFactory.GetUiElement(element));
     }
 }