public void ReadFromRegistry(string registrySubKey) { RegistryUtility regUtil = new RegistryUtility(registrySubKey + "\\" + this.InstanceNumber.ToString("00")); foreach (var prop in this.GetType().GetProperties()) { string strValue = regUtil.Read(prop.Name).ToString(); if (prop.PropertyType == typeof(Int32)) { int intVal = int.Parse(strValue); prop.SetValue(this, intVal, null); } else if (prop.PropertyType == typeof(DatabaseTypes)) { DatabaseTypes dbType = (DatabaseTypes)Enum.Parse(typeof(DatabaseTypes), strValue); prop.SetValue(this, dbType, null); } else if (prop.PropertyType == typeof(SourceLevels)) { SourceLevels level = (SourceLevels)Enum.Parse(typeof(SourceLevels), strValue); prop.SetValue(this, level, null); } else if (prop.PropertyType == typeof(bool)) { bool boolValue = bool.Parse(strValue); prop.SetValue(this, boolValue, null); } else { prop.SetValue(this, strValue, null); } } }
internal bool IsSlackInitialized() { string token = RegistryUtility.Read("MyToken"); var init = Slack.Initialize(token); if (init == null) { throw new SlackApiException("Initialization failed."); } bool hasInitSuccess = init.IsSuccess; if (!hasInitSuccess) { throw new SlackApiException(init.Message); } return(true); }
public static void Main(string[] args) { try { string token = RegistryUtility.Read("MyToken"); var init = Slack.Initialize(token); if (init == null) { throw new ArgumentNullException(nameof(init)); } System.Console.WriteLine(init.Message); if (!init.IsSuccess) { return; } var thread = new Thread(GetMessages); thread.Start(); //var message = new Message //{ // ChannelId = "general", // MessageText = "Testar om meddelande kommer fram." //}; //Slack.SendMessage(message); } catch (Exception ex) { ExceptionLogging.Trace(ex); System.Console.WriteLine(ex.Message); System.Console.ReadLine(); } }