The Registry represents an object that is used to register bindings between a class and a converter implementation. Converter instances created by this registry are lazily created and cached so that they are instantiated only once. This ensures that the overhead of serialization is reduced.
 public void TestConverter() {
    Registry registry = new Registry();
    Strategy interceptor = new RegistryStrategy(registry);
    Persister persister = new Persister(interceptor);
    StringWriter writer = new StringWriter();
    PetShop shop = new PetShop();
    registry.bind(Dog.class, DogConverter.class)
    //public List<Pet> GetPets() {
    //   return list;
    //}
 public void TestCycle() {
    Registry registry = new Registry();
    CycleStrategy inner = new CycleStrategy();
    RegistryStrategy strategy = new RegistryStrategy(registry, inner);
    Persister persister = new Persister(strategy);
    PetBucket bucket = new PetBucket();
    StringWriter writer = new StringWriter();
    registry.bind(Cat.class, CatConverter.class);
Example #3
0
 /// <summary>
 /// Constructor for the <c>RegistryStrategy</c> object. This
 /// is used to create a strategy that will intercept the normal
 /// serialization process by searching for bindings within the
 /// provided <c>Registry</c> instance.
 /// </summary>
 /// <param name="registry">
 /// this is the registry instance with bindings
 /// </param>
 /// <param name="strategy">
 /// this is the strategy to delegate to
 /// </param>
 public RegistryStrategy(Registry registry, Strategy strategy){
    this.registry = registry;
    this.strategy = strategy;
 }
Example #4
0
 /// <summary>
 /// Constructor for the <c>RegistryStrategy</c> object. This
 /// is used to create a strategy that will intercept the normal
 /// serialization process by searching for bindings within the
 /// provided <c>Registry</c> instance.
 /// </summary>
 /// <param name="registry">
 /// this is the registry instance with bindings
 /// </param>
 public RegistryStrategy(Registry registry) {
    this(registry, new TreeStrategy());
 }