From 505d9174828a5192b407c23b5899412a22d7b087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D1=81=D1=82=D0=B0=D0=BD=D1=82=D0=B8?= =?UTF-8?q?=D0=BD=20=D0=94=D1=8C=D1=8F=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Sun, 14 Jul 2019 19:18:05 +0300 Subject: [PATCH] Initial code commit, forked from: https://github.com/Konard/LinksPlatform --- Platform.Ranges.csproj | 24 +++++++++++++ Platform.Ranges.sln | 25 ++++++++++++++ Range.cs | 77 ++++++++++++++++++++++++++++++++++++++++++ push-nuget.bat | 8 +++++ 4 files changed, 134 insertions(+) create mode 100644 Platform.Ranges.csproj create mode 100644 Platform.Ranges.sln create mode 100644 Range.cs create mode 100644 push-nuget.bat diff --git a/Platform.Ranges.csproj b/Platform.Ranges.csproj new file mode 100644 index 0000000..1fa0372 --- /dev/null +++ b/Platform.Ranges.csproj @@ -0,0 +1,24 @@ + + + + LinksPlatform's Platform.Ranges Class Library + Konstantin Diachenko + Platform.Ranges + 0.0.1 + Konstantin Diachenko + netstandard2.0 + Platform.Ranges + Platform.Ranges + LinksPlatform;Ranges;Range + https://raw.githubusercontent.com/linksplatform/Documentation/d65e8dd6e1b647405bc3d33687172e79b70e3435/doc/Avatar-rainbow.png + https://github.com/linksplatform/Ranges + https://github.com/linksplatform/Ranges/blob/master/LICENSE + true + git + git://github.com/linksplatform/Ranges + false + false + false + + + diff --git a/Platform.Ranges.sln b/Platform.Ranges.sln new file mode 100644 index 0000000..b8b0e1f --- /dev/null +++ b/Platform.Ranges.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29020.237 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Platform.Ranges", "Platform.Ranges.csproj", "{37333E88-7378-427D-AFA6-3159F5F9628E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {37333E88-7378-427D-AFA6-3159F5F9628E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {37333E88-7378-427D-AFA6-3159F5F9628E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {37333E88-7378-427D-AFA6-3159F5F9628E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {37333E88-7378-427D-AFA6-3159F5F9628E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4988D786-1DD3-408A-8E42-10D0F3F65B40} + EndGlobalSection +EndGlobal diff --git a/Range.cs b/Range.cs new file mode 100644 index 0000000..2388b5b --- /dev/null +++ b/Range.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; + +namespace Platform.Ranges +{ + /// + /// Represents a range between minumum and maximum values. + /// Представляет диапазон между минимальным и максимальным значениями. + /// + /// + /// Based on http://stackoverflow.com/questions/5343006/is-there-a-c-sharp-type-for-representing-an-integer-range + /// + public struct Range + { + private static readonly Comparer _comparer = Comparer.Default; + + /// + /// Returns minimum value of the range. + /// Возвращает минимальное значение диапазона. + /// + public readonly T Minimum; + + /// + /// Returns maximum value of the range. + /// Возвращает максимальное значение диапазона. + /// + public readonly T Maximum; + + public Range(T minimumAndMaximum) + { + Minimum = minimumAndMaximum; + Maximum = minimumAndMaximum; + } + + public Range(T minimum, T maximum) + { + Minimum = minimum; + Maximum = maximum; + } + + /// + /// Presents the Range in readable format. + /// Представляет диапазон в удобном для чтения формате. + /// + /// String representation of the Range. Строковое представление диапазона. + public override string ToString() => $"[{Minimum}, {Maximum}]"; + + /// + /// Determines if the range is valid. Определяет, является ли диапазон корректным. + /// + /// True if range is valid, else false. True, если диапазон корректный, иначе false. + public bool IsValid() => _comparer.Compare(Minimum, Maximum) <= 0; + + /// + /// Determines if the provided value is inside the range. + /// Определяет, находится ли указанное значение внутри диапазона. + /// + /// The value to test. Значение для проверки. + /// True if the value is inside Range, else false. True, если значение находится внутри диапазона, иначе false. + public bool ContainsValue(T value) => _comparer.Compare(Minimum, value) <= 0 && _comparer.Compare(Maximum, value) >= 0; + + /// + /// Determines if this Range is inside the bounds of another range. + /// Определяет, находится ли этот диапазон в пределах другого диапазона. + /// + /// The parent range to test on. Родительский диапазон для проверки. + /// True if range is inclusive, else false. True, если диапазон включен, иначе false. + public bool IsInsideRange(Range range) => range.ContainsRange(this); + + /// + /// Determines if another range is inside the bounds of this range. + /// Определяет, находится ли другой диапазон внутри границ этого диапазона. + /// + /// The child range to test. Дочерний диапазон для проверки. + /// True if range is inside, else false. True, если диапазон находится внутри, иначе false. + public bool ContainsRange(Range range) => IsValid() && range.IsValid() && ContainsValue(range.Minimum) && ContainsValue(range.Maximum); + } +} diff --git a/push-nuget.bat b/push-nuget.bat new file mode 100644 index 0000000..657f820 --- /dev/null +++ b/push-nuget.bat @@ -0,0 +1,8 @@ +dotnet pack -c Release --include-symbols +cd bin\Release +dotnet nuget push -s https://api.nuget.org/v3/index.json *.symbols.nupkg +del *.symbols.nupkg +dotnet nuget push -s https://api.nuget.org/v3/index.json *.nupkg +del *.nupkg +cd .. +cd .. \ No newline at end of file