Example #1
0
        public void ClearTest()
        {
            // clear filled
            var dict = new Headers <RequestHeader>();

            dict.Set(RequestHeader.Accept, "value");
            dict.Set("Custom1", "value");
            Assert.Equal(2, dict.Count);
            dict.Clear();
            Assert.Equal(0, dict.Count);
            Assert.False(dict.Contains(RequestHeader.Accept));
            Assert.False(dict.Contains("Accept"));
            Assert.False(dict.Contains("Custom1"));

            // clear new
            dict = new Headers <RequestHeader>();
            dict.Clear();
            dict = new Headers <RequestHeader>(new NameValueCollection());
            dict.Clear();
            dict = new Headers <RequestHeader>(new Dictionary <string, string>());
            dict.Clear();

            // clear empty
            dict = new Headers <RequestHeader>();
            dict.Set(RequestHeader.Trailer, "value");
            dict.Remove(RequestHeader.Trailer);
            dict.Clear();
            Assert.Equal(0, dict.Count);
            Assert.False(dict.Contains(RequestHeader.Trailer));

            // clear cleared
            dict = new Headers <RequestHeader>();
            dict.Clear();
            dict.Clear();
        }
Example #2
0
        public void ContainsTest()
        {
            // contains known
            var dict = new Headers <RequestHeader>();
            var coll = dict as ICollection <KeyValuePair <string, string> >;

            dict.Set(RequestHeader.Via, "value");

            Assert.True(dict.Contains("Via"), "containskey failed");
            Assert.False(dict.Contains("Host"), "containskey failed");
            Assert.True(coll.Contains(new KeyValuePair <string, string>("Via", "value")), "contains(key,value) failed");
            Assert.False(coll.Contains(new KeyValuePair <string, string>("Via", "value1")), "contains(key,value) failed");

            // contains new/missing/existing custom
            dict = new Headers <RequestHeader>();
            coll = dict;

            dict.Set("Custom1", "value");

            Assert.True(dict.Contains("Custom1"), "containskey failed");
            Assert.False(dict.Contains("Custom2"), "containskey failed");
            Assert.True(coll.Contains(new KeyValuePair <string, string>("Custom1", "value")), "contains(key,value) failed");
            Assert.False(coll.Contains(new KeyValuePair <string, string>("Custom1", "value1")), "contains(key,value) failed");

            // contains new/missing/existing mixed
            dict = new Headers <RequestHeader>();
            coll = dict;

            dict.Set(RequestHeader.Via, "value");
            dict.Set("Custom1", "value");

            Assert.True(dict.Contains("Custom1"), "containskey failed");
            Assert.False(dict.Contains("Custom2"), "containskey failed");
            Assert.True(coll.Contains(new KeyValuePair <string, string>("Custom1", "value")), "contains(key,value) failed");
            Assert.False(coll.Contains(new KeyValuePair <string, string>("Custom1", "value1")), "contains(key,value) failed");

            Assert.True(dict.Contains("Via"), "containskey failed");
            Assert.True(dict.Contains(RequestHeader.Via), "contains failed");
            Assert.False(dict.Contains("Host"), "containskey failed");
            Assert.True(coll.Contains(new KeyValuePair <string, string>("Via", "value")), "contains(key,value) failed");
            Assert.False(coll.Contains(new KeyValuePair <string, string>("Via", "value1")), "contains(key,value) failed");

            // contains empty
            dict = new Headers <RequestHeader>();
            coll = dict;

            Assert.False(dict.Contains("Custom2"), "containskey failed");
            Assert.False(coll.Contains(new KeyValuePair <string, string>("Custom1", "value1")), "contains(key,value) failed");
        }
Example #3
0
        /// <summary>
        /// Get a DataFrame with only the columns specified by headers
        /// </summary>
        /// <param name="headerArray">Array of strings representing the colums by headers</param>
        /// <returns>A DataFrame</returns>
        public DataFrame this[string[] headerArray]
        {
            get
            {
                if (Headers.Length == 0)
                {
                    throw new IndexOutOfRangeException("Headers dose not contain the index");
                }

                int[] indexArray = new int[headerArray.Length];

                for (int i = 0; i < headerArray.Length; i++)
                {
                    if (!Headers.Contains(headerArray[i]))
                    {
                        throw new IndexOutOfRangeException(string.Format("Headers dose not contain the index {0}", headerArray[i]));
                    }

                    var index = System.Array.FindIndex(Headers, x => x == headerArray[i]);
                    indexArray[i] = index;
                }

                return(this[indexArray]);
            }
        }
