Control the generation process for a single pager item.
        public static PagerItemOptions Merge([CanBeNull] PagerItemOptions baseOptions,
                                             [CanBeNull] PagerItemOptions additionalOptions)
        {
            // If base options is not null, use its clone as base; otherwise, use a new empty item as base.
            var result = baseOptions?.Clone() ?? new PagerItemOptions();

            // Return base item if no additional options are
            if (additionalOptions == null)
            {
                return(result);
            }

            // Merge attributes
            result.Content          = additionalOptions.Content ?? result.Content;
            result.Link             = additionalOptions.Link ?? result.Link;
            result.ActiveMode       = additionalOptions.ActiveMode ?? result.ActiveMode;
            result.InactiveBehavior = additionalOptions.InactiveBehavior ?? result.InactiveBehavior;

            // Merge settings
            foreach (var i in additionalOptions.AdditionalSettings)
            {
                result.AdditionalSettings[i.Key] = i.Value;
            }

            return(result);
        }
Ejemplo n.º 2
0
		/// <summary>
		///     Initialize a new set with all empty settings.
		/// </summary>
		public PagerItemOptionsSet()
		{
			Default = new PagerItemOptions();
			Normal = new PagerItemOptions();
			Current = new PagerItemOptions();
			Omitted = new PagerItemOptions();
			FirstPageButton = new PagerItemOptions();
			LastPageButton = new PagerItemOptions();
			PreviousPageButton = new PagerItemOptions();
			NextPageButton = new PagerItemOptions();
		}
 /// <summary>
 ///     Initialize a new set with all empty settings.
 /// </summary>
 public PagerItemOptionsSet()
 {
     Default            = new PagerItemOptions();
     Normal             = new PagerItemOptions();
     Current            = new PagerItemOptions();
     Omitted            = new PagerItemOptions();
     FirstPageButton    = new PagerItemOptions();
     LastPageButton     = new PagerItemOptions();
     PreviousPageButton = new PagerItemOptions();
     NextPageButton     = new PagerItemOptions();
 }
		/// <summary>
		///     Create a new <see cref="PagerItemGenerationContext" /> from a base <see cref="PagerGenerationContext" />.
		/// </summary>
		/// <param name="baseContext">The base <see cref="PagerGenerationContext" /> instance.</param>
		/// <param name="pagerItem">The current page item.</param>
		/// <param name="pagerItemOptions">The current page item options.</param>
		public PagerItemGenerationContext([NotNull] PagerGenerationContext baseContext, PagerItem pagerItem,
			PagerItemOptions pagerItemOptions)
		{
			if (baseContext == null)
			{
				throw new ArgumentNullException(nameof(baseContext));
			}

			CurrentPage = baseContext.CurrentPage;
			TotalPage = baseContext.TotalPage;
			Options = baseContext.Options;
			ViewContext = baseContext.ViewContext;
			GenerationMode = baseContext.GenerationMode;

			PagerItem = pagerItem;
			PagerItemOptions = pagerItemOptions;
		}
Ejemplo n.º 5
0
        /// <summary>
        ///     Create a new <see cref="PagerItemGenerationContext" /> from a base <see cref="PagerGenerationContext" />.
        /// </summary>
        /// <param name="baseContext">The base <see cref="PagerGenerationContext" /> instance.</param>
        /// <param name="pagerItem">The current page item.</param>
        /// <param name="pagerItemOptions">The current page item options.</param>
        public PagerItemGenerationContext([NotNull] PagerGenerationContext baseContext, PagerItem pagerItem,
                                          PagerItemOptions pagerItemOptions)
        {
            if (baseContext == null)
            {
                throw new ArgumentNullException(nameof(baseContext));
            }

            CurrentPage    = baseContext.CurrentPage;
            TotalPage      = baseContext.TotalPage;
            Options        = baseContext.Options;
            ViewContext    = baseContext.ViewContext;
            GenerationMode = baseContext.GenerationMode;

            PagerItem        = pagerItem;
            PagerItemOptions = pagerItemOptions;
        }
        public PagerItemOptions GetMergedOptionsFor(PagerItemType itemType)
        {
            // Stack used to LIFO operations
            var optionsStack = new Stack <PagerItemOptions>();

            // Recursively get base item
            PagerItemType?current = itemType;

            while (current != null)
            {
                optionsStack.Push(GetOptionsFor(itemType));
                current = GetBaseItemType(current.Value);
            }

            // Put default item
            optionsStack.Push(Default);

            // Merge all items
            return(PagerItemOptions.MergeAll(optionsStack));
        }