練習用です。いろんなものがごちゃまぜです。
(empty log message)
| @@ -0,0 +1,20 @@ | ||
| 1 | +Namespace Iterator.Core | |
| 2 | + | |
| 3 | + Public Class Book | |
| 4 | + | |
| 5 | + Private _name As String = String.Empty | |
| 6 | + | |
| 7 | + Public Sub New(ByVal name As String) | |
| 8 | + _name = name | |
| 9 | + End Sub | |
| 10 | + | |
| 11 | + Public ReadOnly Property Name() As String | |
| 12 | + Get | |
| 13 | + Return _name | |
| 14 | + End Get | |
| 15 | + End Property | |
| 16 | + | |
| 17 | + End Class | |
| 18 | + | |
| 19 | +End Namespace | |
| 20 | + |
| @@ -0,0 +1,37 @@ | ||
| 1 | +Namespace Iterator.Core | |
| 2 | + | |
| 3 | + Public Class BookShelf | |
| 4 | + Implements IEnumerable | |
| 5 | + | |
| 6 | + Private _books() As Book | |
| 7 | + Private _last As Integer = 0 | |
| 8 | + | |
| 9 | + Public Sub New(ByVal maxSize As Integer) | |
| 10 | + ReDim _books(maxSize - 1) | |
| 11 | + End Sub | |
| 12 | + | |
| 13 | + Public ReadOnly Property Length() As Integer | |
| 14 | + Get | |
| 15 | + Return _last | |
| 16 | + End Get | |
| 17 | + End Property | |
| 18 | + | |
| 19 | + Public ReadOnly Property Book(ByVal index As Integer) As Book | |
| 20 | + Get | |
| 21 | + Return _books(index) | |
| 22 | + End Get | |
| 23 | + End Property | |
| 24 | + | |
| 25 | + Public Sub AppendBook(ByVal book As Book) | |
| 26 | + _books(_last) = book | |
| 27 | + _last += 1 | |
| 28 | + End Sub | |
| 29 | + | |
| 30 | + Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator | |
| 31 | + Return New BookShelfEnumerator(Me) | |
| 32 | + End Function | |
| 33 | + | |
| 34 | + End Class | |
| 35 | + | |
| 36 | +End Namespace | |
| 37 | + |
| @@ -0,0 +1,36 @@ | ||
| 1 | +Namespace Iterator.Core | |
| 2 | + | |
| 3 | + Public Class BookShelfEnumerator | |
| 4 | + Implements IEnumerator | |
| 5 | + | |
| 6 | + Private _bookShelf As BookShelf | |
| 7 | + Private _index As Integer = -1 | |
| 8 | + | |
| 9 | + Public Sub New(ByVal bookShelf As BookShelf) | |
| 10 | + _bookShelf = bookShelf | |
| 11 | + End Sub | |
| 12 | + | |
| 13 | + Public ReadOnly Property Current() As Object Implements IEnumerator.Current | |
| 14 | + Get | |
| 15 | + Return _bookShelf.Book(_index) | |
| 16 | + End Get | |
| 17 | + End Property | |
| 18 | + | |
| 19 | + Public Function MoveNext() As Boolean Implements IEnumerator.MoveNext | |
| 20 | + If (_index < _bookShelf.Length - 1) Then | |
| 21 | + _index += 1 | |
| 22 | + Return True | |
| 23 | + Else | |
| 24 | + Return False | |
| 25 | + End If | |
| 26 | + End Function | |
| 27 | + | |
| 28 | + Public Sub Reset() Implements IEnumerator.Reset | |
| 29 | + _index = -1 | |
| 30 | + End Sub | |
| 31 | + | |
| 32 | + End Class | |
| 33 | + | |
| 34 | +End Namespace | |
| 35 | + | |
| 36 | + |
| @@ -0,0 +1,29 @@ | ||
| 1 | +Imports vbGofSample.Iterator.Core | |
| 2 | + | |
| 3 | +Namespace Iterator.CUI | |
| 4 | + | |
| 5 | + Public Class App | |
| 6 | + | |
| 7 | + Public Shared Sub Main() | |
| 8 | + Console.WriteLine("Iterator パターンのサンプル") | |
| 9 | + Console.WriteLine() | |
| 10 | + | |
| 11 | + Dim myBookShelf As BookShelf = New BookShelf(4) | |
| 12 | + | |
| 13 | + myBookShelf.AppendBook(New Book("Around the World in 80 Days")) | |
| 14 | + myBookShelf.AppendBook(New Book("Bible")) | |
| 15 | + myBookShelf.AppendBook(New Book("Cinderella")) | |
| 16 | + myBookShelf.AppendBook(New Book("Daddy-Long-Legs")) | |
| 17 | + | |
| 18 | + Dim myBook As Book | |
| 19 | + | |
| 20 | + For Each myBook In myBookShelf | |
| 21 | + Console.WriteLine("" & myBook.Name) | |
| 22 | + Next | |
| 23 | + | |
| 24 | + End Sub | |
| 25 | + | |
| 26 | + End Class | |
| 27 | + | |
| 28 | +End Namespace | |
| 29 | + |
| @@ -0,0 +1,13 @@ | ||
| 1 | +Module Module1 | |
| 2 | + | |
| 3 | + Sub Main(ByVal args() As String) | |
| 4 | + | |
| 5 | + Iterator.CUI.App.Main() | |
| 6 | + | |
| 7 | + Console.WriteLine() | |
| 8 | + Console.WriteLine("なにかキーを押すと終了します。") | |
| 9 | + Console.ReadKey() | |
| 10 | + | |
| 11 | + End Sub | |
| 12 | + | |
| 13 | +End Module |
| @@ -0,0 +1,13 @@ | ||
| 1 | +'------------------------------------------------------------------------------ | |
| 2 | +' <auto-generated> | |
| 3 | +' This code was generated by a tool. | |
| 4 | +' Runtime Version:4.0.30319.18444 | |
| 5 | +' | |
| 6 | +' Changes to this file may cause incorrect behavior and will be lost if | |
| 7 | +' the code is regenerated. | |
| 8 | +' </auto-generated> | |
| 9 | +'------------------------------------------------------------------------------ | |
| 10 | + | |
| 11 | +Option Strict On | |
| 12 | +Option Explicit On | |
| 13 | + |
| @@ -0,0 +1,62 @@ | ||
| 1 | +'------------------------------------------------------------------------------ | |
| 2 | +' <auto-generated> | |
| 3 | +' This code was generated by a tool. | |
| 4 | +' Runtime Version:4.0.30319.18444 | |
| 5 | +' | |
| 6 | +' Changes to this file may cause incorrect behavior and will be lost if | |
| 7 | +' the code is regenerated. | |
| 8 | +' </auto-generated> | |
| 9 | +'------------------------------------------------------------------------------ | |
| 10 | + | |
| 11 | +Option Strict On | |
| 12 | +Option Explicit On | |
| 13 | + | |
| 14 | + | |
| 15 | +Namespace My.Resources | |
| 16 | + | |
| 17 | + 'This class was auto-generated by the StronglyTypedResourceBuilder | |
| 18 | + 'class via a tool like ResGen or Visual Studio. | |
| 19 | + 'To add or remove a member, edit your .ResX file then rerun ResGen | |
| 20 | + 'with the /str option, or rebuild your VS project. | |
| 21 | + '''<summary> | |
| 22 | + ''' A strongly-typed resource class, for looking up localized strings, etc. | |
| 23 | + '''</summary> | |
| 24 | + <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _ | |
| 25 | + Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ | |
| 26 | + Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ | |
| 27 | + Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _ | |
| 28 | + Friend Module Resources | |
| 29 | + | |
| 30 | + Private resourceMan As Global.System.Resources.ResourceManager | |
| 31 | + | |
| 32 | + Private resourceCulture As Global.System.Globalization.CultureInfo | |
| 33 | + | |
| 34 | + '''<summary> | |
| 35 | + ''' Returns the cached ResourceManager instance used by this class. | |
| 36 | + '''</summary> | |
| 37 | + <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
| 38 | + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager | |
| 39 | + Get | |
| 40 | + If Object.ReferenceEquals(resourceMan, Nothing) Then | |
| 41 | + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("vbGofSample.Resources", GetType(Resources).Assembly) | |
| 42 | + resourceMan = temp | |
| 43 | + End If | |
| 44 | + Return resourceMan | |
| 45 | + End Get | |
| 46 | + End Property | |
| 47 | + | |
| 48 | + '''<summary> | |
| 49 | + ''' Overrides the current thread's CurrentUICulture property for all | |
| 50 | + ''' resource lookups using this strongly typed resource class. | |
| 51 | + '''</summary> | |
| 52 | + <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
| 53 | + Friend Property Culture() As Global.System.Globalization.CultureInfo | |
| 54 | + Get | |
| 55 | + Return resourceCulture | |
| 56 | + End Get | |
| 57 | + Set(ByVal value As Global.System.Globalization.CultureInfo) | |
| 58 | + resourceCulture = value | |
| 59 | + End Set | |
| 60 | + End Property | |
| 61 | + End Module | |
| 62 | +End Namespace |
| @@ -0,0 +1,35 @@ | ||
| 1 | +Imports System | |
| 2 | +Imports System.Reflection | |
| 3 | +Imports System.Runtime.InteropServices | |
| 4 | + | |
| 5 | +' アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 | |
| 6 | +' アセンブリに関連付けられている情報を変更するには、 | |
| 7 | +' これらの属性値を変更してください。 | |
| 8 | + | |
| 9 | +' アセンブリ属性の値を確認します。 | |
| 10 | + | |
| 11 | +<Assembly: AssemblyTitle("vbGofSample")> | |
| 12 | +<Assembly: AssemblyDescription("")> | |
| 13 | +<Assembly: AssemblyCompany("")> | |
| 14 | +<Assembly: AssemblyProduct("vbGofSample")> | |
| 15 | +<Assembly: AssemblyCopyright("Copyright © 2014")> | |
| 16 | +<Assembly: AssemblyTrademark("")> | |
| 17 | + | |
| 18 | +<Assembly: ComVisible(False)> | |
| 19 | + | |
| 20 | +'このプロジェクトが COM に公開される場合、次の GUID がタイプ ライブラリの ID になります。 | |
| 21 | +<Assembly: Guid("e422e71a-8ce0-4fa4-9083-2bcb0443b4d2")> | |
| 22 | + | |
| 23 | +' アセンブリのバージョン情報は、以下の 4 つの値で構成されています: | |
| 24 | +' | |
| 25 | +' Major Version | |
| 26 | +' Minor Version | |
| 27 | +' Build Number | |
| 28 | +' Revision | |
| 29 | +' | |
| 30 | +' すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を | |
| 31 | +' 既定値にすることができます: | |
| 32 | +' <Assembly: AssemblyVersion("1.0.*")> | |
| 33 | + | |
| 34 | +<Assembly: AssemblyVersion("1.0.0.0")> | |
| 35 | +<Assembly: AssemblyFileVersion("1.0.0.0")> |
| @@ -0,0 +1,73 @@ | ||
| 1 | +'------------------------------------------------------------------------------ | |
| 2 | +' <auto-generated> | |
| 3 | +' This code was generated by a tool. | |
| 4 | +' Runtime Version:4.0.30319.18444 | |
| 5 | +' | |
| 6 | +' Changes to this file may cause incorrect behavior and will be lost if | |
| 7 | +' the code is regenerated. | |
| 8 | +' </auto-generated> | |
| 9 | +'------------------------------------------------------------------------------ | |
| 10 | + | |
| 11 | +Option Strict On | |
| 12 | +Option Explicit On | |
| 13 | + | |
| 14 | + | |
| 15 | +Namespace My | |
| 16 | + | |
| 17 | + <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ | |
| 18 | + Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0"), _ | |
| 19 | + Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
| 20 | + Partial Friend NotInheritable Class MySettings | |
| 21 | + Inherits Global.System.Configuration.ApplicationSettingsBase | |
| 22 | + | |
| 23 | + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) | |
| 24 | + | |
| 25 | +#Region "My.Settings Auto-Save Functionality" | |
| 26 | +#If _MyType = "WindowsForms" Then | |
| 27 | + Private Shared addedHandler As Boolean | |
| 28 | + | |
| 29 | + Private Shared addedHandlerLockObject As New Object | |
| 30 | + | |
| 31 | + <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ | |
| 32 | + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) | |
| 33 | + If My.Application.SaveMySettingsOnExit Then | |
| 34 | + My.Settings.Save() | |
| 35 | + End If | |
| 36 | + End Sub | |
| 37 | +#End If | |
| 38 | +#End Region | |
| 39 | + | |
| 40 | + Public Shared ReadOnly Property [Default]() As MySettings | |
| 41 | + Get | |
| 42 | + | |
| 43 | +#If _MyType = "WindowsForms" Then | |
| 44 | + If Not addedHandler Then | |
| 45 | + SyncLock addedHandlerLockObject | |
| 46 | + If Not addedHandler Then | |
| 47 | + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings | |
| 48 | + addedHandler = True | |
| 49 | + End If | |
| 50 | + End SyncLock | |
| 51 | + End If | |
| 52 | +#End If | |
| 53 | + Return defaultInstance | |
| 54 | + End Get | |
| 55 | + End Property | |
| 56 | + End Class | |
| 57 | +End Namespace | |
| 58 | + | |
| 59 | +Namespace My | |
| 60 | + | |
| 61 | + <Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _ | |
| 62 | + Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ | |
| 63 | + Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _ | |
| 64 | + Friend Module MySettingsProperty | |
| 65 | + | |
| 66 | + <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _ | |
| 67 | + Friend ReadOnly Property Settings() As Global.vbGofSample.My.MySettings | |
| 68 | + Get | |
| 69 | + Return Global.vbGofSample.My.MySettings.Default | |
| 70 | + End Get | |
| 71 | + End Property | |
| 72 | + End Module | |
| 73 | +End Namespace |