예제 #1
0
        public bool TryGetEmulationElementByName(string name, object context, out IEmulationElement element)
        {
            if (name == null)
            {
                element = null;
                return(false);
            }
            var machineContext = context as Machine;

            if (machineContext != null)
            {
                IPeripheral outputPeripheral;
                if ((machineContext.TryGetByName(name, out outputPeripheral) || machineContext.TryGetByName(string.Format("sysbus.{0}", name), out outputPeripheral)))
                {
                    element = outputPeripheral;
                    return(true);
                }
            }

            Machine machine;

            if (TryGetMachineByName(name, out machine))
            {
                element = machine;
                return(true);
            }

            IExternal external;

            if (ExternalsManager.TryGetByName(name, out external))
            {
                element = external;
                return(true);
            }

            IHostMachineElement hostMachineElement;

            if (name.StartsWith(string.Format("{0}.", HostMachine.HostMachineName)) &&
                HostMachine.TryGetByName(name.Substring(HostMachine.HostMachineName.Length + 1), out hostMachineElement))
            {
                element = hostMachineElement;
                return(true);
            }

            element = null;
            return(false);
        }