public void TestGenericRebinding() { IDIContext context = ContextHelper.CreateContext(); context.s().BindInstance <ContextEnvironment>(ContextEnvironment.Normal); context.m().BindGeneric(typeof(IDIFactory <>), typeof(ContextFactory <>)); context.m().BindGeneric(typeof(IDIRFactory <,>), typeof(ReproduceContextFactory <,>)); IDIContext childContext = ContextHelper.CreateContext(context); childContext.m().Bind <IMyClass>(() => new MyClass()); childContext.s().Rebind <IDIFactory <IOtherClass> >(); MyClass obj1 = childContext.Resolve <IMyClass>() as MyClass; Assert.That(obj1.factory is ContextFactory <IOtherClass>); Assert.That(obj1.chainFactory is ReproduceContextFactory <IOtherClass, IGlobalContextInitializer>); MyClass obj2 = childContext.Resolve <IMyClass>() as MyClass; Assert.That(obj2.factory is ContextFactory <IOtherClass>); Assert.That(obj2.chainFactory is ReproduceContextFactory <IOtherClass, IGlobalContextInitializer>); Assert.AreSame(obj1.factory, obj2.factory); Assert.AreNotSame(obj1.chainFactory, obj2.chainFactory); }
public static IDIContext CreateContext <T>(IDIContext parent = null, string name = null) where T : class, IContextInitializer { var context = InternalCreateContext(parent, name); context.Initialize <T>(); return(context); }
private void SingletoneCreation(IDIContext context) { IAdvancedWrite write = context.Resolve <IAdvancedWrite>(); Assert.That(write is AdvancedModel); write.tag = "my_test_model"; }
public void Dispose() { _container.Unregister <IBrowserAPIManager>(); _container = null; _browserAPIManager.Dispose(); _browserAPIManager = null; }
public void Dispose() { var memoryReader = _container.Resolve <IMemoryReaderManager>(); memoryReader.OnConnectionStateChanged -= MemoryReader_OnConnectionState; _container = null; }
public void TestNamedParentIntrospection() { IDIContext parentContext = ContextHelper.CreateContext(); parentContext.m().Bind <IApple>(() => new Apple(), BindingName.ForType <Apple>()); IDIContext context = parentContext.Reproduce(); context.m().Bind <IApple>(() => new BigApple(), BindingName.ForType <BigApple>()); IBinding desc = context.Introspect <IApple>(BindingName.ForType <BigApple>()); Assert.IsNotNull(desc); Assert.AreEqual(InstantiationType.Abstract, desc.instantiationType); Assert.That(desc.context == context); object apple = desc.factory(); Assert.That(apple is BigApple); desc = context.Introspect <IApple>(); Assert.IsNotNull(desc); Assert.AreEqual(InstantiationType.Abstract, desc.instantiationType); Assert.That(desc.context == context); apple = desc.factory(); Assert.That(apple is BigApple); desc = context.Introspect <IApple>(BindingName.ForType <Apple>()); Assert.IsNotNull(desc); Assert.AreEqual(InstantiationType.Abstract, desc.instantiationType); Assert.That(desc.context == parentContext); apple = desc.factory(); Assert.That(apple is Apple); }
public void Dispose() { _browserAPIManager.MemoryHandler = null; _browserAPIManager = null; _memoryManager = null; _container = null; }
protected T CreateScene <T> (IDIContext sceneContext, IList <ISceneContextInitializer> initializers, string sceneName, string bindingName = null, Func <IConstruction> construction = null) where T : class, ISceneObject { // UnityEngine.Debug.LogWarning("Resolving scene for construction: "+construction); // Creating scene instance object SceneObject instance = sceneContext.Resolve <T>(construction, bindingName) as SceneObject; if (instance == null) { throw new MindiException("Scene object is expected to be inherited from SceneObject"); } VerifyObjectCreation(bindingName, instance, sceneContext); // Injecting dependencies on the objects that are already on scene, and tracking the other objects on ROR TrackObjects(sceneContext); // Adding auto-instantiated objects PerformAutoInstantiation(sceneContext, initializers); instance.name = sceneName; RegisterCreation(instance); return(instance as T); }
private void PerformAutoInstantiation(IDIContext sceneContext, IList <ISceneContextInitializer> initializers) { foreach (ISceneContextInitializer initializer in initializers) { initializer.AutoInstantiate(sceneContext); } }
public void Initialize(ApplicationStartupHandler handler, IDIContext container) { _container = container ?? throw new ArgumentNullException(nameof(container)); _configManager = _container.Resolve <IConfigManager>(); _memoryManager = _container.Resolve <IMemoryReaderManager>(); var actorManager = _container.Resolve <IActorManager>(); var resourceBundle = _container.Resolve <ILocaleManager>().GetResourceBundle("autotranslate"); var autotranslateProvider = new AutotranslateProvider(resourceBundle); _chatManager = new ChatManager(autotranslateProvider, actorManager); _configManager.AddPropertyChangeListener("behaviour.chat.updateInterval", true, true, ConfigManager_UpdateChatInterval); _configManager.AddPropertyChangeListener("behaviour.channel", true, true, ConfigManager_UpdateChannelProperties); _configManager.AddPropertyChangeListener("behaviour.segment", true, true, ConfigManager_UpdateFormaterProperties); _configManager.AddPropertyChangeListener("behaviour.groups", true, true, ConfigManager_UpdateTriggerGroupProperties); _configManager.AddPropertyChangeListener("behaviour.mentions", true, true, ConfigManager_UpdateMentions); _configManager.AddPropertyChangeListener("behaviour.chat.autodetectEmoteInSay", true, true, ConfigManager_UpdateAutodetectProperties); _configManager.AddPropertyChangeListener("behaviour.language", true, true, ConfigManager_UpdateLanguage); _configManager.AddPropertyChangeListener("behaviour.rangefilter", true, true, ConfigManager_UpdateRangeFilter); _configManager.AddPropertyChangeListener("behaviour.mentions.userCanTriggerMention", true, true, ConfigManager_UpdateUserMentionProperties); _configManager.AddPropertyChangeListener("behaviour.chattabs.data", true, true, ConfigManager_UpdateVisibleChannel); _configManager.AddPropertyChangeListener("behaviour.chattabs.data", true, true, ConfigManager_UpdateUpdateRangeFilterActive); _container.Register <IChatManager>((c, p) => _chatManager); _updater = new IndependendBackgroundWorker(); _updater.Start(UpdateJob); }
private void TrackObjects(IDIContext sceneContext) { var hashObject = sceneContext.Resolve <IRemoteObjectsHash>(); var ror = sceneContext.Resolve <IRemoteObjectsRecord>(); GameObject[] objects = Resources.FindObjectsOfTypeAll <GameObject>(); foreach (GameObject obj in objects) { // Find all the objects on the scene that have no hash, that's the new objects, and track them on this scene if (obj.hideFlags != HideFlags.None) { continue; } if (editorPrefabFilter.IsPrefab(obj)) { continue; } if (hashObject.Contains(obj.GetInstanceID())) { continue; } hashObject.Register(obj); ror.Register(obj); // Injecting mono behaviours RegisterMonoBehaviours(obj, sceneContext, ror); } }
public void Dispose() { _memoryReader.OnConnectionStateChanged -= MemoryReader_OnConnectionState; _chatManager = null; _container = null; }
public void Initialize(ApplicationStartupHandler handler, IDIContext container) { _container = container ?? throw new ArgumentNullException(nameof(container)); _memoryReaderManager = new FFXIVMemoryManager(container); _container.Register <IMemoryReaderManager>((c, p) => _memoryReaderManager); }
public static void Main(string[] args) { IDIContext context = ContextHelper.CreateContext <IGlobalContextInitializer>().Reproduce <IApplicationContextInitializer>(); var world = context.Resolve <IWorld>(); world.Run(); }
public TestBinder(IDIContext context) : base(context) { this.instantiationType = Introspection.InstantiationType.Abstract; this.customFactoryWrapper = (t, f) => { return(new AnotherClass(f())); }; }
public static string GetDefaultBindingName(IDIContext context) { string contextName = (string.IsNullOrEmpty(context.name))?"c":context.name; string name = string.Format("{0}_{1}", "#", contextName); return(name); }
public virtual T Create <T>(string sceneName, bool destroyableObjects, string bindingName = null, Action <IDIContext> customContextInitializer = null, Func <IConstruction> construction = null) where T : class, ISceneObject { if (environment != ContextEnvironment.RemoteObjects) { throw new MindiException("SceneFactory can only work in the Remote objects environment"); } IDIContext newContext = ContextHelper.CreateContext(this.context); if (destroyableObjects) { newContext.s().BindInstance <MBLifeTime>(MBLifeTime.DestroyWithScene); } IList <ISceneContextInitializer> initializers = ContextBuilder.Initialize <ISceneContextInitializer>(newContext, new SceneContextAttribute(sceneName)); BindObjectsRecord(newContext); if (customContextInitializer != null) { customContextInitializer(newContext); } return(CreateScene <T>(newContext, initializers, sceneName, bindingName, construction)); }
public void TestRebindSingletonToSingleton() { IDIContext context = ContextHelper.CreateContext(); context.s().Bind <IMyClass>(() => new MyClass()); IDIContext childContext = ContextHelper.CreateContext(context); childContext.s().Rebind <IMyClass>(); IMyClass a1 = context.Resolve <IMyClass>(); IMyClass a2 = context.Resolve <IMyClass>(); Assert.AreSame(a1, a2); IMyClass b1 = childContext.Resolve <IMyClass>(); IMyClass b2 = childContext.Resolve <IMyClass>(); Assert.AreSame(b1, b2); Assert.AreNotSame(b1, a1); Assert.AreNotSame(b2, a2); IBinding d1 = context.Introspect <IMyClass>(); Assert.AreEqual(InstantiationType.Concrete, d1.instantiationType); Assert.AreEqual(context, d1.context); IBinding d2 = childContext.Introspect <IMyClass>(); Assert.AreEqual(InstantiationType.Concrete, d2.instantiationType); Assert.AreEqual(childContext, d2.context); }
private void RegisterMonoBehaviours(GameObject obj, IDIContext sceneContext, IRemoteObjectsRecord ror) { ContextMonoBehaviour[] behaviours = obj.GetComponents <ContextMonoBehaviour>(); foreach (ContextMonoBehaviour mb in behaviours) { sceneContext.InjectDependencies(mb); } }
public void Dispose() { _container?.Unregister <FFXIVMemoryReader>(); _memoryReaderManager?.Dispose(); _memoryReaderManager = null; _container = null; }
protected void VerifyInstantiationContext(IBinding desc, IDIContext resolutionContext, object instance) { if (desc != null && desc.instantiationType == InstantiationType.Concrete && desc.context != resolutionContext) { throw new MindiException(string.Format("Cannot instantiate an object {0} on factory {1}, because it is already a singleton on different ctx, than the one, this factory resolves objects on. " + "Consider making object multiple, or rebind it as singletone on this factory chaining ctx.", instance, this)); } }
public void Initialize(ApplicationStartupHandler handler, IDIContext container) { _container = container ?? throw new ArgumentNullException(nameof(container)); _browserAPIManager = _container.Resolve <IBrowserAPIManager>(); _memoryManager = _container.Resolve <IMemoryReaderManager>(); _browserAPIManager.MemoryHandler = new BrowserMemoryHandler(this); }
public void Initialize(ApplicationStartupHandler handler, IDIContext container) { _container = container ?? throw new ArgumentNullException(nameof(container)); var memoryReader = _container.Resolve <IMemoryReaderManager>(); memoryReader.OnConnectionStateChanged += MemoryReader_OnConnectionState; OnConnection(memoryReader.ConnectionState); }
public void Initialize(ApplicationStartupHandler handler, IDIContext container) { _container = container ?? throw new ArgumentNullException(nameof(container)); _memoryManager = _container.Resolve <IMemoryReaderManager>(); _configManager = _container.Resolve <IConfigManager>(); _configManager.AddPropertyChangeListener("behaviour.hideOnMinimize", true, true, ConfigManager_UpdateHideOnMinimize); _memoryManager.OnWindowFocusChanged += MemoryReader_OnWindowFocusChanged; }
public void Initialize(ApplicationStartupHandler handler, IDIContext container) { _manager = container.Resolve <IUIManager>(); _configManager = container.Resolve <IConfigManager>(); var synchronizer = _manager.UISynchronizer; synchronizer.RunSync(() => InitializeUI()); }
public void Dispose() { _configManager.RemovePropertyChangeListener(ConfigManager_UpdateHideOnMinimize); _memoryManager.OnWindowFocusChanged -= MemoryReader_OnWindowFocusChanged; _container = null; _memoryManager = null; _configManager = null; }
public void Initialize(IDIContext context) { context.s().Rebind <ILog>(null, BindingName.For(LogType.Decorated)); context.m().Bind <ILogOwner>(() => new MyLogOwner()); context.s().Bind <IWorld>(() => new Earth()); context.s().Bind <ISky>(() => new Sky()); context.m().Bind <IHumanFactory>(() => new HumanFactory()); context.m().Bind <IHuman>(() => new Human()); }
private static IDIContext InternalCreateContext(IDIContext parent, string name) { IDIContext context = new MiniocContext(parent, name); // Binding context itself context.s().BindInstance <IDIContext>(context); return(context); }
public void Initialize(ApplicationStartupHandler handler, IDIContext container) { if (handler == null) { throw new System.ArgumentNullException(nameof(handler)); } DeleteOldPatchData(); var configManager = container.Resolve <IConfigManager>(); var doUpdate = configManager.GetProperty <bool>("behaviour.appUpdate.checkOnline"); if (!doUpdate) { return; } var allowBetaUpdates = configManager.GetProperty <bool>("behaviour.appUpdate.acceptBeta"); var update = GetUpdate(GobchatContext.ApplicationVersion, allowBetaUpdates); if (update == null) { return; } var userRequest = AskUser(update); if (userRequest == UpdateFormDialog.UpdateType.Skip) { return; } if (userRequest == UpdateFormDialog.UpdateType.Auto) { var needRestart = PerformAutoUpdate(container, update); if (needRestart) { handler.StopStartup = true; } } if (userRequest == UpdateFormDialog.UpdateType.Manual) { var dialogText = StringFormat.Format(Resources.Module_Updater_Dialog_ManualInstall_Text, update.Version); var dialogResult = System.Windows.Forms.MessageBox.Show(dialogText, Resources.Module_Updater_Dialog_ManualInstall_Title, System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information); //TODO improve - a lot if (System.Windows.Forms.DialogResult.Yes == dialogResult) { System.Diagnostics.Process downloadProcess = System.Diagnostics.Process.Start(update.PageUrl); handler.StopStartup = true; } } }
public void Initialize(ApplicationStartupHandler handler, IDIContext container) { _container = container ?? throw new ArgumentNullException(nameof(container)); _chatManager = _container.Resolve <IChatManager>(); _memoryReader = _container.Resolve <IMemoryReaderManager>(); _reportError = true; //report error on startup _memoryReader.OnConnectionStateChanged += MemoryReader_OnConnectionState; Report(_memoryReader.ConnectionState); }