mirror of
https://github.com/tonytins/cstdotnet.git
synced 2025-04-30 10:11:40 -04:00
1.0.300
- Switched to Sixam.CST namespace and marked CSTNet namespace as obsolete. - Performance improvements.
This commit is contained in:
parent
e8f7bf4d0a
commit
2d310cee53
9 changed files with 56 additions and 42 deletions
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace CSTNet.Tests
|
namespace Sixam.CST.Tests
|
||||||
{
|
{
|
||||||
static class CSTHelper
|
static class CSTHelper
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace CSTNet.Tests
|
namespace Sixam.CST.Tests
|
||||||
{
|
{
|
||||||
public class MultilineTests
|
public class MultilineTests
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
// This project is licensed under the MIT license.
|
// This project is licensed under the MIT license.
|
||||||
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace CSTNet.Tests
|
namespace Sixam.CST.Tests
|
||||||
{
|
{
|
||||||
public class SingleLineTests
|
public class SingleLineTests
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
extensions: designer.cs generated.cs
|
|
||||||
extensions: .cs .cpp .h
|
|
||||||
// This project is licensed under the MIT license.
|
|
|
@ -1,26 +1,26 @@
|
||||||
// This project is licensed under the MIT license.
|
// This project is licensed under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace CSTNet
|
namespace Sixam.CST
|
||||||
{
|
{
|
||||||
public static class CaretSeparatedText
|
public class CaretSeparatedText
|
||||||
{
|
{
|
||||||
|
|
||||||
const char CARET = '^';
|
const char CARET = '^';
|
||||||
static readonly string _lf = "\u000A";
|
const string LF = "\u000A";
|
||||||
static readonly string _cr = "\u000D";
|
const string CR = "\u000D";
|
||||||
static readonly string _crlf = "\u000D\u000A";
|
const string CRLF = "\u000D\u000A";
|
||||||
static readonly string _ls = "\u2028";
|
const string LS = "\u2028";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the value from the integer-based key.
|
/// Gets the value from the digit-based key.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns the entry</returns>
|
/// <returns>Returns the entry</returns>
|
||||||
public static string Parse(string content, int key)
|
public static string Parse(string content, int key) => Parse(content, key.ToString());
|
||||||
{
|
|
||||||
var entries = NormalizeEntries(content);
|
|
||||||
return GetEntry(entries, key.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the value from the string-based key.
|
/// Gets the value from the string-based key.
|
||||||
|
@ -40,34 +40,28 @@ namespace CSTNet
|
||||||
{
|
{
|
||||||
if (!content.Contains(Environment.NewLine))
|
if (!content.Contains(Environment.NewLine))
|
||||||
{
|
{
|
||||||
if (content.Contains(_lf))
|
if (content.Contains(LF))
|
||||||
content = content.Replace(_lf, Environment.NewLine);
|
content = content.Replace(LF, Environment.NewLine);
|
||||||
|
|
||||||
if (content.Contains(_cr))
|
if (content.Contains(CR))
|
||||||
content = content.Replace(_cr, Environment.NewLine);
|
content = content.Replace(CR, Environment.NewLine);
|
||||||
|
|
||||||
if (content.Contains(_crlf))
|
if (content.Contains(CRLF))
|
||||||
content = content.Replace(_crlf, Environment.NewLine);
|
content = content.Replace(CRLF, Environment.NewLine);
|
||||||
|
|
||||||
if (content.Contains(_ls))
|
if (content.Contains(LS))
|
||||||
content = content.Replace(_ls, Environment.NewLine);
|
content = content.Replace(LS, Environment.NewLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
var lines = content.Split(new[] { $"{CARET}{Environment.NewLine}" },
|
var lines = content.Split(new[] { $"{CARET}{Environment.NewLine}" },
|
||||||
StringSplitOptions.RemoveEmptyEntries);
|
StringSplitOptions.RemoveEmptyEntries);
|
||||||
var entries = new List<string>();
|
|
||||||
|
|
||||||
foreach (var line in lines)
|
return lines.Where(line =>
|
||||||
{
|
!line.StartsWith("//") &&
|
||||||
// Skip comments
|
!line.StartsWith("#") &&
|
||||||
if (line.StartsWith("//") || line.StartsWith("#") ||
|
!line.StartsWith("/*") &&
|
||||||
line.StartsWith("/*") || line.EndsWith("*/"))
|
!line.EndsWith("*/"))
|
||||||
continue;
|
.AsEnumerable();
|
||||||
|
|
||||||
entries.Add(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
return entries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static string GetEntry(IEnumerable<string> entries, string key)
|
static string GetEntry(IEnumerable<string> entries, string key)
|
||||||
|
@ -90,3 +84,9 @@ namespace CSTNet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace CSTNet
|
||||||
|
{
|
||||||
|
[Obsolete("CaretSeparatedText has moved to the Sixam.CST namespace.")]
|
||||||
|
public class CaretSeparatedText : Sixam.CST.CaretSeparatedText { }
|
||||||
|
}
|
||||||
|
|
|
@ -2,9 +2,13 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Version>1.0.2</Version>
|
<Version>1.0.300</Version>
|
||||||
<Authors>Tony Bark</Authors>
|
<Authors>Tony Bark, Sixam Software</Authors>
|
||||||
<PackageDescription>Caret-Separated Text (or CST) is a key-value pair format represented by numbers or words as keys and the value is the string enclosed between carets (^) that contains the contents. CST.NET is a library for prasing the CST format.</PackageDescription>
|
<PackageDescription>
|
||||||
|
Caret-Separated Text (or CST) is a key-value pair format represented by numbers or words as keys and the value is the string enclosed between carets that contains the contents. ([key] ^[value]^)
|
||||||
|
|
||||||
|
CST.NET is a parser for the CST format.
|
||||||
|
</PackageDescription>
|
||||||
<RepositoryUrl>https://github.com/sixamsoft/cst-dotnet</RepositoryUrl>
|
<RepositoryUrl>https://github.com/sixamsoft/cst-dotnet</RepositoryUrl>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<Product>CST.Net</Product>
|
<Product>CST.Net</Product>
|
||||||
|
|
|
@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||||
.editorconfig = .editorconfig
|
.editorconfig = .editorconfig
|
||||||
changelog.md = changelog.md
|
changelog.md = changelog.md
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
|
Sixam.CST.sln.licenseheader = Sixam.CST.sln.licenseheader
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sixam.CST.Tests", "CSTNet.Tests\Sixam.CST.Tests.csproj", "{B6A98C64-1419-4B9A-99CA-72BB11D29472}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sixam.CST.Tests", "CSTNet.Tests\Sixam.CST.Tests.csproj", "{B6A98C64-1419-4B9A-99CA-72BB11D29472}"
|
||||||
|
|
4
Sixam.CST.sln.licenseheader
Normal file
4
Sixam.CST.sln.licenseheader
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
extensions: designer.cs generated.cs
|
||||||
|
extensions: .cs .cpp .h
|
||||||
|
// This project is licensed under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
|
@ -1,11 +1,18 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## 1.0.300
|
||||||
|
|
||||||
|
- Switched to Sixam.CST namespace and marked CSTNet namespace as obsolete.
|
||||||
|
- Performance improvements.
|
||||||
|
|
||||||
## 1.0.2
|
## 1.0.2
|
||||||
|
|
||||||
- Fixed the multiple line parsing in the v2 format.
|
- Fixed the multiple line parsing in the v2 format.
|
||||||
- Replaced "``[ENTRY NOT FOUND]``" message with "``***MISSING***``".
|
- Replaced "``[ENTRY NOT FOUND]``" message with "``***MISSING***``".
|
||||||
|
|
||||||
## 1.0.1
|
## 1.0.1
|
||||||
|
|
||||||
Despite only being a point release, this includes a major refinement to the normalizing algorithm.
|
Despite only being a patch release, this includes a major refinement to the normalizing algorithm.
|
||||||
|
|
||||||
### Rewrote normalizing algorithm
|
### Rewrote normalizing algorithm
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue