SimpleFramework.Xml.Util.ConverterFactory.GetInstance C# (CSharp) Method

GetInstance() public method

This is used to instantiate the converter based on the type of the Convert annotation provided. If the type can not be instantiated for some reason then an exception is thrown from this method.
public GetInstance ( Convert convert ) : Converter
convert Convert /// this is the annotation containing the type ///
return Converter
      public Converter GetInstance(Convert convert) {
         Class type = convert.value();
         if(type.isInterface()) {
            throw new ConvertException("Can not instantiate %s", type);
         }
         return GetInstance(type);
      }
      /// <summary>

Same methods

ConverterFactory::GetInstance ( Class type ) : Converter

Usage Example

Example #1
0
 /// <summary>
 /// This is used to acquire a <c>Converter</c> instance from
 /// this binder. All instances are cached to reduce the overhead
 /// of lookups during the serialization process. Converters are
 /// lazily instantiated and so are only created if demanded.
 /// </summary>
 /// <param name="type">
 /// this is the type to find the converter for
 /// </param>
 /// <returns>
 /// this returns the converter instance for the type
 /// </returns>
 public Converter Create(Class type)
 {
     return(factory.GetInstance(type));
 }