-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from codebude/bugfix/343-svglogo-background-a…
…nd-positioning Bugfix/343 svglogo background and positioning
- Loading branch information
Showing
4 changed files
with
297 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace QRCoder.Extensions | ||
{ | ||
/// <summary> | ||
/// Used to represent a string value for a value in an enum | ||
/// </summary> | ||
public class StringValueAttribute : Attribute | ||
{ | ||
|
||
#region Properties | ||
|
||
/// <summary> | ||
/// Holds the alue in an enum | ||
/// </summary> | ||
public string StringValue { get; protected set; } | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// Init a StringValue Attribute | ||
/// </summary> | ||
/// <param name="value"></param> | ||
public StringValueAttribute(string value) | ||
{ | ||
this.StringValue = value; | ||
} | ||
} | ||
|
||
public static class CustomExtensions | ||
{ | ||
/// <summary> | ||
/// Will get the string value for a given enum's value | ||
/// </summary> | ||
/// <param name="value"></param> | ||
/// <returns></returns> | ||
public static string GetStringValue(this Enum value) | ||
{ | ||
#if NETSTANDARD1_3 | ||
var fieldInfo = value.GetType().GetRuntimeField(value.ToString()); | ||
#else | ||
var fieldInfo = value.GetType().GetField(value.ToString()); | ||
#endif | ||
var attr = fieldInfo.GetCustomAttributes(typeof(StringValueAttribute), false) as StringValueAttribute[]; | ||
return attr.Length > 0 ? attr[0].StringValue : null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.