Example #4
0
        protected virtual Bucket CreateHeaders(string hostName)
        {
            var      bucket = Bucket.Empty;
            Encoding enc    = Encoding.UTF8;

            if (!Headers.Contains(HttpRequestHeader.Host))
            {
                bucket += enc.GetBytes("Host: ").AsBucket()
                          + enc.GetBytes(RequestUri.Host).AsBucket()
                          + enc.GetBytes("\r\n").AsBucket();
            }

            if (!Headers.Contains(HttpRequestHeader.AcceptEncoding))
            {
#if !NETFRAMEWORK
                bucket += Bucket.Create.FromUTF8("Accept-Encoding: gzip, deflate, br\r\n");
#else
                bucket += Bucket.Create.FromUTF8("Accept-Encoding: gzip, deflate\r\n");
#endif
            }

            bucket += Headers.ToByteArray().AsBucket(); // Includes the final \r\n to end the request headers

            return(bucket);
        }
Example #5
0
 public void AddHeader(string v)
 {
     if (!Headers.Contains(v))
     {
         Headers.Add(v);
     }
 }
Example #6
0
 public void SetHeader(string name, string value)
 {
     if (Headers.Contains(name))
     {
         Headers.Remove(name);
     }
     Headers.TryAddWithoutValidation(name, value);
 }
Example #7
0
        internal ExecutionPlan(IList <CommandBinder> binders)
        {
            Contract.Assert(binders.Any(), "Execution plan needs a list of binders, one per command line.");

            _binders         = binders;
            Headers          = binders.Select(l => l.Header.Value).ToArray();
            IsTransaction    = Headers.Contains("MULTI", StringComparer.Ordinal);
            HasScripts       = Headers.Contains("EVALSHA", StringComparer.Ordinal);
            ContextOperation = ExecutionContextOperation.Parse(Headers);
        }
Example #8
0
        /// <summary>
        /// Writes the message to the specified stream.
        /// </summary>
        /// <param name="options">The formatting options.</param>
        /// <param name="stream">The stream.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <para><paramref name="options"/> is <c>null</c>.</para>
        /// <para>-or-</para>
        /// <para><paramref name="stream"/> is <c>null</c>.</para>
        /// </exception>
        public void WriteTo(FormatOptions options, Stream stream)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if (!Headers.Contains("Date"))
            {
                Date = DateTimeOffset.Now;
            }

            if (messageId == null)
            {
                MessageId = MimeUtils.GenerateMessageId();
            }

            if (version == null && Body != null && Body.Headers.Count > 0)
            {
                MimeVersion = new Version(1, 0);
            }

            if (Body == null)
            {
                Headers.WriteTo(stream);

                stream.Write(options.NewLineBytes, 0, options.NewLineBytes.Length);
            }
            else
            {
                using (var filtered = new FilteredStream(stream)) {
                    filtered.Add(options.CreateNewLineFilter());

                    foreach (var header in MergeHeaders())
                    {
                        var name = Encoding.ASCII.GetBytes(header.Field);

                        filtered.Write(name, 0, name.Length);
                        filtered.WriteByte((byte)':');
                        filtered.Write(header.RawValue, 0, header.RawValue.Length);
                    }

                    filtered.Flush();
                }

                options.WriteHeaders = false;
                Body.WriteTo(options, stream);
            }
        }
Example #9
0
 private void SetValue(string headerName, string headerValue)
 {
     if (Headers.Contains(headerName))
     {
         Headers[headerName] = headerValue;
     }
     else
     {
         Headers.Add(headerName, headerValue);
     }
 }
Example #10
0
 // Interfaces
 /// <summary>
 /// Add a new header to current headers, if the header already exists then nothing happens
 /// </summary>
 /// <param name="name">name of header</param>
 public void AddHeader(string name, string fillValue = "")
 {
     if (Headers.Contains(name) == false)
     {
         Headers.Add(name);
         foreach (List <string> row in Rows)
         {
             row.Add(fillValue);
         }
     }
 }
