Skip to content

Commit b85fd23

Browse files
committed
added VB .NET demo
1 parent 091e9f8 commit b85fd23

15 files changed

+513
-0
lines changed

CSVSerializer.NET.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.CS", "Demo.CS\Demo.CS.
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSVSerializer", "CSVSerializer.NET\CSVSerializer.csproj", "{0C962C28-B003-49A6-8991-1E6636583EFE}"
99
EndProject
10+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Demo.VB", "Demo.VB\Demo.VB.vbproj", "{E3A91926-2FAF-4580-81AB-67C2D864CCE0}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
2123
{0C962C28-B003-49A6-8991-1E6636583EFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{0C962C28-B003-49A6-8991-1E6636583EFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{0C962C28-B003-49A6-8991-1E6636583EFE}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{E3A91926-2FAF-4580-81AB-67C2D864CCE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{E3A91926-2FAF-4580-81AB-67C2D864CCE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{E3A91926-2FAF-4580-81AB-67C2D864CCE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{E3A91926-2FAF-4580-81AB-67C2D864CCE0}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE

Demo.VB/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

Demo.VB/Demo.VB.vbproj

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{E3A91926-2FAF-4580-81AB-67C2D864CCE0}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<StartupObject>Demo.VB.MainModule</StartupObject>
10+
<RootNamespace>Demo.VB</RootNamespace>
11+
<AssemblyName>Demo.VB</AssemblyName>
12+
<FileAlignment>512</FileAlignment>
13+
<MyType>Console</MyType>
14+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<DefineDebug>true</DefineDebug>
21+
<DefineTrace>true</DefineTrace>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DocumentationFile>Demo.VB.xml</DocumentationFile>
24+
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<DefineDebug>false</DefineDebug>
30+
<DefineTrace>true</DefineTrace>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DocumentationFile>Demo.VB.xml</DocumentationFile>
34+
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
35+
</PropertyGroup>
36+
<PropertyGroup>
37+
<OptionExplicit>On</OptionExplicit>
38+
</PropertyGroup>
39+
<PropertyGroup>
40+
<OptionCompare>Binary</OptionCompare>
41+
</PropertyGroup>
42+
<PropertyGroup>
43+
<OptionStrict>Off</OptionStrict>
44+
</PropertyGroup>
45+
<PropertyGroup>
46+
<OptionInfer>On</OptionInfer>
47+
</PropertyGroup>
48+
<ItemGroup>
49+
<Reference Include="System" />
50+
<Reference Include="System.Data" />
51+
<Reference Include="System.Deployment" />
52+
<Reference Include="System.Xml" />
53+
<Reference Include="System.Core" />
54+
<Reference Include="System.Xml.Linq" />
55+
<Reference Include="System.Data.DataSetExtensions" />
56+
<Reference Include="System.Net.Http" />
57+
</ItemGroup>
58+
<ItemGroup>
59+
<Import Include="Microsoft.VisualBasic" />
60+
<Import Include="System" />
61+
<Import Include="System.Collections" />
62+
<Import Include="System.Collections.Generic" />
63+
<Import Include="System.Data" />
64+
<Import Include="System.Diagnostics" />
65+
<Import Include="System.Linq" />
66+
<Import Include="System.Xml.Linq" />
67+
<Import Include="System.Threading.Tasks" />
68+
</ItemGroup>
69+
<ItemGroup>
70+
<Compile Include="MainModule.vb" />
71+
<Compile Include="My Project\AssemblyInfo.vb" />
72+
<Compile Include="My Project\Application.Designer.vb">
73+
<AutoGen>True</AutoGen>
74+
<DependentUpon>Application.myapp</DependentUpon>
75+
</Compile>
76+
<Compile Include="My Project\Resources.Designer.vb">
77+
<AutoGen>True</AutoGen>
78+
<DesignTime>True</DesignTime>
79+
<DependentUpon>Resources.resx</DependentUpon>
80+
</Compile>
81+
<Compile Include="My Project\Settings.Designer.vb">
82+
<AutoGen>True</AutoGen>
83+
<DependentUpon>Settings.settings</DependentUpon>
84+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
85+
</Compile>
86+
</ItemGroup>
87+
<ItemGroup>
88+
<EmbeddedResource Include="My Project\Resources.resx">
89+
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
90+
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
91+
<CustomToolNamespace>My.Resources</CustomToolNamespace>
92+
<SubType>Designer</SubType>
93+
</EmbeddedResource>
94+
</ItemGroup>
95+
<ItemGroup>
96+
<None Include="My Project\Application.myapp">
97+
<Generator>MyApplicationCodeGenerator</Generator>
98+
<LastGenOutput>Application.Designer.vb</LastGenOutput>
99+
</None>
100+
<None Include="My Project\Settings.settings">
101+
<Generator>SettingsSingleFileGenerator</Generator>
102+
<CustomToolNamespace>My</CustomToolNamespace>
103+
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
104+
</None>
105+
<None Include="App.config" />
106+
<None Include="users.csv" />
107+
</ItemGroup>
108+
<ItemGroup>
109+
<ProjectReference Include="..\CSVSerializer.NET\CSVSerializer.csproj">
110+
<Project>{0c962c28-b003-49a6-8991-1e6636583efe}</Project>
111+
<Name>CSVSerializer</Name>
112+
</ProjectReference>
113+
</ItemGroup>
114+
<ItemGroup />
115+
<ItemGroup>
116+
<Content Include="Media\Document-format.png" />
117+
<Content Include="Media\usage-step1.gif" />
118+
<Content Include="Media\usage-step2.gif" />
119+
</ItemGroup>
120+
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
121+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
122+
Other similar extension points exist, see Microsoft.Common.targets.
123+
<Target Name="BeforeBuild">
124+
</Target>
125+
<Target Name="AfterBuild">
126+
</Target>
127+
-->
128+
</Project>

Demo.VB/MainModule.vb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Imports CSVSerializer
2+
Imports System.IO
3+
Module MainModule
4+
5+
Sub Main()
6+
Const fileName As String = "users.csv"
7+
8+
' 1. Make sure the file exists, the exception Is Not handled
9+
If (Not File.Exists(fileName)) Then
10+
Console.WriteLine("File not found!")
11+
GoTo exitProgram
12+
End If
13+
14+
' 2. Create a deserializer object with the file name as argument for the constructor
15+
Dim deserializer As New Deserializer(fileName)
16+
17+
' 3. Use Document type to organize the extracted values
18+
Dim doc As Document = deserializer.Deserialize()
19+
20+
' 4. Loop through the headers
21+
For Each s In doc.Headers
22+
Console.Write(s + vbTab)
23+
Next
24+
Console.WriteLine("")
25+
26+
' 5. Loop through the rows
27+
For Each r In doc.Rows
28+
29+
' 6. Loop through the values
30+
For Each v In r.Values
31+
Console.Write(v.ToString() + vbTab)
32+
Next
33+
Console.WriteLine("")
34+
Next
35+
36+
'Let's change some stuff...
37+
doc.Rows(0).UpdateValue(0, New Value(Of Object)("Michael"))
38+
doc.Rows(0).UpdateValue(2, New Value(Of Object)(64))
39+
40+
' 7. Serializer part - Create a serializer
41+
Dim Serializer As New Serializer(doc, "users_.csv")
42+
Serialize(Serializer) 'TODO: doesn't work
43+
exitProgram: Console.ReadLine()
44+
End Sub
45+
'we need to create another method because Main can't be async
46+
Private Async Sub Serialize(ByVal s As Serializer)
47+
If Await s.Serialize() Then
48+
Console.WriteLine("Successfully serialized")
49+
Else
50+
Console.WriteLine("An error has occurred")
51+
End If
52+
End Sub
53+
End Module

Demo.VB/Media/Document-format.png

184 KB
Loading

Demo.VB/Media/usage-step1.gif

1.02 MB
Loading

Demo.VB/Media/usage-step2.gif

489 KB
Loading

Demo.VB/My Project/Application.Designer.vb

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<MySubMain>false</MySubMain>
4+
<SingleInstance>false</SingleInstance>
5+
<ShutdownMode>0</ShutdownMode>
6+
<EnableVisualStyles>true</EnableVisualStyles>
7+
<AuthenticationMode>0</AuthenticationMode>
8+
<ApplicationType>2</ApplicationType>
9+
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
10+
</MyApplicationData>

Demo.VB/My Project/AssemblyInfo.vb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Imports System
2+
Imports System.Reflection
3+
Imports System.Runtime.InteropServices
4+
5+
' General Information about an assembly is controlled through the following
6+
' set of attributes. Change these attribute values to modify the information
7+
' associated with an assembly.
8+
9+
' Review the values of the assembly attributes
10+
11+
<Assembly: AssemblyTitle("Demo.VB")>
12+
<Assembly: AssemblyDescription("")>
13+
<Assembly: AssemblyCompany("")>
14+
<Assembly: AssemblyProduct("Demo.VB")>
15+
<Assembly: AssemblyCopyright("Copyright © 2016")>
16+
<Assembly: AssemblyTrademark("")>
17+
18+
<Assembly: ComVisible(False)>
19+
20+
'The following GUID is for the ID of the typelib if this project is exposed to COM
21+
<Assembly: Guid("264804da-60a1-440c-8aac-d25152c3c258")>
22+
23+
' Version information for an assembly consists of the following four values:
24+
'
25+
' Major Version
26+
' Minor Version
27+
' Build Number
28+
' Revision
29+
'
30+
' You can specify all the values or you can default the Build and Revision Numbers
31+
' by using the '*' as shown below:
32+
' <Assembly: AssemblyVersion("1.0.*")>
33+
34+
<Assembly: AssemblyVersion("1.0.0.0")>
35+
<Assembly: AssemblyFileVersion("1.0.0.0")>

0 commit comments

Comments
 (0)