public static void Render(WebViewPage page, ActivityEntryContract activityEntryContract)
        {
            /*switch (activityEntryContract.EntryType) {
                case ActivityEntryType.EntryEdited:

            }*/
        }
 public PrecompiledView(string virtualPath, WebViewPage type, bool runViewStartPages, IEnumerable<string> fileExtension)
 {
     this.type = type;
     this.virtualPath = virtualPath;
     RunViewStartPages = runViewStartPages;
     ViewStartFileExtensions = fileExtension;
 }
        public BreadCrumbsBuilder(WebViewPage page)
        {
            this.page = page;

            stringBuilder = new StringBuilder();
            stringBuilder.Append("");
        }
Exemple #4
0
 /// <summary>
 /// 获取指定页面的应用 Javascript URL 路径。 
 /// </summary>
 /// <param name="page">当前视图页。</param>
 /// <returns>返回一个路径。</returns>
 public virtual string GetJsUrl(WebViewPage page)
 {
     var routeInfo = MvcClient.RouteInfo;
     var area = string.Empty;
     if(!routeInfo.Area.IsNull()) area = routeInfo.Area + "/";
     var fileName = routeInfo.Controller + "." + routeInfo.Action;
     return page.Url.Content($"~/Scripts/App/{area}{fileName}.js");
 }
        public XrcWebViewPageExtension(WebViewPage page)
        {
            _xrcContext = (IContext)page.ViewData[VIEWDATA_XRCCONTEXT];
            _moduleFactory = (Modules.IModuleFactory)page.ViewData[VIEWDATA_IMODULEFACTORY];
            _moduleCatalog = (Modules.IModuleCatalogService)page.ViewData[VIEWDATA_IMODULECATALOGSERVICE];

            LoadModulesAndParameters(page);
        }
        public AccordeonHelper(string name, string formModelStatePrefix, bool expanded, WebViewPage page)
        {
            _expanded = expanded;

            Name = name;
            FormModelStatePrefix = formModelStatePrefix;
            Page = page;
        }
Exemple #7
0
 public XmlHelper(System.Web.Mvc.ViewContext vc, WebViewPage page)
 {
     // TODO: Complete member initialization
     _vc = vc;
     _page = page;
     _service = new Lazy<IDocumentationService>(
         () => DependencyResolver.Current.GetService<IDocumentationService>()
     );
 }
        public static MvcHtmlString GetPreviousLink(this HtmlHelper html, WebViewPage webPage, int pageNum)
        {
            if (webPage.ViewContext.HttpContext.Request.Form.Count == 0)
                return html.ActionLink("Previous", webPage.ViewContext.RouteData.Values["action"].ToString(),
                                       webPage.ViewContext.RouteData.Values["controller"].ToString(),
                                       new { pageNum = pageNum - 1 }, new { style = "text-align:left", id = "lnkPrevious" });

            return new MvcHtmlString("<a href='#' id='lnkPrevious' style='text-align: left'>Previous</a>");
        }
 public MvcHtmlString Execute(WebViewPage viewPage, ServicePublicData id)
 {
     if (_tableFunc == null)
     {
         var exp = UpdateExpression(_tableAction);
         _tableFunc = exp.Compile();
     }
     return _tableFunc(viewPage, id);
 }
        private void AttachBehaviorsContainer(Type type, WebViewPage view)
        {
            var viewModelType = GetViewModelType(type);
            var containerType = GetBehaviorsContainerType(viewModelType);

            if (!HasContainer(containerType)) return;

            var container = GetContainer(containerType);
            container.AddToView(view);
        }
 internal static Func<NuGetContext> GetNuGetContextThunk(WebViewPage self)
 {
     return () =>
     {
         var ctrl = self.ViewContext.Controller as AppController;
         if (ctrl == null)
         {
             throw new InvalidOperationException("NuGetViewBase should only be used on views for actions on AppControllers");
         }
         return ctrl.NuGetContext;
     };
 }
 // Methods
 public CompiledWebViewPageView(ControllerContext controllerContext,
     string viewPath,
     string layoutPath,
     bool runViewStartPages,
     IEnumerable<string> viewStartFileExtensions,
     WebViewPage page)
 {
     this.viewPath = viewPath;
     this.page = page;
     this.LayoutPath = layoutPath ?? string.Empty;
     this.RunViewStartPages = runViewStartPages;
     this.StartPageLookup = StartPage.GetStartPage;
     this.ViewStartFileExtensions = viewStartFileExtensions ?? Enumerable.Empty<string>();
 }
