Exemple #1
0
        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);
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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 void Dispose()
        {
            var memoryReader = _container.Resolve <IMemoryReaderManager>();

            memoryReader.OnConnectionStateChanged -= MemoryReader_OnConnectionState;
            _container = null;
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        private void ConfigManager_UpdateHideOnMinimize(IConfigManager config, ProfilePropertyChangedCollectionEventArgs evt)
        {
            _hideOnMinimize = config.GetProperty <bool>("behaviour.hideOnMinimize");

            var uiManager = _container.Resolve <IUIManager>();

            uiManager.UISynchronizer.RunSync(() => _memoryManager.ObserveGameWindow = _hideOnMinimize);
        }
        public void Initialize(ApplicationStartupHandler handler, IDIContext container)
        {
            _manager       = container.Resolve <IUIManager>();
            _configManager = container.Resolve <IConfigManager>();

            var synchronizer = _manager.UISynchronizer;

            synchronizer.RunSync(() => InitializeUI());
        }
Exemple #9
0
        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)
        {
            _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);
        }
        public void Initialize(ApplicationStartupHandler handler, IDIContext container)
        {
            _container         = container ?? throw new ArgumentNullException(nameof(container));
            _chatManager       = _container.Resolve <IChatManager>();
            _browserAPIManager = _container.Resolve <IBrowserAPIManager>();

            _browserAPIManager.ChatHandler = new GobchatBrowserChatAPI(_chatManager);

            _browserAPIManager.OnUIReadyChanged += BrowserAPIManager_OnUIReadyChanged;
            _chatManager.OnChatMessage          += ChatManager_ChatMessageEvent;
        }
        public void Initialize(ApplicationStartupHandler handler, IDIContext container)
        {
            _container         = container ?? throw new ArgumentNullException(nameof(container));
            _browserAPIManager = _container.Resolve <IBrowserAPIManager>();
            _configManager     = _container.Resolve <IConfigManager>();
            _chatManager       = _container.Resolve <IChatManager>();

            _browserAPIManager.ConfigHandler = new BrowserConfigHandler(this);

            _configManager.OnProfileChange += ConfigManager_SynchronizeJSConfig;
            _configManager.AddPropertyChangeListener("*", ConfigManager_SynchronizeJSConfig);
        }
        public void TestCreationByNewFactorySingleton()
        {
            IDIContext context = ContextHelper.CreateContext();

            // Let's bind a test type using singleton binder
            context.s().Bind <IDependencyTest>(() => new DependencyTest());

            // Let's see that the dependencies are now injected - this class has injected context
            IDependencyTest test1 = context.Resolve <IDependencyTest>();
            IDependencyTest test2 = context.Resolve <IDependencyTest>();

            Assert.AreSame(test1, test2);
        }
Exemple #14
0
        public void Initialize(ApplicationStartupHandler handler, IDIContext container)
        {
            _container         = container ?? throw new ArgumentNullException(nameof(container));
            _configManager     = _container.Resolve <IConfigManager>();
            _browserAPIManager = _container.Resolve <IBrowserAPIManager>();

            var uiManager = _container.Resolve <IUIManager>();

            _cefOverlay = uiManager.GetUIElement <CefOverlayForm>(AppModuleChatOverlay.OverlayUIId);

            _cefOverlay.Browser.OnBrowserLoadPage     += Browser_BrowserLoadPage;
            _cefOverlay.Browser.OnBrowserLoadPageDone += Browser_BrowserLoadPageDone;
            _cefOverlay.Browser.OnBrowserInitialized  += Browser_BrowserInitialized;
        }
        public void Initialize(ApplicationStartupHandler handler, IDIContext container)
        {
            _container     = container ?? throw new ArgumentNullException(nameof(container));
            _configManager = _container.Resolve <IConfigManager>();
            _memoryManager = _container.Resolve <IMemoryReaderManager>();

            _actorManager = new ActorManager();
            _updater      = new IndependendBackgroundWorker();

            _configManager.AddPropertyChangeListener("behaviour.actor.updateInterval", true, true, ConfigManager_UpdateChatInterval);
            _configManager.AddPropertyChangeListener("behaviour.actor.active", true, true, ConfigManager_UpdateRangeFilter);

            _container.Register <IActorManager>((c, p) => _actorManager);
        }
Exemple #16
0
        public void TestNullNameResolve()
        {
            IDIContext context = ContextHelper.CreateContext();

            context.m().Bind <IApple>(() => new Apple());
            context.m().Bind <IOrange> (() => new Orange1());

            IApple appleInstance = context.Resolve <IApple>(null, null);

            Assert.IsNotNull(appleInstance);

            appleInstance = context.Resolve <IApple>("");
            Assert.IsNotNull(appleInstance);
        }
        public void Test2InterfacesContainerBinding()
        {
            IDIContext context = ContextHelper.CreateContext();

            // Then creating bindings for 2 interfaces through the container
            context.s().BindMany <IAdvancedRead, IAdvancedWrite>(() => new AdvancedModel());

            IAdvancedRead  read  = context.Resolve <IAdvancedRead>();
            IAdvancedWrite write = context.Resolve <IAdvancedWrite>();

            Assert.That(read is AdvancedModel);
            Assert.That(write is AdvancedModel);

            Assert.AreSame(read, write);
        }
