public IDisposable StartRecording(IRecorder recorder, bool dispatchToMethodMocks) { Monitor.Enter(this); this.Recorder = recorder; this.DispatchToMethodMocks = dispatchToMethodMocks; return new RecordingSession(this); }
private static void LoadHistogram(IRecorder histogram) { for (int i = 0; i < 10000; i += 1000) { histogram.RecordValue(i); } }
private static void Load(IRecorder source) { for (long i = 0L; i < 10000L; i++) { source.RecordValue(1000L * i); } }
protected virtual void LoadFullRange(IRecorder source) { for (long i = 0L; i < DefaultHighestTrackableValue; i += 100L) { source.RecordValue(i); } source.RecordValue(DefaultHighestTrackableValue); }
public FolderVM(Folder folder, IRecorder audioRecorder/*, IRecorder camera*/, AnimationStarter animationStarter) { _folder = folder; _audioRecorderView = audioRecorder; //_camera = camera; if (animationStarter == null) throw new ArgumentNullException("FolderVM ctor: animationStarter may not be null"); _animationStarter = animationStarter; }
private AzureCosmosSqlApiRepository(IRecorder recorder, string connectionString, string databaseName) { recorder.GuardAgainstNull(nameof(recorder)); connectionString.GuardAgainstNullOrEmpty(nameof(connectionString)); databaseName.GuardAgainstNullOrEmpty(nameof(databaseName)); this.recorder = recorder; this.connectionString = connectionString; this.databaseName = databaseName; }
protected EventStreamHandlerBase(IRecorder recorder, params IEventNotifyingStorage[] eventingStorages) { recorder.GuardAgainstNull(nameof(recorder)); eventingStorages.GuardAgainstNull(nameof(eventingStorages)); this.recorder = recorder; this.eventingStorages = eventingStorages; ProcessingErrors = new List <EventProcessingError>(); }
public InstructionSenderTests() { _networkAddress = Mock.Create <INetworkAddress>(); _nodeVisitor = Mock.Create <INodeVisitor>(); _sessionHolder = Mock.Create <ISessionHolder>(); _recorder = Mock.Create <IRecorder>(); _sut = new InstructionSender(_nodeVisitor, _networkAddress, _sessionHolder, _recorder); }
public GeneralBlobStorage(IRecorder recorder, string containerName, IBlobository blobository) { recorder.GuardAgainstNull(nameof(recorder)); blobository.GuardAgainstNull(nameof(blobository)); containerName.GuardAgainstNull(nameof(containerName)); this.recorder = recorder; this.blobository = blobository; this.containerName = containerName; }
public CarEntityReadModelProjection(IRecorder recorder, IRepository repository) { recorder.GuardAgainstNull(nameof(recorder)); repository.GuardAgainstNull(nameof(repository)); this.recorder = recorder; this.carStorage = new GeneralReadModelStorage <Car>(recorder, repository); this.unavailabilityStorage = new GeneralReadModelStorage <Unavailability>(recorder, repository); }
/// <summary> /// Executes the action and records the time to complete the action. /// The time is recorded in system clock ticks. /// This time may vary between frameworks and platforms, but is equivalent to <c>(1/Stopwatch.Frequency)</c> seconds. /// Note this is a convenience method and can carry a cost. /// If the <paramref name="action"/> delegate is not cached, then it may incur an allocation cost for each invocation of <see cref="Record"/> /// </summary> /// <param name="recorder">The <see cref="IRecorder"/> instance to record the latency in.</param> /// <param name="action">The functionality to execute and measure</param> /// <remarks> /// <para> /// The units returned from <code>Stopwatch.GetTimestamp()</code> are used as the unit of /// recording here as they are the smallest unit that .NET can measure and require no /// conversion at time of recording. /// Instead conversion (scaling) can be done at time of output to microseconds, milliseconds, /// seconds or other appropriate unit. /// These units are sometimes referred to as ticks, but should not not to be confused with /// ticks used in <seealso cref="DateTime"/> or <seealso cref="TimeSpan"/>. /// </para> /// <para> /// If you are able to cache the <paramref name="action"/> delegate, then doing so is encouraged. /// <example> /// Here are two examples. /// The first does not cache the delegate /// /// <code> /// for (long i = 0; i < loopCount; i++) /// { /// histogram.Record(IncrementNumber); /// } /// </code> /// This second example does cache the delegate /// <code> /// Action incrementNumber = IncrementNumber; /// for (long i = 0; i < loopCount; i++) /// { /// histogram.Record(incrementNumber); /// } /// </code> /// In the second example, we will not be making allocations each time i.e. an allocation of an <seealso cref="Action"/> from <code>IncrementNumber</code>. /// This will reduce memory pressure and therefore garbage collection penalties. /// For performance sensitive applications, this method may not be suitable. /// As always, you are encouraged to test and measure the impact for your scenario. /// </example> /// </para> /// </remarks> public static void Record(this IRecorder recorder, Action action) { var start = Stopwatch.GetTimestamp(); action(); var elapsed = Stopwatch.GetTimestamp() - start; recorder.RecordValue(elapsed); }
public NetworkConnector( Func <ISocket, INetworkTunnel> networkTunnelFactory, Func <AddressFamily, SocketType, ProtocolType, ISocket> socketFactory, IRecorder recorder) { _socketFactory = socketFactory; _networkTunnelFactory = networkTunnelFactory; _recorder = recorder; }
public NodeGateway( INetworkPoint networkPoint, Func <INetworkTunnel, ISession> sessionFactory, IRecorder recorder) { _networkPoint = networkPoint; _sessionFactory = sessionFactory; _networkPoint.Accepted += AcceptedHandler; _recorder = recorder; }
private void ReleaseRecorder() { if (_recorder != null && _recorder.State != RecorderState.Stopped && _recorder.State != RecorderState.Unknown) { _recorder.Stop(); } _recorder.SampleReceived -= OnSampleReceived; _recorder = null; }
public InProcessChangeEventNotificationSubscription(IRecorder recorder, IChangeEventMigrator migrator, IEnumerable <IDomainEventPublisherSubscriberPair> pubSubPairs, params IEventNotifyingStorage[] eventingStorages) : base(recorder, eventingStorages) { recorder.GuardAgainstNull(nameof(recorder)); migrator.GuardAgainstNull(nameof(migrator)); pubSubPairs.GuardAgainstNull(nameof(pubSubPairs)); this.notificationProducer = new DomainEventNotificationProducer(recorder, migrator, pubSubPairs.ToArray()); }
public GeneralQueryStorage(IRecorder recorder, IDomainFactory domainFactory, IRepository repository) { recorder.GuardAgainstNull(nameof(recorder)); repository.GuardAgainstNull(nameof(repository)); domainFactory.GuardAgainstNull(nameof(domainFactory)); this.recorder = recorder; this.repository = repository; this.domainFactory = domainFactory; this.containerName = typeof(TDto).GetEntityNameSafe(); }
public static void ChangeWithTimeout(this IRecorder recorder, int millisecondsTimeout) { if (!recorder.IsStarted) { recorder.StartWithTimeout(millisecondsTimeout); } else { recorder.Stop(); } }
private void ChangeRecType(bool type) { if (type) { recorder = new LoopBackRecorder(); } else { recorder = new Recorder(); } }
public void StartRecoding(String savePath) { FileSavePath = savePath + "BAR-" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".avi"; //图像 IImageProvider imgProvider = null; try { imgProvider = GetImageProvider(); } catch (Exception e) { MessageBox.Show(e.Message); imgProvider?.Dispose(); return; } //声音 IAudioProvider audioProvider = null; try { Settings.Audio.Enabled = true; if (Settings.Audio.Enabled && !Settings.Audio.SeparateFilePerSource) { audioProvider = _audioSource.GetMixedAudioProvider(); } } catch (Exception e) { MessageBox.Show(e.Message); _audioSource?.Dispose(); return; } //视频写入 IVideoFileWriter videoEncoder; try { videoEncoder = GetVideoFileWriterWithPreview(imgProvider, audioProvider); } catch (Exception e) { MessageBox.Show(e.Message); imgProvider?.Dispose(); audioProvider?.Dispose(); return; } _recorder = new Recorder(videoEncoder, imgProvider, Settings.Video.FrameRate, audioProvider); _recorder.Start(); }
public MainViewModel([Import]IScreenSelectorService screenSelectorService) { Initialize(); // we only have the gif recorder for now. _recorder = new GifRecorder(); _screenSelectorService = screenSelectorService; _screenSelectorService.Run(); _dialogManager = new DialogManager(); }
public RemoteRecordsSender( IСonsistentMessageSender consistentMessageSender, IApplicationRecorder applicationRecorder, IRecorder recorder) { _consistentMessageSender = consistentMessageSender; _applicationRecorder = applicationRecorder; _recorder = recorder; _applicationRecorder.RecordReceived += RecordReceivedHandler; }
public DomainEventNotificationProducer(IRecorder recorder, IChangeEventMigrator migrator, params IDomainEventPublisherSubscriberPair[] pubSubPairs) { recorder.GuardAgainstNull(nameof(recorder)); pubSubPairs.GuardAgainstNull(nameof(pubSubPairs)); migrator.GuardAgainstNull(nameof(migrator)); this.recorder = recorder; this.pubSubPairs = pubSubPairs; this.migrator = migrator; }
public TranslatorPage() { InitializeComponent(); // Dependency Injection - reference to classes in Android module recorder = DependencyService.Get <IRecorder>(); speechRecognition = DependencyService.Get <ISpeechRecognition>(); tranlation = DependencyService.Get <ITranslation>(); azureEasyTableClient = DependencyService.Get <IAzureEasyTableClient>(); isRecording = false; }
public TraceableRemoteApiMap( IRemoteApiMap remoteApiMap, IRemoteRecordsSender remoteRecordsSender, IRecorder recorder) { _remoteApiMap = remoteApiMap; _remoteRecordsSender = remoteRecordsSender; _recorder = recorder; RegisterCommand(RemoteApiCommands.TRACE, TraceHandler); }
/// <summary> /// レコーダーを解除する /// </summary> /// <param name="value">レコーダー</param> public void RemoveRecorder(IRecorder value) { foreach (DictionaryEntry de in _recorders) { if (de.Value == value) { _recorders.Remove(de.Key); return; } } }
public void Constructor_WhenCalled_ShouldSubscribe() { _nodeGateway = Mock.Create <INodeGateway>(); _sessionHolder = Mock.Create <ISessionHolder>(); _recorder = Mock.Create <IRecorder>(); _nodeGateway.ArrangeSet(x => x.ConnectionReceived += null).IgnoreArguments().Occurs(1); _sut = new InstructionReceiver(_nodeGateway, _sessionHolder, _recorder); _nodeGateway.AssertAll(); }
public BaseMonitoredRemoteOperatorFactory( IInstructionSenderFactory instructionSenderFactory, IRemoteTraceMonitorСonsistent remoteTraceMonitor, IApplicationRecorder applicationRecorder, IRecorder recorder) { _instructionSenderFactory = instructionSenderFactory; _remoteTraceMonitor = remoteTraceMonitor; _applicationRecorder = applicationRecorder; _recorder = recorder; }
public RecorderViewModel(IRecorder recorder, IEnumerable<IValidationListItemViewModel> validationList, IRecordingController recordingController) { this.recorder = recorder; this.recordingController = recordingController; ValidationList = validationList.ToArray(); RecordCommand = new DelegateCommand(ExecuteRecordCommand, CanExecuteRecordCommand); StopCommand = new DelegateCommand(ExecuteStopCommand, CanExecuteStopCommand); PauseCommand = new DelegateCommand(ExecutePauseCommand, CanExecutePauseCommand); }
/// <summary> /// Shows a sample loop where an action is executed, and the latency of each execution is recorded. /// </summary> private void RecordMeasurements(IRecorder recorder) { var sut = new SocketTester("google.com"); Action actionToMeasure = sut.CreateAndCloseDatagramSocket; var timer = Stopwatch.StartNew(); do { recorder.Record(actionToMeasure); } while (timer.Elapsed < RunPeriod); Interlocked.Increment(ref _isCompleted); }
public PersonsApplication(IRecorder recorder, IIdentifierFactory idFactory, IPersonStorage storage, IEmailService emailService) { recorder.GuardAgainstNull(nameof(recorder)); idFactory.GuardAgainstNull(nameof(idFactory)); storage.GuardAgainstNull(nameof(storage)); emailService.GuardAgainstNull(nameof(emailService)); this.recorder = recorder; this.idFactory = idFactory; this.storage = storage; this.emailService = emailService; }
static IEnumerable <SimEvent> PressureSensor(SimEnvironment env, char tag, IRecorder pressureRecorder) { while (true) { yield return(env.Timeout(MonitoringTime)); // Read the pressure value and record it. var pressure = env.Random.Normal(1000, 50); pressureRecorder.Observe(pressure); Console.WriteLine($"Pressure sensor for machine {tag} has recorded a pressure of {pressure:.00} bar"); } }
public ReadModelCheckpointStore(IRecorder recorder, IIdentifierFactory idFactory, IDomainFactory domainFactory, IRepository repository) { recorder.GuardAgainstNull(nameof(recorder)); idFactory.GuardAgainstNull(nameof(idFactory)); repository.GuardAgainstNull(nameof(repository)); domainFactory.GuardAgainstNull(nameof(domainFactory)); this.recorder = recorder; this.idFactory = idFactory; this.repository = repository; this.domainFactory = domainFactory; }
public QARec() { InitializeComponent(); rec = DependencyService.Get <IRecorder>(); buttonRec.Clicked += StartRecordClicked; buttonStop.Clicked += StopClicked; buttonPause.Clicked += ButtonPause_Clicked; records = new List <RecordedView>(); }
public static AzureQueueStorageRepository FromSettings(IRecorder recorder, IAppSettings settings) { settings.GuardAgainstNull(nameof(settings)); var accountKey = settings.GetString("Storage:AzureStorageAccountKey"); var accountName = settings.GetString("Storage:AzureStorageAccountName"); var connectionString = accountKey.HasValue() ? $"DefaultEndpointsProtocol=https;AccountName={accountName};AccountKey={accountKey};EndpointSuffix=core.windows.net" : "UseDevelopmentStorage=true"; return(new AzureQueueStorageRepository(recorder, connectionString)); }
public CarsApplication(IRecorder recorder, IIdentifierFactory idFactory, ICarStorage storage, IPersonsService personsService) { recorder.GuardAgainstNull(nameof(recorder)); idFactory.GuardAgainstNull(nameof(idFactory)); storage.GuardAgainstNull(nameof(storage)); personsService.GuardAgainstNull(nameof(personsService)); this.recorder = recorder; this.idFactory = idFactory; this.storage = storage; this.personsService = personsService; }
private Manager(IServiceProvider provider) { this.serviceProvider = provider; this.uiShell = (IVsUIShell)provider.GetService(typeof(SVsUIShell)); this.dte = (EnvDTE.DTE)provider.GetService(typeof(SDTE)); this.recorder = (IRecorder)this.serviceProvider.GetService(typeof(IRecorder)); this.LoadShortcuts(); this.shortcutsLoaded = true; this.shortcutsDirty = false; CreateFileSystem(); }
public RemoteApiMap( IInstructionReceiver instructionsReceiver, IRecorder recorder) { _commandWithParametersMap = new Dictionary <string, bool>(); _commandHandlerMap = new Dictionary <string, Action <IEnumerable <string> > >(); _commandDescriptionMap = new Dictionary <string, string>(); _instructionsReceiver = instructionsReceiver; _recorder = recorder; _instructionsReceiver.InstructionReceived += CommandHandler; }
private void AttachRecorder(IRecorder recorder) { DetachRecorder(recorder); IBuildLogger logger = recorder.Logger; // hook up to build events Project.BuildStarted += new BuildEventHandler(logger.BuildStarted); Project.BuildFinished += new BuildEventHandler(logger.BuildFinished); Project.TargetStarted += new BuildEventHandler(logger.TargetStarted); Project.TargetFinished += new BuildEventHandler(logger.TargetFinished); Project.TaskStarted += new BuildEventHandler(logger.TaskStarted); Project.TaskFinished += new BuildEventHandler(logger.TaskFinished); Project.MessageLogged += new BuildEventHandler(logger.MessageLogged); Project.BuildListeners.Add(logger); }
public IGeometry Geometry(IRecorder<IGeometryTarget> records) { var path = new PathGeometry(Factory); try { using (var sink = path.Open()) { var target = new GeometryTarget(Factory, sink); records.Replay(target); target.endOpenFigure(); sink.Close(); } return new GeometryImplementation(path); } catch { path.Dispose(); throw; } }
public void Add(IRecorder recorder) { _list.Add(recorder.Name, recorder); }
public void StopRecord() { if (recorder != null) recorder.Stop(); recordingWindow.Close(); testFileManager.Save(recorder.CurrentTest); projectFileManager.Save(recorder.CurrentTest.Project); appController.MainWindow.Restore(); testController.ShowTest(recorder.CurrentTest); recorder = null; }
public StrategyEnumerator( IRecorder recorder ) { this.recorder = recorder; }
public void StopAudioRecording() { if (recorder != null) { recorder.SampleAvailableEvent -= SampleAvailableEventHandler; try { recorder.Stop(); } finally { recorder = null; } } }
//private List<XmlSegment> pendingRussian; public LogicShit(IRecorder recorder) { this.recorder = recorder; PhraseIndex = 0; //pendingRussian = new List<XmlSegment>(); }
public TraceRecorder(IRecorder wrappedLogger, TextWriter writer ) { this.writer = writer; this.wrappedLogger = wrappedLogger; }
public void StartAudioRecording(string file = "") { try { if (ApplicationVM.ProfileVM.AudioConfigurationVM.LoopbackRecording) { if (recorder == null) { recorder = AudioManager.CreateRecorder(defaultCodec, true); recorder.SampleAvailableEvent += SampleAvailableEventHandler; } recorder.Start(file); } } catch { } }
public LGSPSubactionAndOutputAdditionEnvironment(LGSPGraph graph, LGSPActions actions) : base(graph, actions) { recorder = new Recorder(graph as LGSPNamedGraph, this); }
IVideoFileWriter GetVideoFileWriter(IImageProvider ImgProvider) { var selectedVideoSourceKind = VideoViewModel.SelectedVideoSourceKind; var encoder = VideoViewModel.SelectedCodec; IVideoFileWriter videoEncoder = null; encoder.Quality = VideoViewModel.Quality; if (encoder.Name == "Gif") { if (GifViewModel.Unconstrained) _recorder = new UnconstrainedFrameRateGifRecorder( new GifWriter(_currentFileName, Repeat: GifViewModel.Repeat ? GifViewModel.RepeatCount : -1), ImgProvider); else videoEncoder = new GifWriter(_currentFileName, 1000/VideoViewModel.FrameRate, GifViewModel.Repeat ? GifViewModel.RepeatCount : -1); } else if (selectedVideoSourceKind != VideoSourceKind.NoVideo) videoEncoder = new AviWriter(_currentFileName, encoder); return videoEncoder; }
void OnStopped() { _recorder = null; ReadyToRecord = true; if (OthersViewModel.MinimizeOnStart) WindowState = WindowState.Normal; Status = "Saved to Disk"; _timer.Stop(); IsPaused = false; }
private void ShowRecordingWindow(Test test) { recordingWindow = recordWindowFactory.Create(); recorder = recorderFactory.Create(test); IRecorderViewModel recorderViewModel = recorderViewModelFactory.Create(recorder); recordingWindow.DataContext = recorderViewModel; //appController.MainWindow.Minimize(); recordingWindow.Show(); appController.MainWindow.Minimize(); }
void StartRecording() { var duration = OthersViewModel.Duration; var delay = OthersViewModel.StartDelay; if (duration != 0 && (delay * 1000 > duration)) { Status = "Delay cannot be greater than Duration"; SystemSounds.Asterisk.Play(); return; } if (OthersViewModel.MinimizeOnStart) WindowState = WindowState.Minimized; ReadyToRecord = false; var noVideo = VideoViewModel.SelectedVideoSourceKind == VideoSourceKind.NoVideo; var extension = noVideo ? (AudioViewModel.Encode && AudioViewModel.SelectedAudioSource is WaveInDevice ? ".mp3" : ".wav") : (VideoViewModel.SelectedCodec.Name == "Gif" ? ".gif" : ".avi"); _currentFileName = Path.Combine(OutPath, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + extension); Status = delay > 0 ? $"Recording from t = {delay} ms..." : "Recording..."; _timer.Stop(); TimeSpan = TimeSpan.Zero; WaveFormat wf; var audioSource = AudioViewModel.GetAudioSource(VideoViewModel.FrameRate, out wf); var imgProvider = GetImageProvider(); var videoEncoder = GetVideoFileWriter(imgProvider); if (_recorder == null) { if (noVideo) _recorder = new AudioRecorder(audioSource, AudioViewModel.GetAudioFileWriter(_currentFileName, wf)); else _recorder = new Recorder(videoEncoder, imgProvider, VideoViewModel.FrameRate, audioSource); } _recorder.RecordingStopped += (s, E) => { OnStopped(); if (E?.Error == null) return; Status = "Error"; MessageBox.Show(E.ToString()); }; RecentViewModel.Add(_currentFileName, videoEncoder == null ? RecentItemType.Audio : RecentItemType.Video); _recorder.Start(delay); _timer.Start(); }
private void btnRec_Click(object sender, RoutedEventArgs e) { var res = new ResourceDictionary {Source = new Uri("/Styles/CMIcons.xaml", UriKind.Relative)}; if (_isRecording) { // rec stopped _isRecording = false; _audioRec.Stop(); var dialog = new SaveAudioRecordingWindow(); if (dialog.ShowDialog() == true) { string filepath = dialog.FileLocation; //TODO: method for saving sound file to chosen path //audioRec.SaveRecordedFile(filepath); // current sound is the one just recorded and saved to filepath MediaEL.Source = new Uri(Path.GetFullPath(filepath)); ObjectPath = ConfigurationManager.AppSettings.Get("audio") + "/" + Path.GetFileName(filepath); btnPlay.IsEnabled = true; btnOk.IsEnabled = true; } // enable/disable correct buttons btnOpen.IsEnabled = true; btnStop.IsEnabled = false; btnMoveBackward.IsEnabled = false; btnMoveForward.IsEnabled = false; btnRec.Background = new ImageBrush(res["Rec_Start"] as BitmapImage); } else { var choiceWindow = new ChooseAudioDeviceForAudioRecordingWindow(); if (choiceWindow.ShowDialog() == true) { // rec started _isRecording = true; // start recording _audioRec = new AudioRecorder(choiceWindow.Microphone); _audioRec.Record(); // TODO: method for recording sound // enable/disable correct buttons btnOpen.IsEnabled = false; btnPlay.IsEnabled = false; btnStop.IsEnabled = false; btnMoveBackward.IsEnabled = false; btnMoveForward.IsEnabled = false; btnRec.Background = new ImageBrush(res["Rec_Stop"] as BitmapImage); } } }
public IRecorderViewModel Create(IRecorder recorder) { return createModelFunc(recorder); }
private void DetachRecorder(IRecorder recorder) { IBuildLogger logger = recorder.Logger; // unhook up to build events Project.BuildStarted -= new BuildEventHandler(logger.BuildStarted); Project.BuildFinished -= new BuildEventHandler(logger.BuildFinished); Project.TargetStarted -= new BuildEventHandler(logger.TargetStarted); Project.TargetFinished -= new BuildEventHandler(logger.TargetFinished); Project.TaskStarted -= new BuildEventHandler(logger.TaskStarted); Project.TaskFinished -= new BuildEventHandler(logger.TaskFinished); Project.MessageLogged -= new BuildEventHandler(logger.MessageLogged); if (Project.BuildListeners.Contains(logger)) { Project.BuildListeners.Remove(logger); } }
public override bool Record(IRecorder recorder) { return recorder.RecordEvent(this); }