コード例 #1
0
ファイル: KanColleModel.cs プロジェクト: reniris/KanburaLike
        private void RegisterHomeportListener()
        {
            if (this.IsRegistered)
            {
                return;
            }
            try
            {
                var client = KanColleClient.Current;
                client.Homeport.Repairyard
                .Subscribe(nameof(Repairyard.Docks), () => this.UpdateRepairyard(client.Homeport.Repairyard))
                .AddTo(this);

                client.Homeport.Organization
                .Subscribe(nameof(Organization.Fleets), () => this.UpdateFleets(client.Homeport.Organization))
                .Subscribe(nameof(Organization.Ships), () => this.UpdateShips(client.Homeport.Organization))
                .AddTo(this);

                this.IsRegistered = true;
            }
            catch (Exception e)
            {
                DebugModel.WriteLine(e);
            }
        }
コード例 #2
0
ファイル: DebugModel.cs プロジェクト: reniris/KanburaLike
        public static void Dump(object data, string filename)
        {
            string dir      = SettingPath.GetDllFolder();
            var    fullpath = Path.Combine(dir, filename);

            try
            {
                // XAMLで書き出し
                var text = System.Windows.Markup.XamlWriter.Save(data);
                DebugModel.WriteLine(text);
                System.IO.File.WriteAllText(fullpath + ".xaml", text);

                //XMLで書き出し
                var xmls = new XmlSerializer(data.GetType());
                using (var writer = new StreamWriter(fullpath + ".xml", false, Encoding.UTF8))
                {
                    xmls.Serialize(writer, data);
                    writer.Flush();
                }
            }
            catch (Exception e)
            {
                DebugModel.WriteLine(e);
            }
        }