示例#1
0
 public void ElementStart(IFormHandlerContext context)
 {
     ElementInfo ei = context.CurrentElement;
     string typeName = ei.GetAttributeValue("type");
     if (typeName == null) throw new Exception("type not specified in <custom>");
     Type t = Type.GetType(typeName);
     if (t == null) throw new Exception("Type not found: " + typeName);
     _handler = (IElementHandler) Activator.CreateInstance(t);
     if (_handler == null) throw new Exception("Failed to create instance of type " + typeName);
     _handler.ElementStart(context);
 }
示例#2
0
 public static void MapExcludedWithChildren(IElementHandler handler, Element view)
 {
 }
示例#3
0
 /**
  * Parses the xml data in the given reader and sends created {@link Element}
  * s to the defined ElementHandler.<br />
  * This method configures the XMLWorker and XMLParser to parse (X)HTML/CSS
  * and accept unknown tags.
  *
  * @param d the handler
  * @param in the reader
  * @throws IOException thrown when something went wrong with the IO
  */
 public void ParseXHtml(IElementHandler d, TextReader inp) {
     CssFilesImpl cssFiles = new CssFilesImpl();
     cssFiles.Add(GetDefaultCSS());
     StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
     HtmlPipelineContext hpc = new HtmlPipelineContext(null);
     hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(GetDefaultTagProcessorFactory());
     IPipeline pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(hpc, new ElementHandlerPipeline(d,
             null)));
     XMLWorker worker = new XMLWorker(pipeline, true);
     XMLParser p = new XMLParser();
     p.AddListener(worker);
     p.Parse(inp);
 }
示例#4
0
        private void processHtml(IElementHandler elementsHandler)
        {
            var cssResolver = new StyleAttrCSSResolver();

            if (CssFilesPath != null && CssFilesPath.Any())
            {
                foreach (var cssFile in CssFilesPath)
                {
                    cssResolver.AddCss(XmlWorkerUtils.GetCssFile(cssFile));
                }
            }

            if (!string.IsNullOrEmpty(InlineCss))
            {
                cssResolver.AddCss(InlineCss, "utf-8", true);
            }

            var htmlContext = new HtmlPipelineContext(new CssAppliersImpl(new UnicodeFontProvider(DefaultFont)));
            if (!string.IsNullOrEmpty(ImagesPath))
            {
                htmlContext.SetImageProvider(new ImageProvider { ImagesPath = ImagesPath });
            }
            htmlContext.CharSet(Encoding.UTF8);

            var tagsProcessorFactory = (DefaultTagProcessorFactory)Tags.GetHtmlTagProcessorFactory();
            if (PdfElement != null)
            {
                tagsProcessorFactory.AddProcessor("totalpagesnumber", new TotalPagesNumberXmlWorkerProcessor(PdfElement));
            }

            htmlContext.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(tagsProcessorFactory);
            var pipeline = new CssResolverPipeline(cssResolver,
                                                   new HtmlPipeline(htmlContext, new ElementHandlerPipeline(elementsHandler, null)));
            var worker = new XMLWorker(pipeline, parseHtml: true);
            var parser = new XMLParser();
            parser.AddListener(worker);
            parser.Parse(new StringReader(Html));
        }
示例#5
0
 public static void MapAutomationPropertiesExcludedWithChildren(IElementHandler handler, Element element)
 {
     //TODO : Need to impl
 }
示例#6
0
 public HandlerChangingEventArgs(IElementHandler oldHandler, IElementHandler newHandler)
 {
     NewHandler = newHandler;
     OldHandler = oldHandler;
 }
        public NativeComponentAdapter(NativeComponentRenderer renderer, IElementHandler closestPhysicalParent, IElementHandler knownTargetElement = null)
        {
            Renderer = renderer ?? throw new ArgumentNullException(nameof(renderer));
            _closestPhysicalParent = closestPhysicalParent;
            _targetElement         = knownTargetElement;

            // Assign unique counter value. This *should* all be done on one thread, but just in case, make it thread-safe.
            _debugInstanceCounterValue = Interlocked.Increment(ref DebugInstanceCounter);
        }
