Beispiel #1
0
        public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key)
        {
            var result = device.Register();
            var level  = result == eDeviceRegistrationUnRegistrationResponse.Success ?
                         Debug.ErrorLogLevel.Notice : Debug.ErrorLogLevel.Error;

            Debug.Console(0, level, "Register device result: '{0}', type '{1}', result {2}", key, device, result);
            //if (result != eDeviceRegistrationUnRegistrationResponse.Success)
            //{
            //    Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result);
            //}
            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// Attempts device registration, passing feedback to the console and error log if it fails.
 /// </summary>
 /// <param name="dev">The device to register.</param>
 /// <param name="deviceDescriptor">A description of the device for use if it fails and an error is printed.</param>
 /// <returns>Returns true if the registration succeeds, false if it fails for any reason.</returns>
 public static bool Register(this GenericBase dev, string deviceDescriptor)
 {
     if (dev == null)
     {
         CrestronConsole.PrintLine("Couldn't register {0}, the device was null.", deviceDescriptor);
         ErrorLog.Error("Coudln't reigster {0}, the device was null.", deviceDescriptor);
         return(false);
     }
     if (dev.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
     {
         CrestronConsole.PrintLine("Couldn't register {0} for the reason: {1}", deviceDescriptor, dev.RegistrationFailureReason);
         ErrorLog.Error("Coudln't reigster {0} for the reason: {1}.", deviceDescriptor, dev.RegistrationFailureReason);
         return(false);
     }
     CrestronConsole.PrintLine("Registered: {0}", deviceDescriptor);
     return(true);
 }