Example #11
0
        public void Append(object source, bool addToCache = false)
        {
            Type enumerableType         = source.GetType();
            List <PropertyInfo> columns = enumerableType.GetProperties().Where(o => Headers.Contains(o.Name)).ToList();
            List <string>       row     = new List <string>();

            foreach (PropertyInfo property in columns)
            {
                row.Add(property.GetValue(source).ToString());
            }
            Append(row, addToCache);
        }
Example #12
0
        public virtual HttpRequest RemoveRequestType()
        {
            if (Headers.Contains(CustomHeaders.RequestType))
            {
                Headers.Remove(CustomHeaders.RequestType);
            }

            if (Headers.Contains(CustomHeaders.RequestEntityType))
            {
                Headers.Remove(CustomHeaders.RequestEntityType);
            }

            return(this);
        }
Example #13
0
        public void writeData(SortedList <int, double> ResultData)
        {
            getWriter(DateTime.Now);

            List <double> values = new List <double>();

            foreach (KeyValuePair <int, double> de in ResultData)
            {
                if (Headers.Contains(de.Key))
                {
                    values.Add(de.Value);
                }
            }
            string valueStr = String.Format("{0};{1}", DateTime.Now.AddHours(-2).ToString("dd.MM.yyyy HH:mm:ss"), String.Join(";", values)).Replace(',', '.');

            CurrentWriter.WriteLine(valueStr);
            CurrentWriter.Flush();
        }
Example #14
0
        public CsvReader(string path, char separator, bool hasHeaders)
        {
            m_reader = new StreamReader(path);

            HasHeaders = hasHeaders;
            Separator  = separator;

            if (hasHeaders)
            {
                //Get the headers of the current csv
                Headers = m_reader.ReadLine().ToArgs(separator, ignoreEmpty: false);

                if (Headers.Contains(string.Empty))
                {
                    throw new FormatException($"Empty header found.");
                }
            }
        }
Example #15
0
 bool IsStringableContentType()
 {
     if (Headers.Contains(HeaderField.ContentType))
     {
         if (Headers[HeaderField.ContentType][0].Contains("text/"))
         {
             return(true);
         }
         if (Headers[HeaderField.ContentType][0].Contains("application/json"))
         {
             return(true);
         }
         if (Headers[HeaderField.ContentType][0].Contains("application/xml"))
         {
             return(true);
         }
     }
     return(false);
 }
Example #16
0
        public List <Dictionary <string, string> > GetTaggedLines(string tagColumnHead, string tag)
        {
            List <Dictionary <string, string> > result = new List <Dictionary <string, string> >();

            if (!Headers.Contains(tagColumnHead))
            {
                throw new ArgumentException($"Column header name: {tagColumnHead} does not exist in current Content");
            }
            foreach (Dictionary <string, string> line in Content)
            {
                line.TryGetValue(tagColumnHead, out string csvCell);
                if (csvCell == "")
                {
                    continue;
                }
                var CellContent = csvCell.Split(',').ToList();
                if (CellContent.Contains(tag))
                {
                    result.Add(line);
                }
            }

            return(result);
        }