示例#8
0
 public static T InvokeWithResult <T>(this IElementHandler handler, string commandName,
                                      RetrievePlatformValueRequest <T> args)
 {
     handler?.Invoke(commandName, args);
     return(args.Result);
 }
 public abstract bool IsParentOfChild(IElementHandler parentHandler, IElementHandler childHandler);
 public abstract bool IsParented(IElementHandler handler);
 public abstract int GetPhysicalSiblingIndex(IElementHandler handler);
 public abstract void AddChildElement(IElementHandler parentHandler, IElementHandler childHandler, int physicalSiblingIndex);
示例#13
0
 public ElementHandlerFactoryContext(NativeComponentRenderer renderer, IElementHandler parentHandler)
 {
     Renderer      = renderer ?? throw new ArgumentNullException(nameof(renderer));
     ParentHandler = parentHandler;
 }
示例#14
0
 public static void MapIsInAccessibleTree(IElementHandler handler, Element element)
 {
     Platform.AccessibilityExtensions.SetAutomationPropertiesAccessibilityView(
         handler.NativeView as Microsoft.UI.Xaml.FrameworkElement, element);
 }
示例#15
0
 public static PlatformView ToPlatform(this IElementHandler elementHandler) =>
 (elementHandler.VirtualView?.ToPlatform() as PlatformView) ??
 throw new InvalidOperationException($"Unable to convert {elementHandler} to {typeof(PlatformView)}");
 public abstract void RemoveChildElement(IElementHandler parentHandler, IElementHandler childHandler);
示例#17
0
 public static Task <T> InvokeAsync <T>(this IElementHandler handler, string commandName,
                                        TaskCompletionSource <T> args)
 {
     handler?.Invoke(commandName, args);
     return(args.Task);
 }
示例#18
0
 public BasicMatchingHandler(IElementHandler inner, ITestContext context)
 {
     _inner = inner;
     _context = context;
 }
示例#19
0
 public void SetElementReference(IElementHandler elementHandler)
 {
     ElementHandler = elementHandler ?? throw new ArgumentNullException(nameof(elementHandler));
 }
