Ejemplo n.º 1
0
        /**
         * 注册一个数据工人到当前工厂。
         * @param worker 要注册到当前工厂的数据工人实例。
         * @return 注册成功则返回true,否则返回false。
         */
        public bool registerDataWorker(SABaseDataWorker worker)
        {//注册一个数据工人到工人组
            SAWorkers workers;

            if (!workersTreeList.ContainsKey(DATA_WORKER))
            {//如果数据工人不存在 则新建
                workers = new SAWorkers(DATA_WORKER, this);
                workersTreeList.Add(DATA_WORKER, workers);
            }
            workers = workersTreeList[DATA_WORKER];
            workers.registerWorker(worker);
            return(true);
        }
Ejemplo n.º 2
0
 /**
  * 移除一个数据工人从当前工厂。
  * @param worker 要从当前工厂移除的数据工人名称。
  * @return 移除成功则返回true,否则返回false。
  */
 public bool removeDataWorker(string workerName)
 {
     if (workersTreeList.ContainsKey(DATA_WORKER))
     {
         SAWorkers        workers = workersTreeList[DATA_WORKER];                       //得到数据工人组
         SABaseDataWorker worker  = (SABaseDataWorker)workers.removeWorker(workerName); //移除数据工人组中的一名工人
         if (worker != null)
         {
             worker.onRemove();
             worker.unInitialize(this);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
        /**
         * 注册一个图形工人到当前工厂。
         * @param worker 要注册到当前工厂的图形工人实例。
         * @return 注册成功则返回true,否则返回false。
         */
        public void registerGraphicsWorker(SABaseGraphWorker worker)
        {
            SAWorkers workers;

            if (!workersTreeList.ContainsKey(GRAPH_WORKER))
            {
                workers = new SAWorkers(GRAPH_WORKER, this);
                workersTreeList.Add(GRAPH_WORKER, workers);
            }
            workers = workersTreeList[GRAPH_WORKER];
            workers.registerWorker(worker);//添加图形工人到图形工人组
            //worker.initialize(this);
            worker.onSrart(args);

            Dictionary <string, string> .Enumerator en = worker.handleActions.GetEnumerator();
            while (en.MoveNext())
            {
                addEventDispatcher(en.Current.Key, worker, "handleAction");
                //addEventDispatcher(en.Current.Key, worker, en.Current.Value);
            }
        }
Ejemplo n.º 4
0
 /**
  * 移除一个图形工人从当前工厂。
  * @param worker 要从当前工厂移除的图形工人名称。
  * @return 移除成功则返回true,否则返回false。
  */
 public bool removeGraphicsWorker(string workerName)
 {
     if (workersTreeList.ContainsKey(GRAPH_WORKER))
     {
         SAWorkers         workers = workersTreeList[GRAPH_WORKER];
         SABaseGraphWorker worker  = workers.removeWorker(workerName) as SABaseGraphWorker;//得到画板工人组
         if (worker != null)
         {
             Dictionary <string, string> .Enumerator en = worker.handleActions.GetEnumerator();
             while (en.MoveNext())
             {
                 removeEventDispatcher(en.Current.Key, worker, "handleAction");
                 //removeEventDispatcher(en.Current.Key, worker, en.Current.Value);
             }
             worker.onRemove();
             worker.onDispose();
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }