Exemple #1
0
 public BindUnityScreenConnector(
     FromPage fromPage,
     Key key = null
     ) : base(key: key)
 {
     this.fromPage = fromPage;
 }
Exemple #2
0
        // Convert this object into a string.
        public override String ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("[PrinterSettings ");
            builder.Append(PrinterName);
            builder.Append(" Copies=");
            builder.Append(Copies.ToString());
            builder.Append(" Collate=");
            builder.Append(Collate.ToString());
            builder.Append(" Duplex=");
            builder.Append(Duplex.ToString());
            builder.Append(" FromPage=");
            builder.Append(FromPage.ToString());
            builder.Append(" LandscapeAngle=");
            builder.Append(LandscapeAngle.ToString());
            builder.Append(" MaximumCopies=");
            builder.Append(MaximumCopies.ToString());
            builder.Append(" OutputPort=");
            builder.Append(ToolkitPrinter.OutputPort.ToString());
            builder.Append(" ToPage=");
            builder.Append(ToPage.ToString());
            builder.Append(']');
            return(builder.ToString());
        }
        public virtual string ExtractFromKey(Type type)
        {
            //Check if type is a controller without a FromAction
            if (type.IsController() && string.IsNullOrWhiteSpace(FromAction) && FromController != null)
            {
                //should only come here if type is a controller and attribute is placed at controller class level
                return(FromController.ExtractMvcControllerKey());
            }

            if (!string.IsNullOrWhiteSpace(FromAction))
            {
                var fromControllerType = FromController;

                if (fromControllerType == null)
                {
                    // Try to infer it from the type
                    if (!type.IsController())
                    {
                        throw new SmartBreadcrumbsException($"Can't infer FromController as '{type.Name}' is a Razor Page.");
                    }

                    fromControllerType = type;
                }

                if (!fromControllerType.IsController())
                {
                    throw new SmartBreadcrumbsException($"'{fromControllerType.Name}' is used in FromController but isn't a Controller.");
                }

                var actionMethod = fromControllerType.GetMethods(BindingFlags.Instance | BindingFlags.Public)
                                   .FirstOrDefault(m => m.Name == FromAction); //to prevent AmbiguousMatchException

                if (actionMethod == null || actionMethod.ReturnType.IsAction() == false)
                {
                    throw new SmartBreadcrumbsException($"{fromControllerType.Name} doesn't contain a valid action named {FromAction}.");
                }

                return(fromControllerType.ExtractMvcKey(actionMethod));
            }

            if (FromPage == null)
            {
                return(null); // Will use default as parent
            }
            if (!FromPage.IsRazorPage())
            {
                throw new SmartBreadcrumbsException($"'{FromPage.Name}' is used in FromPage but isn't a Razor Page.");
            }

            return(FromPage.ExtractRazorPageKey());
        }
        public virtual string ExtractFromKey(Type type)
        {
            if (!string.IsNullOrWhiteSpace(FromAction))
            {
                var fromControllerType = FromController;

                if (fromControllerType == null)
                {
                    // Try to infer it from the type
                    if (!type.IsController())
                    {
                        throw new SmartBreadcrumbsException($"Can't infer FromController as '{type.Name}' is a Razor Page.");
                    }

                    fromControllerType = type;
                }

                if (!fromControllerType.IsController())
                {
                    throw new SmartBreadcrumbsException($"'{fromControllerType.Name}' is used in FromController but isn't a Controller.");
                }

                var actionMethod = fromControllerType.GetMethod(FromAction, BindingFlags.Instance | BindingFlags.Public);
                if (actionMethod == null || actionMethod.ReturnType.IsAction() == false)
                {
                    throw new SmartBreadcrumbsException($"{fromControllerType.Name} doesn't contain a valid action named {FromAction}.");
                }

                return(fromControllerType.ExtractMvcKey(actionMethod));
            }

            if (FromPage == null)
            {
                return(null); // Will use default as parent
            }
            if (!FromPage.IsRazorPage())
            {
                throw new SmartBreadcrumbsException($"'{FromPage.Name}' is used in FromPage but isn't a Razor Page.");
            }

            return(FromPage.ExtractRazorPageKey());
        }
 public WaitNavigationContext <TFrom> Using(Action <TFrom> func)
 {
     FromPage.ClickAndWaitForLoad(func);
     return(this);
 }
Exemple #6
0
 public void PostbackUsing(Action <TFrom> func)
 {
     FromPage.PerformActionOnElementAndWaitForReload(func);
 }
Exemple #7
0
 public BindUnityScreenConnector(FromPage fromPage)
 {
     this.fromPage = fromPage;
 }