Archetype.Extensions.HtmlHelperExtensions._renderPartial C# (CSharp) Метод

_renderPartial() приватный статический Метод

Renders the fieldset partial
private static _renderPartial ( System.Web.Mvc.HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialPath, ViewDataDictionary viewDataDictionary ) : IHtmlString
htmlHelper System.Web.Mvc.HtmlHelper The HTML helper.
fieldsetModel ArchetypeFieldsetModel
partialPath string The partial path.
viewDataDictionary ViewDataDictionary The view data dictionary.
Результат IHtmlString
        private static IHtmlString _renderPartial(HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialPath, ViewDataDictionary viewDataDictionary)
        {
            var context = HttpContext.Current;

            if (fieldsetModel == null || context == null)
            {
                return new HtmlString("");
            }

            var sb = new StringBuilder();

            //default
            var pathToPartials = "~/Views/Partials/Archetype/";

            if (!string.IsNullOrEmpty(partialPath))
            {
                pathToPartials = partialPath;
            }

            var partial = string.Format("{0}{1}.cshtml", pathToPartials, fieldsetModel.Alias);

            if (System.IO.File.Exists(context.Server.MapPath(partial)))
            {
                sb.AppendLine(htmlHelper.Partial(partial, fieldsetModel, viewDataDictionary).ToString());
            }
            else
            {
                LogHelper.Info<ArchetypeModel>(string.Format("The partial for {0} could not be found.  Please create a partial with that name or rename your alias.", context.Server.MapPath(partial)));
            }

            return new HtmlString(sb.ToString());
        }