Example #17
0
        public void GetSetTest()
        {
            // set new/existing known
            // get missing/existing known
            var dict = new Headers <RequestHeader>();

            dict.Set(RequestHeader.Trailer, "value");
            Assert.Equal(1, dict.Count);
            Assert.Equal(dict[RequestHeader.Trailer], "value");
            Assert.False(dict.Contains(RequestHeader.AcceptCharset));

            dict.Set(RequestHeader.Trailer, "value2");
            Assert.Equal(1, dict.Count);
            Assert.Equal(dict[RequestHeader.Trailer], "value2");
            Assert.False(dict.Contains(RequestHeader.AcceptCharset));

            dict.Set(RequestHeader.Trailer, "valueA");
            dict.Set(RequestHeader.Via, "valueB");
            Assert.Equal(2, dict.Count);
            Assert.Equal(dict[RequestHeader.Trailer], "valueA");
            Assert.Equal(dict[RequestHeader.Via], "valueB");
            Assert.False(dict.Contains(RequestHeader.AcceptCharset));

            // set new/existing custom
            // get missing/existing custom
            dict = new Headers <RequestHeader>();

            dict.Set("Custom1", "value");
            Assert.Equal(1, dict.Count);
            Assert.Equal(dict["Custom1"], "value");

            dict.Set("Custom1", "value2");
            Assert.Equal(1, dict.Count);
            Assert.Equal(dict["Custom1"], "value2");

            dict.Set("Custom1", "valueA");
            dict.Set("Custom2", "valueB");
            Assert.Equal(2, dict.Count);
            Assert.Equal(dict["Custom1"], "valueA");
            Assert.Equal(dict["Custom2"], "valueB");
            Assert.False(dict.Contains("Custom3"));

            // get missing/existing custom case-insensitive
            Assert.Equal(dict["custom1"], "valueA");
            Assert.Equal(dict["custom2"], "valueB");
            Assert.False(dict.Contains("custom3"));

            // set new/existing mixed
            // get missing/existing mixed
            dict = new Headers <RequestHeader>();
            dict.Set("Custom1", "value");
            dict.Set(RequestHeader.Trailer, "value");
            Assert.Equal(2, dict.Count);
            Assert.Equal(dict["Custom1"], "value");
            Assert.Equal(dict[RequestHeader.Trailer], "value");

            dict.Set("Custom1", "value2");
            dict.Set(RequestHeader.Trailer, "value2");
            Assert.Equal(2, dict.Count);
            Assert.Equal(dict["Custom1"], "value2");
            Assert.Equal(dict[RequestHeader.Trailer], "value2");

            dict.Set("Custom1", "valueA");
            dict.Set("Custom2", "valueB");
            dict.Set(RequestHeader.Trailer, "valueA");
            dict.Set(RequestHeader.Via, "valueB");
            Assert.Equal(4, dict.Count);
            Assert.Equal(dict[RequestHeader.Trailer], "valueA");
            Assert.Equal(dict[RequestHeader.Via], "valueB");
            Assert.Equal(dict["Custom1"], "valueA");
            Assert.Equal(dict["Custom2"], "valueB");

            // get missing/existing mixed case-insensitive
            Assert.Equal(dict["custom1"], "valueA");
            Assert.Equal(dict["custom2"], "valueB");
            Assert.Equal(dict["trailer"], "valueA");
            Assert.Equal(dict["via"], "valueB");

            // get empty
            dict = new Headers <RequestHeader>();
            Assert.Equal(0, dict.Count);
            Assert.Equal(dict.Get(RequestHeader.Via), "");
            Assert.Equal(dict.Get("Via"), "");
            Assert.Equal(dict.Get("Custom"), "");
            Assert.False(dict.Contains(RequestHeader.Via));
            Assert.False(dict.Contains("Via"));
            Assert.False(dict.Contains("Custom"));
        }
