internal static int AddEntryListener(string prefix, EntryListenerFunction listener, NotifyFlags flags) { // ReSharper disable once InconsistentNaming Interop.NT_EntryListenerCallback modCallback = (uid, data, name, len, value, flags_) => { NtType type = Interop.NT_GetValueType(value); object obj; ulong lastChange = 0; UIntPtr size = UIntPtr.Zero; IntPtr ptr; switch (type) { case NtType.Unassigned: obj = null; break; case NtType.Boolean: int boolean = 0; Interop.NT_GetValueBoolean(value, ref lastChange, ref boolean); obj = boolean != 0; break; case NtType.Double: double val = 0; Interop.NT_GetValueDouble(value, ref lastChange, ref val); obj = val; break; case NtType.String: ptr = Interop.NT_GetValueString(value, ref lastChange, ref size); obj = ReadUTF8String(ptr, size); break; case NtType.Raw: ptr = Interop.NT_GetValueRaw(value, ref lastChange, ref size); obj = GetRawDataFromPtr(ptr, size); break; case NtType.BooleanArray: ptr = Interop.NT_GetValueBooleanArray(value, ref lastChange, ref size); obj = GetBooleanArrayFromPtr(ptr, size); break; case NtType.DoubleArray: ptr = Interop.NT_GetValueDoubleArray(value, ref lastChange, ref size); obj = GetDoubleArrayFromPtr(ptr, size); break; case NtType.StringArray: ptr = Interop.NT_GetValueStringArray(value, ref lastChange, ref size); obj = GetStringArrayFromPtr(ptr, size); break; case NtType.Rpc: ptr = Interop.NT_GetValueRaw(value, ref lastChange, ref size); obj = GetRawDataFromPtr(ptr, size); break; default: obj = null; break; } string key = ReadUTF8String(name, len); listener((int)uid, key, obj, (NotifyFlags)flags_); }; UIntPtr prefixSize; byte[] prefixStr = CreateUTF8String(prefix, out prefixSize); int retVal = (int)Interop.NT_AddEntryListener(prefixStr, prefixSize, IntPtr.Zero, modCallback, (uint)flags); s_entryCallbacks.Add(retVal, modCallback); return(retVal); }