Example #1
0
        internal void LoadHandler(HandlerInfo hi)
        {
            // create handler assembly object
            HandlerAssembly ha = new HandlerAssembly();

            // laod the assembly and get handler pieces
            ha.Load(hi.Location, hi.Assembly, hi.Param);
            // check if we don't have it already
            if (!_loadedAssemblies.ContainsKey(ha.Handler.ID))
            {
                // add it to our collection
                _loadedAssemblies[ha.Handler.ID] = ha;
                // is it our default?
                if (ha.IsDefault)
                {
                    _defaultHandlerAssembly = ha;
                }
                else
                {
                    // add toolstrip button
                    AddToolbarButton(ha.Handler.ID, ha.ToolstrupImage, ha.Tooltip);
                }
                // hook session events
                HookEvents(ha.Handler);

                // alloc collection to store sessions opened for this handler
                _sessions[ha.Handler.ID] = new List <int>(5);
            }
            else
            {
                ha.Unload();
            }
        }
Example #2
0
        internal void UnloadHandler(Guid hid)
        {
            // can't unload default handler
            if (_loadedAssemblies.ContainsKey(hid) && !_defaultHandlerAssembly.Handler.ID.Equals(hid))
            {
                HandlerAssembly ha = _loadedAssemblies[hid];
                // first, close all sessions for this handler. closing session will modify the sessions list
                // as it will delete items from it. so, I'l copy it first
                int[] sessions = _sessions[hid].ToArray();
                foreach (int sid in sessions)
                {
                    CloseSession(hid, sid);
                }
                _sessions.Remove(hid);

                // remove button
                RemoveToolbarButton(hid);

                // unhook session events
                UnHookEvents(ha.Handler);

                // remove from our map
                _loadedAssemblies.Remove(hid);
            }
        }
Example #3
0
 internal void ReloadHandler(Guid hid)
 {
     if (_loadedAssemblies.ContainsKey(hid) && !_defaultHandlerAssembly.Handler.ID.Equals(hid))
     {
         HandlerAssembly ha = _loadedAssemblies[hid];
         // unload
         UnloadHandler(hid);
         // reload
         LoadHandler(new HandlerInfo(hid, "", ha.Assembly, ha.LoadParam, true));
     }
 }