Exemplo n.º 1
0
        public DmdDevice()
        {
            _currentFrameFormat    = new BehaviorSubject <FrameFormat>(FrameFormat.Rgb24);
            _vpmGray2Source        = new VpmGray2Source(_currentFrameFormat);
            _vpmGray4Source        = new VpmGray4Source(_currentFrameFormat);
            _vpmRgb24Source        = new VpmRgb24Source(_currentFrameFormat);
            _vpmAlphaNumericSource = new VpmAlphaNumericSource(_currentFrameFormat);

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            // setup logger
            var assembly      = Assembly.GetCallingAssembly();
            var assemblyPath  = Path.GetDirectoryName(new Uri(assembly.CodeBase).LocalPath);
            var logConfigPath = Path.Combine(assemblyPath, "DmdDevice.log.config");

            if (File.Exists(logConfigPath))
            {
                LogManager.Configuration = new XmlLoggingConfiguration(logConfigPath, true);
#if !DEBUG
                LogManager.Configuration.AddTarget("memory", MemLogger);
                LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, MemLogger));
                LogManager.ReconfigExistingLoggers();
#endif
            }
#if !DEBUG
            else
            {
                SimpleConfigurator.ConfigureForTargetLogging(MemLogger, LogLevel.Debug);
            }
#endif
            CultureUtil.NormalizeUICulture();
            _config       = new Configuration();
            _altcolorPath = GetColorPath();

            // read versions from assembly
            var attr = assembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
            var fvi  = FileVersionInfo.GetVersionInfo(assembly.Location);
            _version = fvi.ProductVersion;
            if (attr.Length > 0)
            {
                var aca = (AssemblyConfigurationAttribute)attr[0];
                _sha = aca.Configuration;
                if (string.IsNullOrEmpty(_sha))
                {
                    _fullVersion = _version;
                }
                else
                {
                    _fullVersion = $"{_version} ({_sha})";
                }
            }
            else
            {
                _fullVersion = fvi.ProductVersion;
                _sha         = "";
            }

            Logger.Info("Starting VPinMAME API {0} through {1}.exe.", _fullVersion, Process.GetCurrentProcess().ProcessName);
            Logger.Info("Assembly located at {0}", assembly.Location);
        }