mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-05 14:25:37 +00:00
Initial commit
This commit is contained in:
parent
d0eb68594c
commit
c0d4d11b54
24 changed files with 463 additions and 0 deletions
37
vs4win/Chapter07/SharedLibrary/SharedLibrary.csproj
Normal file
37
vs4win/Chapter07/SharedLibrary/SharedLibrary.csproj
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageId>Packt.CSdotnet.SharedLibrary</PackageId>
|
||||
<PackageVersion>7.0.0.0</PackageVersion>
|
||||
<Title>C# 11 and .NET 7 Shared Library</Title>
|
||||
<Authors>Mark J Price</Authors>
|
||||
<PackageLicenseExpression>
|
||||
MS-PL
|
||||
</PackageLicenseExpression>
|
||||
<PackageProjectUrl>
|
||||
https://github.com/markjprice/cs11dotnet7
|
||||
</PackageProjectUrl>
|
||||
<PackageIcon>packt-csdotnet-sharedlibrary.png</PackageIcon>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<PackageReleaseNotes>
|
||||
Example shared library packaged for NuGet.
|
||||
</PackageReleaseNotes>
|
||||
<Description>
|
||||
Three extension methods to validate a string value.
|
||||
</Description>
|
||||
<Copyright>
|
||||
Copyright © 2016-2022 Packt Publishing Limited
|
||||
</Copyright>
|
||||
<PackageTags>string extensions packt csharp dotnet</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="packt-csdotnet-sharedlibrary.png">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath></PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
26
vs4win/Chapter07/SharedLibrary/StringExtensions.cs
Normal file
26
vs4win/Chapter07/SharedLibrary/StringExtensions.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Packt.Shared
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static bool IsValidXmlTag(this string input)
|
||||
{
|
||||
return Regex.IsMatch(input,
|
||||
@"^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$");
|
||||
}
|
||||
|
||||
public static bool IsValidPassword(this string input)
|
||||
{
|
||||
// minimum of eight valid characters
|
||||
return Regex.IsMatch(input, "^[a-zA-Z0-9_-]{8,}$");
|
||||
}
|
||||
|
||||
public static bool IsValidHex(this string input)
|
||||
{
|
||||
// three or six valid hex number characters
|
||||
return Regex.IsMatch(input,
|
||||
"^#?([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$");
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
vs4win/Chapter07/SharedLibrary/packt-csdotnet-sharedlibrary.png
Normal file
BIN
vs4win/Chapter07/SharedLibrary/packt-csdotnet-sharedlibrary.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Loading…
Add table
Add a link
Reference in a new issue