/// <summary> /// Initializes a new instance of the <see cref="SerializationOptions"/> class. /// </summary> public SerializationOptions() { PortableFactories = new List <FactoryOptions <IPortableFactory> >(); PortableFactoriesBinder = new CollectionBinder <IdentifiedInjectionOptions>(item => { PortableFactories.Add(new FactoryOptions <IPortableFactory> { Id = item.Id, Creator = () => ServiceFactory.CreateInstance <IPortableFactory>(item.TypeName, item.Args) }); }); DataSerializableFactories = new List <FactoryOptions <IDataSerializableFactory> >(); DataSerializableFactoriesBinder = new CollectionBinder <IdentifiedInjectionOptions>(item => { DataSerializableFactories.Add(new FactoryOptions <IDataSerializableFactory> { Id = item.Id, Creator = () => ServiceFactory.CreateInstance <IDataSerializableFactory>(item.TypeName, item.Args) }); }); Serializers = new List <SerializerOptions>(); SerializersBinder = new CollectionBinder <SerializerInjectionOptions>(item => { Serializers.Add(new SerializerOptions { SerializedType = Type.GetType(item.SerializedTypeName) ?? throw new ConfigurationException($"Unknown serialized type \"{item.SerializedTypeName}\"."), Creator = () => ServiceFactory.CreateInstance <ISerializer>(item.TypeName, item.Args) }); });
public IBinder Apply() { var binder = new CollectionBinder <T>(_collection, _action); if (Set == null) { throw new InvalidOperationException("Binding set is not set"); } Set.Add(binder); binder.Start(); return(binder); }
public void Test() { var l = new List <int>(); var binder = new CollectionBinder <int>(value => l.Add(value)); Assert.Throws <NotSupportedException>(() => _ = binder.Count); Assert.Throws <NotSupportedException>(() => _ = binder.IsReadOnly); Assert.Throws <NotSupportedException>(() => _ = binder.Contains(1)); Assert.Throws <NotSupportedException>(() => _ = binder.Remove(1)); Assert.Throws <NotSupportedException>(() => _ = binder.GetEnumerator()); Assert.Throws <NotSupportedException>(() => _ = ((IEnumerable)binder).GetEnumerator()); Assert.Throws <NotSupportedException>(() => binder.CopyTo(Array.Empty <int>(), 0)); Assert.Throws <NotSupportedException>(() => binder.Clear()); binder.Add(1); binder.Add(2); Assert.That(l.Count, Is.EqualTo(2)); Assert.That(l[0], Is.EqualTo(1)); Assert.That(l[1], Is.EqualTo(2)); }
/// <summary> /// Initializes a new instance of the <see cref="HazelcastOptions"/> class. /// </summary> public HazelcastOptions() { Subscribers = new List <IHazelcastClientEventSubscriber>(); SubscribersBinder = new CollectionBinder <InjectionOptions>(x => Subscribers.Add(new HazelcastClientEventSubscriber(x.TypeName))); }