/// <summary> /// Test if x is a dependent variable. /// </summary> /// <param name="x">Expression to test.</param> /// <param name="On">Dependent expressions.</param> /// <returns></returns> public static bool IsDependentVariable(Expression x, params Expression[] On) { return (x is Call d && d.Target is UnknownFunction && On.SequenceEqual(d.Arguments)); }
public CommandFactory(IPersister persister, ISecurityManager security, IVersionManager versionMaker, IEditUrlManager editUrlManager, IContentAdapterProvider adapters, StateChanger changer) { this.persister = persister; makeVersionOfMaster = On.Master(new MakeVersionCommand(versionMaker)); replaceMaster = new ReplaceMasterCommand(versionMaker); makeVersion = new MakeVersionCommand(versionMaker); useNewVersion = new UseNewVersionCommand(versionMaker); updateObject = new UpdateObjectCommand(); delete = new DeleteCommand(persister.Repository); showPreview = new RedirectToPreviewCommand(adapters); showEdit = new RedirectToEditCommand(editUrlManager); useMaster = new UseMasterCommand(); clone = new CloneCommand(); validate = new ValidateCommand(); this.security = security; save = new SaveCommand(persister); incrementVersionIndex = new IncrementVersionIndexCommand(versionMaker); draftState = new UpdateContentStateCommand(changer, ContentState.Draft); publishedState = new UpdateContentStateCommand(changer, ContentState.Published); saveActiveContent = new ActiveContentSaveCommand(); moveToPosition = new MoveToPositionCommand(); unpublishedDate = new EnsureNotPublishedCommand(); publishedDate = new EnsurePublishedCommand(); updateReferences = new UpdateReferencesCommand(); }
private static IDisposable TemporarySynchronizationContext(SynchronizationContext synchronizationContext) { var originalContext = SynchronizationContext.Current; SynchronizationContext.SetSynchronizationContext(synchronizationContext); return(On.Dispose(() => SynchronizationContext.SetSynchronizationContext(originalContext))); }
/// <summary> /// Begins expecting callbacks. When the returned scope is disposed, stops expecting callbacks and throws <see cref="AssertionException"/> /// if <see cref="OnCallback"/> was not called the expected number of times between beginning and ending. /// </summary> /// <param name="count"> /// The number of times that <see cref="OnCallback"/> is expected to be called before the returned scope is disposed. /// </param> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="count"/> is less than 1.</exception> /// <exception cref="InvalidOperationException">Thrown when the returned scope from the previous call has not been disposed.</exception> /// <exception cref="AssertionException">Thrown when <see cref="OnCallback"/> was not called the expected number of times between beginning and ending.</exception> public IDisposable ExpectCallback(int count = 1) { if (count < 0) { throw new ArgumentOutOfRangeException(nameof(count), _expectedCount, "Expected callback count must be greater than or equal to zero."); } if (_expectedCount != 0) { throw new InvalidOperationException($"The previous {nameof(ExpectCallback)} scope must be disposed before calling again."); } _expectedCount = count; _actualCount = 0; return(On.Dispose(() => { try { if (_actualCount < _expectedCount) { Assert.Fail($"Expected {(_expectedCount == 1 ? "a single call" : _expectedCount + " calls")}, but there {(_actualCount == 1 ? "was" : "were")} {_actualCount}."); } } finally { _expectedCount = 0; } })); }
public void ToListen <T>(string method) { _hubProxy.On <T>(method, param => { On.Invoke(param); }); }
public void Wait_For_X_To_Play_First() { Game game = Play(); On on = IsType <On>(game); Equal(X, on.Player); }
public override int GetHashCode() { unchecked { return((On.GetHashCode() * 397) ^ By.GetHashCode()); } }
public void Not_Allow_A_Position_To_Be_Played_Twice() { Game game = Play(TopLeft, TopLeft); On on = IsType <On>(game); Equal(O, on.Player); }
public void Alternate_The_Players() { Game game = Play(TopLeft); On on = IsType <On>(game); Equal(O, on.Player); }
protected override void ProcessRecord() { if (UIElement != null) { UIElement.SetFocus(); TogglePattern tp = GetPattern.GetTogglePattern(UIElement); if ((!On.ToBool() && !Off.ToBool()) || (On.ToBool() && Off.ToBool())) { tp.Toggle(); } else if (Off.ToBool()) { while (tp.Current.ToggleState != ToggleState.Off && Timeout > 0) { tp.Toggle(); Thread.Sleep(1000); Timeout = Timeout - 1000; } } else if (On.ToBool()) { while (tp.Current.ToggleState != ToggleState.On && Timeout > 0) { tp.Toggle(); Thread.Sleep(1000); Timeout = Timeout - 1000; } } } }
private static IDisposable TempSyncContext(SynchronizationContext synchronizationContext) { var previous = SynchronizationContext.Current; SynchronizationContext.SetSynchronizationContext(synchronizationContext); return(On.Dispose(() => SynchronizationContext.SetSynchronizationContext(previous))); }
/// <summary> /// Return a text-representation of this object. /// </summary> public override String ToString() => String.Concat(Periods.AggregateWith(", "), " -> ", On.AsString(), UnstructuredText.IsNotNullOrEmpty() ? "; " + UnstructuredText : "");
public ActionResult Index() { Voice voice = new Voice(); voice.Say("Welcome to my Tropo Web API, you are now being transferred."); Say e1 = new Say( VALUE("Sorry, I did not hear anything."), EVENT("timeout") ); Say e2 = new Say( VALUE("Sorry, that was not a valid option."), EVENT("nomatch:1") ); Say e3 = new Say( VALUE("Nope, still not a valid response"), EVENT("nomatch:2") ); Say say = new Say( VALUE("Please enter your 5 digit zip code."), ARRAY(e1, e2, e3) ); Choices choices = new Choices("[5 DIGITS]"); Ask ask = new Ask( INSTANCE(choices), ATTEMPTS(3), BARGEIN(false), NAME("foo"), REQUIRED(true), INSTANCE(say), TIMEOUT(5) ); On ring = new On( EVENT("ring"), INSTANCE(new Say("http://openovate.com/hold-music.mp3")) ); On connect = new On( EVENT("connect"), INSTANCE(ask) ); On on = new On(ARRAY(ring, connect)); voice.Transfer( TO("9053801178"), RING_REPEAT(2), INSTANCE(on) ); return(Content(voice.Render().ToString(), "application/json")); }
public TOFChannel GetResult() { TOFChannel tc = new TOFChannel(); tc.On = On.GetResult(); tc.Off = Off.GetResult(); tc.Difference = Difference.GetResult(); return(tc); }
public virtual T Save(T entity) { return(On <T> .Value(entity) .When(entity.HasId()) .Then(() => { UpdateStrategy.Save(entity); }) .Else() .Then(() => { InsertStrategy.Save(entity); }) .Result()); }
private void PacketRecieved(Packet pkt) { _processor.Process(this, pkt, _client); if (PacketLog) { $"[{DateTime.Now.ToString()}] ^e<= ^w{pkt.Command.PadRight(24, ' ')} ^y{pkt.Payload?.Length}".ColouredConsole(); } On.Trigger("pr", pkt); }
/// <summary> /// Test if x is a dependent variable. /// </summary> /// <param name="x">Expression to test.</param> /// <param name="On">Dependent expressions.</param> /// <returns></returns> public static bool IsDependentVariable(Expression x, params Expression[] On) { Call d = x as Call; return (!ReferenceEquals(d, null) && d.Target is UnknownFunction && On.SequenceEqual(d.Arguments)); }
private void PacketSent(Packet pkt) { if (PacketLog) { $"[{DateTime.Now.ToString()}] ^c=> ^w{pkt.Command.PadRight(24, ' ')} ^y{pkt.Payload?.Length}".ColouredConsole(); } On.Trigger("ps", pkt); }
/// <summary> /// Compares two opening times for equality. /// </summary> /// <param name="OpeningTimes">An opening time to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(OpeningTime OpeningTimes) => Periods.Count().Equals(OpeningTimes.Periods.Count()) && Periods.All(period => OpeningTimes.Periods.Contains(period)) && On.Equals(OpeningTimes.On) && ((!UnstructuredText.IsNullOrEmpty() && !OpeningTimes.UnstructuredText.IsNullOrEmpty()) || (UnstructuredText.IsNullOrEmpty() && OpeningTimes.UnstructuredText.IsNullOrEmpty() && UnstructuredText.Equals(OpeningTimes.UnstructuredText)));
public void TestTVOn() { Device device = new Television(); Command command = new On(device); DeviceButton button = new DeviceButton(command); button.press(); Assert.AreEqual(device.status, Status.on); }
/** * Initialize an "on" command. * * @param Key[] * @return this */ public Voice On(params Key[] keys) { // initialize on On on = new On(keys); // push to our commands this.rootArray.Add(on.GetAction()); return(this); }
public async Task IsProducingBlocks_returns_expected_results() { On result = await On.Goerli .CreateNode(TestItem.PrivateKeyA) .ProcessGenesis() .IsProducingBlocks(TestItem.PrivateKeyA, true, null) .StopNode(TestItem.PrivateKeyA); result .IsProducingBlocks(TestItem.PrivateKeyA, false, null); }
public override int GetHashCode() { int hash = 17; hash = hash * 31 + Mix.GetHashCode(); hash = hash * 31 + On.GetHashCode(); hash = hash * 31 + Gain.GetHashCode(); //TODO: This might have to be improved to refelect the hashcodes of the contents not the identity of the collection hash = hash * 31 + EqBands.GetHashCode(); return(hash); }
/// <summary> /// Return the hash code of this object. /// </summary> /// <returns>The hash code of this object.</returns> public override Int32 GetHashCode() { unchecked { return(Periods.Aggregate(0, (hashCode, period) => hashCode ^ period.GetHashCode()) ^ On.GetHashCode() * 3 ^ (UnstructuredText.IsNullOrEmpty() ? UnstructuredText.GetHashCode() : 0)); } }
public ActionResult Index() { VoiceBase voice = new VoiceBase(); voice.Say("Welcome to my Tropo Web API, please hold while you are being transferred."); Say say = new Say("Press 1 to accept this call or any other number to reject"); Choices choices = new Choices( VALUE("1"), MODE(Mode.DTMF) ); Ask ask = new Ask( INSTANCE(choices), NAME("color"), INSTANCE(say), TIMEOUT(60) ); On connect1 = new On( EVENT("connect"), INSTANCE(ask) ); On connect2 = new On( EVENT("connect"), INSTANCE(new Say("You are now being connected.")) ); On ring = new On( EVENT("ring"), INSTANCE(new Say("http://openovate.com/hold-music.mp3")) ); On connect = new On(ARRAY(ring, connect1, connect2)); voice.Transfer( TO("9054799241"), NAME("foo"), INSTANCE(connect), REQUIRED(true), TERMINATOR("*") ); voice.On( EVENT("incomplete"), NEXT("/transferwhisper/hangup"), INSTANCE(new Say("You are now being disconnected.")) ); return(Content(voice.Render().ToString(), "application/json")); }
public override int GetHashCode() { unchecked { int hash = 17; if (Status != default(ScheduleStatus)) { hash = hash * 23 + Status.GetHashCode(); } if (Every != default(int)) { hash = hash * 23 + Every.GetHashCode(); } if (Period != default(SchedulePeriod)) { hash = hash * 23 + Period.GetHashCode(); } if (On != default(ScheduleOn)) { hash = hash * 23 + On.GetHashCode(); } if (InWords != default(String)) { hash = hash * 23 + InWords.GetHashCode(); } if (StartDate != default(DateTime)) { hash = hash * 23 + StartDate.GetHashCode(); } if (EndDate != default(DateTime)) { hash = hash * 23 + EndDate.GetHashCode(); } if (Charge != default(ChargeScheduling)) { hash = hash * 23 + Charge.GetHashCode(); } if (Transfer != default(TransferScheduling)) { hash = hash * 23 + Transfer.GetHashCode(); } if (Occurrences != default(ScopedList <Occurrence>)) { hash = hash * 23 + Occurrences.GetHashCode(); } if (NextOccurrences != default(ScopedList <Occurrence>)) { hash = hash * 23 + NextOccurrences.GetHashCode(); } return(hash); } }
/// <summary> /// User starts up the Piano and Sheet Music Forms /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void uxOpen_Click(object sender, EventArgs e) { bool rests = true; Chromatic type = Chromatic.Natural; if (Off.Checked == false && On.Checked == false) { MessageBox.Show("Must Select to Show Rests or Not before continuing"); } else if (Off.Checked == true && On.Checked == true) { MessageBox.Show("Must Select only On or Off, not both"); } else if (Off.Checked == true || On.Checked == true) { if (uxSharp.Checked == true) { type = Chromatic.Sharp; } if (uxFlats.Checked) { type = Chromatic.Flat; } if (On.Checked == true) { rests = true; Off.Checked = false; Off.CheckState = CheckState.Unchecked; Off.Update(); this.Update(); } if (Off.Checked == true) { rests = false; On.Checked = false; On.CheckState = CheckState.Unchecked; On.Update(); this.Update(); } // Positions the Forms so they aren't on top of each other SheetMusic sheet = new SheetMusic(); sheet.Location = new Point(500, 200); Piano piano = new Piano(Convert.ToInt32(BPM.Text), type, sheet, rests); piano.Location = new Point(250, 0); // Shows the Piano and hides the Main Form piano.Show(); this.Hide(); } }
private static int TurnOn(On opts) { using (var port = OpenPort(opts.ComPort)) { var message = CreateMessage(opts.DisplayId, Command.PowerControl, Power.On); port.Write(message, 0, message.Length); var response = new byte[1024]; int read = port.Read(response, 0, 1024); return(0); } }
private void SetupSut() { _runEnvironment = new RunEnvironment(); _mockProgramRepository = new Mock <IProgramRepository>(); _mockProgramRepository.Setup(mpr => mpr.GetLine(1000)).Returns(new ProgramLine(1000, new List <IToken> { })); _mockProgramRepository.Setup(mpr => mpr.GetLine(2000)).Returns(new ProgramLine(2000, new List <IToken> { })); _mockProgramRepository.Setup(mpr => mpr.GetLine(3000)).Returns(new ProgramLine(3000, new List <IToken> { })); _mockExpressionEvaluator = new Mock <IExpressionEvaluator>(); _sut = new On(_runEnvironment, _mockExpressionEvaluator.Object, _mockProgramRepository.Object); }
public VcsPluginContext(TransportMock transportMock) { _transport = transportMock; _contextExpectations = new ContextExpectations(this); TpUsers = new List <TpUserMappingInfo>(); Transport.On <RetrieveAllUsersQuery>() .Reply(x => CreateRetrieveAllUsersQueryReply()); On.CreateCommand <RevisionDTO>().Reply(CreateRevisionCreatedMessage); On.CreateCommand <RevisionFileDTO>().Reply(CreateRevisionFileCreatedMessage); On.CreateCommand <RevisionAssignableDTO>().Reply(CreateRevisionAssignableCreatedMessage); }