-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
139 additions
and
7 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
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
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
34 changes: 34 additions & 0 deletions
34
UGemini/Packages/com.uralstech.ugemini/Runtime/Scripts/Data/Common/EnumExtensions.cs
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,34 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Uralstech.UGemini | ||
{ | ||
/// <summary> | ||
/// Extensions for <see cref="Enum"/> type objects. | ||
/// </summary> | ||
public static class EnumExtensions | ||
{ | ||
/// <summary> | ||
/// Converts a <see cref="GeminiContentType"/> to its <see href="https://www.iana.org/assignments/media-types/media-types.xhtml">MIME type</see>. | ||
/// </summary> | ||
/// <param name="enumValue">The <see cref="GeminiContentType"/> value.</param> | ||
/// <returns>The MIME type as a string.</returns> | ||
public static string MimeType(this GeminiContentType enumValue) | ||
{ | ||
Type type = enumValue.GetType(); | ||
MemberInfo[] memberInfo = type.GetMember(enumValue.ToString()); | ||
|
||
if (memberInfo != null && memberInfo.Length > 0) | ||
{ | ||
object[] attributes = memberInfo[0].GetCustomAttributes(typeof(EnumMemberAttribute), false); | ||
|
||
if (attributes != null && attributes.Length > 0) | ||
return ((EnumMemberAttribute)attributes[0]).Value; | ||
} | ||
|
||
// Return the enum name if no EnumMember attribute is found | ||
return enumValue.ToString(); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
UGemini/Packages/com.uralstech.ugemini/Runtime/Scripts/Data/Common/EnumExtensions.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
UGemini/Packages/com.uralstech.ugemini/Runtime/Scripts/Data/Common/GeminiContent.cs
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
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
3 changes: 1 addition & 2 deletions
3
UGemini/Packages/com.uralstech.ugemini/Runtime/Scripts/Data/Common/GeminiContentType.cs
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
29 changes: 29 additions & 0 deletions
29
UGemini/Packages/com.uralstech.ugemini/Runtime/Scripts/Data/Common/GeminiFileData.cs
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,29 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Serialization; | ||
using System.ComponentModel; | ||
|
||
namespace Uralstech.UGemini | ||
{ | ||
/// <summary> | ||
/// URI based data. | ||
/// </summary> | ||
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] | ||
public class GeminiFileData | ||
{ | ||
/// <summary> | ||
/// The IANA standard MIME type of the source data. | ||
/// </summary> | ||
/// <remarks> | ||
/// You can use <see cref="EnumExtensions.MimeType(GeminiContentType)"/> to convert <see cref="GeminiContentType"/> | ||
/// values to their <see cref="string"/> MIME type, like: | ||
/// <c>GeminiContentType.ImagePNG.MimeType()</c> | ||
/// </remarks> | ||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore), DefaultValue(null)] | ||
public string MimeType = null; | ||
|
||
/// <summary> | ||
/// URI. | ||
/// </summary> | ||
public string FileUri; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
UGemini/Packages/com.uralstech.ugemini/Runtime/Scripts/Data/Common/GeminiFileData.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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