Пример #1
0
 public string GetAbsolutePath(string executingFilePath, string pagePath)
 {
     _locker.EnterReadLock();
     try
     {
         return(_current.GetAbsolutePath(executingFilePath, pagePath));
     }
     finally
     {
         _locker.ExitReadLock();
     }
 }
Пример #2
0
        private async Task RenderViewStartsAsync(ViewContext context)
        {
            string layout      = null;
            var    oldFilePath = context.ExecutingFilePath;

            try
            {
                for (var i = 0; i < ViewStartPages.Count; i++)
                {
                    var viewStart = ViewStartPages[i];
                    context.ExecutingFilePath = viewStart.Path;

                    // If non-null, copy the layout value from the previous view start to the current. Otherwise leave
                    // Layout default alone.
                    if (layout != null)
                    {
                        viewStart.Layout = layout;
                    }

                    await RenderPageCoreAsync(viewStart, context);

                    // Pass correct absolute path to next layout or the entry page if this view start set Layout to a
                    // relative path.
                    layout = _viewEngine.GetAbsolutePath(viewStart.Path, viewStart.Layout);
                }
            }
            finally
            {
                context.ExecutingFilePath = oldFilePath;
            }

            // If non-null, copy the layout value from the view start page(s) to the entry page.
            if (layout != null)
            {
                RazorPage.Layout = layout;
            }
        }