Skip to content

Commit

Permalink
added net8 target; removed Enums.NET
Browse files Browse the repository at this point in the history
  • Loading branch information
karakasa committed Jul 29, 2023
1 parent 192d221 commit b934822
Show file tree
Hide file tree
Showing 17 changed files with 248 additions and 69 deletions.
20 changes: 16 additions & 4 deletions OpenXmlFormats/Encryption/Encryption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace NPOI.OpenXmlFormats.Encryption
using System.Xml;
using System.Collections.Generic;
using NPOI.OpenXml4Net.Util;
using EnumsNET;

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.3761.0")]
[System.SerializableAttribute()]
Expand Down Expand Up @@ -434,7 +433,7 @@ public static CT_KeyEncryptor Parse(XmlNode node, XmlNamespaceManager nameSpaceM
if (node.Attributes["uri"] != null)
{
ctObj.uriFieldSpecified = true;
ctObj.uriField = Enums.Parse<CT_KeyEncryptorUri>(node.Attributes["uri"].Value, false, EnumFormat.Description);
ctObj.uriField = CT_KeyEncryptorUriParser.Parse(node.Attributes["uri"].Value);
}
foreach(XmlNode child in node.ChildNodes)
{
Expand All @@ -458,14 +457,27 @@ public static CT_KeyEncryptor Parse(XmlNode node, XmlNamespaceManager nameSpaceM
public enum CT_KeyEncryptorUri
{
/// <remarks/>
[Description("http://schemas.microsoft.com/office/2006/keyEncryptor/password")]
[Description(CT_KeyEncryptorUriParser.httpschemasmicrosoftcomoffice2006keyEncryptorpassword)]
httpschemasmicrosoftcomoffice2006keyEncryptorpassword,

/// <remarks/>
[Description("http://schemas.microsoft.com/office/2006/keyEncryptor/certificate")]
[Description(CT_KeyEncryptorUriParser.httpschemasmicrosoftcomoffice2006keyEncryptorcertificate)]
httpschemasmicrosoftcomoffice2006keyEncryptorcertificate,
}

internal static class CT_KeyEncryptorUriParser
{
public const string httpschemasmicrosoftcomoffice2006keyEncryptorpassword = "http://schemas.microsoft.com/office/2006/keyEncryptor/password";
public const string httpschemasmicrosoftcomoffice2006keyEncryptorcertificate = "http://schemas.microsoft.com/office/2006/keyEncryptor/certificate";

public static CT_KeyEncryptorUri Parse(string uri) => uri switch
{
httpschemasmicrosoftcomoffice2006keyEncryptorcertificate => CT_KeyEncryptorUri.httpschemasmicrosoftcomoffice2006keyEncryptorcertificate,
httpschemasmicrosoftcomoffice2006keyEncryptorpassword => CT_KeyEncryptorUri.httpschemasmicrosoftcomoffice2006keyEncryptorpassword,
_ => throw new ArgumentOutOfRangeException(nameof(uri))
};
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.3761.0")]
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlFormats/NPOI.OpenXmlFormats.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
<TargetFrameworks>net472;netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<AssemblyName>NPOI.OpenXmlFormats</AssemblyName>
<RootNamespace>NPOI.OpenXmlFormats</RootNamespace>
<SignAssembly>true</SignAssembly>
Expand Down
24 changes: 19 additions & 5 deletions OpenXmlFormats/Shared/Math.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using NPOI.OpenXml4Net.Util;
using NPOI.OpenXmlFormats.Dml.WordProcessing;
using System.ComponentModel;
using EnumsNET;
using System.Runtime.CompilerServices;

namespace NPOI.OpenXmlFormats.Shared
{
Expand Down Expand Up @@ -720,7 +720,7 @@ public static CT_BreakBinSub Parse(XmlNode node, XmlNamespaceManager namespaceMa
internal void Write(StreamWriter sw, string nodeName)
{
sw.Write(string.Format("<m:{0}", nodeName));
XmlHelper.WriteAttribute(sw, "m:val", this.val.AsString(EnumFormat.Description));
XmlHelper.WriteAttribute(sw, "m:val", this.val.AsString());
sw.Write("/>");
}

Expand Down Expand Up @@ -758,18 +758,32 @@ public enum ST_BreakBinSub
{


[Description("--")]
[Description(ST_BreakBinSubParser.Item)]
Item,


[Description("-+")]
[Description(ST_BreakBinSubParser.Item1)]
Item1,


[Description("+-")]
[Description(ST_BreakBinSubParser.Item2)]
Item2,
}

internal static class ST_BreakBinSubParser
{
public const string Item = "--";
public const string Item1 = "-+";
public const string Item2 = "+-";

public static string AsString(this ST_BreakBinSub val) => val switch
{
ST_BreakBinSub.Item => Item,
ST_BreakBinSub.Item1 => Item1,
ST_BreakBinSub.Item2 => Item2,
_ => throw new ArgumentOutOfRangeException(nameof(val))
};
}

[Serializable]

Expand Down
103 changes: 83 additions & 20 deletions OpenXmlFormats/Spreadsheet/AutoFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System.Xml;
using NPOI.OpenXml4Net.Util;
using System.IO;
using EnumsNET;

namespace NPOI.OpenXmlFormats.Spreadsheet
{
Expand Down Expand Up @@ -979,74 +978,138 @@ public bool iconIdSpecified

public enum ST_IconSetType
{
[Description("3Arrows")]
[Description(ST_IconSetTypeParser.Item3Arrows)]
Item3Arrows,


[Description("3ArrowsGray")]
[Description(ST_IconSetTypeParser.Item3ArrowsGray)]
Item3ArrowsGray,


[Description("3Flags")]
[Description(ST_IconSetTypeParser.Item3Flags)]
Item3Flags,


[Description("3TrafficLights1")]
[Description(ST_IconSetTypeParser.Item3TrafficLights1)]
Item3TrafficLights1,


[Description("3TrafficLights2")]
[Description(ST_IconSetTypeParser.Item3TrafficLights2)]
Item3TrafficLights2,


[Description("3Signs")]
[Description(ST_IconSetTypeParser.Item3Signs)]
Item3Signs,


[Description("3Symbols")]
[Description(ST_IconSetTypeParser.Item3Symbols)]
Item3Symbols,


[Description("3Symbols2")]
[Description(ST_IconSetTypeParser.Item3Symbols2)]
Item3Symbols2,


[Description("4Arrows")]
[Description(ST_IconSetTypeParser.Item4Arrows)]
Item4Arrows,


[Description("4ArrowsGray")]
[Description(ST_IconSetTypeParser.Item4ArrowsGray)]
Item4ArrowsGray,


[Description("4RedToBlack")]
[Description(ST_IconSetTypeParser.Item4RedToBlack)]
Item4RedToBlack,


[Description("4Rating")]
[Description(ST_IconSetTypeParser.Item4Rating)]
Item4Rating,


[Description("4TrafficLights")]
[Description(ST_IconSetTypeParser.Item4TrafficLights)]
Item4TrafficLights,


[Description("5Arrows")]
[Description(ST_IconSetTypeParser.Item5Arrows)]
Item5Arrows,


[Description("5ArrowsGray")]
[Description(ST_IconSetTypeParser.Item5ArrowsGray)]
Item5ArrowsGray,


[Description("5Rating")]
[Description(ST_IconSetTypeParser.Item5Rating)]
Item5Rating,


[Description("5Quarters")]
[Description(ST_IconSetTypeParser.Item5Quarters)]
Item5Quarters,
}

public static class ST_IconSetTypeParser
{
public const string Item3Arrows = "3Arrows";
public const string Item3ArrowsGray = "3ArrowsGray";
public const string Item3Flags = "3Flags";
public const string Item3TrafficLights1 = "3TrafficLights1";
public const string Item3TrafficLights2 = "3TrafficLights2";
public const string Item3Signs = "3Signs";
public const string Item3Symbols = "3Symbols";
public const string Item3Symbols2 = "3Symbols2";
public const string Item4Arrows = "4Arrows";
public const string Item4ArrowsGray = "4ArrowsGray";
public const string Item4RedToBlack = "4RedToBlack";
public const string Item4Rating = "4Rating";
public const string Item4TrafficLights = "4TrafficLights";
public const string Item5Arrows = "5Arrows";
public const string Item5ArrowsGray = "5ArrowsGray";
public const string Item5Rating = "5Rating";
public const string Item5Quarters = "5Quarters";

public static ST_IconSetType Parse(string name) => name switch
{
Item3Arrows => ST_IconSetType.Item3Arrows,
Item3ArrowsGray => ST_IconSetType.Item3ArrowsGray,
Item3Flags => ST_IconSetType.Item3Flags,
Item3TrafficLights1 => ST_IconSetType.Item3TrafficLights1,
Item3TrafficLights2 => ST_IconSetType.Item3TrafficLights2,
Item3Signs => ST_IconSetType.Item3Signs,
Item3Symbols => ST_IconSetType.Item3Symbols,
Item3Symbols2 => ST_IconSetType.Item3Symbols2,
Item4Arrows => ST_IconSetType.Item4Arrows,
Item4ArrowsGray => ST_IconSetType.Item4ArrowsGray,
Item4RedToBlack => ST_IconSetType.Item4RedToBlack,
Item4Rating => ST_IconSetType.Item4Rating,
Item4TrafficLights => ST_IconSetType.Item4TrafficLights,
Item5Arrows => ST_IconSetType.Item5Arrows,
Item5ArrowsGray => ST_IconSetType.Item5ArrowsGray,
Item5Rating => ST_IconSetType.Item5Rating,
Item5Quarters => ST_IconSetType.Item5Quarters,
_ => throw new ArgumentOutOfRangeException(nameof(name))
};

public static string AsString(this ST_IconSetType val) => val switch
{
ST_IconSetType.Item3Arrows => Item3Arrows,
ST_IconSetType.Item3ArrowsGray => Item3ArrowsGray,
ST_IconSetType.Item3Flags => Item3Flags,
ST_IconSetType.Item3TrafficLights1 => Item3TrafficLights1,
ST_IconSetType.Item3TrafficLights2 => Item3TrafficLights2,
ST_IconSetType.Item3Signs => Item3Signs,
ST_IconSetType.Item3Symbols => Item3Symbols,
ST_IconSetType.Item3Symbols2 => Item3Symbols2,
ST_IconSetType.Item4Arrows => Item4Arrows,
ST_IconSetType.Item4ArrowsGray => Item4ArrowsGray,
ST_IconSetType.Item4RedToBlack => Item4RedToBlack,
ST_IconSetType.Item4Rating => Item4Rating,
ST_IconSetType.Item4TrafficLights => Item4TrafficLights,
ST_IconSetType.Item5Arrows => Item5Arrows,
ST_IconSetType.Item5ArrowsGray => Item5ArrowsGray,
ST_IconSetType.Item5Rating => Item5Rating,
ST_IconSetType.Item5Quarters => Item5Quarters,
_ => throw new ArgumentOutOfRangeException(nameof(val))
};
}
public class CT_Top10
{

Expand Down Expand Up @@ -1318,7 +1381,7 @@ public static CT_SortCondition Parse(XmlNode node, XmlNamespaceManager namespace
if (node.Attributes["dxfId"] != null)
ctObj.dxfId = XmlHelper.ReadUInt(node.Attributes["dxfId"]);
if (node.Attributes["iconSet"] != null)
ctObj.iconSet = Enums.Parse<ST_IconSetType>(node.Attributes["iconSet"].Value,false, EnumFormat.Description);
ctObj.iconSet = ST_IconSetTypeParser.Parse(node.Attributes["iconSet"].Value);
if (node.Attributes["iconId"] != null)
ctObj.iconId = XmlHelper.ReadUInt(node.Attributes["iconId"]);
return ctObj;
Expand All @@ -1334,7 +1397,7 @@ internal void Write(StreamWriter sw, string nodeName)
XmlHelper.WriteAttribute(sw, "ref", this.@ref);
XmlHelper.WriteAttribute(sw, "customList", this.customList);
XmlHelper.WriteAttribute(sw, "dxfId", this.dxfId);
XmlHelper.WriteAttribute(sw, "iconSet", this.iconSet.AsString(EnumFormat.Description));
XmlHelper.WriteAttribute(sw, "iconSet", this.iconSet.AsString());
XmlHelper.WriteAttribute(sw, "iconId", this.iconId);
sw.Write("/>");
}
Expand Down
Loading

0 comments on commit b934822

Please sign in to comment.