Beispiel #1
0
        /// <summary>
        /// Subscribes to the PropertyChanged event in a manner that avoids
        /// memory leaks.
        /// </summary>
        /// <param name="vm"> The INPC that we want to subscribe to.</param>
        /// <param name="targetObject"> The object whose property we'll be updating.</param>
        /// <param name="handler"> The action to be performed when the event triggers. </param>
        public static void WeakSubscribe
        (
            INPC vm,
            object targetObject,
            PropertyChangedEventHandler handler
        )
        {
            // If this vm is not in the weak subscription system yet, add it.
            WeakKeyDictionary <object, HandlerList> vmTableEntry;

            if (!dispatchTable.TryGetValue(vm, out vmTableEntry))
            {
                vmTableEntry = new WeakKeyDictionary <object, HandlerList>();
                dispatchTable.Add(vm, vmTableEntry);
                vm.PropertyChanged += DispatchWeakEvent;
            }

            // If a handler list for this object doesn't exist yet, make one.
            HandlerList handlerList;

            if (!vmTableEntry.TryGetValue(targetObject, out handlerList))
            {
                handlerList = new HandlerList();
                vmTableEntry.Add(targetObject, handlerList);
            }

            // Add the handler to the list.
            handlerList.Add(handler);
        }
Beispiel #2
0
        }                                                 //타겟 아이템

        private void Awake()
        {
            //핸들러 리스트에 현재 핸들러 추가
            if (!HandlerList.Contains(this))
            {
                HandlerList.Add(this);
            }
            if (!HandlerDiction.ContainsValue(this))
            {
                HandlerDiction.Add(this.name, this);
            }

            //아이템 이동 불가시 탭 이동, 스위칭, 머징 끄기
            if (!movable)
            {
                moveToOtherSlot = false;
                switching       = false;
                merging         = false;
            }

            //그래픽 레이캐스트 설정
            if (canvas != null)
            {
                gr = canvas.GetComponent <GraphicRaycaster>();
            }
        }
Beispiel #3
0
        public IDisposable Subscribe(Handler <TArg> action)
        {
            var e = new HandlerList <TArg>();

            e.Subscribe(action);
            return(_subscribe(e));
        }
Beispiel #4
0
    private void HandlerDataBind()
    {
        TSysUserVo objUser = new TSysUserVo();

        objUser.IS_USE  = "1";
        objUser.IS_DEL  = "0";
        objUser.IS_HIDE = "0";
        DataTable dt = new DataTable();

        dt = new TSysUserLogic().SelectByTable(objUser);

        HandlerList.DataSource     = dt;
        HandlerList.DataTextField  = "REAL_NAME";
        HandlerList.DataValueField = "ID";
        HandlerList.DataBind();

        //有直接上级就默认选择直接上级
        if (HandlerList.Items.Count > 0)
        {
            string    strLocalUserID = base.LogInfo.UserInfo.ID;
            DataTable dtDeptAdmin    = new TSysUserPostLogic().SelectDeptAdmin_byTable(strLocalUserID);
            if (dtDeptAdmin.Rows.Count > 0)
            {
                string strDeptAdminId = dtDeptAdmin.Rows[0]["user_id"].ToString();
                for (int i = 0; i < HandlerList.Items.Count; i++)
                {
                    if (HandlerList.Items[i].Value == strDeptAdminId)
                    {
                        HandlerList.SelectedIndex = i;
                    }
                }
            }
        }
    }
        /// <summary>
        /// Unloads a module with the specified id.
        /// </summary>
        /// <param name='id'>
        /// The identifier of the module to unload.
        /// </param>
        public virtual void Unload(Guid id)
        {
            lock (ScannerList)
            {
                try
                {
                    Debugger.Status("Attempt to remove module: " + id.ToString());

                    //Remove the scanner items and invoke garbage collection.
                    if (ScannerList.ContainsKey(id))
                    {
                        ScannerList.Remove(id);
                        ScheduledList.Remove(id);
                    }
                    else if (HandlerList.ContainsKey(id))
                    {
                        HandlerList.Remove(id);
                    }
                    else
                    {
                        throw new Exception("Module not found.");
                    }

                    GC.Collect();
                    Debugger.Success();
                }
                catch (Exception e)
                {
                    Debugger.Failure(e);
                }
            }
        }
        private void FireEvent(Event evt)
        {
            HandlerList handlers = evt.GetHandlers();

            RegisteredListener[] listeners = handlers.GetRegisteredListeners();

            foreach (RegisteredListener registration in listeners)
            {
                if (!registration.Plugin.IsEnabled())
                {
                    continue;
                }

                try
                {
                    registration.CallEvent(evt);
                }
                catch (Exception ex)
                {
                    IPlugin plugin = registration.Plugin;

                    if (plugin.IsNaggable())
                    {
                        plugin.SetNaggable(false);

                        server.GetLogger().Log(Level.SEVERE, String.Format(
                                                   "Nag author(s): '{0}' of '{1}' about the following: {2}",
                                                   plugin.PluginDescription.Authors,
                                                   plugin.PluginDescription.FullName,
                                                   ex.Message
                                                   ));
                    }
                }
            }
        }
 public void ClearPlugins()
 {
     DisablePlugins();
     plugins.Clear();
     lookupNames.Clear();
     HandlerList.UnregisterAll();
     permissions.Clear();
     defaultPerms[true].Clear();
     defaultPerms[false].Clear();
 }
