示例#1
0
        private void Register(IPeripheral peripheral, IRegistrationPoint registrationPoint, IPeripheral parent)
        {
            using (ObtainPausedState())
            {
                Action executeAfterLock = null;
                lock (collectionSync)
                {
                    var parentNode = registeredPeripherals.GetNode(parent);
                    parentNode.AddChild(peripheral, registrationPoint);
                    var ownLife = peripheral as IHasOwnLife;
                    if (ownLife != null)
                    {
                        ownLifes.Add(ownLife);
                        if (state == State.Paused)
                        {
                            executeAfterLock = delegate
                            {
                                ownLife.Start();
                                ownLife.Pause();
                            };
                        }
                    }
                }
                if (executeAfterLock != null)
                {
                    executeAfterLock();
                }

                if (peripheral is ITimeSink timeSink)
                {
                    LocalTimeSource.RegisterSink(timeSink);
                }
            }

            OnMachinePeripheralsChanged(peripheral, PeripheralsChangedEventArgs.PeripheralChangeType.Addition);
            EmulationManager.Instance.CurrentEmulation.BackendManager.TryCreateBackend(peripheral);
        }