ArtemisComm.Utility.WriteToStream C# (CSharp) Method

WriteToStream() static private method

static private WriteToStream ( Type targetType, object item, MemoryStream stream ) : void
targetType System.Type
item object
stream System.IO.MemoryStream
return void
        static void WriteToStream(Type targetType, object item, MemoryStream stream)
        {
            if (targetType == typeof(byte))
            {
                stream.Write(Convert.ToByte(item, CultureInfo.InvariantCulture));
            }
            if (targetType == typeof(short))
            {
                stream.Write(Convert.ToInt16(item, CultureInfo.InvariantCulture));
            }
            if (targetType == typeof(int))
            {
                stream.Write(Convert.ToInt32(item, CultureInfo.InvariantCulture));
            }
            if (targetType == typeof(float))
            {
                stream.Write(Convert.ToSingle(item, CultureInfo.InvariantCulture));
            }
            if (targetType == typeof(long))
            {
                stream.Write(Convert.ToInt64(item, CultureInfo.InvariantCulture));
            }
            if (targetType == typeof(string))
            {
                byte[] ar = System.Text.ASCIIEncoding.ASCII.GetBytes((string)item);
                stream.Write(ar, 0, ar.Length);
            }
            if (targetType == typeof(ArtemisString))
            {
                ArtemisString artyString = item as ArtemisString;
                stream.Write(artyString);
            }
        }
        public static void DisposeProperties(this IDisposable disposableObject)