diff --git a/sources/custom/Object.cs b/sources/custom/Object.cs index bd35dff962..be3c70c9f2 100644 --- a/sources/custom/Object.cs +++ b/sources/custom/Object.cs @@ -14,6 +14,7 @@ // along with this program. If not, see . using System; +using System.Collections.Generic; using System.Runtime.InteropServices; namespace Gst { @@ -22,14 +23,25 @@ namespace Gst { partial class Object { + private Dictionary PropertyNameCache = new Dictionary (); + [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr g_object_class_find_property (IntPtr klass, IntPtr name); + bool PropertyExists (string name) { + if (PropertyNameCache.ContainsKey (name)) + return PropertyNameCache [name]; + var ptr = g_object_class_find_property (GType.GetClassPtr (), GLib.Marshaller.StringToPtrGStrdup (name)); var result = ptr != IntPtr.Zero; GLib.Marshaller.Free (ptr); + // just cache the positive results because there might + // actually be new properties getting installed + if (result) + PropertyNameCache [name] = result; + return result; }