Loading Generics in .NET - Working Files/Chapter 1/Introduction.sln 0 → 100755 +22 −0 Changes for Generics in .NET - Working Files/Chapter 1/Introduction.sln: 22 added lines, 0 removed lines. Original line number Diff line number Diff line Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Introduction", "Introduction\Introduction.csproj", "{F2AF7590-0298-4F8F-9410-034308A38AF0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {F2AF7590-0298-4F8F-9410-034308A38AF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F2AF7590-0298-4F8F-9410-034308A38AF0}.Debug|Any CPU.Build.0 = Debug|Any CPU {F2AF7590-0298-4F8F-9410-034308A38AF0}.Release|Any CPU.ActiveCfg = Release|Any CPU {F2AF7590-0298-4F8F-9410-034308A38AF0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal Generics in .NET - Working Files/Chapter 1/Introduction/Examples/ListExample.cs 0 → 100755 +36 −0 Changes for Generics in .NET - Working Files/Chapter 1/Introduction/Examples/ListExample.cs: 36 added lines, 0 removed lines. Original line number Diff line number Diff line using System.Collections; using System.Collections.Generic; using System.Diagnostics; namespace Introduction.Examples { public class Person { public string FirstName { get; set; } public string LastName { get; set; } } public static class ListExample { public static void NonGenericList() { ArrayList list = new ArrayList { new Person {FirstName = "Cheryl", LastName = "Smith"}, new Person {FirstName = "John", LastName = "Jones"}, new object() }; Write( ( list[ 0 ] as Person ).FirstName ); } public static void GenericList() { List<Person> list = new List<Person> { new Person {FirstName = "Cheryl", LastName = "Smith"}, new Person {FirstName = "John", LastName = "Jones"}, //new object() }; Write( list[ 0 ].FirstName ); } private static void Write( string toWrite ) { Debug.WriteLine( toWrite ); } } } No newline at end of file Generics in .NET - Working Files/Chapter 1/Introduction/Introduction.csproj 0 → 100755 +72 −0 Changes for Generics in .NET - Working Files/Chapter 1/Introduction/Introduction.csproj: 72 added lines, 0 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{F2AF7590-0298-4F8F-9410-034308A38AF0}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Introduction</RootNamespace> <AssemblyName>Introduction</AssemblyName> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="FluentAssertions"> <HintPath>..\packages\FluentAssertions.3.4.1\lib\net45\FluentAssertions.dll</HintPath> </Reference> <Reference Include="FluentAssertions.Core"> <HintPath>..\packages\FluentAssertions.3.4.1\lib\net45\FluentAssertions.Core.dll</HintPath> </Reference> <Reference Include="nunit.framework"> <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> <Reference Include="Telerik.JustMock"> <HintPath>..\packages\JustMock.2015.2.715.1\lib\Net35\Telerik.JustMock.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <Compile Include="Examples\ListExample.cs" /> <Compile Include="Tests\SampleTests.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="packages.config" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project> No newline at end of file Generics in .NET - Working Files/Chapter 1/Introduction/Properties/AssemblyInfo.cs 0 → 100755 +36 −0 Changes for Generics in .NET - Working Files/Chapter 1/Introduction/Properties/AssemblyInfo.cs: 36 added lines, 0 removed lines. Original line number Diff line number Diff line using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Introduction")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Hewlett-Packard")] [assembly: AssemblyProduct("Introduction")] [assembly: AssemblyCopyright("Copyright © Hewlett-Packard 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("8926ab6b-26d1-4672-bb6d-487b5090fb08")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] Generics in .NET - Working Files/Chapter 1/Introduction/Tests/SampleTests.cs 0 → 100755 +45 −0 Changes for Generics in .NET - Working Files/Chapter 1/Introduction/Tests/SampleTests.cs: 45 added lines, 0 removed lines. Original line number Diff line number Diff line using System; using FluentAssertions; using NUnit.Framework; namespace Introduction.Tests { [TestFixture] public class SampleTests { private int _y; [SetUp] public void BeforeEachTest() { _y = 56; } [Test] public void CompareIntegerTest() { int x = 42; x.Should().Be( 42 ); } [Test] public void CompareIntegerFieldTest() { _y.Should().Be( 56 ); } [Test] public void CompareCollectionTest() { string[] names = {"John", "Cheryl", "Susie"}; string[] othernames = {"Cheryl", "John", "Susie"}; names.Should().NotBeEmpty().And.HaveCount( 3 ); names.Should().BeEquivalentTo( othernames ); } [Test] public void ThrowExceptionTest() { Action action = () => { throw new Exception( "Some exception" ); }; action.ShouldThrow<Exception>().WithMessage( "Some Exception" ); } } } No newline at end of file Loading
Generics in .NET - Working Files/Chapter 1/Introduction.sln 0 → 100755 +22 −0 Changes for Generics in .NET - Working Files/Chapter 1/Introduction.sln: 22 added lines, 0 removed lines. Original line number Diff line number Diff line Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Introduction", "Introduction\Introduction.csproj", "{F2AF7590-0298-4F8F-9410-034308A38AF0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {F2AF7590-0298-4F8F-9410-034308A38AF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F2AF7590-0298-4F8F-9410-034308A38AF0}.Debug|Any CPU.Build.0 = Debug|Any CPU {F2AF7590-0298-4F8F-9410-034308A38AF0}.Release|Any CPU.ActiveCfg = Release|Any CPU {F2AF7590-0298-4F8F-9410-034308A38AF0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal
Generics in .NET - Working Files/Chapter 1/Introduction/Examples/ListExample.cs 0 → 100755 +36 −0 Changes for Generics in .NET - Working Files/Chapter 1/Introduction/Examples/ListExample.cs: 36 added lines, 0 removed lines. Original line number Diff line number Diff line using System.Collections; using System.Collections.Generic; using System.Diagnostics; namespace Introduction.Examples { public class Person { public string FirstName { get; set; } public string LastName { get; set; } } public static class ListExample { public static void NonGenericList() { ArrayList list = new ArrayList { new Person {FirstName = "Cheryl", LastName = "Smith"}, new Person {FirstName = "John", LastName = "Jones"}, new object() }; Write( ( list[ 0 ] as Person ).FirstName ); } public static void GenericList() { List<Person> list = new List<Person> { new Person {FirstName = "Cheryl", LastName = "Smith"}, new Person {FirstName = "John", LastName = "Jones"}, //new object() }; Write( list[ 0 ].FirstName ); } private static void Write( string toWrite ) { Debug.WriteLine( toWrite ); } } } No newline at end of file
Generics in .NET - Working Files/Chapter 1/Introduction/Introduction.csproj 0 → 100755 +72 −0 Changes for Generics in .NET - Working Files/Chapter 1/Introduction/Introduction.csproj: 72 added lines, 0 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{F2AF7590-0298-4F8F-9410-034308A38AF0}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Introduction</RootNamespace> <AssemblyName>Introduction</AssemblyName> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="FluentAssertions"> <HintPath>..\packages\FluentAssertions.3.4.1\lib\net45\FluentAssertions.dll</HintPath> </Reference> <Reference Include="FluentAssertions.Core"> <HintPath>..\packages\FluentAssertions.3.4.1\lib\net45\FluentAssertions.Core.dll</HintPath> </Reference> <Reference Include="nunit.framework"> <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> <Reference Include="Telerik.JustMock"> <HintPath>..\packages\JustMock.2015.2.715.1\lib\Net35\Telerik.JustMock.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <Compile Include="Examples\ListExample.cs" /> <Compile Include="Tests\SampleTests.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <None Include="packages.config" /> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project> No newline at end of file
Generics in .NET - Working Files/Chapter 1/Introduction/Properties/AssemblyInfo.cs 0 → 100755 +36 −0 Changes for Generics in .NET - Working Files/Chapter 1/Introduction/Properties/AssemblyInfo.cs: 36 added lines, 0 removed lines. Original line number Diff line number Diff line using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Introduction")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Hewlett-Packard")] [assembly: AssemblyProduct("Introduction")] [assembly: AssemblyCopyright("Copyright © Hewlett-Packard 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("8926ab6b-26d1-4672-bb6d-487b5090fb08")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
Generics in .NET - Working Files/Chapter 1/Introduction/Tests/SampleTests.cs 0 → 100755 +45 −0 Changes for Generics in .NET - Working Files/Chapter 1/Introduction/Tests/SampleTests.cs: 45 added lines, 0 removed lines. Original line number Diff line number Diff line using System; using FluentAssertions; using NUnit.Framework; namespace Introduction.Tests { [TestFixture] public class SampleTests { private int _y; [SetUp] public void BeforeEachTest() { _y = 56; } [Test] public void CompareIntegerTest() { int x = 42; x.Should().Be( 42 ); } [Test] public void CompareIntegerFieldTest() { _y.Should().Be( 56 ); } [Test] public void CompareCollectionTest() { string[] names = {"John", "Cheryl", "Susie"}; string[] othernames = {"Cheryl", "John", "Susie"}; names.Should().NotBeEmpty().And.HaveCount( 3 ); names.Should().BeEquivalentTo( othernames ); } [Test] public void ThrowExceptionTest() { Action action = () => { throw new Exception( "Some exception" ); }; action.ShouldThrow<Exception>().WithMessage( "Some Exception" ); } } } No newline at end of file