static public T GetObject(IntPtr nativeReference) { // We must allow GetObject for null reference if (nativeReference == IntPtr.Zero) { return(null); } IReference obj; if (!_instances.TryGetValue(nativeReference, out obj)) { obj = Reference.CreateObject(nativeReference) as IReference; if (obj is T) // if we have a valid factory created we will register in here { //If we have an auto register in constructor we will hit the false condition if (!_instances.TryAdd(nativeReference, obj)) { bool ok = _instances.TryGetValue(nativeReference, out obj); System.Diagnostics.Debug.Assert(ok); } } } return(obj as T); }
public DistObject GetObject(IntPtr nativeReference) { // We must allow GetObject for null reference if (nativeReference == IntPtr.Zero) { return(null); } lock (instanses) { DistObject obj; if (!instanses.TryGetValue(nativeReference, out obj)) { obj = Reference.CreateObject(nativeReference) as DistObject; // At least we will always get a DistObject instanses.Add(nativeReference, obj); } if (obj == null || !obj.IsValid()) { instanses[nativeReference] = obj = Reference.CreateObject(nativeReference) as DistObject; } return(obj); } }
static private void OnEvent_callback(IntPtr instance, IntPtr e) { DistClient client = ReferenceDictionary <DistClient> .GetObject(instance); if (client != null) { DistEvent @event = Reference.CreateObject(e) as DistEvent; if (@event != null) { if (client.UseAutoProperty && @event.GetType().IsDefined(typeof(DistPropertyAutoRestore), true)) { @event.RestorePropertiesAndFields(); } try { client.OnEvent?.Invoke(client, @event); } catch (Exception ex) { Message.SendException("DistClient", ex); } } } }
public DistObject GetObject(IntPtr nativeReference) { // We must allow GetObject for null reference if (nativeReference == IntPtr.Zero) { return(null); } DistObject obj; if (!_instanses.TryGetValue(nativeReference, out obj)) { // At least we will always get a DistObject obj = Reference.CreateObject(nativeReference) as DistObject; // we must protect against race conditions, we must never allow 2 different managed objects to be returned // for same native reference! if (!_instanses.TryAdd(nativeReference, obj)) { var r = _instanses.TryGetValue(nativeReference, out obj); System.Diagnostics.Debug.Assert(r); return(obj); } } if (obj == null || !obj.IsValid()) { // In case we lost the factory native ref _instanses[nativeReference] = obj = Reference.CreateObject(nativeReference) as DistObject; } return(obj); }
static private void OnEvent_callback(IntPtr instance, IntPtr sender, UInt64 event_id, IntPtr a0, IntPtr a1, IntPtr a2, IntPtr a3, IntPtr a4, IntPtr a5, IntPtr a6, IntPtr a7, IntPtr a8, IntPtr a9) { DynamicEventReceiver recv = ReferenceDictionary <DynamicEventReceiver> .GetObject(instance); if (recv != null) { recv.OnEvent?.Invoke(recv, Reference.CreateObject(sender) as DynamicEventInterface, event_id, new DynamicType(a0), new DynamicType(a1), new DynamicType(a2), new DynamicType(a3), new DynamicType(a4), new DynamicType(a5), new DynamicType(a6), new DynamicType(a7), new DynamicType(a8), new DynamicType(a9)); } }
static private DistObject GetObject(IntPtr o) { DistObject obj = ReferenceDictionary <DistObject> .GetObject(o); if (obj == null) { obj = Reference.CreateObject(o) as DistObject; } return(obj); }
private void OnEvent_callback(IntPtr e) { DistEvent @event = Reference.CreateObject(e) as DistEvent; if (@event != null) { if (UseAutoProperty && @event.GetType().IsDefined(typeof(DistPropertyAutoRestore), true)) { @event.RestorePropertiesAndFields(); } OnEvent?.Invoke(this, @event); } }
public DistEvent AwaitResponse(DistEvent responseEventType, UInt32 timeout = 100) { DistEvent response = Reference.CreateObject(DistClient_awaitResponse(GetNativeReference(), responseEventType.GetNativeReference(), timeout)) as DistEvent; if (response?.IsValid() ?? false) { if (UseAutoProperty && response.GetType().IsDefined(typeof(DistPropertyAutoRestore), true)) { response.RestorePropertiesAndFields(); } } return(response); }
private void OnEvent_callback(IntPtr e) { OnEvent?.Invoke(this, Reference.CreateObject(e) as DistEvent); }
public DistEvent GetEvent(string typeName = "gzDistEvent") { return(Reference.CreateObject(DistManager_getEvent(GetNativeReference(), typeName)) as DistEvent); }
public Camera GetCamera() { return(Reference.CreateObject(Intersector_getCamera(GetNativeReference())) as Camera); }
static public Module GetModule(string moduleName) { return(Reference.CreateObject(Module_getModule(moduleName)) as Module); }
private void OnEvent_callback(IntPtr sender, UInt64 event_id, IntPtr a0, IntPtr a1, IntPtr a2, IntPtr a3, IntPtr a4, IntPtr a5, IntPtr a6, IntPtr a7, IntPtr a8, IntPtr a9) { OnEvent?.Invoke(this, Reference.CreateObject(sender) as DynamicEventInterface, event_id, new DynamicType(a0), new DynamicType(a1), new DynamicType(a2), new DynamicType(a3), new DynamicType(a4), new DynamicType(a5), new DynamicType(a6), new DynamicType(a7), new DynamicType(a8), new DynamicType(a9)); }
static public Node LoadDB(string url, string extension = "", AdapterFlags flags = 0, UInt32 version = 0, string password = "", Reference associatedData = null) { return(Reference.CreateObject((DbManager_loadDB(url, extension, flags, version, password, associatedData?.GetNativeReference() ?? IntPtr.Zero))) as Node); }
public DistEvent GetEvent(string className="gzDistEvent") { return Reference.CreateObject(DistManager_getEvent(GetNativeReference(),className)) as DistEvent; }