public void Subscribe <T>(string dataRef, float accuracy = 0.0f, Action <DataRef <T> > changed = null) { if (string.IsNullOrWhiteSpace(dataRef)) { throw new ArgumentNullException("dataRef"); } if (DataRefs.Contains(dataRef)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Can't subscribe to dataref: dataref {0} already subscribed to", dataRef)); } var refObj = new DataRef <T>(dataRef, accuracy); if (changed != null) { refObj.Changed += (o, e) => changed(e); } DataRefs.Add <T>(refObj); Commands.Enqueue(new SubscribeCommand(dataRef, accuracy)); }
public void Add <T>(DataRef <T> dataRef) { DataRefs.TryAdd(dataRef.Name, dataRef); }