Ejemplo n.º 1
0
        public Func <Task> GetSectionDelegate(string name)
        {
            TkDebug.AssertArgumentNullOrEmpty(name, nameof(name), this);

            SectionWriters.TryGetValue(name, out var result);
            return(result);
        }
Ejemplo n.º 2
0
 public void DefineSection(string name, SectionWriter action)
 {
     if (SectionWriters.ContainsKey(name))
     {
         throw new HttpException(String.Format(CultureInfo.InvariantCulture, WebPageResources.WebPage_SectionAleadyDefined, name));
     }
     SectionWriters[name] = action;
 }
Ejemplo n.º 3
0
 public void DefineSection(string name, SectionWriter action)
 {
     if (SectionWriters.ContainsKey(name))
     {
         throw new HttpException(String.Format("WebPageResources.WebPage_SectionAleadyDefined {0}", name));
     }
     SectionWriters[name] = action;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a named content section in the page that can be invoked in a Layout page using
 /// <see cref="RenderSection(string)"/> or <see cref="RenderSectionAsync(string, bool)"/>.
 /// </summary>
 /// <param name="name">The name of the section to create.</param>
 /// <param name="section">The <see cref="RenderAsyncDelegate"/> to execute when rendering the section.</param>
 public void DefineSection([NotNull] string name, [NotNull] RenderAsyncDelegate section)
 {
     if (SectionWriters.ContainsKey(name))
     {
         throw new InvalidOperationException(Resources.FormatSectionAlreadyDefined(name));
     }
     SectionWriters[name] = section;
 }
Ejemplo n.º 5
0
        public void RenderSection(string name)
        {
            if (!SectionWriters.ContainsKey(name))
            {
                return;
            }

            var section = SectionWriters[name];

            section(builder);
        }
Ejemplo n.º 6
0
        public void DefineSection(string name, Func <Task> section)
        {
            TkDebug.AssertArgumentNullOrEmpty(name, nameof(name), this);
            TkDebug.AssertArgumentNull(section, nameof(section), this);

            if (SectionWriters.ContainsKey(name))
            {
                throw new InvalidOperationException();
            }
            SectionWriters[name] = section;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a named content section in the page that can be invoked in a Layout page using
        /// <see cref="RenderSection(string)"/> or <see cref="RenderSectionAsync(string, bool)"/>.
        /// </summary>
        /// <param name="name">The name of the section to create.</param>
        /// <param name="section">The <see cref="RenderAsyncDelegate"/> to execute when rendering the section.</param>
        public override void DefineSection(string name, RenderAsyncDelegate section)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            if (SectionWriters.ContainsKey(name))
            {
                throw new InvalidOperationException($"Section {name} is already defined");
            }
            SectionWriters[name] = section;
        }
        /// <summary>
        /// Creates a named content section in the page that can be invoked in a Layout page using
        /// <c>RenderSection</c> or <c>RenderSectionAsync</c>
        /// </summary>
        /// <param name="name">The name of the section to create.</param>
        /// <param name="section">The <see cref="RenderAsyncDelegate"/> to execute when rendering the section.</param>
        public virtual void DefineSection(string name, RenderAsyncDelegate section)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            if (SectionWriters.ContainsKey(name))
            {
                throw new InvalidOperationException();
            }
            SectionWriters[name] = section;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a named content section in the page that can be invoked in a Layout page using
        /// <see cref="RenderSection(string)"/> or <see cref="RenderSectionAsync(string, bool)"/>.
        /// </summary>
        /// <param name="name">The name of the section to create.</param>
        /// <param name="section">The <see cref="RenderAsyncDelegate"/> to execute when rendering the section.</param>
        public void DefineSection(string name, RenderAsyncDelegate section)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            if (SectionWriters.ContainsKey(name))
            {
                throw new InvalidOperationException(Resources.FormatSectionAlreadyDefined(name));
            }
            SectionWriters[name] = section;
        }
Ejemplo n.º 10
0
 public Component MountAsPage(string populateElementRef)
 {
     SectionWriters.Clear();
     return(Mount(populateElementRef, replace: false, enableLayouts: true));
 }
Ejemplo n.º 11
0
        public bool IsSectionDefined(string name)
        {
            TkDebug.AssertArgumentNullOrEmpty(name, nameof(name), this);

            return(SectionWriters.ContainsKey(name));
        }