Exemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name = "value"></param>
        /// <returns>string.Empty if the value is null</returns>
        public string ConvertToString(object value)
        {
            if (value == null)
            {
                return(string.Empty);
            }

            // Array of byte
            if (value.GetType() == typeof(byte[]))
            {
                return(Convert.ToBase64String((byte[])value));
            }

            // Type
            if (isType(value))
            {
                return(_typeNameConverter.ConvertToTypeName((Type)value));
            }

            // Char which is \0
            if (value.Equals(NullChar))
            {
                return(NullCharAsString);
            }

            return(Convert.ToString(value, _cultureInfo));
        }
Exemplo n.º 2
0
        //------------------------------------------------------------------------------
        public string ConvertToTypeName(Type type)
        {
            if (m_customTypeNameConverter == null)
            {
                return(GetDefaultTypeNameConverter().ConvertToTypeName(type));
            }

            return(m_customTypeNameConverter.ConvertToTypeName(type));
        }
Exemplo n.º 3
0
        ///<summary>
        ///  Writes attribute of type Type
        ///</summary>
        ///<param name = "attributeId"></param>
        ///<param name = "type"></param>
        public void WriteAttribute(string attributeId, Type type)
        {
            if (type == null)
            {
                return;
            }
            string valueAsText = _typeNameProvider.ConvertToTypeName(type);

            WriteAttribute(attributeId, valueAsText);
        }
Exemplo n.º 4
0
 /// <summary>
 ///   Writes type
 /// </summary>
 /// <param name = "type"></param>
 public void WriteType(Type type)
 {
     if (type == null)
     {
         _writer.Write(false);
     }
     else
     {
         _writer.Write(true);
         _writer.Write(_typeNameConverter.ConvertToTypeName(type));
     }
 }
        private void WriteTypesHeader(BinaryWriter writer)
        {
            // count
            BinaryWriterTools.WriteNumber(_types.Items.Count, writer);

            // Items
            foreach (var type in _types.Items)
            {
                var typeName = _typeNameConverter.ConvertToTypeName(type);
                BinaryWriterTools.WriteString(typeName, writer);
            }
        }