SimpleFramework.Xml.Util.Registry.Lookup C# (CSharp) Method

Lookup() public method

This is used to acquire a Converter instance from the registry. All instances are cache to reduce the overhead of lookups during the serialization process. Converters are lazily instantiated and so are only created if demanded.
public Lookup ( Class type ) : Converter
type Class /// this is the type to find the converter for ///
return Converter
      public Converter Lookup(Class type) {
         Converter converter = cache.fetch(type);
         if(converter == null) {
            return Create(type);
         }
         return converter;
      }
      /// <summary>

Usage Example

Example #1
0
 /// <summary>
 /// This is used to acquire a <c>Converter</c> instance for
 /// the provided value object. The value object is used to resolve
 /// the converter to use for the serialization process.
 /// </summary>
 /// <param name="type">
 /// this is the type representing the field or method
 /// </param>
 /// <param name="value">
 /// this is the value that is to be serialized
 /// </param>
 /// <returns>
 /// this returns the converter instance that is matched
 /// </returns>
 public Converter Lookup(Type type, Value value) {
    Class real = type.getType();
    if(value != null) {
       real = value.getType();
    }
    return registry.Lookup(real);
 }