예제 #1
0
        public void AMethod()
        {
            Console.WriteLine("This message is printed from AMethod");
            CDelegate cDelegate = new CDelegate(CMethod);

            BMethod(cDelegate);
        }
 public static KeyValuePair <string, Tuple <string, CDelegate> >[] GetKeyValuePairs()
 {
     KeyValuePair <string, Tuple <string, CDelegate> >[] valuePair = new KeyValuePair <string, Tuple <string, CDelegate> > [commands.Length];
     CDelegate[] DelegateArr = new CDelegate[commands.Length];
     DelegateArr[0]  = ShowDir;
     DelegateArr[1]  = ShowHelp;
     DelegateArr[2]  = ChangeDir;
     DelegateArr[3]  = StartMC;
     DelegateArr[4]  = Del;
     DelegateArr[5]  = Add;
     DelegateArr[6]  = CLS;
     DelegateArr[7]  = CopyTo;
     DelegateArr[8]  = MoveTo;
     DelegateArr[9]  = ReadFile;
     DelegateArr[10] = ShowMan;
     DelegateArr[11] = GetLastCommands;
     for (int i = 0; i < commands.Length; ++i)
     {
         try
         {
             valuePair[i] = new KeyValuePair <string, Tuple <string, CDelegate> >(commands[i], new Tuple <string, CDelegate>(descriptions[i], DelegateArr[i]));
         }
         catch (IndexOutOfRangeException)
         {
             valuePair[i] = new KeyValuePair <string, Tuple <string, CDelegate> >(commands[i], new Tuple <string, CDelegate>("No comments added", DelegateArr[i]));
         }
     }
     return(valuePair);
 }
예제 #3
0
            public void PerformClusterTesting()
            {
                var cluster = new FakeCluster <ProxyEvent0_Cluster>(
                    null
                    );

                var propertyContainer = cluster.Get <IEventContainer>();

                Assert.IsNotNull(propertyContainer);

                propertyContainer.AEvent += a => { };
                Assert.IsFalse(SessionSaver.ProxyWasInDeal);

                SessionSaver.ProxyWasInDeal = false;
                propertyContainer.BEvent   += b => 1;
                Assert.IsFalse(SessionSaver.ProxyWasInDeal);

                CDelegate cDelegate = c => null;

                SessionSaver.ProxyWasInDeal = false;
                propertyContainer.CEvent   += cDelegate;
                Assert.IsTrue(SessionSaver.ProxyWasInDeal);
                Assert.AreEqual(typeof(EventContainer).FullName, SessionSaver.FullClassName);
                Assert.AreEqual(nameof(EventContainer.CEvent), SessionSaver.MemberName);
                Assert.IsTrue(SessionSaver.TakenInSeconds > 0.0);
                Assert.IsNull(SessionSaver.Exception);
                Assert.IsNotNull(SessionSaver.Arguments);
                Assert.AreEqual(2, SessionSaver.Arguments.Length);
                Assert.IsTrue(
                    Enumerable.SequenceEqual(
                        SessionSaver.Arguments,
                        new object[] { "value", cDelegate }
                        )
                    );

                SessionSaver.ProxyWasInDeal = false;
                propertyContainer.CEvent   -= cDelegate;
                Assert.IsTrue(SessionSaver.ProxyWasInDeal);
                Assert.AreEqual(typeof(EventContainer).FullName, SessionSaver.FullClassName);
                Assert.AreEqual(nameof(EventContainer.CEvent), SessionSaver.MemberName);
                Assert.IsTrue(SessionSaver.TakenInSeconds > 0.0);
                Assert.IsNull(SessionSaver.Exception);
                Assert.IsNotNull(SessionSaver.Arguments);
                Assert.AreEqual(2, SessionSaver.Arguments.Length);
                Assert.IsTrue(
                    Enumerable.SequenceEqual(
                        SessionSaver.Arguments,
                        new object[] { "value", cDelegate }
                        )
                    );
            }
예제 #4
0
 static DelegateExtensions()
 {
     if (CrestronEnvironment.RuntimeEnvironment == eRuntimeEnvironment.SimplSharpPro)
     {
         try
         {
             var typeMonoThreadPool = Type.GetType("SSMono.Threading.ThreadPool, SSMonoProThreadingLibrary", false).GetCType();
             if (typeMonoThreadPool != null)
             {
                 _delQueueUserWorkItem = (DelQueueUserWorkItem)CDelegate.CreateDelegate(typeof(DelQueueUserWorkItem), null,
                                                                                        typeMonoThreadPool.GetMethod("QueueUserWorkItem", new CType[] { typeof(WaitCallback), typeof(object) }));
             }
         }
         catch
         {
         }
     }
 }
예제 #5
0
 public static TDelegate CreateDelegate <TDelegate, TTarget> (string method) where TDelegate : class
 {
     return(CDelegate.CreateDelegate(typeof(TDelegate), null, typeof(TTarget).GetCType().GetMethod(method)) as TDelegate);
 }
예제 #6
0
 public static TDelegate CreateDelegate <TDelegate> (CType target, string method) where TDelegate : class
 {
     return(CDelegate.CreateDelegate(typeof(TDelegate), null, target.GetMethod(method)) as TDelegate);
 }