Example #18
0
        public void RemoveTest()
        {
            // remove new/missing/existing known
            var dict = new Headers <RequestHeader>();

            dict.Set(RequestHeader.Accept, "value");
            Assert.Equal(1, dict.Count);
            Assert.Equal("value", dict[RequestHeader.Accept]);
            dict.Remove(RequestHeader.Accept);
            Assert.Equal(0, dict.Count);
            Assert.False(dict.Contains(RequestHeader.Accept));

            //  remove missing value
            dict.Remove(RequestHeader.Accept);
            dict.Remove(RequestHeader.Via);

            //  remove modified value
            dict.Set(RequestHeader.Accept, "value");
            dict.Set("accept", "value2");
            Assert.Equal(1, dict.Count);
            Assert.Equal("value2", dict[RequestHeader.Accept]);
            dict.Remove(RequestHeader.Accept);
            Assert.Equal(0, dict.Count);
            Assert.False(dict.Contains(RequestHeader.Accept));

            // remove new/missing/existing custom
            dict = new Headers <RequestHeader>();
            dict.Set("Custom1", "value");
            Assert.Equal(1, dict.Count);
            Assert.Equal("value", dict["Custom1"]);
            dict.Remove("Custom1");
            Assert.Equal(0, dict.Count);
            Assert.False(dict.Contains("Custom1"));

            //  remove missing value
            dict.Remove("Custom1");
            dict.Remove("Custom2");

            //  remove modified value
            dict.Set("Custom1", "value");
            dict.Set("Custom1", "value2");
            Assert.Equal(1, dict.Count);
            Assert.Equal("value2", dict["Custom1"]);
            dict.Remove("Custom1");
            Assert.Equal(0, dict.Count);
            Assert.False(dict.Contains("Custom1"));

            // remove new/missing/existing mixed
            dict = new Headers <RequestHeader>();
            dict.Set("Custom1", "value");
            dict.Set(RequestHeader.Accept, "value");
            Assert.Equal(2, dict.Count);
            Assert.Equal("value", dict["Custom1"]);
            Assert.Equal("value", dict[RequestHeader.Accept]);
            dict.Remove("Custom1");
            dict.Remove(RequestHeader.Accept);
            Assert.Equal(0, dict.Count);
            Assert.False(dict.Contains("Custom1"));
            Assert.False(dict.Contains(RequestHeader.Accept));

            //  remove missing value
            dict.Remove("Custom1");
            dict.Remove("Custom2");
            dict.Remove(RequestHeader.Accept);
            dict.Remove(RequestHeader.Via);

            //  remove modified value
            dict.Set("Custom1", "value");
            dict.Set("Custom1", "value2");
            dict.Set(RequestHeader.Accept, "value");
            dict.Set(RequestHeader.Accept, "value2");
            Assert.Equal(2, dict.Count);
            Assert.Equal("value2", dict["Custom1"]);
            Assert.Equal("value2", dict[RequestHeader.Accept]);
            dict.Remove("Custom1");
            dict.Remove(RequestHeader.Accept);
            Assert.Equal(0, dict.Count);
            Assert.False(dict.Contains("Custom1"));
            Assert.False(dict.Contains(RequestHeader.Accept));

            // remove non existing
            dict = new Headers <RequestHeader>();
            dict.Remove(RequestHeader.Host);
            dict.Remove("Custom");
        }
Example #19
0
 public bool ContainsHeader(string name, string value)
 {
     return(Headers.Contains(name, value));
 }
Example #20
0
        /// <summary>
        /// 読み込まれたCSVデータの内容をカスタムオブジェクトで取得します
        /// </summary>
        /// <typeparam name="T"> マッピングするオブジェクトの型 </typeparam>
        /// <returns> マッピングされたオブジェクトのList </returns>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="NotSupportedException"></exception>
        /// <exception cref="MissingMethodException"></exception>
        /// <exception cref="MethodAccessException"></exception>
        /// <exception cref="InvalidCastException"></exception>
        /// <exception cref="OverflowException"></exception>
        /// <exception cref="FormatException"></exception>
        /// <exception cref="TypeLoadException"></exception>
        /// <exception cref="TargetException"></exception>
        /// <exception cref="TargetInvocationException"></exception>
        /// <exception cref="AmbiguousMatchException"></exception>
        /// <exception cref="FailedMappingException"></exception>
        public List <T> GetContents <T>() where T : new()
        {
            var res  = new List <T>();
            var maps = new List <MappingObject>();

            if (Headers.Count == 0)
            {
                return(res);
            }

            PropertyInfo[] properties = typeof(T).GetProperties();

            if (properties.Length != Headers.Count)
            {
                throw new FailedMappingException
                          ("マッピングしようとしているPropertyの数とヘッダーの数が一致しません。");
            }

            foreach (PropertyInfo prop in properties)
            {
                var map = new MappingObject();

                // Propertyに紐付いた属性値を取得
                HeaderAttribute header_atrb =
                    prop.GetCustomAttribute <HeaderAttribute>();

                if (prop.PropertyType.Name.Contains("Nullable"))
                {
                    // Nullableの型の時
                    // GetUnderlyingTypeから型を取得する
                    map.ObjectType = Nullable.GetUnderlyingType(prop.PropertyType);

                    // Nullableフラグを立てる
                    map.IsNullable = true;
                }
                else
                {
                    // Nullableの型でないときは普通にPropertyTypeから取得
                    map.ObjectType = prop.PropertyType;
                }

                if (header_atrb != null && Headers.Contains(header_atrb.Name))
                {
                    // 属性値が設定されていて、属性値に対応するヘッダーが存在している場合
                    // ヘッダーに対応するプロパティ名を取得
                    map.Name   = prop.Name;
                    map.Number = Headers.IndexOf(header_atrb.Name);
                }
                else if (Headers.Contains(prop.Name))
                {
                    // 属性値が設定されていなければヘッダーに対応するプロパティ名を
                    // 検索して取得
                    map.Name   = prop.Name;
                    map.Number = Headers.IndexOf(prop.Name);
                }
                else
                {
                    throw new FailedMappingException
                              ("ヘッダー名称がマッピングしようとしているオブジェクト内に" +
                              "存在しません。");
                }

                maps.Add(map);
            }

            // プロパティに値を設定するためのローカル関数
            void setValue(ref T obj, string propName, object value) =>
            typeof(T).GetRuntimeProperty(propName).SetValue(obj, value);

            foreach (var ctn in Contents)
            {
                // ジェネリクスのインスタンス作成
                var Tobj = Activator.CreateInstance <T>();

                foreach (var map in maps)
                {
                    // コンテンツから値を取得
                    string str = ctn[map.Number];

                    if (map.ObjectType.Equals(typeof(string)))
                    {
                        // マッピング先の型がstringならそのまま値を入れる
                        setValue(ref Tobj, map.Name, str);
                    }
                    else
                    {
                        // マッピング先の型がstring以外なら値を変換
                        TypeCode code  = Type.GetTypeCode(map.ObjectType);
                        object   value = string.IsNullOrWhiteSpace(str) ?
                                         null : str.ConvertValue(code);

                        // valueがnullで、マッピング先の型がNullableでない場合を除き
                        // 値を設定する
                        if (!(value == null && (!map.IsNullable)))
                        {
                            setValue(ref Tobj, map.Name, value);
                        }

                        // valueがnullで、マッピング先の型がNullableでない場合は
                        // マッピング先クラスのコンストラクタの初期値に依存させる
                    }
                }

                res.Add(Tobj);
            }

            return(res);
        }
