OSDN Git Service

SettingManager, TabInformations の初期化をTweenMainの外へ移動
authorKimura Youichi <kim.upsilon@bucyou.net>
Sun, 3 Apr 2022 23:17:49 +0000 (08:17 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Fri, 15 Apr 2022 20:04:00 +0000 (05:04 +0900)
OpenTween/ApplicationContainer.cs
OpenTween/Tween.cs

index 5fa8772..7902f25 100644 (file)
@@ -22,6 +22,7 @@
 #nullable enable
 
 using System;
+using OpenTween.Models;
 using OpenTween.Setting;
 
 namespace OpenTween
@@ -32,6 +33,8 @@ namespace OpenTween
 
         public SettingManager Settings { get; } = SettingManager.Instance;
 
+        public TabInformations TabInfo { get; } = TabInformations.GetInstance();
+
         public CultureService CultureService
             => this.cultureServiceLazy.Value;
 
@@ -51,7 +54,7 @@ namespace OpenTween
             => new(this.Settings.Common);
 
         private TweenMain CreateTweenMain()
-            => new();
+            => new(this.Settings, this.TabInfo);
 
         public void Dispose()
         {
index a0706f8..bc391e2 100644 (file)
@@ -133,7 +133,7 @@ namespace OpenTween
         private FormWindowState formWindowState = FormWindowState.Normal; // フォームの状態保存用 通知領域からアイコンをクリックして復帰した際に使用する
 
         // 設定ファイル
-        private readonly SettingManager settings = SettingManager.Instance;
+        private readonly SettingManager settings;
 
         // twitter解析部
         private readonly TwitterApi twitterApi = new(ApplicationSettings.TwitterConsumerKey, ApplicationSettings.TwitterConsumerSecret);
@@ -285,6 +285,8 @@ namespace OpenTween
         private readonly StringFormat sfTab = new();
 
         //////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+        /// <summary>発言保持クラス</summary>
         private readonly TabInformations statuses;
 
         /// <summary>
@@ -758,8 +760,11 @@ namespace OpenTween
             }
         }
 
-        public TweenMain()
+        public TweenMain(SettingManager settingManager, TabInformations tabInfo)
         {
+            this.settings = settingManager;
+            this.statuses = tabInfo;
+
             this.InitializeComponent();
 
             if (!this.DesignMode)
@@ -799,9 +804,6 @@ namespace OpenTween
 
             Regex.CacheSize = 100;
 
-            // 発言保持クラス
-            this.statuses = TabInformations.GetInstance();
-
             // アイコン設定
             this.LoadIcons();
             this.Icon = this.mainIcon;              // メインフォーム(TweenMain)