Beispiel #8
0
        public void AddHandler <T>(Func <TMessage, Task> handler)
        {
            HandlerList list;

            if (!_handlers.TryGetValue(typeof(T), out list))
            {
                list = new HandlerList();
                _handlers.Add(typeof(T), list);
            }

            list.AddLast(handler);
        }
        static CustomExpHandlerManager()
        {
            _ActiveHandlers = new HandlerList();

            _Handlers       = new HandlerTypeDict();
            _GlobalHandlers = new HandlerTypeList();

            GlobalMessage.OnLevelCleanup += () =>
            {
                UnloadAllHandler();
            };
        }
 private void OnUpdate(object src, CommandRecievedEventArgs e)
 {
     if (e.CommandID == (int)CommandStateEnum.GET_APP_CONFIG)
     {
         NewConfiguration(e);
     }
     else if (e.CommandID == (int)CommandStateEnum.CLOSE_HANDLER)
     {
         HandlerList.Remove(e.Args[0]);
     }
     Changed?.Invoke();
 }
        public void DisablePlugin(IPlugin plugin)
        {
            if (plugin.IsEnabled())
            {
                try
                {
                    plugin.GetPluginLoader().DisablePlugin(plugin);
                }
                catch (Exception ex)
                {
                    server.GetLogger().Log(Level.SEVERE, "Error occurred (in the plugin loader) while disabling " + plugin.PluginDescrption.FullName + " (Is it up to date?)", ex);
                }

                try
                {
                    server.GetScheduler().CancelTasks(plugin);
                }
                catch (Exception ex)
                {
                    server.GetLogger().Log(Level.SEVERE, "Error occurred (in the plugin loader) while cancelling tasks for " + plugin.PluginDescrption.FullName + " (Is it up to date?)", ex);
                }

                try
                {
                    server.getServicesManager().unregisterAll(plugin);
                }
                catch (Exception ex)
                {
                    server.GetLogger().Log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering services for " + plugin.PluginDescrption.FullName + " (Is it up to date?)", ex);
                }

                try
                {
                    HandlerList.unregisterAll(plugin);
                }
                catch (Exception ex)
                {
                    server.GetLogger().Log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering events for " + plugin.PluginDescrption.FullName + " (Is it up to date?)", ex);
                }

                try
                {
                    server.GetMessenger().UnregisterIncomingPluginChannel(plugin);
                    server.GetMessenger().UnregisterOutgoingPluginChannel(plugin);
                }
                catch (Exception ex)
                {
                    server.GetLogger().Log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering plugin channels for " + plugin.PluginDescrption.FullName + " (Is it up to date?)", ex);
                }
            }
        }
