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
using System; | |
namespace ConsoleApplication3 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
FizzBuzz(4, 7, 120); | |
} |
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
using System; | |
namespace ConsoleApplication3 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
FizzBuzz(); | |
} |
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
protected override void OnClosing(CancelEventArgs e) | |
{ | |
base.OnClosing(e); | |
// 何か処理追加 | |
} |
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
public MainWindow() | |
{ | |
InitializeComponent(); | |
var mView = new ViewModel.MainViewModel(); | |
this.All.DataContext = mView; | |
// OnClose時に処理を行いたいので、Model側で閉じられるようthis.CloseをVMに渡す。 | |
if(mView.Model.CloseAction == null) | |
mView.Model.CloseAction = new Action(() => this.Close()); | |
} |
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
// 閉じる処理プロパティ | |
public Action CloseAction { get; set; } | |
public void OnClosing() | |
{ | |
// 追加したい処理 | |
CloseAction(); | |
} |
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
public ICommand Close { get; private set; } | |
public MainViewModel() | |
{ | |
Close = new RelayCommand(_Model.OnClosing); | |
} |
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
<Button x:Name="CloseButton" Content="r" Style="{DynamicResource CaptionButtonStyleKey}" Command="{Binding Close}"> |
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
publi class Person | |
{ | |
public string Name { get; set; } | |
public string Age { get; set; } | |
} |
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
public void SaveXml(List<Person> personList) | |
{ | |
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Person[])); | |
// Data.xmlは保存するファイル名 | |
using (System.IO.FileStream fs = new System.IO.FileStream("Data.xml", System.IO.FileMode.Create)) | |
{ | |
serializer.Serialize(fs, personList.ToArray()); | |
} |
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
public List<Person> LoadXml() | |
{ | |
Person[] loadAry; | |
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Person[])); | |
using (System.IO.StreamReader sr = new System.IO.StreamReader("Data.xml", new System.Text.UTF8Encoding(false))) | |
{ | |
loadAry = (Person[])serializer.Deserialize(sr); | |
} |
OlderNewer