Add a method to convert an integer value into the Flags/EnumValues
This commit is contained in:
parent
817c83f7f0
commit
1811d89b6e
@ -101,6 +101,17 @@ namespace Gst {
|
||||
}
|
||||
}
|
||||
|
||||
public EnumValue this[int val] {
|
||||
get {
|
||||
foreach (EnumValue v in Values) {
|
||||
if (v.value == val)
|
||||
return v;
|
||||
}
|
||||
|
||||
throw new Exception ();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsEnumType (GLib.GType gtype) {
|
||||
return (g_type_is_a (gtype.Val, GType.Enum.Val));
|
||||
}
|
||||
@ -176,6 +187,21 @@ namespace Gst {
|
||||
return (g_type_is_a (gtype.Val, GType.Flags.Val));
|
||||
}
|
||||
|
||||
public FlagsValue[] this[uint flags] {
|
||||
get {
|
||||
System.Collections.ArrayList ret = new System.Collections.ArrayList ();
|
||||
|
||||
foreach (FlagsValue v in Values) {
|
||||
if (flags == 0 && v.value == 0)
|
||||
ret.Add (v);
|
||||
else if ((v.value & flags) != 0)
|
||||
ret.Add (v);
|
||||
}
|
||||
|
||||
return (FlagsValue[]) ret.ToArray (typeof (FlagsValue));
|
||||
}
|
||||
}
|
||||
|
||||
public FlagsInfo (GLib.GType gtype) {
|
||||
if (!IsFlagsType (gtype))
|
||||
throw new ArgumentException ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user