private void Deserialize(Stream Wire) { BinaryReader BR = new BinaryReader(Wire); Type = (DelegateTypes)BR.ReadByte(); switch (Type) { case DelegateTypes.WRITESCREEN: Write = new WriteDelegate(WriteScreen); break; default: Write = new WriteDelegate(WriteFile); break; } }
public ViewModel() { _disposables = new CompositeDisposable(); this.ObservableForProperty(vm => vm.Delegate, beforeChange: true) .Subscribe(OnDelegateChanging) .AddTo(_disposables); this.WhenAnyValue(vm => vm.SelectedIndex) .Subscribe(OnDelegateChanged) .AddTo(_disposables); SelectedIndex = DelegateTypes.Select((d, idx) => new { Data = d, Index = idx }) .Where(t => t.Data == typeof(Delegates.ColorPalletCanvasViewDelegate)) .Select(t => t.Index) .Single(); }
/// <summary> /// Main constructor of the DelegateWrapper class. /// </summary> /// <param name="write">The WriteDelegate delegate wrapped by this class</param> /// <param name="type">The DelegateType type indicating the Method wrapped /// by the delegate</param> public DelegateWrapper(WriteDelegate write, DelegateTypes type) { Write = write; Type = type; }