Exemple #13
0
 private static void PrintHtml(WebViewPage<string> view, string color)
 {
     try
     {
         view.ViewData.Model = color;
         view.PushContext(new WebPageContext(), new StringWriter());
         view.Execute();
         Console.Out.WriteLine(view.Output.ToString());
         view.PopContext();
     }
     catch (Exception ex)
     {
         Console.Out.WriteLine(ex.ToString());
     }
 }
        public static IHtmlString ContextInfo(WebViewPage page)
        {
            //ResultExecutingContext

            var res = new StringBuilder();
            res.AppendLine("<pre style='margin:10px'>");
            res.AppendLine("Page context");
            res.AppendLine("OutputStack.Count:{0}", page.OutputStack.Count);
            res.AppendLine("Output:{0} {1}", page.Output.GetHashCode(), Collapsible(ContextInfo(page.Output)));
            res.AppendLine("ViewContext:{0} {1}", page.ViewContext.GetHashCode(), Collapsible(ContextInfo(page.ViewContext)));
            res.AppendLine("Html.ViewContext:{0} {1}", page.Html.ViewContext.GetHashCode(), Collapsible(ContextInfo(page.Html.ViewContext)));
            res.AppendLine("HttpContext {0} {1}", page.Context.GetHashCode(), Collapsible(ContextInfo(page.Context)));
            res.AppendLine("PageContext {0} {1}", page.PageContext.GetHashCode(), Collapsible(ContextInfo(page.PageContext)));
            res.AppendLine("</pre>");
            return new MvcHtmlString(res.ToString());
        }
Exemple #15
0
 public string GetFullUrl(WebViewPage page, string parentPath, string filename)
 {
     if(parentPath == null)
     {
         parentPath = "~/";
         switch(System.IO.Path.GetExtension(filename))
         {
             case ".css":
                 parentPath = Convert.ToString(Webx.Container.Get("css-path") ?? "~/Content");
                 break;
             case ".js":
                 parentPath = Convert.ToString(Webx.Container.Get("js-path") ?? "~/Scripts");
                 break;
         }
     }
     return page.Url.Content(System.IO.Path.Combine(parentPath, filename));
 }
        // Methods
        internal CompiledViewPageView(ControllerContext controllerContext,
            string viewPath,
            WebViewPage viewpage)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }
            if (string.IsNullOrEmpty(viewPath))
            {
                throw new ArgumentException("viewPath is null or empty");
            }

            this._controllerContext = controllerContext;
            this.ViewPath = viewPath;
            this.page = viewpage;
        }
