-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul configuration system to handle new features.
- Add support for multiple bots and channels. - Refactor event handling. - Add team project creation/deletion handler.
- Loading branch information
Showing
29 changed files
with
942 additions
and
1,175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Tfs2Slack - http://github.com/kria/Tfs2Slack | ||
* | ||
* Copyright (C) 2014 Kristian Adrup | ||
* | ||
* This file is part of Tfs2Slack. | ||
* | ||
* Tfs2Slack is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. See included file COPYING for details. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DevCore.Tfs2Slack.Configuration | ||
{ | ||
public class BotElement : ConfigurationElement | ||
{ | ||
[ConfigurationProperty("name", IsRequired = true, IsKey = true)] | ||
public string Name | ||
{ | ||
get { return (string)this["name"]; } | ||
} | ||
|
||
[ConfigurationProperty("slackWebhookUrl")] | ||
public string SlackWebhookUrl | ||
{ | ||
get { return (string)this["slackWebhookUrl"]; } | ||
} | ||
|
||
[ConfigurationProperty("slackChannels", IsRequired = true)] | ||
public string SlackChannels | ||
{ | ||
get { return (string)this["slackChannels"]; } | ||
} | ||
|
||
[ConfigurationProperty("slackUsername")] | ||
public string SlackUsername | ||
{ | ||
get { return (string)this["slackUsername"]; } | ||
} | ||
|
||
[ConfigurationProperty("slackIconEmoji")] | ||
public string SlackIconEmoji | ||
{ | ||
get { return (string)this["slackIconEmoji"]; } | ||
} | ||
|
||
[ConfigurationProperty("slackIconUrl")] | ||
public string SlackIconUrl | ||
{ | ||
get { return (string)this["slackIconUrl"]; } | ||
} | ||
|
||
[ConfigurationProperty("slackColor")] | ||
public string SlackColor | ||
{ | ||
get { return (string)this["slackColor"]; } | ||
} | ||
|
||
[ConfigurationProperty("notifyOn")] | ||
public TfsEvents NotifyOn | ||
{ | ||
get { return (TfsEvents)this["notifyOn"]; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Tfs2Slack - http://github.com/kria/Tfs2Slack | ||
* | ||
* Copyright (C) 2014 Kristian Adrup | ||
* | ||
* This file is part of Tfs2Slack. | ||
* | ||
* Tfs2Slack is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. See included file COPYING for details. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DevCore.Tfs2Slack.Configuration | ||
{ | ||
public class BotElementCollection : ConfigurationElementCollection, | ||
IEnumerable<BotElement> | ||
{ | ||
protected override ConfigurationElement CreateNewElement() | ||
{ | ||
return new BotElement(); | ||
} | ||
protected override object GetElementKey(ConfigurationElement element) | ||
{ | ||
return ((BotElement)element).Name; | ||
} | ||
public BotElement this[int index] | ||
{ | ||
get { return (BotElement)BaseGet(index); } | ||
} | ||
|
||
public new IEnumerator<BotElement> GetEnumerator() | ||
{ | ||
int count = base.Count; | ||
for (int i = 0; i < count; i++) | ||
{ | ||
yield return base.BaseGet(i) as BotElement; | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Tfs2Slack - http://github.com/kria/Tfs2Slack | ||
* | ||
* Copyright (C) 2014 Kristian Adrup | ||
* | ||
* This file is part of Tfs2Slack. | ||
* | ||
* Tfs2Slack is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. See included file COPYING for details. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DevCore.Tfs2Slack.Configuration | ||
{ | ||
public class ConfigurationHelper | ||
{ | ||
public static T GetConfigurationSection<T>(Assembly assembly, string sectionName) where T : ConfigurationSection | ||
{ | ||
ResolveEventHandler resolver = (s, a) => { return assembly; }; | ||
AppDomain.CurrentDomain.AssemblyResolve += resolver; | ||
|
||
string configPath = new Uri(assembly.CodeBase).LocalPath + ".config"; | ||
var configuration = ConfigurationManager.OpenMappedExeConfiguration( | ||
new ExeConfigurationFileMap() { ExeConfigFilename = configPath }, | ||
ConfigurationUserLevel.None); | ||
var section = configuration.GetSection(sectionName) as T; | ||
|
||
AppDomain.CurrentDomain.AssemblyResolve -= resolver; | ||
|
||
return section; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Tfs2Slack - http://github.com/kria/Tfs2Slack | ||
* | ||
* Copyright (C) 2014 Kristian Adrup | ||
* | ||
* This file is part of Tfs2Slack. | ||
* | ||
* Tfs2Slack is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. See included file COPYING for details. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DevCore.Tfs2Slack.Configuration | ||
{ | ||
public class SettingsElement : ConfigurationElement | ||
{ | ||
[ConfigurationProperty("logfile")] | ||
public string Logfile | ||
{ | ||
get { return (string)this["logfile"]; } | ||
} | ||
|
||
[ConfigurationProperty("stripUserDomain")] | ||
public bool StripUserDomain | ||
{ | ||
get { return (bool)this["stripUserDomain"]; } | ||
} | ||
|
||
[ConfigurationProperty("commentMaxLength")] | ||
public int CommentMaxLength | ||
{ | ||
get { return (int)this["commentMaxLength"]; } | ||
} | ||
|
||
[ConfigurationProperty("maxLines")] | ||
public int MaxLines | ||
{ | ||
get { return (int)this["maxLines"]; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Tfs2Slack - http://github.com/kria/Tfs2Slack | ||
* | ||
* Copyright (C) 2014 Kristian Adrup | ||
* | ||
* This file is part of Tfs2Slack. | ||
* | ||
* Tfs2Slack is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. See included file COPYING for details. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DevCore.Tfs2Slack.Configuration | ||
{ | ||
public class StringElement : ConfigurationElement | ||
{ | ||
[ConfigurationProperty("value")] | ||
public string Value | ||
{ | ||
get { return (string)this["value"]; } | ||
set { this["value"] = value; } | ||
} | ||
} | ||
} |
Oops, something went wrong.