mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 08:48:30 +00:00
27 lines
608 B
C#
27 lines
608 B
C#
using System;
|
|
|
|
namespace Example_Ambilight_full.TakeAsIs.Model.Extensions
|
|
{
|
|
public static class EnumExtension
|
|
{
|
|
#region Methods
|
|
|
|
public static Enum SetFlag(this Enum e, Enum value, bool set, Type t)
|
|
{
|
|
if (e == null || value == null || t == null) return e;
|
|
|
|
int eValue = Convert.ToInt32(e);
|
|
int valueValue = Convert.ToInt32(value);
|
|
|
|
if (set)
|
|
eValue |= valueValue;
|
|
else
|
|
eValue &= ~valueValue;
|
|
|
|
return (Enum)Enum.ToObject(t, eValue);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|