//init public TemporaryStorage() { _reflectionInvoker = new ReflectionInvoker(); _listOperations = new ListOperations(); _runningTasks = new List <Task>(); _entitiesAwaitingFlush = new Dictionary <Type, IList>(); }
public void InlinePropertyReflection() { var invoker = new ReflectionInvoker(typeof(TestClass), "Group.Struct.Width"); var width = (int)invoker.GetValue(testReference); Assert.AreEqual(value, width, "Reflection Fail Get Operation"); invoker.SetValue(testReference, width + 1); Assert.AreEqual(value + 1, testReference.Group.Struct.Width, "Reflection Fail Set Operation"); }
public void PropertyReflection() { var invoker = new ReflectionInvoker(typeof(TestClass), "X"); var x = (int)invoker.GetValue(testReference); Assert.AreEqual(value, x, "Reflection Fail Get Operation"); invoker.SetValue(testReference, x + 1); Assert.AreEqual(value + 1, testReference.X, "Reflection Fail Set Operation"); }
public void InlineFieldReflection() { var invoker = new ReflectionInvoker(typeof(TestClass), "Struct.Field"); var x = (int)invoker.GetValue(testReference); Assert.AreEqual(value, x, "Reflection Fail Get Operation"); x++; invoker.SetValue(testReference, x); Assert.AreEqual(value + 1, testReference.Struct.Field, "Reflection Fail Set Operation"); }
//init public GeneratorSetup() { _reflectionInvoker = new ReflectionInvoker(); EntityDescriptions = new Dictionary <Type, IEntityDescription>(); TemporaryStorage = new TemporaryStorage(); DefaultSpreadStrategy = new EvenSpreadStrategy(); DefaultFlushStrategy = new LimitedCapacityFlushStrategy(100); DefaultPersistentStorages = new List <IPersistentStorage>(); Supervisor = new CompleteSupervisor(); }
public void Register(Assembly assembly) { foreach (var type in assembly.GetTypes()) { if (type.IsInterface) { continue; } foreach (var interfaceType in type.GetInterfaces()) { if (!interfaceType.IsGenericType || interfaceType.GetGenericTypeDefinition() != typeof(IHandlerOf <>)) { continue; } var componentType = interfaceType.GetGenericArguments()[0]; var instance = Activator.CreateInstance(type); var method = instance.GetType().GetMethod("DoWork", new[] { componentType }); _handlers[componentType] = new ReflectionInvoker(instance, method); } } }