Beispiel #12
0
 private void NewConfiguration(CommandRecievedEventArgs e)
 {
     OutputDir     = e.Args[0];
     SourceName    = e.Args[1];
     LogName       = e.Args[2];
     ThumbnailSize = e.Args[3];
     string[] handler = e.Args[4].Split(';');
     if (handler[0] != "")
     {
         foreach (string handle in handler)
         {
             HandlerList.Add(handle);
         }
     }
 }
Beispiel #13
0
    private void HandlerDataBind()
    {
        TSysUserVo objUser = new TSysUserVo();

        objUser.IS_USE  = "1";
        objUser.IS_DEL  = "0";
        objUser.IS_HIDE = "0";
        DataTable dt = new DataTable();

        dt = new TSysUserLogic().SelectByTable(objUser);

        HandlerList.DataSource     = dt;
        HandlerList.DataTextField  = "REAL_NAME";
        HandlerList.DataValueField = "ID";
        HandlerList.DataBind();
    }
 private void NewConfiguration(CommandRecievedEventArgs e)
 {
     OutputDir  = e.Args[0];
     SourceName = e.Args[1];
     LogName    = e.Args[2];
     ThumbS     = Int32.Parse(e.Args[3]);
     string[] handler = e.Args[4].Split(';');
     if (handler[0] != "")
     {
         foreach (string handle in handler)
         {
             if (!(HandlerList.Contains(handle)))
             {
                 HandlerList.Add(handle);
             }
         }
     }
 }
Beispiel #15
0
        public IHotkeyCollection Add(Hotkey hotkey, Action <Hotkey> handler)
        {
            HandlerList handlers;

            if (!storage.TryGetValue(hotkey, out handlers))
            {
                handlers = new HandlerList((short)hotkey.GetHashCode());
                if (Win32.RegisterHotKey(WindowInteropHelper.Handle, handlers.Atom, (uint)hotkey.Modifier, (uint)KeyInterop.VirtualKeyFromKey(hotkey.Key)))
                {
                    storage[hotkey] = handlers;
                }
                else
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }
            }

            handlers.Handlers.Add(handler);
            return(this);
        }
Beispiel #16
0
        public ProjectDebugForm(Handling.Project project)
        {
            InitializeComponent();

            Text = Lang.Get["TitleDebug"];
            btnReprocess.Text    = Lang.Get["DebugProjectReprocess"];
            btnLoadOriginal.Text = Lang.Get["DebugProjectLoadOriginal"];
            btnDebug.Text        = Lang.Get["DebugProjectDebug"];

            foreach (File file in project.SearchData.Files.Where(file => HandlerList.GetFileHandler(file) is AbstractLanguageFileHandler))
            {
                entries.Add(new RelativeFile(project.SearchData.Root, file));
            }

            textBoxFilterFiles_TextChanged(textBoxFilterFiles, new EventArgs());
            listBoxFiles_SelectedValueChange(listBoxFiles, new EventArgs());

            #if WINDOWS
            SendMessage(textBoxCode.Handle, 0x00CB, new IntPtr(1), new [] { 16 });
            #endif
        }
