private SunsetLake GetSepLake(Dictionary <string, object> args) { SunsetLake s_lake = new SunsetLake(); s_lake.RegisterSingleton <ILogger>(LoggerFactory.Auto(this.GetType().Name)); s_lake.RegisterSingleton <ClassTextReader>(() => { return(ClassTextReaderCache.Acquire(this.GetType())); }); s_lake.RegisterSingleton <IExtensionInfo>(() => { return(this.GetExtensionInfo()); }); s_lake.RegisterSingleton <ILeafUI>(() => { ILeafUI leafUI = this.lake !.Get <ILeafUI>(); IExtensionInfo inf = this.GetExtensionInfo(); leafUI.Title = inf.Name(); leafUI.Icon = inf.Icon(); return(leafUI); }); s_lake.RegisterSingleton <Dictionary <string, object> >(() => { return(args ?? new Dictionary <string, object>()); }); return(s_lake); }
public ComponentFactoryTest() { lake = new SunsetLake(); var reader = new ComponentFactoryReader(lake, typeof(TestFactory)); reader.Read(); }
#pragma warning restore CS8618 // 不可为 null 的字段未初始化。请考虑声明为可以为 null。 /// <summary> /// 构造应用 /// </summary> public App() : base() { Current = this; Thread.CurrentThread.Name = "Application Main Thread"; AppLoader = new GeneralAppLoader(); Lake = new SunsetLake(); }
public void MainTest() { IRegisterableLake lake = new SunsetLake(); new ClassComponentsLoader("AutumnBox.Tests.OpenFX.Leafx", lake).Do(); Assert.IsTrue(lake.Get <F**k>().Yes()); }
public void GetComponentsCompatibilitTest() { IRegisterableLake lake = new SunsetLake(); lake.RegisterSingleton("t", "2401"); Assert.AreEqual("2401", lake.GetComponents("t").FirstOrDefault()); }
public void RegisterTest() { IRegisterableLake lake = new SunsetLake(); int time = 0; lake.Register <int>(() => time++); Assert.IsTrue((lake.Get <int>() - lake.Get <int>()) == -1); }
public void RegisterSingletonTest() { IRegisterableLake lake = new SunsetLake(); lake.RegisterSingleton(typeof(int), () => 1); lake.RegisterSingleton <string>("test string"); Assert.IsTrue(lake.Get <int>() == 1); Assert.IsTrue(lake.Get <string>() == "test string"); }
private static IRegisterableLake BuildLake() { SunsetLake lake = new SunsetLake(); new ClassComponentsLoader( "AutumnBox.GUI.Services.Impl", lake) .Do(); return(lake); }
public void FieldTest() { SunsetLake lake = new SunsetLake(); lake.RegisterSingleton(FieldInjectTarget.TEST_STR_ID, () => FieldInjectTarget.TEST_STR); lake.RegisterSingleton <FieldInjectTarget, FieldInjectTarget>(); var target = lake.Get <FieldInjectTarget>(); Assert.IsTrue(target.IsAllRight()); }
public void ByTypeInject() { const string TEST_STR = "test string"; SunsetLake lake = new SunsetLake(); lake.RegisterSingleton <string>(TEST_STR); var instance = new InjectTarget(); new DependenciesInjector(instance, lake).Inject(); Assert.IsTrue(instance.Str == TEST_STR); }
public void IntelliInject() { SunsetLake lake = new SunsetLake(); lake.Register <DateTime>(() => DateTime.Now); var instance = new InjectTarget(); var originalDateTime = instance.CreateDateTime; new DependenciesInjector(instance, lake).Inject(); Assert.IsTrue(instance.CreateDateTime != originalDateTime); }
public void CheckTest() { Assert.ThrowsException <NotSupportedException>(() => { ILake lake = new SunsetLake(); lake.GetComponents("t"); }); ILake lake = new TestLake(); Assert.IsTrue(lake.GetComponents("t").Count() == 0); }
public void InjectingTest() { IRegisterableLake lake = new SunsetLake(); const int TEST_SUM = 50; const string TEST_STR = "test str"; lake.RegisterSingleton("sum", () => TEST_SUM); lake.RegisterSingleton <string>(TEST_STR); lake.RegisterSingleton <InjectTestClass, InjectTestClass>(); var testClass = lake.Get <InjectTestClass>(); Assert.IsTrue(testClass.Sum == TEST_SUM); Assert.IsTrue(testClass.Str == TEST_STR); }
public void ObjectBuildTest() { const int sum = 5; const string str = "test string"; IRegisterableLake lake = new SunsetLake(); lake.RegisterSingleton <int>(sum); lake.RegisterSingleton <string>(str); lake.RegisterSingleton <ITestInterface, TestClass>(); ITestInterface testInterfaceImpl = lake.Get <ITestInterface>(); Assert.IsTrue(testInterfaceImpl.Str == str); Assert.IsTrue(testInterfaceImpl.Sum == sum); }
public void FindEntryPoint() { IRegisterableLake lake = new SunsetLake(); { var leaf = lake.CreateInstance <EEntryPointFindingTest1>(); var result = leaf.Main(new Dictionary <string, object>()); Assert.AreEqual(result, EEntryPointFindingTest1.TEST_RESULT); } { var leaf = lake.CreateInstance <EEntryPointFindingTest2>(); var result = leaf.Main(new Dictionary <string, object>()); Assert.AreEqual(result, EEntryPointFindingTest2.TEST_RESULT); } { var leaf = lake.CreateInstance <EEntryPointFindingTest3>(); var result = leaf.Main(new Dictionary <string, object>()); Assert.AreEqual(result, EEntryPointFindingTest3.TEST_RESULT); } }
public void MixArgsTest() { const string TEST_STR = "test string"; const int SUM = 3; SunsetLake lake = new SunsetLake(); lake.RegisterSingleton <string>("f**k"); SunsetLake lake2 = new SunsetLake(); lake.RegisterSingleton <string>(TEST_STR); MethodProxy maxProxy = new MethodProxy(this, nameof(HashCodeAdd), lake + lake2); long result = (long)maxProxy.Invoke(new Dictionary <string, object>() { { "x", 3 } }); long correctResult = HashCodeAdd(SUM, TEST_STR); Assert.IsTrue(correctResult == result); }
private ILake GetSepLake() { SunsetLake s_lake = new SunsetLake(); s_lake.RegisterSingleton <ILogger>(LoggerFactory.Auto(this.GetType().Name)); s_lake.RegisterSingleton <ClassTextReader>(() => { return(ClassTextReader.GetReader(this)); }); s_lake.RegisterSingleton <IExtensionInfo>(() => { return(this.GetExtensionInfo()); }); s_lake.RegisterSingleton <ILeafUI>(() => { ILeafUI leafUI = this.lake !.Get <ILeafUI>(); IExtensionInfo inf = this.GetExtensionInfo(); leafUI.Title = inf.Name(); leafUI.Icon = inf.Icon(); return(leafUI); }); return(s_lake); }