protected void CallRequestReceived(IOwner owner, IValue request, ICallbacks callbacks) { if (RequestReceived != null) { RequestReceived(this, owner, request, callbacks); } }
protected void CallAuthorizeReceived(IOwner owner, string name, ICallbacks callbacks) { if (AuthorizeReceived != null) { AuthorizeReceived(this, owner, name, callbacks); } }
public virtual void Callbacks(ICallbacks cb) { lock (Lock()) { CheckClosed(); _server.Callbacks(cb); } }
public static IEnumerable <string> ResetMonitors(ICallbacks parent, ResetMonitors resetDialog, HeliosProfile profile) { Logger.Debug("resetting Monitors"); // WARNING: monitor naming is 1-based but indexing and NewMonitor references are 0-based Monitor[] localMonitors = ConfigManager.DisplayManager.Displays.ToArray <Monitor>(); yield return("acquired displays"); foreach (Monitor localMonitor in localMonitors) { Logger.Info("detected display of size {Width} x {Height}", localMonitor.Width, localMonitor.Height); } // pass1: process all new and/or old monitors in order int existingMonitors = Math.Min(localMonitors.Length, profile.Monitors.Count); // monitors that are preserved for (int monitorIndex = 0; monitorIndex < existingMonitors; monitorIndex++) { ViewModel.MonitorResetItem item = resetDialog.MonitorResets[monitorIndex]; foreach (string progress in ResetExistingMonitor(monitorIndex, item)) { yield return(progress); } yield return($"reset existing monitor {monitorIndex + 1}"); } // monitors added (may be zero iterations) for (int monitorIndex = existingMonitors; monitorIndex < localMonitors.Length; monitorIndex++) { // monitorIndex does not refer to any reset item, as we are off the end of the list ResetAddedMonitor(profile, monitorIndex, localMonitors[monitorIndex]); yield return($"reset added monitor {monitorIndex + 1}"); } // monitors removed (may be zero iterations) for (int monitorIndex = existingMonitors; monitorIndex < resetDialog.MonitorResets.Count; monitorIndex++) { ViewModel.MonitorResetItem item = resetDialog.MonitorResets[monitorIndex]; foreach (string progress in ResetRemovedMonitor(parent, profile, monitorIndex, item, localMonitors.Length)) { yield return(progress); } yield return($"reset removed monitor {monitorIndex + 1}"); } // pass2: place all controls that were temporarily lifted and // copy over any settings from source to target monitors foreach (ViewModel.MonitorResetItem item in resetDialog.MonitorResets) { Logger.Debug($"placing controls for old monitor {item.OldMonitor.Name} onto Monitor {item.NewMonitor + 1}"); foreach (string progress in item.PlaceControls(profile.Monitors[item.NewMonitor])) { yield return(progress); } item.CopySettings(profile.Monitors[item.NewMonitor]); } }
private static IEnumerable <string> ResetRemovedMonitor(ICallbacks parent, HeliosProfile profile, int monitorIndex, ViewModel.MonitorResetItem item, int monitorToRemove) { Logger.Debug($"removing Monitor {monitorIndex + 1} and saving its controls for replacement"); parent.CloseProfileItem(profile.Monitors[monitorToRemove]); foreach (string progress in item.RemoveControls()) { yield return(progress); } ConfigManager.UndoManager.AddUndoItem(new UndoEvents.DeleteMonitorUndoEvent(profile, profile.Monitors[monitorToRemove], monitorToRemove)); profile.Monitors.RemoveAt(monitorToRemove); }
public override void Request(IOwner owner, IValue value, ICallbacks callbacks) { if (_toAutorized.Contains(owner.Id)) { int id = _countRequest; var requestInfo = new RequestInfo(owner, id, _now.Get); _sent.AddLast(requestInfo); _callbacks.Add(id, new Tuple <ICallbacks, RequestInfo>(callbacks, requestInfo)); _protocol.Request(owner.Id, id, value); _countRequest++; } }
public CallbacksImpl(ICallbacks callbacks) { _callbacks = callbacks; _isTypeValidDelegate = IsTypeValid; GCHandle.Alloc(_isTypeValidDelegate); _releaseNetReferenceDelegate = ReleaseNetReference; GCHandle.Alloc(_releaseNetReferenceDelegate); _releaseNetDelegateGCHandleDelegate = ReleaseNetDelegateGCHandle; GCHandle.Alloc(_releaseNetDelegateGCHandleDelegate); _createLazyTypeInfoDelegate = CreateLazyTypeInfo; GCHandle.Alloc(_createLazyTypeInfoDelegate); _loadTypeInfoDelegate = LoadTypeInfo; GCHandle.Alloc(_loadTypeInfoDelegate); _instantiateTypeDelgate = InstantiateType; GCHandle.Alloc(_instantiateTypeDelgate); _callComponentCompletedDelegate = CallComponentCompleted; GCHandle.Alloc(_callComponentCompletedDelegate); _callObjectDestroyedDelegate = CallObjectDestroyed; GCHandle.Alloc(_callObjectDestroyedDelegate); _readPropertyDelegate = ReadProperty; GCHandle.Alloc(_readPropertyDelegate); _writePropertyDelegate = WriteProperty; GCHandle.Alloc(_writePropertyDelegate); _invokeMethodDelegate = InvokeMethod; GCHandle.Alloc(_invokeMethodDelegate); _gcCollectDelegate = GCCollect; GCHandle.Alloc(_gcCollectDelegate); _raiseNetSignalsDelegate = RaiseNetSignals; GCHandle.Alloc(_raiseNetSignalsDelegate); _awaitTaskDelegate = AwaitTask; GCHandle.Alloc(_awaitTaskDelegate); _serializeDelegate = Serialize; GCHandle.Alloc(_serializeDelegate); _invokeDelegateDelegate = InvokeDelegate; GCHandle.Alloc(_invokeDelegateDelegate); }
public override void OnAttach(Context context) { base.OnAttach(context); if (this.Host is ICallbacks callbacks) { this.callbacks = callbacks; } else { throw new InvalidCastException("Parent fragment doesn't implement Callbacks!"); } }
public override void Authorize(IOwner owner, string name, ICallbacks callbacks) { string address = owner.Id; if (!_toAutorized.Contains(address)) { int id = _countRequest; _countRequest++; var requestInfo = new RequestInfo(owner, id, _now.Get); _sent.AddLast(requestInfo); _callbacks.Add(id, new Tuple <ICallbacks, RequestInfo>(callbacks, requestInfo)); _authorizing.Add(address); _protocol.Authorize(address, id, name); } }
public Callbacks(Instance instance, ICallbacks callbacks) { _instance = instance; CallbacksImpl = callbacks; _handle = GCHandle.Alloc(this); _functions = new FMI2.fmi2CallbackFunctions { logger = LoggerCallback, allocateMemory = Marshalling.AllocateMemory, freeMemory = Marshalling.FreeMemory, stepFinished = StepFinishedCallback, componentEnvironment = GCHandle.ToIntPtr(_handle) }; Structure = Marshalling.AllocateMemory(1, (ulong)Marshal.SizeOf(_functions)); Marshal.StructureToPtr(_functions, Structure, false); }
/// <summary> /// Returns an /// <see cref="IEventRegistry">IEventRegistry</see> /// for registering events with the specified container. /// </summary> public static IEventRegistry ForObjectContainer(IObjectContainer objectContainer) { if (null == objectContainer) { throw new ArgumentNullException(); } IInternalObjectContainer container = ((IInternalObjectContainer)objectContainer); ICallbacks callbacks = container.Callbacks(); if (callbacks is IEventRegistry) { return((IEventRegistry)callbacks); } if (callbacks is NullCallbacks) { EventRegistryImpl impl = container.NewEventRegistry(); container.Callbacks(impl); return(impl); } // TODO: create a MulticastingCallbacks and register both // the current one and the new one throw new ArgumentException(); }
public virtual void Callbacks(ICallbacks cb) { if (cb == null) { throw new ArgumentException(); } _callbacks = cb; }
public void Remove(ICallbacks callback) { m_Callbacks.RemoveAll(callbackWithPriority => callbackWithPriority.Callback == callback); }
public abstract void Authorize(IOwner owner, string name, ICallbacks callbacks);
public void UnregisterCallbacks <T>(T testCallbacks) where T : ICallbacks { Callback = null; }
public IInstance CreateCoSimulationInstance(string name, ICallbacks callbacks) { return(new Instance(name, this, CoSimulation, FMI2.fmi2Type.fmi2CoSimulation, callbacks)); }
public CallbackWithPriority(ICallbacks callback, int priority) { Callback = callback; Priority = priority; }
public void RegisterCallbacks <T>(T testCallbacks, int priority = 0) where T : ICallbacks { Callback = testCallbacks; }
public void Add(ICallbacks callback, int priority) { m_Callbacks.Add(new CallbackWithPriority(callback, priority)); }
public override void OnDetach() { base.OnDetach(); mCallBacks = null; }
public virtual extern void SetEventCallbacks([In] ICallbacks callbacks);
public override void OnAttach(Android.App.Activity activity) { base.OnAttach(activity); mCallBacks = (ICallbacks)activity; }
public abstract void Request(IOwner owner, IValue value, ICallbacks callbacks);
private void OnRequestReceived(IUdpNetwork network, IOwner owner, IValue request, ICallbacks callbacks) { var chatValue = (ChatValue)request; Console.WriteLine("Server receive chat message, address: {0}, name: {1}, message: {2}", owner.Id, chatValue.Name, chatValue.Message); _request.Enqueue(new Tuple <IOwner, IValue, ICallbacks>(owner, request, callbacks)); }
public override void OnAttach(Android.App.Activity activity) { base.OnAttach(activity); mCallbacks = (ICallbacks)activity; }
public override void OnDetach() { base.OnDetach(); mCallbacks = null; }
private void OnAuthorizeReceived(IUdpNetwork network, IOwner owner, string name, ICallbacks callbacks) { if (string.IsNullOrEmpty(name)) { Console.WriteLine("Authorized failed, empty name, address {0}", owner.Id); callbacks.Fail(_incorrectUsername); _network.Authorize(owner, false); return; } foreach (var item in _clients.Values) { if (item == name) { Console.WriteLine("Authorized failed, dublicate name, address {0}", owner.Id); callbacks.Fail(_dublicateUsername); _network.Authorize(owner, false); return; } } Console.WriteLine("Authorized true, address: {0}", owner.Id); callbacks.Ack(_ok); _network.Authorize(owner, true); _clients.Add(owner, name); }
public Instance(string name, ModelImpl model, Library library, FMI2.fmi2Type instanceType, ICallbacks cb) { Name = name; _library = library; _model = model; _callbacks = new Callbacks(this, cb); CurrentTime = model.DefaultStartTime; StopTime = model.DefaultStopTime; _handle = library.fmi2Instantiate( name, instanceType, model.GUID, model.TmpFolder, _callbacks.Structure, FMI2.fmi2Boolean.fmi2False, FMI2.fmi2Boolean.fmi2False ); if (_handle == IntPtr.Zero) { throw new Exception("Cannot instanciate model"); } }