Beispiel #17
0
        private HandlerList GetComHandlerList(object instance)
        {
            HandlerList hl = (HandlerList)Marshal.GetComObjectData(instance, this);

            if (hl == null)
            {
                lock (_staticTarget) {
                    hl = (HandlerList)Marshal.GetComObjectData(instance, this);
                    if (hl == null)
                    {
                        hl = new ComHandlerList();
                        if (!Marshal.SetComObjectData(instance, this, hl))
                        {
                            throw new COMException("Failed to set COM Object Data");
                        }
                    }
                }
            }

            return(hl);
        }
        internal static CustomExpHandlerBase[] FireAllGlobalHandler(LG_Layer layer, WardenObjectiveDataBlock objectiveData)
        {
            var handlerList = new HandlerList();

            foreach (var handler in _GlobalHandlers)
            {
                if (!_AllowedGlobalHandlers.Any(x => !string.IsNullOrEmpty(handler.GUID) && x.Equals(handler.GUID, StringComparison.OrdinalIgnoreCase)))
                {
                    continue;
                }

                var handlerInstance = FireHandlerByContainer(handler, layer, objectiveData, isGlobalHandler: true);

                if (handlerInstance != null)
                {
                    handlerList.Add(handlerInstance);
                }
            }

            return(handlerList.ToArray());
        }
        public void EnablePlugin(IPlugin plugin)
        {
            if (!plugin.IsEnabled())
            {
                List <Command> pluginCommands = PluginCommandJSONParser.Parse(plugin);

                if (pluginCommands.Any())
                {
                    commandMap.RegisterAll(plugin.PluginDescription.Name, pluginCommands);
                }

                try
                {
                    plugin.GetPluginLoader().EnablePlugin(plugin);
                }
                catch (Exception ex)
                {
                    server.GetLogger().Log(Level.SEVERE, "Error occurred (in the plugin loader) while enabling " + plugin.PluginDescription.FullName + " (Is it up to date?)", ex);
                }

                HandlerList.BakeAll();
            }
        }
        /// <summary>
        /// Loads the scanner modules stored in a specified path.
        /// </summary>
        /// <param name='path'>
        /// The path that should be searched for scanners.
        /// </param>
        public virtual void Load(string path)
        {
            var handlersToLoad = new List <Type>();
            var scannersToLoad = new List <Type>();

            try
            {
                Debugger.Status("Searching for loadable modules...");

                // Determine if the directory actually exists before attempting to load the directory.
                if (!Directory.Exists(path))
                {
                    throw new DirectoryNotFoundException();
                }

                //Loop through all of the assembly files in the directory.
                foreach (var file in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(
                             f => f.EndsWith(".exe", StringComparison.CurrentCultureIgnoreCase) ||
                             f.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase)))
                {
                    try
                    {
                        /*
                         * Load each assembly into memory and attempt to search it for any `Scanner` types.
                         */
                        var assembly = Assembly.LoadFile(file);
                        foreach (var type in assembly.GetTypes())
                        {
                            if (type.IsSubclassOf(typeof(Scanner)))
                            {
                                //Add this module to the list of scanners to load.
                                scannersToLoad.Add(type);
                            }

                            if (type.IsSubclassOf(typeof(Handler)))
                            {
                                //Add this module to the list of handlers to load.
                                handlersToLoad.Add(type);
                            }
                        }
                    }
                    catch { continue; }
                }

                //Notify user that searching was successful, as well as the number of modules found.
                Debugger.Success();
                Debugger.Put(2, "\tFound {0} loadable modules", Console.ForegroundColor, scannersToLoad.Count);
                Debugger.Put(1, "Loading modules into memory...");

                lock (ScannerList)
                {
                    foreach (var type in scannersToLoad)
                    {
                        /*
                         * LOAD SCANNERS
                         */
                        try
                        {
                            Debugger.Status("\tLoading scanner '" + type.Name + "'");

                            /*
                             * Create a new instance of the class and determine if the class has
                             * been previously loaded (we ignore duplicates--first come, first server).
                             */
                            var module = (Scanner)Activator.CreateInstance(type, new[] { Debugger });
                            if (ScannerList.ContainsKey(module.Id))
                            {
                                throw new Exception("Scanner has already been added!");
                            }

                            /*
                             * Create entries for the module in the scheduler list as well as the
                             * module list.  The next run date is computed based on the module frequency.
                             */
                            ScannerList.Add(module.Id, module);
                            ScheduledList.Add(module.Id, DateTime.Now.AddSeconds(module.Frequency));

                            Debugger.Success();
                            Debugger.Put(3, "\t\tId: {0}\n\t\tVersion: {1}",
                                         ConsoleColor.DarkCyan,
                                         module.Id,
                                         module.Version);
                        }
                        catch (Exception e)
                        {
                            Debugger.Failure(e.InnerException ?? e);
                        }
                    }
                }

                lock (HandlerList)
                {
                    /*
                     * LOAD HANDLERS
                     */
                    try
                    {
                        foreach (var type in handlersToLoad)
                        {
                            Debugger.Status("\tLoading handler '" + type.Name + "'");

                            /*
                             * Create a new instance of the class and determine if the class has
                             * been previously loaded (we ignore duplicates--first come, first server).
                             */
                            var module = (Handler)Activator.CreateInstance(type, new[] { Debugger });
                            if (HandlerList.ContainsKey(module.Id))
                            {
                                throw new Exception("Handler has already been added!");
                            }

                            //Add this handler to the list of handlers.
                            HandlerList.Add(module.Id, module);

                            Debugger.Success();
                            Debugger.Put(3, "\t\tId: {0}\n\t\tVersion: {1}",
                                         ConsoleColor.DarkCyan,
                                         module.Id,
                                         module.Version);
                        }
                    }
                    catch (Exception e)
                    {
                        Debugger.Failure(e.InnerException ?? e);
                    }
                }
            }
            catch (Exception e)
            {
                Debugger.Failure(e);

                //If the module path specified didn't exist we should exit after notifying the user!
                Environment.Exit(-200);
            }
        }
