-
-
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.
Merge pull request #3 from Uralstech/preview
Merge preview into main for UGemini v1.1.0-preview.3
- Loading branch information
Showing
68 changed files
with
5,685 additions
and
64 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
8 changes: 8 additions & 0 deletions
8
UGemini/Packages/com.uralstech.ugemini/Runtime/Scripts/Data/Common/Content.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
UGemini/Packages/com.uralstech.ugemini/Runtime/Scripts/Data/Common/Content/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,59 @@ | ||
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> | ||
/// <exception cref="NotImplementedException">Thrown if the MIME type of the enum value could not be found.</exception> | ||
public static string MimeType(this GeminiContentType enumValue) | ||
{ | ||
Type type = typeof(GeminiContentType); | ||
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; | ||
} | ||
|
||
// Throw error if no EnumMember attribute is found. | ||
throw new NotImplementedException($"No {nameof(EnumMemberAttribute)} found for content type \"{enumValue}\"!"); | ||
} | ||
|
||
/// <summary> | ||
/// Converts a <see cref="string"/> MIME type to a <see cref="GeminiContentType"/>. | ||
/// </summary> | ||
/// <param name="mimeType">The MIME type string.</param> | ||
/// <returns>The <see cref="GeminiContentType"/> equivalent.</returns> | ||
/// <exception cref="NotImplementedException">Thrown if <see cref="GeminiContentType"/> does not have an equivalent MIME type to <paramref name="mimeType"/>.</exception> | ||
public static GeminiContentType ContentType(this string mimeType) | ||
{ | ||
Type type = typeof(GeminiContentType); | ||
foreach (string name in Enum.GetNames(type)) | ||
{ | ||
MemberInfo[] memberInfo = type.GetMember(name); | ||
if (memberInfo != null && memberInfo.Length > 0) | ||
{ | ||
object[] attributes = memberInfo[0].GetCustomAttributes(typeof(EnumMemberAttribute), false); | ||
if (attributes != null && attributes.Length > 0 && ((EnumMemberAttribute)attributes[0]).Value == mimeType) | ||
return (GeminiContentType)Enum.Parse(type, name); | ||
} | ||
} | ||
|
||
// Throw error if no enum value is found. | ||
throw new NotImplementedException($"No {nameof(GeminiContentType)} found for MIME type \"{mimeType}\"!"); | ||
} | ||
} | ||
} |
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...Scripts/Data/Common/GeminiContent.cs.meta → ...Data/Common/Content/GeminiContent.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
2 changes: 1 addition & 1 deletion
2
...pts/Data/Common/GeminiContentBlob.cs.meta → .../Common/Content/GeminiContentBlob.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
2 changes: 1 addition & 1 deletion
2
...pts/Data/Common/GeminiContentPart.cs.meta → .../Common/Content/GeminiContentPart.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
2 changes: 1 addition & 1 deletion
2
...pts/Data/Common/GeminiContentType.cs.meta → .../Common/Content/GeminiContentType.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.