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); }
public static void MapExcludedWithChildren(IElementHandler handler, Element view) { }
/** * 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); }
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)); }
public static void MapAutomationPropertiesExcludedWithChildren(IElementHandler handler, Element element) { //TODO : Need to impl }
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); }
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);
public ElementHandlerFactoryContext(NativeComponentRenderer renderer, IElementHandler parentHandler) { Renderer = renderer ?? throw new ArgumentNullException(nameof(renderer)); ParentHandler = parentHandler; }
public static void MapIsInAccessibleTree(IElementHandler handler, Element element) { Platform.AccessibilityExtensions.SetAutomationPropertiesAccessibilityView( handler.NativeView as Microsoft.UI.Xaml.FrameworkElement, element); }
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);
public static Task <T> InvokeAsync <T>(this IElementHandler handler, string commandName, TaskCompletionSource <T> args) { handler?.Invoke(commandName, args); return(args.Task); }
public BasicMatchingHandler(IElementHandler inner, ITestContext context) { _inner = inner; _context = context; }
public void SetElementReference(IElementHandler elementHandler) { ElementHandler = elementHandler ?? throw new ArgumentNullException(nameof(elementHandler)); }
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); } }));
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)); }
/** * 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; }
public bool IsNavigationBarVisible(IElementHandler handler) => IsNavigationBarVisible(handler.MauiContext);
public static void MapAutomationPropertiesIsInAccessibleTree(IElementHandler handler, Element element) { //TODO : Need to impl }
string GetToolbarTitle(IElementHandler handler) => GetPlatformToolbar(handler).Title;
/// <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); }
/** * @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; }