Update shared library to reference data library instead of separate nuget package

This commit is contained in:
RaidMax 2022-01-20 11:41:26 -06:00
parent bd27977b1e
commit a8d581eab7
2 changed files with 74 additions and 55 deletions

View File

@ -4,7 +4,7 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<PackageId>RaidMax.IW4MAdmin.SharedLibraryCore</PackageId> <PackageId>RaidMax.IW4MAdmin.SharedLibraryCore</PackageId>
<Version>2022.01.08.1</Version> <Version>2022.01.20.1</Version>
<Authors>RaidMax</Authors> <Authors>RaidMax</Authors>
<Company>Forever None</Company> <Company>Forever None</Company>
<Configurations>Debug;Release;Prerelease</Configurations> <Configurations>Debug;Release;Prerelease</Configurations>
@ -19,7 +19,7 @@
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>
<PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageLicenseExpression>MIT</PackageLicenseExpression>
<Description>Shared Library for IW4MAdmin</Description> <Description>Shared Library for IW4MAdmin</Description>
<PackageVersion>2022.01.08.1</PackageVersion> <PackageVersion>2022.01.08.2</PackageVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Prerelease|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Prerelease|AnyCPU'">
@ -44,13 +44,25 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.10"/> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.10"/>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.10"/> <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.10"/>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/> <PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
<PackageReference Include="RaidMax.IW4MAdmin.Data" Version="1.1.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0"/> <PackageReference Include="Serilog.AspNetCore" Version="3.4.0"/>
<PackageReference Include="SimpleCrypto.NetCore" Version="1.0.0"/> <PackageReference Include="SimpleCrypto.NetCore" Version="1.0.0"/>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Data\Data.csproj"/>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent"> <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="if not exist &quot;$(ProjectDir)..\BUILD&quot; (&#xD;&#xA;if $(ConfigurationName) == Debug (&#xD;&#xA;md &quot;$(ProjectDir)..\BUILD&quot;&#xD;&#xA;)&#xD;&#xA;)&#xD;&#xA;if not exist &quot;$(ProjectDir)..\BUILD\Plugins&quot; (&#xD;&#xA;if $(ConfigurationName) == Debug (&#xD;&#xA;md &quot;$(ProjectDir)..\BUILD\Plugins&quot;&#xD;&#xA;)&#xD;&#xA;)"/> <Exec Command="if not exist &quot;$(ProjectDir)..\BUILD&quot; (&#xD;&#xA;if $(ConfigurationName) == Debug (&#xD;&#xA;md &quot;$(ProjectDir)..\BUILD&quot;&#xD;&#xA;)&#xD;&#xA;)&#xD;&#xA;if not exist &quot;$(ProjectDir)..\BUILD\Plugins&quot; (&#xD;&#xA;if $(ConfigurationName) == Debug (&#xD;&#xA;md &quot;$(ProjectDir)..\BUILD\Plugins&quot;&#xD;&#xA;)&#xD;&#xA;)"/>
</Target> </Target>
<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<Target DependsOnTargets="BuildOnlySettings;ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"/>
</ItemGroup>
</Target>
</Project> </Project>

View File

@ -1,28 +1,35 @@
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.AspNetCore.Razor.TagHelpers;
using SharedLibraryCore.Configuration;
namespace SharedLibraryCore namespace SharedLibraryCore
{ {
[HtmlTargetElement("color-code")] [HtmlTargetElement("color-code")]
public class ColorCode : TagHelper public class ColorCode : TagHelper
{ {
public ColorCode(ApplicationConfiguration appConfig)
{
_allow = appConfig?.EnableColorCodes ?? false;
}
public string Value { get; set; } public string Value { get; set; }
public bool Allow { get; set; } = false; private readonly bool _allow;
public override void Process(TagHelperContext context, TagHelperOutput output) public override void Process(TagHelperContext context, TagHelperOutput output)
{ {
output.TagName = "ColorCode"; output.TagName = "ColorCode";
output.TagMode = TagMode.StartTagAndEndTag; output.TagMode = TagMode.StartTagAndEndTag;
if (Allow) if (_allow)
{ {
var matches = Regex.Matches(Value, @"\^([0-9]|\:)([^\^]*)"); var matches = Regex.Matches(Value, @"\^([0-9]|\:)([^\^]*)");
foreach (Match match in matches) foreach (Match match in matches)
{ {
char colorCode = match.Groups[1].ToString().Last(); var colorCode = match.Groups[1].ToString().Last();
output.PreContent.AppendHtml($"<span class='text-color-code-{(colorCode >= 48 && colorCode <= 57 ? colorCode.ToString() : ((int)colorCode).ToString())}'>"); output.PreContent.AppendHtml(
$"<span class='text-color-code-{(colorCode >= 48 && colorCode <= 57 ? colorCode.ToString() : ((int) colorCode).ToString())}'>");
output.PreContent.Append(match.Groups[2].ToString()); output.PreContent.Append(match.Groups[2].ToString());
output.PreContent.AppendHtml("</span>"); output.PreContent.AppendHtml("</span>");
} }