コード例 #1
0
        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));
        }
コード例 #2
0
 public void Add <T>(DataRef <T> dataRef)
 {
     DataRefs.TryAdd(dataRef.Name, dataRef);
 }