Exemple #17
0
        /// <summary>Creates the pagination bootstrap component.</summary>
        /// <param name="page">The <see cref="WebViewPage"/>. Use <c>this</c> in a Razor view.</param>
        /// <param name="currentPage">The current page number.</param>
        /// <param name="pageCount">The page count.</param>
        /// <param name="actionName">The name of the controller action.</param>
        /// <param name="routeValues">The route values. </param>
        /// <param name="pageKeyName">The page key name. </param>
        /// <returns>The HTML string. </returns>
        public static IHtmlString Pagination(WebViewPage page, int currentPage, int pageCount, string actionName, object routeValues = null, string pageKeyName = "page")
        {
            var html = new StringBuilder();
            html.AppendLine(@"<nav>");
            html.AppendLine(@" <ul class=""pagination"">");

            // previous page
            var previousValues = new RouteValueDictionary(routeValues);
            previousValues.Add(pageKeyName, currentPage - 1);

            html.AppendLine(@"  <li class=""" + (currentPage == 1 ? "disabled" : string.Empty) + @""">");
            html.AppendLine(@"   <a href=""" + (currentPage == 1 ? "#" : page.Url.Action(actionName, previousValues)) + @""" aria-label=""Previous"">");
            html.AppendLine(@"    <span aria-hidden=""true"">&laquo;</span>");
            html.AppendLine(@"   </a>");
            html.AppendLine(@"  </li>");

            // pages
            for (int i = 1; i <= pageCount; i++)
            {
                var values = new RouteValueDictionary(routeValues);
                values.Add(pageKeyName, i);

                html.AppendLine(@"  <li class=""" + (i == currentPage ? "active" : string.Empty) + @""">");
                html.AppendLine(@"   <a href=""" + (i == currentPage ? "#" : page.Url.Action(actionName, values)) + @""">" + i + @"</a>");
                html.AppendLine(@"  </li>");
            }

            // next page
            var nextValues = new RouteValueDictionary(routeValues);
            nextValues.Add(pageKeyName, currentPage + 1);

            var canGoNext = currentPage == pageCount || pageCount == 0;
            html.AppendLine(@"  <li class=""" + (canGoNext ? "disabled" : string.Empty) + @""">");
            html.AppendLine(@"   <a href=""" + (canGoNext ? "#" : page.Url.Action(actionName, nextValues)) + @""" aria-label=""Next"">");
            html.AppendLine(@"    <span aria-hidden=""true"">&raquo;</span>");
            html.AppendLine(@"   </a>");
            html.AppendLine(@"  </li>");

            html.AppendLine(@" </ul>");
            html.AppendLine(@"</nav>");

            return new HtmlString(html.ToString());
        }
Exemple #18
0
 /// <summary>
 /// 获取指定文件名的完整 URL 路径。
 /// </summary>
 /// <param name="page">当前视图页。</param>
 /// <param name="parentPath">父级目录,可以为 null 值。</param>
 /// <param name="filename">文件名。</param>
 /// <returns>完整 URL 路径。</returns>
 public virtual string GetFullUrl(WebViewPage page, string parentPath, string filename)
 {
     if(page == null) throw new ArgumentNullException(nameof(page));
     if(string.IsNullOrWhiteSpace(filename)) throw new ArgumentNullException(nameof(filename));
     if(filename[0] == '~' && filename[1] == '/') return page.Url.Content(filename);
     if(parentPath == null)
     {
         parentPath = "~/";
         switch(System.IO.Path.GetExtension(filename))
         {
             case ".css":
                 parentPath = Convert.ToString(Webx.Container.Get("css-path") ?? "~/Content");
                 break;
             case ".js":
                 parentPath = Convert.ToString(Webx.Container.Get("js-path") ?? "~/Scripts");
                 break;
         }
     }
     return page.Url.Content(System.IO.Path.Combine(parentPath, filename));
 }
 private void LoadModulesAndParameters(WebViewPage page)
 {
     // TODO Valutare se si riesce a non ciclare su tutte le property, perchè ptrebbe anche creare dei problemi se si sovrascrive una property errata
     foreach (var p in page.GetType().GetProperties())
     {
         ComponentDefinition component;
         if (_moduleCatalog.TryGet(p.Name, out component) &&
             p.PropertyType.IsAssignableFrom(component.Type))
         {
             var interceptor = new ModuleInterceptor(component, _xrcContext, _moduleFactory);
             p.SetValue(page, _generator.CreateInterfaceProxyWithoutTarget(p.PropertyType, interceptor), null);
         }
         else
         {
             ContextParameter parameter;
             if (_xrcContext.Parameters.TryGetValue(p.Name, out parameter) &&
                             p.PropertyType.IsAssignableFrom(parameter.Type))
                 p.SetValue(page, parameter.Value, null);
         }
     }
 }
Exemple #20
0
 public static string GetDropDownListOptionalText(this System.Web.Mvc.WebViewPage view, string text = MvcSelectExtensions.EmptyDropDownListDefaultText)
 {
     return(MvcSelectExtensions.GetDropDownListOptionalText(text));
 }
Exemple #21
0
 private void ManageScripts(CQ cqDoc, WebViewPage viewPage) {
     ScriptManager mgr = new ScriptManager();
     mgr.Options = Options;
     mgr.LibraryPath = LibraryPath;
     mgr.ResolveScriptDependencies(cqDoc);
     
 }
Exemple #22
0
        public static string SiteTitle(this System.Web.Mvc.WebViewPage view, params object[] args)
        {
            object[] formatArgs = new object[] { System.Configuration.ConfigurationManager.AppSettings["siteTitle"] };

            return(string.Format(System.Configuration.ConfigurationManager.AppSettings["siteTitleFormat"], formatArgs.Concat(args).ToArray()));
        }
Exemple #23
0
        //public static MvcHtmlString DisplayNameFor<TModel, TValue>(this HtmlHelper<IEnumerable<TModel>> htmlHelper, Expression<Func<TModel, TValue>> expression, bool useShortName)
        //{
        //    if (useShortName)
        //    {
        //        var metaData = ModelMetadata.FromLambdaExpression(expression, new ViewDataDictionary<TModel>(htmlHelper.ViewData.Model.FirstOrDefault()));
        //        var displayMetaData = metaData.GetMetaDataAttribute<DisplayAttribute>();
        //        if (displayMetaData != null)
        //            return htmlHelper.DisplayName(displayMetaData.GetShortName());
        //    }

        //    return htmlHelper.DisplayNameFor(expression);
        //}

        //public static MvcHtmlString DisplayNameFor<TModel, TValue>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TValue>> expression, bool useShortName)
        //{
        //    if (useShortName)
        //    {
        //        var metaData = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
        //        var displayMetaData = metaData.GetMetaDataAttribute<DisplayAttribute>();
        //        if (displayMetaData != null)
        //            return htmlHelper.DisplayName(displayMetaData.GetShortName());
        //    }

        //    return htmlHelper.DisplayNameFor(expression);
        //}

        ///// <summary>
        ///// Returns a single-selection select element using the specified HTML helper, the name of the form field, and the specified list items, with an initial value optional value.
        ///// </summary>
        ///// <param name="htmlHelper">The HTML helper instance that this method extends.</param>
        ///// <param name="name">The name of the form field to return.</param>
        ///// <param name="selectList">A collection of <see cref="System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param>
        ///// <param name="sortSelectList">Indicates if the <paramref name="selectList"/> should be sorted.</param>
        ///// <param name="sortAscending">Indicates if the sorting of the <paramref name="selectList"/> should be ascending or descending.</param>
        ///// <returns>An HTML select element with an option subelement for each item in the list.</returns>
        //public static MvcHtmlString DefaultDropDownList(this HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, bool sortSelectList = true, bool sortAscending = true)
        //{
        //    string optionalText = CommonExtensions.ProcessDropDownList(ref selectList, sortSelectList, sortAscending);

        //    return htmlHelper.DropDownList(name, selectList, optionalText);
        //}

        //public static MvcHtmlString DefaultDropDownList(this HtmlHelper htmlHelper, string name)
        //{
        //    return htmlHelper.DefaultDropDownList(name, Enumerable.Empty<SelectListItem>());
        //}

        ///// <summary>
        ///// Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and option label, with an initial value optional value.
        ///// </summary>
        ///// <typeparam name="TModel">The type of the model.</typeparam>
        ///// <typeparam name="TProperty">The type of the value.</typeparam>
        ///// <param name="htmlHelper">The HTML helper instance that this method extends.</param>
        ///// <param name="expression">An expression that identifies the object that contains the properties to display.</param>
        ///// <param name="selectList">A collection of System.Web.Mvc.SelectListItem objects that are used to populate the drop-down list.</param>
        ///// <param name="sortSelectList">Indicates if the <paramref name="selectList"/> should be sorted.</param>
        ///// <param name="sortAscending">Indicates if the sorting of the <paramref name="selectList"/> should be ascending or descending.</param>
        ///// <returns>An HTML select element for each property in the object that is represented by the expression.</returns>
        //public static MvcHtmlString DefaultDropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, bool sortSelectList = true, bool sortAscending = true)
        //{
        //    string optionalText = CommonExtensions.ProcessDropDownList(ref selectList, sortSelectList, sortAscending);

        //    return htmlHelper.DropDownListFor(expression, selectList, optionalText);
        //}

        //public static MvcHtmlString DefaultDropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
        //{
        //    return htmlHelper.DefaultDropDownListFor(expression, Enumerable.Empty<SelectListItem>());
        //}

        //public static MvcHtmlString DatePicker(this HtmlHelper htmlHelper, string name, string dateFormat = "yyyy-MM-dd")
        //{
        //    return htmlHelper.TextBox(name, dateFormat, new { Class = "text-box single-line user-success", Type = "date" });
        //}

        //public static string GetDropDownListOptionalText(this System.Web.Mvc.WebViewPage view, string text = CommonExtensions.EmptyDropDownListDefaultText)
        //{
        //    return CommonExtensions.GetDropDownListOptionalText(text);
        //}

        public static string SiteTitle(this System.Web.Mvc.WebViewPage view)
        {
            return(System.Configuration.ConfigurationManager.AppSettings["siteTitle"]);
        }
 public MvcHtmlString Execute(WebViewPage viewPage, string containerId)
 {
     throw new InvalidOperationException();
 }
 public MvcHtmlString Execute(WebViewPage viewPage)
 {
     throw new InvalidOperationException();
 }
 private static IController GetController(WebViewPage page)
 {
     return page.ViewContext.Controller;
 }
 /// <summary>
 /// Creates the specified page.
 /// </summary>
 /// <returns>JavascriptHelper</returns>
 /// <remarks>
 /// Used in view pages functions:
 /// 	var script = StateTheaterMvc.Component.JavascriptHelper.Create(this);
 /// </remarks>
 public static JavascriptHelper Create(WebViewPage page)
 {
     return Create(page.ViewContext);
 }
 public AccordianHelper(string name, string formModelStatePrefix, WebViewPage page)
 {
     Name = name;
     FormModelStatePrefix = formModelStatePrefix;
     Page = page;
 }
Exemple #29
0
 /// <summary>
 /// Default constructor. Creates a new helper.
 /// </summary>
 /// <param name="parent">The parent view.</param>
 public UIHelper(WebViewPage parent)
 {
     Parent = parent ;
 }
 public DynamicLocator(WebViewPage viewPage)
     : this(viewPage.ViewContext.ServiceLocator()) {
 }
        /// <summary>
        ///     Returns an breadcrumb
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="page">current view</param>
        /// <param name="items">BreadCrumb items</param>
        /// <returns></returns>
        public static HtmlString RenderBreadCrumbs(this HtmlHelper htmlHelper, WebViewPage page, params Jarboo.Admin.Web.Infrastructure.BreadCrumbItem[] items)
        {
            var bc = new Jarboo.Admin.Web.Infrastructure.BreadCrumbsBuilder(page);
            foreach (var item in items)
	        {
		        if (item.Action != null) bc = bc.Add(item.Action, item.Label);
                else bc = bc.Add(item.Label);
	        }

            return bc.Done();
        }
Exemple #32
0
 public ScriptBlock(WebViewPage webPageBase)
 {
     this.webPageBase = webPageBase;
     this.webPageBase.OutputStack.Push(new StringWriter());
 }
Exemple #33
0
 /// <summary>
 /// Default constructor. Creates a new helper.
 /// </summary>
 /// <param name="parent">The parent view.</param>
 public PiranhaHelper(WebViewPage parent)
 {
     Parent = parent ;
 }