예제 #1
0
        public void Write(BinaryWriter writer)
        {
            var adaptor = new BinaryWriteAdaptor(writer);

            adaptor.WriteNullable(_domain);
            adaptor.Write(DateTime.FromSystemDateTime(_expires, TimeZone.UTC));
            adaptor.Write(_httpOnly);
            adaptor.WriteNullable(_name);
            adaptor.WriteNullable(_path);
            adaptor.Write(_secure);
            adaptor.WriteNullable(_value);
        }
예제 #2
0
        private void WriteXml(XmlWriteAdaptor adaptor)
        {
            // Source.

            adaptor.WriteStartElement(Constants.Xml.SourceElement);
            adaptor.WriteName(_source);
            adaptor.WriteEndElement();

            // Event.

            adaptor.WriteStartElement(Constants.Xml.EventElement);
            adaptor.WriteName(_event);
            adaptor.WriteEndElement();

            // Type, Method, Message, Time, Sequence.

            adaptor.WriteElement(Constants.Xml.TypeElement, _type);
            adaptor.WriteElement(Constants.Xml.MethodElement, _method);
            adaptor.WriteElement(Constants.Xml.MessageElement, _message);

            // The message time is in UTC, but System.Xml.XmlConvert assumes it's local time and writes
            // the local timezone. Use LinkMe.Framework.Type.DateTime to avoid this.

            DateTime time = DateTime.FromSystemDateTime(_time, TimeZone.UTC);

            adaptor.WriteElement(Constants.Xml.TimeElement, TypeXmlConvert.ToString(time));

            if (_sequence != 0)
            {
                adaptor.WriteElement(Constants.Xml.SequenceElement, TypeXmlConvert.ToString(_sequence));
            }

            // Exception.

            if (_exception != null)
            {
                adaptor.WriteStartElement(Constants.Xml.ExceptionElement);
                _exception.WriteXml(adaptor.XmlWriter);
                adaptor.WriteEndElement();
            }

            // Details and Parameters.

            WriteDetails(adaptor);
            WriteParameters(adaptor);
        }
예제 #3
0
파일: TypeClone.cs 프로젝트: formist/LinkMe
        /// <summary>
        /// Clones the supplied primitive value-typed data.
        /// </summary>
        /// <param name="value">The value to be cloned</param>
        /// <returns>Cloned object</returns>
        public static object Clone(object value)
        {
            const string method = "Clone";

            if (value == null)
            {
                return(null);
            }
            if (value is System.String)
            {
                return(value);
            }
            if (value is System.Byte)
            {
                return((System.Byte)value);
            }
            if (value is System.Int16)
            {
                return((System.Int16)value);
            }
            if (value is System.Int32)
            {
                return((System.Int32)value);
            }
            if (value is System.Int64)
            {
                return((System.Int64)value);
            }
            if (value is System.Single)
            {
                return((System.Single)value);
            }
            if (value is System.Double)
            {
                return((System.Double)value);
            }
            if (value is System.Decimal)
            {
                return((System.Decimal)value);
            }
            if (value is System.Boolean)
            {
                return((System.Boolean)value);
            }
            if (value is System.Guid)
            {
                return((System.Guid)value);
            }
            if (value is Date)
            {
                return((Date)value);
            }
            if (value is DateTime)
            {
                return((DateTime)value);
            }
            if (value is System.DateTime)
            {
                return(DateTime.FromSystemDateTime((System.DateTime)value, System.TimeZone.CurrentTimeZone));
            }
            if (value is TimeOfDay)
            {
                return((TimeOfDay)value);
            }
            if (value is TimeSpan)
            {
                return((TimeSpan)value);
            }
            else
            {
                throw new InvalidParameterValueException(typeof(TypeClone), method, "value", value.GetType(), value);
            }
        }