public static LiveListState <T> CreateState(ObservableType executionType, IBaseListCollection <T> list, int startingIndex, TimeSpan timeout) { var tracker = new ListCollectionIndexOffsetTracker <T>(); tracker.SetOriginalIndexAndResetCurrent(startingIndex); list.CollectionChangedEvent += tracker.HandleEvent; list.CollectionChangedEvent += (_, e) => { if (e != null) { lock (tracker) { Monitor.Pulse(tracker); } } }; return(new LiveListState <T>() { List = list, Tracker = tracker, Timeout = timeout, ExecutionType = executionType }); }
public void ToObservableList([Values] ObservableType type) { var list = new List <int>(); var obs = list.ToObservable(type); Assert.That(obs, Is.Not.Null); }
public void GetObservableTypeList([Values] ObservableType type) { var list = new List <int>(); var obs = list.ToObservable(type); var testedType = obs.GetObservableType(); Assert.That(testedType, Is.EqualTo(type)); }
public void ToObservableBaseListCollection([Values] ObservableType type) { var list = new List <int>(); var baseList = list.AsListCollection(); var obs = baseList.ToObservable(type); Assert.That(obs, Is.Not.Null); }
public void ToObservableBaseListCollectionNull([Values] ObservableType type) { IBaseListCollection <int> list = null; Assert.Throws <ArgumentNullException>(() => { list.ToObservable(type); }); }
public void GetObservableTypeBaseListCollection([Values] ObservableType type) { var list = new List <int>(); var baseList = list.AsListCollection(); var obs = baseList.ToObservable(type); var testedType = obs.GetObservableType(); Assert.That(testedType, Is.EqualTo(type)); }
public Observable( ObservableType type, string name, int index = -1, // default for dedicated types Func <float> getter = null) { Type = type; Name = name; Index = index; Getter = getter; // TODO Should be some systematic color scheme. Color = UnityEngine.Random.ColorHSV(0, 1, 0.5f, 1, 0.5f, 1, 1, 1); }
/// <summary> /// Convert a <see cref="IList{T}"/> into an <see cref="IObservable{T}"/> of a specific type. /// </summary> /// <typeparam name="T">Type of data.</typeparam> /// <param name="source">Source data.</param> /// <param name="type">What type of observable should be created.</param> /// <returns>An <see cref="IObservable{T}"/> based off the <paramref name="source"/>.</returns> public static IObservable <T> ToObservable <T>(this IList <T> source, ObservableType type) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (type == ObservableType.Traditional) { // System.Reactive, at the time of this writing, uses CurrentThreadScheduler.Instance for the scheduler. // But in case that changes in the future, let the default ToObservable run instead of passing in the scheduler return(System.Reactive.Linq.Observable.ToObservable(source)); } return(source.ToObservable(type, CurrentThreadScheduler.Instance)); }
/// <summary> /// Convert a <see cref="IList{T}"/> into an <see cref="IObservable{T}"/> of a specific type., using the specified scheduler to run the enumeration loop. /// </summary> /// <typeparam name="T">Type of data.</typeparam> /// <param name="source">Source data.</param> /// <param name="type">What type of observable should be created.</param> /// <param name="scheduler">Scheduler to run the enumeration of the input sequence on.</param> /// <returns>An <see cref="IObservable{T}"/> based off the <paramref name="source"/>.</returns> public static IObservable <T> ToObservable <T>(this IList <T> source, ObservableType type, IScheduler scheduler) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } switch (type) { case ObservableType.LiveUpdating: case ObservableType.InfiniteLiveUpdating: return(new LiveListObservable <T>(type, source.AsListCollection(), scheduler)); case ObservableType.Traditional: return(System.Reactive.Linq.Observable.ToObservable(source, scheduler)); } throw new ArgumentException("Unknown type", nameof(type)); }
/// <summary> /// This constructor is the key for generating the fields used for each different type of indicator. /// The creation of new fields in this constructor (along with the GUIFieldType property) on each one, determines which /// fields show up on the gui when one adds a new indicatior. The GUI for adding indicators is all driven from this code below /// /// /// If what you are adding adds a new type of field not already included, you will need to write the corresponding code for that /// field in the "toXML" and/or other export functions /// /// </summary> /// <param name="type">The type of this observable: Domain, Sample etc.</param> public ObservableObject(ObservableType type, ref ObservableCollection collection) { ID = HelperClass.GenerateID(collection.ReportingOrganisation, collection.IncidentName, "Observable"); Type = type; Fields = new List <ObservableObjectField>(); Fields.Add(new ObservableObjectField(ref collection) { FieldName = "Title", FieldType = ObservableObjectField.GUIFieldType.TextBox }); Fields.Add(new ObservableObjectField(ref collection) { FieldName = "Description", FieldType = ObservableObjectField.GUIFieldType.LongTextBox }); if (Type == ObservableObject.ObservableType.Domain) { FriendlyTypeName = "Domain"; Fields.Add(new ObservableObjectField(ref collection) { FieldName = "Domain", FieldType = ObservableObjectField.GUIFieldType.TextBox }); } else if (Type == ObservableObject.ObservableType.IPAddress) { FriendlyTypeName = "IP Address"; Fields.Add(new ObservableObjectField(ref collection) { FieldName = "IPv4", FieldType = ObservableObjectField.GUIFieldType.TextBox }); Fields.Add(new ObservableObjectField(ref collection) { FieldName = "IPv6", FieldType = ObservableObjectField.GUIFieldType.TextBox }); //Fields.Add(new STIXField(ref collection) { FieldName = "TestDropDown", FieldType = STIXField.GUIFieldType.DropDown, DropDownOptions = new List<string>() { "Item1", "Item2" } }); } else if (Type == ObservableObject.ObservableType.Sample) { FriendlyTypeName = "Malware Sample"; Fields.Add(new ObservableObjectField(ref collection) { FieldName = "Hashes.MD5", FieldType = ObservableObjectField.GUIFieldType.TextBox }); Fields.Add(new ObservableObjectField(ref collection) { FieldName = "Hashes.SHA1", FieldType = ObservableObjectField.GUIFieldType.TextBox }); Fields.Add(new ObservableObjectField(ref collection) { FieldName = "File_Name", FieldType = ObservableObjectField.GUIFieldType.TextBox }); Fields.Add(new ObservableObjectField(ref collection) { FieldName = "File_Path", FieldType = ObservableObjectField.GUIFieldType.TextBox }); } else if (Type == ObservableObject.ObservableType.Registry) { FriendlyTypeName = "Registry"; Fields.Add(new ObservableObjectField(ref collection) { FieldName = "Key", FieldType = ObservableObjectField.GUIFieldType.TextBox }); Fields.Add(new ObservableObjectField(ref collection) { FieldName = "Hive", FieldType = ObservableObjectField.GUIFieldType.TextBox }); Fields.Add(new ObservableObjectField(ref collection) { FieldName = "Value", FieldType = ObservableObjectField.GUIFieldType.TextBox }); } }
private bool HasObservableType(ObservableType type) { return(m_Observables.Any(o => o.Type == type)); }
public LiveListObservable(ObservableType type, IBaseListCollection <T> list, IScheduler scheduler, TimeSpan executionTimeout, int startingIndex = STARTING_INDEX) : base(type, scheduler, () => LiveListState <T> .CreateState(type, list, startingIndex, executionTimeout)) { SupportsLongRunning = true; }
public LiveListObservable(ObservableType type, IBaseListCollection <T> list, IScheduler scheduler, int startingIndex = STARTING_INDEX) : this(type, list, scheduler, DEFAULT_EX_TIMEOUT, startingIndex) { }
protected ScheduledObservable(ObservableType type, IScheduler scheduler, Func <S> stateGenerator) : base(type, scheduler) { this.stateGenerator = stateGenerator; }
protected ScheduledObservable(ObservableType type, IScheduler scheduler) : this(type, scheduler, () => default(S)) { }
protected TypedObservable(ObservableType type, IScheduler scheduler) { this.Type = type; this.scheduler = scheduler; }