示例#1
0
        public static void Load()
        {
            _internalSettings = new ApplicationInternalSettings();
            _internalSettings.Upgrade();
            _internalSettings.Reload();

            try
            {
                var element = XElement.Load(System.IO.Directory.GetCurrentDirectory() + "\\settings.xml");
                var q       = from p in element.Elements("Configuration")
                              select new
                {
                    CroudiaAccessToken      = (string)p.Element("CroudiaAccessToken"),
                    CroudiaRefreshToken     = (string)p.Element("CroudiaRefreshToken"),
                    CroudiaScreenName       = (string)p.Element("CroudiaScreenName"),
                    TwitterAceessToken      = (string)p.Element("TwitterAccessToken"),
                    TwitterAccessTokenSecet = (string)p.Element("TwitterAccessTokenSecret"),
                    TwitterScreenName       = (string)p.Element("TwitterScreenName"),
                    TextFormat = (string)p.Element("TextFormat"),
                    IsTopLevel = Boolean.Parse((string)p.Element("IsTopLevel")),
                    AutoTweet  = p.Element("AutoTweet") != null && Boolean.Parse((string)p.Element("AutoTweet"))
                };
                foreach (var item in q)
                {
                    Settings.TextFormat              = item.TextFormat;
                    Settings.TwitterAccessToken      = item.TwitterAceessToken;
                    Settings.TwitterAccessTokenSecet = item.TwitterAccessTokenSecet;
                    Settings.TwitterScreenName       = item.TwitterScreenName;
                    Settings.CroudiaAccessToken      = item.CroudiaAccessToken;
                    Settings.CroudiaRefreshToken     = item.CroudiaRefreshToken;
                    Settings.CroudiaScreenName       = item.CroudiaScreenName;
                    Settings.IsTopLevel              = item.IsTopLevel;
                    Settings.AutoTweet = item.AutoTweet;
                }
            }
            catch (Exception)
            {
                Settings.TextFormat              = "%{song} - %{artist} / %{album} #NowPlaying";
                Settings.TwitterAccessToken      = "";
                Settings.TwitterAccessTokenSecet = "";
                Settings.TwitterScreenName       = "";
                Settings.CroudiaAccessToken      = "";
                Settings.CroudiaRefreshToken     = "";
                Settings.CroudiaScreenName       = "";
                Settings.IsTopLevel              = false;
                Settings.AutoTweet = false;
            }
        }
示例#2
0
        public static void Load()
        {
            _internalSettings = new ApplicationInternalSettings();
            _internalSettings.Upgrade();
            _internalSettings.Reload();

            try
            {
                var element = XElement.Load(System.IO.Directory.GetCurrentDirectory() + "\\settings.xml");
                var q = from p in element.Elements("Configuration")
                        select new
                        {
                            CroudiaAccessToken = (string)p.Element("CroudiaAccessToken"),
                            CroudiaRefreshToken = (string)p.Element("CroudiaRefreshToken"),
                            CroudiaScreenName = (string)p.Element("CroudiaScreenName"),
                            TwitterAceessToken = (string)p.Element("TwitterAccessToken"),
                            TwitterAccessTokenSecet = (string)p.Element("TwitterAccessTokenSecret"),
                            TwitterScreenName = (string)p.Element("TwitterScreenName"),
                            TextFormat = (string)p.Element("TextFormat"),
                            IsTopLevel = Boolean.Parse((string)p.Element("IsTopLevel")),
                            AutoTweet = p.Element("AutoTweet") != null && Boolean.Parse((string)p.Element("AutoTweet"))
                        };
                foreach (var item in q)
                {
                    Settings.TextFormat = item.TextFormat;
                    Settings.TwitterAccessToken = item.TwitterAceessToken;
                    Settings.TwitterAccessTokenSecet = item.TwitterAccessTokenSecet;
                    Settings.TwitterScreenName = item.TwitterScreenName;
                    Settings.CroudiaAccessToken = item.CroudiaAccessToken;
                    Settings.CroudiaRefreshToken = item.CroudiaRefreshToken;
                    Settings.CroudiaScreenName = item.CroudiaScreenName;
                    Settings.IsTopLevel = item.IsTopLevel;
                    Settings.AutoTweet = item.AutoTweet;
                }
            }
            catch (Exception)
            {
                Settings.TextFormat = "%{song} - %{artist} / %{album} #NowPlaying";
                Settings.TwitterAccessToken = "";
                Settings.TwitterAccessTokenSecet = "";
                Settings.TwitterScreenName = "";
                Settings.CroudiaAccessToken = "";
                Settings.CroudiaRefreshToken = "";
                Settings.CroudiaScreenName = "";
                Settings.IsTopLevel = false;
                Settings.AutoTweet = false;
            }
        }