GetConverter() private method

private GetConverter ( Type type ) : Converter
type System.Type
return Converter
Example #1
0
        public void UserDefinedConvertersHavePriority()
        {
            var lookup             = new ConverterLookup();
            var alternateConverter = new AlternateStringConverter();

            lookup.AddConverter(alternateConverter);
            Assert.That(lookup.GetConverter(typeof(string)), Is.EqualTo(alternateConverter));
        }
        public object ConvertAnother()
        {
            string nullAttribute = reader.GetAttribute(Attributes.Null);

            if (nullAttribute != null && nullAttribute == "true")
            {
                return(null);
            }
            object result = Find();

            if (result != null)
            {
                return(result);
            }
            Converter converter = converterLookup.GetConverter(reader.GetNodeName());

            if (converter == null)
            {
                return(ConvertOriginal());
            }
            return(converter.FromXml(reader, this));
        }
Example #3
0
        internal void ConvertAnother(object value)
        {
            Converter converter = converterLookup.GetConverter(value);

            if (converter != null)
            {
                converter.ToXml(value, writer, this);
            }
            else
            {
                ConvertObject(value);
            }
        }
Example #4
0
        private object ConvertField(Type fieldType)
        {
            string classAttribute = reader.GetAttribute(Attributes.classType);

            if (!string.IsNullOrEmpty(classAttribute))
            {
                fieldType = Type.GetType(Xmlifier.UnXmlify(classAttribute));
            }
            Converter converter = converterLookup.GetConverter(fieldType);

            if (converter != null)
            {
                return(converter.FromXml(reader, context));
            }
            else
            {
                return(Unmarshal(fieldType));
            }
        }
        internal void ConvertAnother(object value)
        {
            if (value == null)
            {
                // TODO: Make this a configuration option
                // Don't export null values.
                return;
            }

            Converter converter = converterLookup.GetConverter(value);

            if (converter != null)
            {
                converter.ToXml(value, writer, this);
            }
            else
            {
                ConvertObject(value);
            }
        }
		public void UserDefinedConvertersHavePriority () {
			var lookup = new ConverterLookup ();
			var alternateConverter = new AlternateStringConverter ();
			lookup.AddConverter (alternateConverter);
			Assert.That (lookup.GetConverter (typeof(string)), Is.EqualTo (alternateConverter));
		}