Beispiel #21
0
 private static AbstractLanguageFileHandler GetLanguageHandler(File file)
 {
     return((AbstractLanguageFileHandler)HandlerList.GetFileHandler(file));
 }
Beispiel #22
0
    // Use this for initialization
    void Start()
    {
        if (!(GetComponentInParent <PhotonView> ().IsMine == true || PhotonNetwork.IsConnected == false))
        {
            // Disable all external control of this avatar's elements.
            enabled = false;
            if (ovrManager != null)
            {
                ovrManager.enabled = false;
            }
            ovrCameraRig.enabled = false;
            viewcamera.gameObject.SetActive(false);
            return;
        }

        // don't draw own avatar. Gets in the way.
        avatarShape.SetActive(false);

        exclusiveRegisteredHandlers = new Dictionary <ControlInput.ControllerDescription, HandlerList> ();
        registeredHandlers          = new Dictionary <ControlInput.ControllerDescription, HandlerList> ();

        if (SelectController.getActivePlatform() == SelectController.DeviceOptions.NoDevice)
        {
            leftControllerObject.transform.localPosition  = new Vector3(-0.2f, 0.0f, 0.3f);
            rightControllerObject.transform.localPosition = new Vector3(0.2f, 0.0f, 0.3f);
        }

        // Part of daydream shutdown requirements.
        Input.backButtonLeavesApp = true;

        // Identify, enable and disable controllers.
        leftControllerObject.SetActive(false);
        rightControllerObject.SetActive(false);
        controllerObjects = new List <ControllerDescription> ();
        // Only use one controller - whichever is associated with the specified dominant hand.
        if (!SelectController.singleController() || SelectController.isLeftHanded())
        {
            setupController(leftControllerObject, true, leftBeam, leftTarget);
//       ControllerDescription leftControl = new ControllerDescription (leftControllerObject, true, leftBeam, leftTarget);
//       if (controllerMenuTemplate != null)
//       {
//         leftControl.controllerMenu = Instantiate (controllerMenuTemplate);
//         leftControl.controllerMenu.transform.SetParent (leftControllerObject.transform);
//       }
//       controllerObjects.Add (leftControl);
//       leftControllerObject.SetActive (true);
            Debug.Log("Enabled left controller");
        }
        if (!SelectController.singleController() || !SelectController.isLeftHanded())
        {
            setupController(rightControllerObject, false, rightBeam, rightTarget);
//       controllerObjects.Add (new ControllerDescription (rightControllerObject, false, rightBeam, rightTarget));
//       rightControllerObject.SetActive (true);
            Debug.Log("Enabled right controller");
        }

        foreach (ControllerDescription co in controllerObjects)
        {
            exclusiveRegisteredHandlers[co] = new HandlerList();
            registeredHandlers[co]          = new HandlerList();
        }

        gameObject.SetActive(false);
        gameObject.SetActive(true);

        Debug.Log("Awake complete");
    }
Beispiel #23
0
 void Start()
 {
     rHadlerList = GetComponent <HandlerList>();              //获取HandlerList对象
 }