internal FileTransmitterEncoderBuilder(FluentJdfLibrary fluentJdfLibrary, EncodingSettings encodingSettings, FileTransmitterEncoder encoder)
     : base(fluentJdfLibrary)
 {
     ParameterCheck.ParameterRequired(encodingSettings, "encodingSettings");
     this.fluentJdfLibrary = fluentJdfLibrary;
     this.encodingSettings = encodingSettings;
     this.encoder          = encoder;
 }
        /// <summary>
        /// Add a new FileTransmitterEncoder
        /// </summary>
        /// <param name="id">The id of the encoder</param>
        /// <param name="urlBase">The url base</param>
        /// <param name="useMime">UseMime</param>
        /// <param name="nameValues">Additional Parameters</param>
        /// <returns></returns>
        public FileTransmitterEncoderBuilder FileTransmitterEncoder(string id, Uri urlBase, bool useMime = false, IDictionary <string, string> nameValues = null)
        {
            ParameterCheck.StringRequiredAndNotWhitespace(id, "id");
            ParameterCheck.ParameterRequired(urlBase, "urlBase");

            var newEncoder = new FileTransmitterEncoder(id, urlBase, useMime, nameValues);

            encodingSettings.AddFileTransmitterEncoders(newEncoder);
            return(new FileTransmitterEncoderBuilder(fluentJdfLibrary, encodingSettings, newEncoder));
        }
        /// <summary>
        /// Add a new FileTransmitterEncoder
        /// </summary>
        /// <param name="id">The id of the encoder</param>
        /// <param name="urlBase">The url base</param>
        /// <param name="useMime">UseMime</param>
        /// <param name="nameValues">Extra Values</param>
        /// <returns></returns>
        public FileTransmitterEncoderBuilder FileTransmitterEncoder(string id, string urlBase, bool useMime = false, IDictionary <string, string> nameValues = null)
        {
            ParameterCheck.StringRequiredAndNotWhitespace(id, "id");
            ParameterCheck.StringRequiredAndNotWhitespace(urlBase, "urlBase");

            if (encodingSettings.FileTransmitterEncoders.ContainsKey(id))
            {
                throw new JdfException(string.Format("FileTransmitterEncoder Id already exists {0}", id));
            }
            var newEncoder = new FileTransmitterEncoder(id, urlBase, useMime, nameValues);

            encodingSettings.AddFileTransmitterEncoders(newEncoder);
            return(new FileTransmitterEncoderBuilder(fluentJdfLibrary, encodingSettings, newEncoder));
        }
示例#4
0
        /// <summary>
        /// Add a <see cref="FileTransmitterEncoder"/>
        /// </summary>
        /// <param name="encoder"></param>
        public void AddFileTransmitterEncoders(FileTransmitterEncoder encoder)
        {
            string itemPath = encoder.LocalPath;

            if (FileTransmitterEncoders.ContainsKey(encoder.Id))
            {
                throw new JdfException(string.Format("Collection already contains a " + typeof(FileTransmitterEncoder).Name + " with ID={0}", encoder.Id));
            }
            else if (FileTransmitterEncoders.Values.Any(item => item.LocalPath.Equals(encoder.LocalPath, StringComparison.OrdinalIgnoreCase)))
            {
                throw new JdfException(string.Format("Collection already contains a " + typeof(FileTransmitterEncoder).Name + " with BaseUrl={0}", encoder.UrlBase));
            }
            else
            {
                fileTransmitterEncoderList[encoder.Id] = encoder;
            }
        }