/// <summary>
        ///     Create a Threat List Update Constraints Model.
        /// </summary>
        /// <param name="this">
        ///     A <see cref="ThreatListUpdateConstraints" />.
        /// </param>
        /// <returns>
        ///     A <see cref="ThreatListUpdateConstraintsModel" /> if <paramref name="this" /> is not a null reference.
        ///     A null reference otherwise.
        /// </returns>
        internal static ThreatListUpdateConstraintsModel AsClientConstraintsModel(this ThreatListUpdateConstraints @this)
        {
            ThreatListUpdateConstraintsModel threatListUpdateConstraintsModel = null;

            if (@this != null)
            {
                threatListUpdateConstraintsModel = new ThreatListUpdateConstraintsModel();
                threatListUpdateConstraintsModel.ClientLocation            = @this.ClientLocation;
                threatListUpdateConstraintsModel.MaximumDatabaseEntries    = @this.MaximumDatabaseEntries;
                threatListUpdateConstraintsModel.MaximumResponseEntries    = @this.MaximumResponseEntries;
                threatListUpdateConstraintsModel.SupportedCompressionTypes = CreateSupportedCompressionTypes();
                threatListUpdateConstraintsModel.ThreatListLanguage        = @this.ThreatListLanguage;
                threatListUpdateConstraintsModel.ThreatListLocation        = @this.ThreatListLocation;
            }

            return(threatListUpdateConstraintsModel);

            // <summary>
            //      Create Supported Compression Types.
            // </summary>
            string[] CreateSupportedCompressionTypes()
            {
                var cSupportedCompressionTypes = new string[1];

                cSupportedCompressionTypes[0] = CompressionType.Uncompressed.AsCompressionTypeModel();
                return(cSupportedCompressionTypes);
            }
        }
        /// <summary>
        ///     Restrict Updates.
        /// </summary>
        /// <param name="threatType">
        ///     A <see cref="ThreatType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="platformType">
        ///     A <see cref="PlatformType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="threatEntryType">
        ///     A <see cref="ThreatEntryType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="updateConstraintsAction">
        ///     An action to create the <see cref="ThreatListUpdateConstraints" /> to apply when the
        ///     <see cref="ThreatList" /> identified by <paramref name="threatType" />,
        ///     <paramref name="platformType" />, and <paramref name="threatEntryType" /> is retrieved.
        /// </param>
        /// <returns>
        ///     This managed service builder.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     Thrown if <paramref name="updateConstraintsAction" /> is a null reference.
        /// </exception>
        public ManagedBrowsingServiceBuilder RestrictUpdatesTo(ThreatType threatType, PlatformType platformType, ThreatEntryType threatEntryType, Func <ThreatListUpdateConstraintsBuilder, ThreatListUpdateConstraints> updateConstraintsAction)
        {
            Guard.ThrowIf(nameof(updateConstraintsAction), updateConstraintsAction).Null();

            // ...
            //
            // Throws an exception if the operation fails.
            var threatListUpdateConstraintsBuilder = ThreatListUpdateConstraints.Build();
            var threatListUpdateConstraints        = updateConstraintsAction(threatListUpdateConstraintsBuilder);

            this.RestrictUpdatesTo(threatType, platformType, threatEntryType, threatListUpdateConstraints);

            return(this);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Restrict Updates.
        /// </summary>
        /// <param name="threatListDescriptor">
        ///     A <see cref="ThreatListDescriptor" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="updateConstraintsAction">
        ///     An action to create the <see cref="ThreatListUpdateConstraints" /> to apply when the
        ///     <see cref="ThreatList" /> identified by <paramref name="threatListDescriptor" /> is retrieved.
        /// </param>
        /// <returns>
        ///     This database manager builder.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     Thrown if <paramref name="threatListDescriptor" /> is a null reference, or if
        ///     <paramref name="updateConstraintsAction" /> is a null reference.
        /// </exception>
        public BrowsingDatabaseManagerBuilder RestrictUpdatesTo(ThreatListDescriptor threatListDescriptor, Func <ThreatListUpdateConstraintsBuilder, ThreatListUpdateConstraints> updateConstraintsAction)
        {
            Guard.ThrowIf(nameof(updateConstraintsAction), updateConstraintsAction).Null();

            // ...
            //
            // Throws an exception if the operation fails.
            var threatListUpdateConstraintsBuilder = ThreatListUpdateConstraints.Build();
            var threatListUpdateConstraints        = updateConstraintsAction(threatListUpdateConstraintsBuilder);

            this.RestrictUpdatesTo(threatListDescriptor, threatListUpdateConstraints);

            return(this);
        }
        /// <summary>
        ///     Restrict Updates.
        /// </summary>
        /// <param name="threatType">
        ///     A <see cref="ThreatType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="platformType">
        ///     A <see cref="PlatformType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="threatEntryType">
        ///     A <see cref="ThreatEntryType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="updateConstraints">
        ///     The <see cref="ThreatListUpdateConstraints" /> to apply when the <see cref="ThreatList" /> identified
        ///     by <paramref name="threatType" />, <paramref name="platformType" />, and
        ///     <paramref name="threatEntryType" /> is retrieved.
        /// </param>
        /// <returns>
        ///     This managed service builder.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     Thrown if <paramref name="updateConstraints" /> is a null reference.
        /// </exception>
        public ManagedBrowsingServiceBuilder RestrictUpdatesTo(ThreatType threatType, PlatformType platformType, ThreatEntryType threatEntryType, ThreatListUpdateConstraints updateConstraints)
        {
            Guard.ThrowIf(nameof(updateConstraints), updateConstraints).Null();

            var threatListDescriptor = new ThreatListDescriptor(threatType, platformType, threatEntryType);

            this.UpdateConstraints[threatListDescriptor] = updateConstraints;
            return(this);
        }
        /// <summary>
        ///     Restrict Updates.
        /// </summary>
        /// <param name="threatListDescriptor">
        ///     A <see cref="ThreatListDescriptor" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="updateConstraints">
        ///     The <see cref="ThreatListUpdateConstraints" /> to apply when the <see cref="ThreatList" /> identified
        ///     by <paramref name="threatListDescriptor" /> is retrieved.
        /// </param>
        /// <returns>
        ///     This managed service builder.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     Thrown if <paramref name="threatListDescriptor" /> is a null reference, or if
        ///     <paramref name="updateConstraints" /> is a null reference.
        /// </exception>
        public ManagedBrowsingServiceBuilder RestrictUpdatesTo(ThreatListDescriptor threatListDescriptor, ThreatListUpdateConstraints updateConstraints)
        {
            Guard.ThrowIf(nameof(threatListDescriptor), threatListDescriptor).Null();
            Guard.ThrowIf(nameof(updateConstraints), updateConstraints).Null();

            this.UpdateConstraints[threatListDescriptor] = updateConstraints;
            return(this);
        }