Example #21
0
 /// <summary>
 /// Validates this definition.
 /// </summary>
 /// <returns>A flag indicating if the definition is valid.</returns>
 public bool Validate()
 => !Rows.Any(r => r.Any(c => !Headers.Contains(c.Header)));
Example #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MimeKit.MimeMessage"/> class.
        /// <param name="args">An array of initialization parameters: headers and message parts.</param>
        /// </summary>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="args"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// <para><paramref name="args"/> contains more than one <see cref="MimeKit.MimeEntity"/>.</para>
        /// <para>-or-</para>
        /// <para><paramref name="args"/> contains one or more arguments of an unknown type.</para>
        /// </exception>
        public MimeMessage(params object[] args) : this(ParserOptions.Default.Clone())
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            MimeEntity body = null;

            foreach (object obj in args)
            {
                if (obj == null)
                {
                    continue;
                }

                // Just add the headers and let the events (already setup) keep the
                // addresses in sync.

                var header = obj as Header;
                if (header != null)
                {
                    if (!header.Field.StartsWith("Content-", StringComparison.OrdinalIgnoreCase))
                    {
                        Headers.Add(header);
                    }

                    continue;
                }

                var headers = obj as IEnumerable <Header>;
                if (headers != null)
                {
                    foreach (var h in headers)
                    {
                        if (!h.Field.StartsWith("Content-", StringComparison.OrdinalIgnoreCase))
                        {
                            Headers.Add(h);
                        }
                    }

                    continue;
                }

                var entity = obj as MimeEntity;
                if (entity != null)
                {
                    if (body != null)
                    {
                        throw new ArgumentException("Message body should not be specified more than once.");
                    }

                    body = entity;
                    continue;
                }

                throw new ArgumentException("Unknown initialization parameter: " + obj.GetType());
            }

            if (body != null)
            {
                Body = body;
            }

            // Do exactly as in the parameterless constructor but avoid setting a default
            // value if an header already provided one.

            if (!Headers.Contains("From"))
            {
                Headers["From"] = string.Empty;
            }
            if (!Headers.Contains("To"))
            {
                Headers["To"] = string.Empty;
            }
            if (date == default(DateTimeOffset))
            {
                Date = DateTimeOffset.Now;
            }
            if (!Headers.Contains("Subject"))
            {
                Subject = string.Empty;
            }
        }