コード例 #1
0
        /// <summary>
        /// Add a cache handle configuration with the required name and type attributes.
        /// </summary>
        /// <param name="cacheHandleBaseType">The handle's type without generic attribute.</param>
        /// <param name="handleName">The name to be used for the cache handle.</param>
        /// <param name="isBackPlateSource">
        /// Set this to true if this cache handle should be the source of the back plate.
        /// <para>This setting will be ignored if no back plate is configured.</para>
        /// </param>
        /// <returns>The builder part.</returns>
        /// <exception cref="System.ArgumentNullException">If handleName is null.</exception>
        /// <exception cref="System.InvalidOperationException">
        /// Only one cache handle can be the backplate's source.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Thrown if handleName or cacheHandleBaseType are null.
        /// </exception>
        public ConfigurationBuilderCacheHandlePart WithHandle(Type cacheHandleBaseType, string handleName, bool isBackPlateSource)
        {
            if (cacheHandleBaseType == null)
            {
                throw new ArgumentNullException("cacheHandleBaseType");
            }

            if (string.IsNullOrWhiteSpace(handleName))
            {
                throw new ArgumentNullException("handleName");
            }

            var handleCfg = new CacheHandleConfiguration(handleName)
            {
                HandleType = cacheHandleBaseType
            };

            handleCfg.IsBackPlateSource = isBackPlateSource;

            if (this.Configuration.CacheHandleConfigurations.Any(p => p.IsBackPlateSource))
            {
                throw new InvalidOperationException("Only one cache handle can be the back plate's source.");
            }

            this.Configuration.CacheHandleConfigurations.Add(handleCfg);
            var part = new ConfigurationBuilderCacheHandlePart(handleCfg, this);

            return(part);
        }
コード例 #2
0
        /// <summary>
        /// Adds a cache handle with the given <c>Type</c> and name.
        /// The type must be an open generic.
        /// </summary>
        /// <param name="cacheHandleBaseType">The cache handle type.</param>
        /// <param name="handleName">The name to be used for the cache handle.</param>
        /// <param name="isBackplaneSource">
        /// Set this to true if this cache handle should be the source of the backplane.
        /// <para>This setting will be ignored if no backplane is configured.</para>
        /// </param>
        /// <returns>The builder part.</returns>
        /// <exception cref="System.ArgumentNullException">If handleName is null.</exception>
        /// <exception cref="System.InvalidOperationException">
        /// Only one cache handle can be the backplane's source.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Thrown if handleName or cacheHandleBaseType are null.
        /// </exception>
        public ConfigurationBuilderCacheHandlePart WithHandle(Type cacheHandleBaseType, string handleName, bool isBackplaneSource)
        {
            NotNull(cacheHandleBaseType, nameof(cacheHandleBaseType));
            NotNullOrWhiteSpace(handleName, nameof(handleName));

            var handleCfg = new CacheHandleConfiguration(handleName)
            {
                HandleType = cacheHandleBaseType
            };

            handleCfg.IsBackplaneSource = isBackplaneSource;

            if (isBackplaneSource && this.Configuration.CacheHandleConfigurations.Any(p => p.IsBackplaneSource))
            {
                throw new InvalidOperationException("Only one cache handle can be the backplane's source.");
            }

            this.Configuration.CacheHandleConfigurations.Add(handleCfg);
            var part = new ConfigurationBuilderCacheHandlePart(handleCfg, this);

            return(part);
        }
コード例 #3
0
        /// <summary>
        /// Adds a cache handle with the given <c>Type</c> and name.
        /// The type must be an open generic.
        /// </summary>
        /// <param name="cacheHandleBaseType">The cache handle type.</param>
        /// <param name="handleName">The name to be used for the cache handle.</param>
        /// <param name="isBackplaneSource">
        /// Set this to true if this cache handle should be the source of the backplane.
        /// <para>This setting will be ignored if no backplane is configured.</para>
        /// </param>
        /// <returns>The builder part.</returns>
        /// <exception cref="System.ArgumentNullException">If handleName is null.</exception>
        /// <exception cref="System.InvalidOperationException">
        /// Only one cache handle can be the backplane's source.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Thrown if handleName or cacheHandleBaseType are null.
        /// </exception>
        public ConfigurationBuilderCacheHandlePart WithHandle(Type cacheHandleBaseType, string handleName, bool isBackplaneSource)
        {
            NotNull(cacheHandleBaseType, nameof(cacheHandleBaseType));
            NotNullOrWhiteSpace(handleName, nameof(handleName));

            var handleCfg = new CacheHandleConfiguration(handleName)
            {
                HandleType = cacheHandleBaseType
            };

            handleCfg.IsBackplaneSource = isBackplaneSource;

            if (isBackplaneSource && this.Configuration.CacheHandleConfigurations.Any(p => p.IsBackplaneSource))
            {
                throw new InvalidOperationException("Only one cache handle can be the backplane's source.");
            }

            this.Configuration.CacheHandleConfigurations.Add(handleCfg);
            var part = new ConfigurationBuilderCacheHandlePart(handleCfg, this);
            return part;
        }