/// <summary>Create a new hook chaining the given hooks together.</summary>
        /// <remarks>Create a new hook chaining the given hooks together.</remarks>
        /// <param name="hooks">hooks to execute, in order.</param>
        /// <returns>a new hook chain of the given hooks.</returns>
        public static AdvertiseRefsHook NewChain <_T0>(IList <_T0> hooks) where _T0 : AdvertiseRefsHook
        {
            AdvertiseRefsHook[] newHooks = new AdvertiseRefsHook[hooks.Count];
            int i = 0;

            foreach (AdvertiseRefsHook hook in hooks)
            {
                if (hook != AdvertiseRefsHook.DEFAULT)
                {
                    newHooks[i++] = hook;
                }
            }
            if (i == 0)
            {
                return(AdvertiseRefsHook.DEFAULT);
            }
            else
            {
                if (i == 1)
                {
                    return(newHooks[0]);
                }
                else
                {
                    return(new NGit.Transport.AdvertiseRefsHookChain(newHooks, i));
                }
            }
        }
Esempio n. 2
0
		/// <summary>Set the hook used while advertising the refs to the client.</summary>
		/// <remarks>
		/// Set the hook used while advertising the refs to the client.
		/// <p>
		/// If the
		/// <see cref="AdvertiseRefsHook">AdvertiseRefsHook</see>
		/// chooses to call
		/// <see cref="SetAdvertisedRefs(System.Collections.Generic.IDictionary{K, V})">SetAdvertisedRefs(System.Collections.Generic.IDictionary&lt;K, V&gt;)
		/// 	</see>
		/// , only refs set by this hook <em>and</em>
		/// selected by the
		/// <see cref="RefFilter">RefFilter</see>
		/// will be shown to the client.
		/// </remarks>
		/// <param name="advertiseRefsHook">the hook; may be null to show all refs.</param>
		public virtual void SetAdvertiseRefsHook(AdvertiseRefsHook advertiseRefsHook)
		{
			if (advertiseRefsHook != null)
			{
				this.advertiseRefsHook = advertiseRefsHook;
			}
			else
			{
				this.advertiseRefsHook = AdvertiseRefsHook.DEFAULT;
			}
		}