/// <summary> /// Notifies the provider that an observer is to receive notifications. /// </summary> /// <param name="observer">The object that is to receive notifications.</param> /// <returns> /// A reference to an interface that allows observers to stop receiving notifications before /// the provider has finished sending them. /// </returns> public IDisposable Subscribe(IObserver <T> observer) { if (IsDisposed) { observer.OnCompleted(); return(InternalDisposable.Empty); } if (IsRaiseLatestValueOnSubscribe) { observer.OnNext(_latestValue); } // subscribe node, node as subscription. var next = new ObserverNode <T>(this, observer); if (_root == null) { _root = _last = next; } else { _last !.Next = next; next.Previous = _last; _last = next; } return(next); }
/// <summary> /// Unsubscribe all subscription. /// </summary> public void Dispose() { if (IsDisposed) { return; } var node = _root; _root = _last = null; _mode = (ReactivePropertyMode)IsDisposedFlagNumber; while (node != null) { node.OnCompleted(); node = node.Next; } ValidationTrigger.Dispose(); SourceDisposable.Dispose(); ValidateNotifyErrorSubscription.Dispose(); if (ErrorsTrigger.IsValueCreated) { ErrorsTrigger.Value.OnCompleted(); ErrorsTrigger.Value.Dispose(); } }
public void SendSignal(ObserverNode on1, ObserverNode on2, Vector2 angle) { Debug.Log("SignalSending"); signal.SetActive(true); signal.transform.position = on1.transform.position; signal.GetComponent <Signalmovement>().velocity = angle * signalSpeed; on2.GetComponent <CircleCollider2D>().enabled = true; }
void CallObserverAction(ObserverNode on1, ObserverNode on2) { Debug.Log("Nodes/Observers called"); Vector2 signalangle = new Vector2(on2.transform.position.x - on1.transform.position.x, on2.transform.position.y - on1.transform.position.y).normalized; Debug.Log("signal Angle Set"); Mediator.Instance.SendSignal(on1, on2, signalangle); }
private void createObserverLink(ObserverNode observerNode, MoleculeNode moleculeNode) { var observerLink = new ObserverLink(); observerLink.Initialize(observerNode, moleculeNode); observerLink.SetColorFrom(DiagramOptions.DiagramColors); observerLink.IsVisible = DiagramOptions.ObserverLinksVisible; }
/// <summary> /// Create json string from ObserverNode. /// </summary> /// <param name="node"></param> /// <returns></returns> public static string ToJson(this ObserverNode node) { return(Object(null, true, Field("type", node.NodeName), Field("ID", node.Id), Field("functionID", node.FuncIndex), //Field("functionName", node.FuncNames[node.FuncIndex]), Field("functionName", node.ConditionGroup != ConditionGroup.Time ? node.FunctionName : node.FormattedTime), Field("conditionGroup", node.ConditionGroup), Field("minTime", node.MinTime), Field("maxTime", node.MaxTime), node.Rect.ToJson())); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Debug.Log(" Space Clicked"); ObserverNode on1 = _observers[Random.Range(0, 4)]; ObserverNode on2 = _observers[Random.Range(0, 4)]; while (on1 == on2) { on2 = _observers[Random.Range(0, 4)]; } CallObserverAction(on1, on2); } }
/// <summary> /// Create ObserverNode from json string. /// </summary> /// <param name="node"></param> /// <param name="jObj"></param> /// <returns></returns> private static Node Serialize(this ObserverNode node, JsonObject jObj) { node.NodeName = jObj["type"].String; node.Id = jObj["ID"].String; //node.FuncIndex = jObj["functionID"].Int; node.ConditionGroup = jObj["conditionGroup"].ConditionGroup; node.FuncNames = AgentFunctions.GetConditionStrings(node.ConditionGroup); try { node.FunctionName = jObj["functionName"].String; } catch (Exception) { /*Debug.Log("Your behaviour has a deprecated format");*/ } try { node.MinTime = jObj["minTime"].Float; node.MaxTime = jObj["maxTime"].Float; } catch (Exception) { /*Debug.Log("Your behaviour has a deprecated format");*/ } var sortedFunctions = node.FuncNames; System.Array.Sort(sortedFunctions, StringComparer.InvariantCulture); if (node.FunctionName != null) { for (var i = 0; i < node.FuncNames.Length; i++) { if (node.FuncNames[i] == node.FunctionName) { node.FuncIndex = i; } } } if (node.FuncIndex == -1) { node.FuncIndex = jObj["functionID"].Int; } var x = jObj["rect"]["posX"].Float; var y = jObj["rect"]["posY"].Float; var w = jObj["rect"]["width"].Float; var h = jObj["rect"]["height"].Float; node.Rect = new Rect(x, y, w, h); return(node); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting /// unmanaged resources. /// </summary> public void Dispose() { if (IsDisposed) { return; } var node = _root; _root = _last = null; _mode = (ReactivePropertyMode)IsDisposedFlagNumber; while (node != null) { node.OnCompleted(); node = node.Next; } }
void IObserverLinkedList <TState> .UnsubscribeNode(ObserverNode <TState> node) { if (node == root) { root = node.Next; } if (node == last) { last = node.Previous; } if (node.Previous != null) { node.Previous.Next = node.Next; } if (node.Next != null) { node.Next.Previous = node.Previous; } }
void IObserverLinkedList <T> .UnsubscribeNode(ObserverNode <T> node) { if (node == _root) { _root = node.Next; } if (node == _last) { _last = node.Previous; } if (node.Previous != null) { node.Previous.Next = node.Next; } if (node.Next != null) { node.Next.Previous = node.Previous; } }
/// <summary> /// Notifies the provider that an observer is to receive notifications. /// </summary> /// <param name="observer"> /// The object that is to receive notifications. /// </param> /// <returns> /// A reference to an interface that allows observers to stop receiving notifications /// before the provider has finished sending them. /// </returns> public IDisposable Subscribe(IObserver <TState> observer) { if (observer == null) { throw new ArgumentNullException(nameof(observer)); } var next = new ObserverNode <TState>(this, observer); if (root == null) { root = last = next; } else { last.Next = next; next.Previous = last; last = next; } return(next); }
public ObserverEntry(ObserverNode _enclosing, android.database.IContentObserver o , bool n, object observersLock, int _uid, int _pid) { throw new System.NotImplementedException(); }
void RemoveObserver(ObserverNode on) { _observers.Remove(on); }