/// <summary> /// 指定フィーチャーにトークンをセットする /// </summary> /// <param name="feature">フィーチャー</param> /// <param name="tokenID">トークンID</param> protected void requestStartup(FeatureGroupBase group, Type feature, NamedId tokenID) { //lock(_children.SyncRoot) // 途中でAddChildしないので、スレッドセーフ。途中でAddChildしてしまうと下のループでAssertされる { foreach (var cg in _children) { if (cg is FeatureGroupBase) { requestStartup((FeatureGroupBase)cg, feature, tokenID); } if (cg is FeatureBase) { if (((FeatureBase)cg).Enabled == false) { continue; } if (cg.GetType().Equals(feature)) { ((FeatureBase)cg).RequestStartup(tokenID); } } } } }
/// <summary> /// 緊急トークン処理再帰ループ /// </summary> private void invokeUrgentTokenLoop(NamedId id, NamedId who, object param, FeatureGroupBase tar) { //lock(_children.SyncRoot) // 途中でAddChildしないので、スレッドセーフ。途中でAddChildしてしまうと下のループでAssertされる { foreach (var c in _children) { if (c is FeatureGroupBase) { ((FeatureGroupBase)c).invokeUrgentTokenLoop(id, who, param, tar); } else if (c is FeatureBase) { if (((FeatureBase)c).Enabled == false) { continue; } if (TokenTray.ContainsTokenID((FeatureBase)c, id)) { if (((FeatureBase)c).CanStart) { ((FeatureBase)c).Start(who); ((FeatureBase)c).Start(who, param); } } } } } }
/// <summary> /// GetChildFeatureInstanceで使用する再帰関数 /// </summary> /// <param name="buf">結果を収める配列</param> /// <param name="fg">検索開始するフィーチャーグループ</param> private void _getChildFeatureInstances(IList buf, FeatureGroupBase fg) { //lock(fg._children.SyncRoot) // 途中でAddChildしないので、スレッドセーフ。途中でAddChildしてしまうと下のループでAssertされる { foreach (var cg in fg._children) { if (cg is FeatureGroupBase) { _getChildFeatureInstances(buf, (FeatureGroupBase)cg); } if (cg is FeatureBase) { buf.Add(cg); } } } }
private void paramloop(FeatureGroupBase tar, List <FeatureBase> fcs) { //lock(_children.SyncRoot) // 途中でAddChildしないので、スレッドセーフ。途中でAddChildしてしまうと下のループでAssertされる { foreach (var c in _children) { if (c is FeatureGroupBase) { ((FeatureGroupBase)c).paramloop(tar, fcs); } else if (c is FeatureBase fc) { if (string.IsNullOrEmpty(fc.CommandParameter) == false) { fcs.Add(fc); } } } } }
/// <summary> /// ルートグループを指定する /// </summary> public void SetFeatureRootGroup(FeatureGroupBase root) { _root = root; }