예제 #7
0
 public static TDelegate CreateDelegate <TDelegate> (object firstArgument, MethodInfo method) where TDelegate : class
 {
     return(CDelegate.CreateDelegate(typeof(TDelegate), firstArgument, method) as TDelegate);
 }
예제 #8
0
 public static TDelegate CreateDelegate <TDelegate> (MethodInfo method) where TDelegate : class
 {
     return(CDelegate.CreateDelegate(typeof(TDelegate), null, method) as TDelegate);
 }
예제 #9
0
 public static object CreateDelegate(this MethodInfo mi, CType delegateType, object target)
 {
     return(CDelegate.CreateDelegate(delegateType, target, mi));
 }
예제 #10
0
 public static object CreateDelegate(this MethodInfo mi, CType delegateType)
 {
     return(CDelegate.CreateDelegate(delegateType, null, mi));
 }
 private static object ConvertToCrestronThreadCallbackFunction(ThreadCallbackFunction func)
 {
     return(CDelegate.CreateDelegate(_ctypeThreadCallbackFunction, func.Target, func.GetMethod()));
 }
예제 #12
0
 public void UnRegisterEvent(CDelegate CallBack)
 {
 }
예제 #13
0
 public void RegisterEvent(EGuiEventType EventType, CDelegate CallBack, CGuiEventFilter Filter)
 {
 }
예제 #14
0
 public void RegisterEvent(EGuiEventType EventType, CDelegate CallBack)
 {
 }
예제 #15
0
 public static TDelegate CreateDelegate <TDelegate> (CType type, object target, string method) where TDelegate : class
 {
     return(CDelegate.CreateDelegate(typeof(TDelegate), type, target == null ? null : target.GetCType().GetMethod(method)) as TDelegate);
 }
예제 #16
0
        /// <summary>
        /// Create a UIController instance
        /// </summary>
        /// <param name="system">The base system</param>
        /// <param name="device">The UI device used for the UIController</param>
        /// <param name="defaultRoom">The default room for the UI</param>
        protected UIController(SystemBase system, BasicTriList device, RoomBase defaultRoom)
        {
            _idCount++;
            Id      = _idCount;
            _system = system;
            _system.SystemStartupProgressChange += OnSystemStartupProgressChange;

            Device      = device;
            DefaultRoom = defaultRoom;

            CloudLog.Debug("Creating {0} for device: {1} ({2}) with ID 0x{3:X2}", GetType().Name, device.GetType().Name, device.Name, device.ID);

            try
            {
                device.IpInformationChange += DeviceOnIpInformationChange;
                _isEthernetDevice           = true;
            }
            catch
            {
                CloudLog.Debug("{0} is not Ethernet Device", device.ToString());
            }
            device.OnlineStatusChange += DeviceOnOnlineStatusChange;
            device.SigChange          += OnSigChange;

            var tswFt5Button = device as TswFt5Button;

            if (tswFt5Button != null)
            {
                tswFt5Button.ExtenderEthernetReservedSigs.Use();
                tswFt5Button.ExtenderEthernetReservedSigs.DeviceExtenderSigChange +=
                    ExtenderEthernetReservedSigsOnDeviceExtenderSigChange;
            }

            var tswx52ButtonVoiceControl = device as Tswx52ButtonVoiceControl;

            if (tswx52ButtonVoiceControl != null)
            {
                tswx52ButtonVoiceControl.ExtenderSystemReservedSigs.Use();
                tswx52ButtonVoiceControl.ExtenderAutoUpdateReservedSigs.Use();
                tswx52ButtonVoiceControl.ExtenderAutoUpdateReservedSigs.DeviceExtenderSigChange += ExtenderAutoUpdateReservedSigsOnDeviceExtenderSigChange;
            }

            var tswX60BaseClass = device as TswX60BaseClass;

            if (tswX60BaseClass != null)
            {
                tswX60BaseClass.ExtenderHardButtonReservedSigs.Use();
                Debug.WriteInfo("Setting up hard buttons for TswX60BaseClass device");
                _hardButtons = new ButtonCollection();
                for (uint b = 1; b <= 5; b++)
                {
                    var extender  = tswX60BaseClass.ExtenderHardButtonReservedSigs;
                    var t         = extender.GetType().GetCType();
                    var offMethod = t.GetMethod(string.Format("TurnButton{0}BackLightOff", b));
                    var onMethod  = t.GetMethod(string.Format("TurnButton{0}BackLightOn", b));
                    var delType   = typeof(HardKeyBackLightMethod).GetCType();
                    var offDel    = (HardKeyBackLightMethod)CDelegate.CreateDelegate(delType, extender, offMethod);
                    var onDel     = (HardKeyBackLightMethod)CDelegate.CreateDelegate(delType, extender, onMethod);
                    var button    = new UIHardButton(this, b, onDel, offDel);
                    _hardButtons.Add(b, button);
                }
            }
            else if (device is Tswx52ButtonVoiceControl)
            {
                Debug.WriteInfo("Setting up hard buttons for Tswx52ButtonVoiceControl device");
                _hardButtons = new ButtonCollection();
                for (uint b = 1; b <= 5; b++)
                {
                    var button = new UIHardButton(this, b);
                    _hardButtons.Add(b, button);
                }
            }

            _system.UIControllers.Add(this);
        }
예제 #17
0
 public void BMethod(CDelegate k)
 {
     Console.WriteLine("This message is printed from BMethod");
     k(100);
     k.Invoke(200);
 }