示例#20
0
        Task RunWindowTest <THandler>(IWindow window, Func <THandler, Task> action)
            where THandler : class, IElementHandler
        {
            return(InvokeOnMainThreadAsync(async() =>
            {
                var testingRootPanel = (WPanel)MauiProgram.CurrentWindow.Content;
                IElementHandler newWindowHandler = null;
                NavigationRootManager navigationRootManager = null;
                try
                {
                    var scopedContext = new MauiContext(MauiContext.Services);
                    scopedContext.AddWeakSpecific(MauiProgram.CurrentWindow);
                    var mauiContext = scopedContext.MakeScoped(true);
                    navigationRootManager = mauiContext.GetNavigationRootManager();

                    MauiContext
                    .Services
                    .GetRequiredService <WWindow>()
                    .SetWindowHandler(window, mauiContext);

                    newWindowHandler = window.Handler;
                    var content = window.Content.Handler.ToPlatform();
                    await content.OnLoadedAsync();
                    await Task.Delay(10);

                    if (typeof(THandler).IsAssignableFrom(newWindowHandler.GetType()))
                    {
                        await action((THandler)newWindowHandler);
                    }
                    else if (typeof(THandler).IsAssignableFrom(window.Content.Handler.GetType()))
                    {
                        await action((THandler)window.Content.Handler);
                    }
                    else if (window.Content is ContentPage cp && typeof(THandler).IsAssignableFrom(cp.Content.Handler.GetType()))
                    {
                        await action((THandler)cp.Content.Handler);
                    }
                    else
                    {
                        throw new Exception($"I can't work with {typeof(THandler)}");
                    }
                }
                finally
                {
                    if (navigationRootManager != null)
                    {
                        navigationRootManager.Disconnect();
                    }

                    if (newWindowHandler != null)
                    {
                        newWindowHandler.DisconnectHandler();
                    }

                    // Set the root window panel back to the testing panel
                    if (testingRootPanel != null && MauiProgram.CurrentWindow.Content != testingRootPanel)
                    {
                        MauiProgram.CurrentWindow.Content = testingRootPanel;
                        await testingRootPanel.OnLoadedAsync();
                        await Task.Delay(10);
                    }

                    // reset the appbar title to our test runner
                    MauiProgram
                    .CurrentWindow
                    .GetWindow()
                    .Handler
                    .MauiContext
                    .GetNavigationRootManager()
                    .UpdateAppTitleBar(true);
                }
            }));
示例#21
0
        UIViewController GetVisibleViewController(IElementHandler handler)
        {
            var vcs = GetActiveChildViewControllers(handler);

            return(vcs[vcs.Length - 1]);
        }
 /// <summary>
 /// Creates a component of type <typeparamref name="TComponent"/> and adds it as a child of <paramref name="parent"/>.
 /// </summary>
 /// <typeparam name="TComponent"></typeparam>
 /// <param name="parent"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public async Task <TComponent> AddComponent <TComponent>(IElementHandler parent, Dictionary <string, object> parameters = null) where TComponent : IComponent
 {
     return((TComponent) await AddComponent(typeof(TComponent), parent, parameters).ConfigureAwait(false));
 }
示例#23
0
 /**
  * Does not use a context.
  * @param handler the ElementHandler
  * @param next the next pipeline in line. (or <code>null</code> if none )
  */
 public ElementHandlerPipeline(IElementHandler handler, IPipeline next) : base(next)
 {
     this.handler = handler;
 }
示例#24
0
 public bool IsNavigationBarVisible(IElementHandler handler) =>
 IsNavigationBarVisible(handler.MauiContext);
示例#25
0
 public static void MapAutomationPropertiesIsInAccessibleTree(IElementHandler handler, Element element)
 {
     //TODO : Need to impl
 }
示例#26
0
 string GetToolbarTitle(IElementHandler handler) =>
 GetPlatformToolbar(handler).Title;
 /**
  * Does not use a context.
  * @param handler the ElementHandler
  * @param next the next pipeline in line. (or <code>null</code> if none )
  */
 public ElementHandlerPipeline(IElementHandler handler, IPipeline next) : base(next) {
     this.handler = handler;
 }
 /// <summary>
 /// Creates a component of type <typeparamref name="TComponent"/> and adds it as a child of <paramref name="parent"/>.
 /// </summary>
 /// <typeparam name="TComponent"></typeparam>
 /// <param name="parent"></param>
 /// <returns></returns>
 public async Task AddComponent <TComponent>(IElementHandler parent) where TComponent : IComponent
 {
     await AddComponent(typeof(TComponent), parent).ConfigureAwait(false);
 }
示例#29
0
 /**
  * @param d the ElementHandler
  * @param inp the Stream
  * @throws IOException if something went seriously wrong with IO.
  */
 public void ParseXHtml(IElementHandler d, Stream inp, Encoding charset) {
     CssFilesImpl cssFiles = new CssFilesImpl();
     cssFiles.Add(GetDefaultCSS());
     StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
     HtmlPipelineContext hpc = new HtmlPipelineContext(null);
     hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(GetDefaultTagProcessorFactory());
     IPipeline pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(hpc, new ElementHandlerPipeline(d,
             null)));
     XMLWorker worker = new XMLWorker(pipeline, true);
     XMLParser p = new XMLParser(true, worker, charset);
     if (charset != null) {
         p.Parse(inp, charset);
     } else {
         p.Parse(inp);
     }
 }
 public BasicMatchingHandler(IElementHandler inner)
 {
     _inner = inner;
 }