public void AutoWireConverters() { IReflectionService reflectionService = ReflectionFactory.FromCurrentAppDomain(); using (ITypeExecutorService executors = reflectionService.PrepareTypeExecutors()) { executors.AddConverters(); } string value; Assert.AreEqual(true, Converts.Repository.TryConvert <int, string>(5, out value)); Assert.AreEqual("5", value); }
public void BaseComposition() { StringBuilder result = new StringBuilder(); IReflectionService reflectionService = ReflectionFactory.FromCurrentAppDomain(); using (ITypeExecutorService executors = reflectionService.PrepareTypeExecutors()) { executors.AddFiltered(true) .AddFilterNotInterface() .AddFilterNotAbstract() .AddHandler(t => result.AppendLine(t.FullName)); } File.WriteAllText("C:/Temp/Files.txt", result.ToString()); }
public void AttributeFiltering() { IReflectionService reflectionService = ReflectionFactory.FromCurrentAppDomain(); int matchCount = 0; using (ITypeExecutorService executors = reflectionService.PrepareTypeExecutors()) { executors.AddFiltered(false) .AddFilterHasAttribute <ConverterAttribute>() .AddHandler(t => { Assert.AreEqual(typeof(IntToStringConverter), t); matchCount++; }); } Assert.AreEqual(1, matchCount); }
public void AbstractFiltering() { IReflectionService reflectionService = ReflectionFactory.FromCurrentAppDomain(); int matchCount = 0; using (ITypeExecutorService executors = reflectionService.PrepareTypeExecutors()) { executors.AddFiltered(false) .AddFilterNotAbstract() .AddHandler(t => { Assert.AreEqual(false, t.IsAbstract); matchCount++; }); } Ensure.Positive(matchCount, "matchCount"); }