Ejemplo n.º 1
0
        private ReadOnlyDictionary <uint, T> getItemSigCollection <T>(uint index, uint increment) where T : Crestron.SimplSharpPro.Sig
        {
            string prefix = String.Empty;
            SigCollectionBase <T> smartObjectSignalCollection = null;

            if (typeof(T) == typeof(BoolInputSig))
            {
                prefix = BooleanInputPrefix;
                smartObjectSignalCollection = _smartObject.BooleanInput as SigCollectionBase <T>;
            }
            else if (typeof(T) == typeof(BoolOutputSig))
            {
                increment = _digitalIncrement;
                prefix    = BooleanOutputPrefix;
                smartObjectSignalCollection = _smartObject.BooleanOutput as SigCollectionBase <T>;
            }
            else if (typeof(T) == typeof(UShortInputSig))
            {
                prefix = UShortInputPrefix;
                smartObjectSignalCollection = _smartObject.UShortInput as SigCollectionBase <T>;
            }
            else if (typeof(T) == typeof(UShortOutputSig))
            {
                prefix = UShortOutputPrefix;
                smartObjectSignalCollection = _smartObject.UShortOutput as SigCollectionBase <T>;
            }
            else if (typeof(T) == typeof(StringInputSig))
            {
                prefix = StringInputPrefix;
                smartObjectSignalCollection = _smartObject.StringInput as SigCollectionBase <T>;
            }
            else if (typeof(T) == typeof(StringOutputSig))
            {
                prefix = StringOutputPrefix;
                smartObjectSignalCollection = _smartObject.StringOutput as SigCollectionBase <T>;
            }
            else
            {
                throw new Exception("Signal type is unknown");
            }

            Dictionary <uint, T> itemSignals = new Dictionary <uint, T>((int)increment);
            uint startSigIndex = 1 + (index - 1) * increment;
            uint sigIndex      = 0;

            for (uint i = startSigIndex; i < startSigIndex + increment; i++)
            {
                sigIndex++;
                itemSignals.Add(sigIndex, smartObjectSignalCollection[prefix + i]);
            }

            return(new ReadOnlyDictionary <uint, T>(itemSignals));
        }
 public static void AttachSigEventHandler <T> (this SigCollectionBase <T> coll, string name, UnifiedSigEventHandler handler, eSigEvent eventType) where T : Sig
 {
     coll[name].AttachSigEventHandler(handler, eventType);
 }
 public static void AttachSigEventHandler <T> (this SigCollectionBase <T> coll, uint index, UnifiedSigEventHandler handler, eSigEvent eventType) where T : Sig
 {
     coll[index].AttachSigEventHandler(handler, eventType);
 }
 public static void SetUserObject <T> (this SigCollectionBase <T> coll, string name, object value) where T : Sig
 {
     coll[name].SetUserObject(value);
 }
 public static void SetUserObject <T> (this SigCollectionBase <T> coll, uint index, object value) where T : Sig
 {
     coll[index].SetUserObject(value);
 }
 public static object GetUserObject <T> (this SigCollectionBase <T> coll, string name) where T : Sig
 {
     return(coll[name].GetUserObject());
 }
 public static object GetUserObject <T> (this SigCollectionBase <T> coll, uint index) where T : Sig
 {
     return(coll[index].GetUserObject());
 }
 public static void DetachAllSigEventHandlers <T> (this SigCollectionBase <T> coll, string name) where T : Sig
 {
     coll[name].DetachAllSigEventHandlers();
 }
 public static void DetachAllSigEventHandlers <T> (this SigCollectionBase <T> coll, uint index) where T : Sig
 {
     coll[index].DetachAllSigEventHandlers();
 }
 public static void DetachSigEventHandler <T> (this SigCollectionBase <T> coll, string name, UnifiedSigEventHandler handler) where T : Sig
 {
     coll[name].DetachSigEventHandler(handler);
 }
 public static void DetachSigEventHandler <T> (this SigCollectionBase <T> coll, uint index, UnifiedSigEventHandler handler) where T : Sig
 {
     coll[index].DetachSigEventHandler(handler);
 }