Exemple #18
0
        public void TestValueInstanceBinding()
        {
            IDIContext context = ContextHelper.CreateContext();

            context.s().BindInstance <int>(5);

            int i = context.Resolve <int>();

            Assert.AreEqual(5, i);

            context.s().BindInstance <MyEnum>(MyEnum.Viktoria);
            MyEnum name = context.Resolve <MyEnum>();

            Assert.AreEqual(MyEnum.Viktoria, name);
        }
        private void SingletoneCreation(IDIContext context)
        {
            IAdvancedWrite write = context.Resolve <IAdvancedWrite>();

            Assert.That(write is AdvancedModel);
            write.tag = "my_test_model";
        }
        public void TestCreationByNewFactoryMultiple()
        {
            IDIContext context = ContextHelper.CreateContext();

            // Then let's create a standard factory we will use
            MultipleBinder binder = new MultipleBinder(context);

            // Let's bind a test type using our factory
            binder.Bind <IDependencyTest>(() => new DependencyTest());

            // Let's see that the dependencies are now injected - this class has injected context
            IDependencyTest test1 = context.Resolve <IDependencyTest>();
            IDependencyTest test2 = context.Resolve <IDependencyTest>();

            Assert.AreNotSame(test1, test2);
        }
Exemple #21
0
        public void TestInstanceBindingST()
        {
            MyClass obj = new MyClass();

            IDIContext context = ContextHelper.CreateContext();

            context.s().BindInstance <IMyClass>(obj);

            IMyClass anotherObj = context.Resolve <IMyClass>();

            Assert.AreSame(obj, anotherObj);

            IMyClass oneMorerObj = context.Resolve <IMyClass>();

            Assert.AreSame(obj, oneMorerObj);
        }
Exemple #22
0
        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);
        }
Exemple #23
0
        public static void Main(string[] args)
        {
            IDIContext context = ContextHelper.CreateContext <IGlobalContextInitializer>().Reproduce <IApplicationContextInitializer>();
            var        world   = context.Resolve <IWorld>();

            world.Run();
        }
Exemple #24
0
        public void Initialize(ApplicationStartupHandler handler, IDIContext container)
        {
            _container = container ?? throw new ArgumentNullException(nameof(container));

            _chatLogger = new CustomChatLogger();
            //_chatLogger.LogChannels = Enum.GetValues(typeof(ChatChannel)).Cast<ChatChannel>(); //will log everything that comes from the chat manager

            _configManager = _container.Resolve <IConfigManager>();
            _configManager.AddPropertyChangeListener("behaviour.chatlog.active", true, true, ConfigManager_UpdateWriteLog);
            _configManager.AddPropertyChangeListener("behaviour.chatlog.path", true, true, ConfigManager_UpdateLogPath);
            _configManager.AddPropertyChangeListener("behaviour.chatlog.format", true, true, ConfigManager_UpdateLogFormat);
            _configManager.AddPropertyChangeListener("behaviour.channel.log", true, true, ConfigManager_UpdateLogChannels);

            _chatManager = _container.Resolve <IChatManager>();
            _chatManager.OnChatMessage += ChatManager_ChatMessageEvent;
        }
        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);
        }
Exemple #26
0
        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;
                }
            }
        }
Exemple #27
0
        public void TestRequirementError()
        {
            IDIContext context = ContextHelper.CreateContext();

            context.s().Bind <IMyClass>(() => new MyClassRequirement());

            Assert.Throws <MiniocException>(() => {
                context.Resolve <IMyClass>();
            });
        }
Exemple #28
0
        public void TestwWithoutCustomFactoryWrapper()
        {
            IDIContext context = ContextHelper.CreateContext();

            context.m().Bind <IMyClass>(() => new MyClass());

            IMyClass obj = context.Resolve <IMyClass> ();

            Assert.IsInstanceOf <MyClass>(obj);
        }
Exemple #29
0
        public void Initialize(ApplicationStartupHandler handler, IDIContext container)
        {
            _container = container ?? throw new ArgumentNullException(nameof(container));

            var uiManager = _container.Resolve <IUIManager>();
            var overlay   = uiManager.GetUIElement <CefOverlayForm>(AppModuleChatOverlay.OverlayUIId);

            _browserAPIManager = new BrowserAPIManager(overlay, uiManager.UISynchronizer);
            _container.Register <IBrowserAPIManager>((c, p) => _browserAPIManager);
        }
Exemple #30
0
        public void TestSoftResolutionWithDefault()
        {
            IDIContext context = ContextHelper.CreateContext();

            context.s().Bind <IMyClass>(() => new MyClassWithDefault());

            IMyClass obj = context.Resolve <IMyClass>();

            Assert.That(obj.orange is DefaultOrange);
            Assert.That(obj.apple is DefaultApple);
        }