public static DerefResults commonDeref( Identifier name, IDictionary<Identifier,IScidentre> scidentres, IEnumerable<ISieve> sieves, IEnumerable<IWorker> exposes, IScope scope ) { DerefResults results = new DerefResults(null, null); if( scidentres != null && scidentres.ContainsKey(name) ) results.Add( scidentres[name].deref() ); if(sieves != null) foreach(ISieve d in sieves) results.Add(d.deref(name)); if(exposes != null && results.worker == null) { foreach(IWorker w in exposes) { DerefResults exposeResults = GE.deref(w, name); if(results.workerList == null || exposeResults.worker == null) results.Add(exposeResults); } } if(scope != null && results.worker == null) { DerefResults scopeResults = scope.upDeref(name); if(results.workerList == null || scopeResults.worker == null) results.Add(scopeResults); } return results; }
public void Add( DerefResults other ) { if(other.worker != null) { if(_worker != null) throw new Exception("cannot add worker because already have worker"); if(_workerList != null) throw new Exception("cannot add worker because already have workerList"); _worker = other.worker; } if(other.workerList != null) { if(_worker != null) throw new Exception("cannot add workerList because already have worker"); if(_workerList == null) _workerList = other.workerList; else G.addEach(_workerList, other.workerList); } }