Skip to content

Commit

Permalink
Preparing version 4.1.0
Browse files Browse the repository at this point in the history
- Converted most examples projects to .NetCore 2.2 apps
  • Loading branch information
danm-de committed May 24, 2019
1 parent a49201c commit 4fefa76
Show file tree
Hide file tree
Showing 87 changed files with 1,212 additions and 2,738 deletions.
7 changes: 0 additions & 7 deletions Examples/CardStatus/App.config

This file was deleted.

60 changes: 7 additions & 53 deletions Examples/CardStatus/CardStatus.csproj
Original file line number Diff line number Diff line change
@@ -1,58 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0CC8FDCD-10CF-4C5A-8E66-9ADAFB54080F}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>CardStatus</RootNamespace>
<AssemblyName>CardStatus</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\PCSC\PCSC.csproj">
<Project>{d0bc6275-c71b-4987-a28d-f9e9bda861e7}</Project>
<Name>PCSC</Name>
</ProjectReference>
</ItemGroup>

<ItemGroup>
<Content Include="App.config" />
<ProjectReference Include="..\..\src\PCSC\PCSC.csproj" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

</Project>
27 changes: 13 additions & 14 deletions Examples/CardStatus/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
using System.Linq;
using PCSC;

namespace CardStatus
{
public class Program
{
namespace CardStatus {
public class Program {
public static void Main() {
var contextFactory = ContextFactory.Instance;

using (var context = contextFactory.Establish(SCardScope.System)) {
var readerNames = context.GetReaders();

if (NoReaderFound(readerNames)) {
if (IsEmpty(readerNames)) {
Console.WriteLine("No readers found.");
Console.ReadKey();
return;
}

DisplayReaderStatus(context, readerNames);

Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}

/// <summary>
/// Displays the card status of each reader in <paramref name="readerNames"/>
/// </summary>
/// <param name="context">Smartcard context to connect</param>
/// <param name="readerNames">Smartcard readers</param>
/// <param name="context">Smart-card context to connect</param>
/// <param name="readerNames">Smart-card readers</param>
private static void DisplayReaderStatus(ISCardContext context, IEnumerable<string> readerNames) {
foreach (var readerName in readerNames) {
try {
Expand All @@ -37,9 +37,9 @@ private static void DisplayReaderStatus(ISCardContext context, IEnumerable<strin
Console.WriteLine();
}
} catch (Exception exception) {
Console.WriteLine(
Console.Error.WriteLine(
"No card inserted or reader '{0}' is reserved exclusively by another application.", readerName);
Console.WriteLine("Error message: {0} ({1})\n", exception.Message, exception.GetType());
Console.Error.WriteLine("Error message: {0} ({1})\n", exception.Message, exception.GetType());
}
}
}
Expand All @@ -57,13 +57,13 @@ private static void PrintReaderStatus(ICardReader reader) {
status.State);
PrintCardAtr(status.GetAtr());
} catch (Exception exception) {
Console.WriteLine("Unable to retrieve card status.\nError message: {0} ({1}", exception,
Console.Error.WriteLine("Unable to retrieve card status.\nError message: {0} ({1}", exception,
exception.GetType());
}
}

/// <summary>
/// Prints the smartcard's ATR as hex string
/// Prints the smart-card's ATR as hex string
/// </summary>
/// <param name="atr">ATR bytes</param>
private static void PrintCardAtr(byte[] atr) {
Expand All @@ -77,9 +77,8 @@ private static void PrintCardAtr(byte[] atr) {
/// <summary>
/// Returns <c>true</c> if the supplied collection <paramref name="readerNames"/> does not contain any reader.
/// </summary>
/// <param name="readerNames">Collection of smartcard reader names</param>
/// <param name="readerNames">Collection of smart-card reader names</param>
/// <returns><c>true</c> if no reader found</returns>
private static bool NoReaderFound(ICollection<string> readerNames) =>
readerNames == null || readerNames.Count < 1;
private static bool IsEmpty(ICollection<string> readerNames) => readerNames == null || readerNames.Count < 1;
}
}
18 changes: 0 additions & 18 deletions Examples/CardStatus/Properties/AssemblyInfo.cs

This file was deleted.

6 changes: 0 additions & 6 deletions Examples/ConnectedReaderStatus/App.config

This file was deleted.

60 changes: 7 additions & 53 deletions Examples/ConnectedReaderStatus/ConnectedReaderStatus.csproj
Original file line number Diff line number Diff line change
@@ -1,58 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5E8D4452-E8F3-4160-BCD2-3C6EEE1B73C8}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConnectedReaderStatus</RootNamespace>
<AssemblyName>ConnectedReaderStatus</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\PCSC\PCSC.csproj">
<Project>{d0bc6275-c71b-4987-a28d-f9e9bda861e7}</Project>
<Name>PCSC</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\PCSC\PCSC.csproj" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

</Project>
11 changes: 5 additions & 6 deletions Examples/ConnectedReaderStatus/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
using System.Linq;
using PCSC;

namespace ConnectedReaderStatus
{
class Program
{
namespace ConnectedReaderStatus {
class Program {
static void Main(string[] args) {
using (var ctx = ContextFactory.Instance.Establish(SCardScope.User)) {
var firstReader = ctx
Expand All @@ -24,9 +22,10 @@ static void Main(string[] args) {
Console.WriteLine($"Protocol: {status.Protocol}");
Console.WriteLine($"State: {status.State}");
Console.WriteLine($"ATR: {BitConverter.ToString(status.GetAtr() ?? new byte[0])}");

Console.ReadKey();
}

Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
Expand Down
36 changes: 0 additions & 36 deletions Examples/ConnectedReaderStatus/Properties/AssemblyInfo.cs

This file was deleted.

7 changes: 0 additions & 7 deletions Examples/GetReaderAttrib/App.config

This file was deleted.

60 changes: 7 additions & 53 deletions Examples/GetReaderAttrib/GetReaderAttrib.csproj
Original file line number Diff line number Diff line change
@@ -1,58 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{ECD5D8CD-77B2-4825-85BB-3CBDDBA58F0E}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>GetReaderAttrib</RootNamespace>
<AssemblyName>GetReaderAttrib</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\PCSC\PCSC.csproj">
<Project>{d0bc6275-c71b-4987-a28d-f9e9bda861e7}</Project>
<Name>PCSC</Name>
</ProjectReference>
</ItemGroup>

<ItemGroup>
<Content Include="App.config" />
<ProjectReference Include="..\..\src\PCSC\PCSC.csproj" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

</Project>
Loading

0 comments on commit 4fefa76

Please sign in to comment.