mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-05-08 18:26:03 +03:00
CustomEnumStorageType parameter for importing custom enums
This commit is contained in:
parent
a4da49c486
commit
a7ad3b49a1
1 changed files with 4 additions and 4 deletions
|
@ -52,7 +52,7 @@ public class CustomEnumDefinition : ICustomTypeDefinition
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static CustomEnumDefinition FromEnum<T>() where T : Enum
|
public static CustomEnumDefinition FromEnum<T>(CustomEnumStorageType storageType = CustomEnumStorageType.Int) where T : Enum
|
||||||
{
|
{
|
||||||
var type = typeof(T);
|
var type = typeof(T);
|
||||||
var isFlags = type.GetCustomAttributes(typeof(FlagsAttribute), false).Length != 0;
|
var isFlags = type.GetCustomAttributes(typeof(FlagsAttribute), false).Length != 0;
|
||||||
|
@ -60,7 +60,7 @@ public class CustomEnumDefinition : ICustomTypeDefinition
|
||||||
return new CustomEnumDefinition
|
return new CustomEnumDefinition
|
||||||
{
|
{
|
||||||
Name = type.Name,
|
Name = type.Name,
|
||||||
StorageType = CustomEnumStorageType.Int,
|
StorageType = storageType,
|
||||||
Values = Enum.GetNames(type).ToList(),
|
Values = Enum.GetNames(type).ToList(),
|
||||||
ValueAsFlags = isFlags
|
ValueAsFlags = isFlags
|
||||||
};
|
};
|
||||||
|
@ -70,7 +70,7 @@ public class CustomEnumDefinition : ICustomTypeDefinition
|
||||||
/// Creates a custom enum definition from the specified enum type.
|
/// Creates a custom enum definition from the specified enum type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static CustomEnumDefinition FromEnum(Type type)
|
public static CustomEnumDefinition FromEnum(Type type, CustomEnumStorageType storageType = CustomEnumStorageType.Int)
|
||||||
{
|
{
|
||||||
if (!type.IsEnum)
|
if (!type.IsEnum)
|
||||||
throw new ArgumentException("Type must be an enum.", nameof(type));
|
throw new ArgumentException("Type must be an enum.", nameof(type));
|
||||||
|
@ -80,7 +80,7 @@ public class CustomEnumDefinition : ICustomTypeDefinition
|
||||||
return new CustomEnumDefinition
|
return new CustomEnumDefinition
|
||||||
{
|
{
|
||||||
Name = type.Name,
|
Name = type.Name,
|
||||||
StorageType = CustomEnumStorageType.Int,
|
StorageType = storageType,
|
||||||
Values = Enum.GetNames(type).ToList(),
|
Values = Enum.GetNames(type).ToList(),
|
||||||
ValueAsFlags = isFlags
|
ValueAsFlags = isFlags
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue