Пример #1
0
        private RenderingChrome GetPlaceHolderChrome(string placeholderKey)
        {
            var result  = new RenderingChrome();
            var wrapper = new global::Sitecore.Mvc.ExperienceEditor.Pipelines.Response.RenderPlaceholder.AddWrapper();

            using (var sw = new StringWriter())
            {
                var sb   = sw.GetStringBuilder();
                var args = new RenderPlaceholderArgs(placeholderKey, sw)
                {
                };
                using (PlaceholderContext.Enter(new PlaceholderContext(args.PlaceholderName)))
                {
                    wrapper.Process(args);
                    result.Start = sb.ToString();
                    sb.Clear();
                    foreach (var disposable in args.Disposables)
                    {
                        disposable.Dispose();
                    }
                }
                result.End = sb.ToString();
            }
            return(result);
        }
Пример #2
0
        private RenderingChrome?GetRenderingChrome(global::Sitecore.Mvc.Presentation.Rendering rendering)
        {
            var result = new RenderingChrome();

            using (var sw = new StringWriter())
                using (RenderingContext.EnterContext(rendering))
                    using (PlaceholderContext.Enter(new PlaceholderContext("dummy"))) //todo: can a rendering chrome differ per placeholder?
                    {
                        var sb      = sw.GetStringBuilder();
                        var wrapper = new global::Sitecore.Mvc.ExperienceEditor.Pipelines.Response.RenderRendering.AddWrapper();
                        var args    = new RenderRenderingArgs(rendering, sw);
                        wrapper.Process(args);
                        result.Start = sb.ToString();
                        sb.Clear();
                        foreach (var disposable in args.Disposables)
                        {
                            disposable.Dispose();
                        }
                        result.End = sb.ToString();
                    }

            return(result);
        }