/// <summary> /// Unplug this block from its superior block. If this block is a statement, /// optionally reconnect the block underneath with the block on top. /// </summary> /// <param name="optHealStack">Disconnect child statement and reconnect stack</param> public void UnPlug(bool optHealStack = false) { if (this.OutputConnection != null) { if (this.OutputConnection.IsConnected) { this.OutputConnection.Disconnect(); } } else if (this.PreviousConnection != null) { Connection previousTarget = null; if (this.PreviousConnection.IsConnected) { previousTarget = PreviousConnection.TargetConnection; PreviousConnection.Disconnect(); } Block nextBlock = this.NextBlock; if (optHealStack && nextBlock != null) { var nextTarget = this.NextConnection.TargetConnection; nextTarget.Disconnect(); if (previousTarget != null && previousTarget.CheckType(nextTarget)) { previousTarget.Connect(nextTarget); } } } }
public Task SetActiveConnectionAsync(PreviousConnection toSet) { var keys = ApplicationData .Current .RoamingSettings .Values .Where(kv => kv.Key.Contains("previous:mongodb:")) .Select(entry => Json.ToObjectAsync <PreviousConnection>(entry.Value as string) .ContinueWith(prevTask => { var result = prevTask.Result; if (result.KeyName == toSet.KeyName) { result.IsActive = true; } else { result.IsActive = false; } return(ApplicationData.Current.RoamingSettings.SaveAsync(entry.Key, result)); }) ); return(Task.WhenAll(keys)); }
public Task SaveConnection(string keyName, PreviousConnection value) { if (ApplicationData.Current.IsRoamingStorageAvailable()) { return(ApplicationData.Current.RoamingSettings.SaveAsync($"previous:mongodb:{keyName}", value)); } throw new Exception("Out of Roaming Storage"); }
/// <summary> /// updates the inputs and all connections with potentially new values, /// changing the shape of the block. This method should only be called by the constructor, or Mutators. /// </summary> public void Reshape(List <Input> newInputList, Connection updatedOutput, Connection updatedPrev, Connection updatedNext) { if (updatedOutput != null) { if (updatedPrev != null) { throw new Exception("A block cannot have both an output connection and a previous connection."); } if (updatedOutput.Type != Define.EConnection.OutputValue) { throw new Exception("updatedOutput Connection type is not OUTPUT_VALUE"); } } if (updatedPrev != null && updatedPrev.Type != Define.EConnection.PrevStatement) { throw new Exception("updatedPrev Connection type is not PREVIOUS_STATEMENT"); } if (updatedNext != null && updatedNext.Type != Define.EConnection.NextStatement) { throw new Exception("updatedNext Connection type is not CONNECTION_TYPE_NEXT"); } bool updateInputs = false; bool updateConnection = false; //dispose old first List <Input> oldInputs = InputList; foreach (Input input in oldInputs) { if (!newInputList.Contains(input)) { input.Dispose(); updateInputs = true; } } foreach (Input input in newInputList) { if (!oldInputs.Contains(input)) { input.SourceBlock = this; updateInputs = true; } } InputList = newInputList; updateConnection = OutputConnection != updatedOutput || PreviousConnection != updatedPrev || NextConnection != updatedNext; if (updatedOutput != null) { updatedOutput.SourceBlock = this; } if (OutputConnection != null && OutputConnection != updatedOutput) { OutputConnection.Disconnect(); OutputConnection.Dispose(); } OutputConnection = updatedOutput; if (updatedPrev != null) { updatedPrev.SourceBlock = this; } if (PreviousConnection != null && PreviousConnection != updatedPrev) { PreviousConnection.Disconnect(); PreviousConnection.Dispose(); } PreviousConnection = updatedPrev; if (updatedNext != null) { updatedNext.SourceBlock = this; } if (NextConnection != null && NextConnection != updatedNext) { NextConnection.Disconnect(); NextConnection.Dispose(); } NextConnection = updatedNext; if (updateInputs && updateConnection) { FireUpdate(1 << (int)UpdateState.Inputs | 1 << (int)UpdateState.Connections); } else if (updateInputs) { FireUpdate(1 << (int)UpdateState.Inputs); } else if (updateConnection) { FireUpdate(1 << (int)UpdateState.Connections); } }
public void RemoveConnection(PreviousConnection toRemove) { ApplicationData.Current.RoamingSettings.RemoveKeyValue($"previous:mongodb:{toRemove.KeyName}"); return; }