private void Run(string[] args) { AssemblyInformationalVersionAttribute versionAttribute = Attribute.GetCustomAttribute(typeof(Program).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; Console.WriteLine("Wyam version {0}", versionAttribute == null ? "unknown" : versionAttribute.InformationalVersion); // Parse the command line if (!ParseArgs(args)) { return; } // It's not a serious console app unless there's some ASCII art OutputLogo(); // Fix the root folder and other files _rootFolder = _rootFolder == null ? Environment.CurrentDirectory : Path.Combine(Environment.CurrentDirectory, _rootFolder); _logFile = _logFile == null ? null : Path.Combine(_rootFolder, _logFile); _configFile = string.IsNullOrWhiteSpace(_configFile) ? Path.Combine(_rootFolder, "config.wyam") : Path.Combine(_rootFolder, _configFile); // Get the engine Engine engine = GetEngine(); if (engine == null) { return; } // Pause if (_pause) { engine.Trace.Information("Pause requested, hit any key to continue"); Console.ReadKey(); } // Configure and execute if (!Configure(engine)) { return; } Console.WriteLine("Root folder: {0}", engine.RootFolder); Console.WriteLine("Input folder: {0}", engine.InputFolder); Console.WriteLine("Output folder: {0}", engine.OutputFolder); if (!Execute(engine)) { return; } bool messagePump = false; // Start the preview server IDisposable previewServer = null; if (_preview) { messagePump = true; try { engine.Trace.Information("Preview server listening on port {0} and serving from {1}", _previewPort, engine.OutputFolder); previewServer = Preview(engine); } catch (Exception ex) { engine.Trace.Critical("Error while running preview server: {0}", ex.Message); } } // Start the watchers IDisposable inputFolderWatcher = null; IDisposable configFileWatcher = null; if (_watch) { messagePump = true; engine.Trace.Information("Watching folder {0}", engine.InputFolder); inputFolderWatcher = new ActionFileSystemWatcher(engine.InputFolder, true, "*.*", path => { _changedFiles.Enqueue(path); _messageEvent.Set(); }); if (_configFile != null) { engine.Trace.Information("Watching configuration file {0}", _configFile); configFileWatcher = new ActionFileSystemWatcher(Path.GetDirectoryName(_configFile), false, Path.GetFileName(_configFile), path => { if (path == _configFile) { _newEngine.Set(); _messageEvent.Set(); } }); } } // Start the message pump if an async process is running if (messagePump) { // Start the key listening thread engine.Trace.Information("Hit any key to exit"); var thread = new Thread(() => { Console.ReadKey(); _exit.Set(); _messageEvent.Set(); }) { IsBackground = true }; thread.Start(); // Wait for activity while (true) { _messageEvent.WaitOne(); // Blocks the current thread until a signal if (_exit) { break; } // See if we need a new engine if (_newEngine) { // Get a new engine engine.Trace.Information("Configuration file {0} has changed, re-running", _configFile); engine.Dispose(); engine = GetEngine(); // Configure and execute if (!Configure(engine)) { break; } Console.WriteLine("Root folder: {0}", engine.RootFolder); Console.WriteLine("Input folder: {0}", engine.InputFolder); Console.WriteLine("Output folder: {0}", engine.OutputFolder); if (!Execute(engine)) { break; } // Clear the changed files since we just re-ran string changedFile; while (_changedFiles.TryDequeue(out changedFile)) { } _newEngine.Unset(); } else { // Execute if files have changed HashSet <string> changedFiles = new HashSet <string>(); string changedFile; while (_changedFiles.TryDequeue(out changedFile)) { if (changedFiles.Add(changedFile)) { engine.Trace.Verbose("{0} has changed", changedFile); } } if (changedFiles.Count > 0) { engine.Trace.Information("{0} files have changed, re-executing", changedFiles.Count); if (!Execute(engine)) { break; } } } // Check one more time for exit if (_exit) { break; } engine.Trace.Information("Hit any key to exit"); _messageEvent.Reset(); } // Shutdown engine.Trace.Information("Shutting down"); engine.Dispose(); inputFolderWatcher?.Dispose(); configFileWatcher?.Dispose(); previewServer?.Dispose(); } }
/// <summary> /// Obtains the <see cref="AssemblyVersionInfo"/> for the specified Assembly. /// </summary> /// <param name="assembly">the assembly.</param> /// <returns>the assembly version info.</returns> public static AssemblyVersionInfo FromAssembly(Assembly assembly) { if (assembly == null) { throw new ArgumentNullException("assembly"); } AssemblyVersionInfo i = default(AssemblyVersionInfo); AssemblyName assemblyName = assembly.GetName(); #region get assembly attributes foreach (Attribute attribute in assembly.GetCustomAttributes(false)) { { AssemblyCompanyAttribute a = attribute as AssemblyCompanyAttribute; if (a != null) { i.Company = a.Company; continue; } } { AssemblyConfigurationAttribute a = attribute as AssemblyConfigurationAttribute; if (a != null) { i.Configuration = a.Configuration; continue; } } { AssemblyCopyrightAttribute a = attribute as AssemblyCopyrightAttribute; if (a != null) { i.Copyright = a.Copyright; continue; } } { AssemblyDescriptionAttribute a = attribute as AssemblyDescriptionAttribute; if (a != null) { i.Description = a.Description; continue; } } { AssemblyFileVersionAttribute a = attribute as AssemblyFileVersionAttribute; if (a != null) { i.FileVersion = new Version(a.Version); continue; } } { AssemblyInformationalVersionAttribute a = attribute as AssemblyInformationalVersionAttribute; if (a != null) { i.InformalVersion = SemanticVersion.TryParse(a.InformationalVersion); continue; } } { AssemblyProductAttribute a = attribute as AssemblyProductAttribute; if (a != null) { i.Product = a.Product; continue; } } { AssemblyTitleAttribute a = attribute as AssemblyTitleAttribute; if (a != null) { i.Title = a.Title; continue; } } { AssemblyTrademarkAttribute a = attribute as AssemblyTrademarkAttribute; if (a != null) { i.Trademark = a.Trademark; continue; } } { GuidAttribute a = attribute as GuidAttribute; if (a != null) { i.Guid = new Guid(a.Value); continue; } } { AssemblyUpdateURI a = attribute as AssemblyUpdateURI; if (a != null) { i.UpdateURI = a.URI; continue; } } { AssemblySoftwareFlags a = attribute as AssemblySoftwareFlags; if (a != null) { i.SoftwareFlags = a.Flags; continue; } } { AssemblySetupVersion a = attribute as AssemblySetupVersion; if (a != null) { i.SetupVersion = a.SetupVersion; continue; } } { AssemblySetupPackage a = attribute as AssemblySetupPackage; if (a != null) { i.SetupPackage = a.SetupPackage; continue; } } } #endregion // get assembly name properties { i.AssemblyVersion = assemblyName.Version; i.Culture = assemblyName.CultureInfo; i.PublicKey = assemblyName.GetPublicKey(); i.PublicKeyToken = assemblyName.GetPublicKeyToken().ToHexString(); } return(i); }
private static void Main(string[] args) { try { AssemblyInformationalVersionAttribute attribute = (AssemblyInformationalVersionAttribute)Assembly.GetExecutingAssembly() .GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)[0]; var a = Assembly.GetExecutingAssembly().GetName(); byte[] pt = a.GetPublicKeyToken(); PublicKeyToken = ""; for (int i = 0; i < pt.Length; i++) { PublicKeyToken += String.Format("{0:x2}", pt[i]); } Console.Title = String.Format("XVM Stat v{0} for XVM {1}+", Assembly.GetExecutingAssembly().GetName().Version, attribute.InformationalVersion); Log(Console.Title); // Check args if (!CheckArgs(args)) { return; } // CD to game dir string game_dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); Debug("Change dir: " + game_dir); Directory.SetCurrentDirectory(game_dir); // --- DEBUG ---------------------------------------- //Dossier.Dossier.Instance.GetDossierInfo("1;sirmax2;1381374000;3600;24;4;battlesCount,wins;;"); //Thread.Sleep(1000); //return; // --- DEBUG ---------------------------------------- // Check for another instance started bool ok; Mutex m = new Mutex(true, "xvm-stat", out ok); if (!ok) { throw new Exception("Another proxy instance is already running."); } GC.KeepAlive(m); // Check game start file exists Debug("Check start file exists: " + wotExeFileName); if (!File.Exists(wotExeFileName)) { throw new Exception("Game start file not found: " + wotExeFileName); } // Clear log file ClearLogFile(); string mp = Settings.Default.MountPoint; DokanOptions opt = new DokanOptions() { VolumeLabel = "XVMfs", DebugMode = false, MountPoint = Path.GetFullPath(mp), ThreadCount = 1, }; Debug("MountPoint: " + opt.MountPoint); PrepareMountPoint(opt.MountPoint); Debug("Creating server thread"); Thread thread = new Thread(StartDokan); try { Debug("Starting server thread"); thread.Start(opt); Thread.Sleep(2000); if (!thread.IsAlive) { Debug("Dokan thread is not alive. Exiting."); } else { ProcessMainThread(args); } } finally { Log("Stopping server"); // Unmount and clean. DokanNet.DokanRemoveMountPoint(opt.MountPoint); if (thread.IsAlive) { thread.Join(); } Directory.Delete(opt.MountPoint); } } catch (Exception ex) { Log(String.Format("{0}{1}{1}Press any key to exit.", ex, Environment.NewLine)); Console.ReadKey(true); } }
/// <inheritdoc/> public virtual void OnEnabled() { AssemblyInformationalVersionAttribute attribute = Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>(); Log.Info($"{Name} v{(attribute == null ? $"{Version.Major}.{Version.Minor}.{Version.Build}" : attribute.InformationalVersion)} by {Author} has been enabled!"); }
protected void OnBtnSaveClicked(object sender, EventArgs e) { SaveFileDialog dlgSave = new SaveFileDialog { CheckFileExists = true }; dlgSave.Filters.Add(new FileFilter { Extensions = new[] { "log" }, Name = "Log files" }); DialogResult result = dlgSave.ShowDialog(this); if (result != DialogResult.Ok) { return; } try { FileStream logFs = new FileStream(dlgSave.FileName, FileMode.Create, FileAccess.ReadWrite); StreamWriter logSw = new StreamWriter(logFs); logSw.WriteLine("Log saved at {0}", DateTime.Now); PlatformID platId = DetectOS.GetRealPlatformID(); string platVer = DetectOS.GetVersion(); AssemblyInformationalVersionAttribute assemblyVersion = Attribute.GetCustomAttribute(typeof(DicConsole).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; logSw.WriteLine("################# System information #################"); logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer, Environment.Is64BitOperatingSystem ? 64 : 32); if (DetectOS.IsMono) { logSw.WriteLine("Mono {0}", Version.GetMonoVersion()); } else if (DetectOS.IsNetCore) { logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion()); } else { logSw.WriteLine(RuntimeInformation.FrameworkDescription); } logSw.WriteLine(); logSw.WriteLine("################# Program information ################"); logSw.WriteLine("DiscImageChef {0}", assemblyVersion?.InformationalVersion); logSw.WriteLine("Running in {0}-bit", Environment.Is64BitProcess ? 64 : 32); logSw.WriteLine("Running GUI mode using {0}", Application.Instance.Platform.ID); #if DEBUG logSw.WriteLine("DEBUG version"); #endif logSw.WriteLine("Command line: {0}", Environment.CommandLine); logSw.WriteLine(); logSw.WriteLine("################# Console ################"); foreach (LogEntry entry in ConsoleHandler.Entries) { if (entry.Type != "Info") { logSw.WriteLine("{0}: ({1}) {2}", entry.Timestamp, entry.Type.ToLower(), entry.Message); } else { logSw.WriteLine("{0}: {1}", entry.Timestamp, entry.Message); } } logSw.Close(); logFs.Close(); } catch (Exception exception) { MessageBox.Show("Exception {0} trying to save logfile, details has been sent to console.", exception.Message); DicConsole.ErrorWriteLine("Console", exception.Message); DicConsole.ErrorWriteLine("Console", exception.StackTrace); } }
public static void Install(string gxPath) { if (string.IsNullOrEmpty(gxPath)) { throw new Exception("You must enter the path to a GeneXus installation"); } if (!Directory.Exists(gxPath)) { throw new DirectoryNotFoundException($"'{gxPath}' does not look like a valid directory"); } string gxExe = Path.Combine(gxPath, Config.GXENEXUS_EXE); if (!File.Exists(gxExe)) { throw new Exception($"'{gxPath}' does not look like a valid GeneXus installation folder"); } AssemblyInformationalVersionAttribute afv = Assembly.LoadFrom(gxExe).GetCustomAttribute <AssemblyInformationalVersionAttribute>(); s_instance = new Config { GeneXusPath = gxPath, GeneXusVersion = afv.InformationalVersion, CurrentVersion = Application.ProductVersion }; var dir = AppDomain.CurrentDomain.BaseDirectory; string modulesPath = Path.Combine(dir, GXCLI_MODULES); foreach (string dllPath in Directory.GetFiles(modulesPath, "*.dll")) { Assembly ass = Assembly.LoadFrom(dllPath); Console.WriteLine($"Analyzing {ass.GetName().Name}..."); Attribute att = ass.GetCustomAttribute(typeof(GXCliVerbProviderAttribute)); if (att == null) { continue; } Console.WriteLine($"{ass.GetName().Name} is a gxcli verb provider"); Console.WriteLine($"Adding {ass.GetName().Name} verbs..."); foreach (Type t in ass.GetExportedTypes()) { if (typeof(IGXCliVerbProvider).IsAssignableFrom(t)) { IGXCliVerbProvider obj = Activator.CreateInstance(t) as IGXCliVerbProvider; ConfigProvider configProvider = new ConfigProvider(dllPath, t.FullName, obj) { HasValidator = typeof(ParameterValidator).IsAssignableFrom(t) }; if (!s_instance.Providers.ContainsKey(obj.Name)) { Console.WriteLine($"- {obj.Name}"); s_instance.Providers.Add(obj.Name.ToLower(), configProvider); } } } } s_instance.Save(); }
public static string ObterVersion() { AssemblyInformationalVersionAttribute attribute = (AssemblyInformationalVersionAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false).FirstOrDefault(); return(attribute?.InformationalVersion); }
private static void Main(string[] args) { try { AssemblyInformationalVersionAttribute attribute = (AssemblyInformationalVersionAttribute)Assembly.GetExecutingAssembly() .GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)[0]; Console.Title = "XVM Stat v" + Assembly.GetExecutingAssembly().GetName().Version + " for XVM " + attribute.InformationalVersion + "+"; Log(Console.Title); // Check args if (!CheckArgs(args)) { return; } // CD to game dir string game_dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); Debug("Change dir: " + game_dir); Directory.SetCurrentDirectory(game_dir); // Check for another instance started bool ok; Mutex m = new Mutex(true, "xvm-stat", out ok); if (!ok) { throw new Exception("Another proxy instance is already running."); } GC.KeepAlive(m); // Check game start file exists Debug("Check start file exists: " + wotExeFileName); if (!File.Exists(wotExeFileName)) { throw new Exception("Game start file not found: " + wotExeFileName); } // Clear log file ClearLogFile(); string mp = String.Format("res_mods{0}{1}", Path.DirectorySeparatorChar, Settings.Default.MountPoint); DokanOptions opt = new DokanOptions() { DebugMode = true, MountPoint = Path.GetFullPath(mp), ThreadCount = 5, }; Debug("MountPoint: " + opt.MountPoint); PrepareMountPoint(opt.MountPoint); Debug("Creating server thread"); Thread thread = new Thread(StartDokan); try { Debug("Starting server thread"); thread.Start(opt); Thread.Sleep(2000); if (!thread.IsAlive) { Debug("Dokan thread is not alive. Exiting."); } else { ProcessMainThread(args); } } finally { Log("Stopping server"); // Unmount and clean. DokanNet.DokanRemoveMountPoint(opt.MountPoint); if (thread.IsAlive) { thread.Join(); } Directory.Delete(opt.MountPoint); } if (isDebug) { Log("Press any key to exit."); Console.ReadKey(true); } } catch (Exception ex) { Log(String.Format("{0}{1}{1}Press any key to exit.", ex, Environment.NewLine)); Console.ReadKey(true); } }
private static void CopyAssemblyVersion(AssemblyBuilder targetAssemblyBuilder, Assembly srcAsm) { Action <Type, string> AddCustomStringAttribute = (Type type, string content) => { if (string.IsNullOrEmpty(content)) { return; } ConstructorInfo ctor = type.GetConstructor(new Type[] { typeof(string) }); targetAssemblyBuilder.SetCustomAttribute(new CustomAttributeBuilder(ctor, new object[] { content })); }; bool hasInformationalVersionAttr = false; object[] attrs = srcAsm.GetCustomAttributes(false); foreach (var attr in attrs) { AssemblyCompanyAttribute cmp = attr as AssemblyCompanyAttribute; if (cmp != null) { AddCustomStringAttribute(attr.GetType(), cmp.Company); continue; } AssemblyCopyrightAttribute copy = attr as AssemblyCopyrightAttribute; if (copy != null) { AddCustomStringAttribute(attr.GetType(), copy.Copyright); continue; } AssemblyDescriptionAttribute da = attr as AssemblyDescriptionAttribute; if (da != null) { AddCustomStringAttribute(attr.GetType(), da.Description); continue; } AssemblyFileVersionAttribute fva = attr as AssemblyFileVersionAttribute; if (fva != null) { AddCustomStringAttribute(attr.GetType(), fva.Version); if (!hasInformationalVersionAttr) { // Also set AssemblyInformationalVersionAttribute, if not set already. // The unmanaged ProductVersion is taken from that attribute. AddCustomStringAttribute(typeof(AssemblyInformationalVersionAttribute), fva.Version); } continue; } AssemblyInformationalVersionAttribute iva = attr as AssemblyInformationalVersionAttribute; if (iva != null) { AddCustomStringAttribute(attr.GetType(), iva.InformationalVersion); hasInformationalVersionAttr = true; continue; } AssemblyProductAttribute pa = attr as AssemblyProductAttribute; if (pa != null) { AddCustomStringAttribute(attr.GetType(), pa.Product); continue; } AssemblyTitleAttribute ta = attr as AssemblyTitleAttribute; if (ta != null) { AddCustomStringAttribute(attr.GetType(), ta.Title); continue; } AssemblyTrademarkAttribute tm = attr as AssemblyTrademarkAttribute; if (tm != null) { AddCustomStringAttribute(attr.GetType(), tm.Trademark); continue; } AssemblyVersionAttribute va = attr as AssemblyVersionAttribute; if (va != null) { AddCustomStringAttribute(attr.GetType(), va.Version); continue; } } targetAssemblyBuilder.DefineVersionInfoResource(); }
/// <summary> /// Determines if the program is running on a processor (appliance) or server (VC-4). /// /// Sets Global.FilePathPrefix and Global.ApplicationDirectoryPathPrefix based on platform /// </summary> public void DeterminePlatform() { try { Debug.Console(0, Debug.ErrorLogLevel.Notice, "Determining Platform...."); string filePathPrefix; var dirSeparator = Global.DirectorySeparator; string directoryPrefix; directoryPrefix = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationRootDirectory(); var fullVersion = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); AssemblyInformationalVersionAttribute fullVersionAtt = fullVersion[0] as AssemblyInformationalVersionAttribute; Global.SetAssemblyVersion(fullVersionAtt.InformationalVersion); if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS { Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on 3-series Appliance", Global.AssemblyVersion); // Check if User/ProgramX exists if (Directory.Exists(Global.ApplicationDirectoryPathPrefix + dirSeparator + "User" + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber))) { Debug.Console(0, @"User/program{0} directory found", InitialParametersClass.ApplicationNumber); filePathPrefix = directoryPrefix + dirSeparator + "User" + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; } // Check if Nvram/Programx exists else if (Directory.Exists(directoryPrefix + dirSeparator + "Nvram" + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber))) { Debug.Console(0, @"Nvram/program{0} directory found", InitialParametersClass.ApplicationNumber); filePathPrefix = directoryPrefix + dirSeparator + "Nvram" + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; } // If neither exists, set path to User/ProgramX else { Debug.Console(0, @"No previous directory found. Using User/program{0}", InitialParametersClass.ApplicationNumber); filePathPrefix = directoryPrefix + dirSeparator + "User" + dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator; } } else // Handles Linux OS (Virtual Control) { Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on Virtual Control Server", Global.AssemblyVersion); // Set path to User/ filePathPrefix = directoryPrefix + dirSeparator + "User" + dirSeparator; } Global.SetFilePathPrefix(filePathPrefix); } catch (Exception e) { Debug.Console(0, "Unable to Determine Platform due to Exception: {0}", e.Message); } }
public static int Main(string[] args) { object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); _assemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title; attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); _assemblyVersion = Attribute.GetCustomAttribute(typeof(MainClass).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; _assemblyCopyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; if (args.Length == 1 && args[0].ToLowerInvariant() == "gui") { return(Gui.Main.Start(args)); } AaruConsole.WriteLineEvent += System.Console.WriteLine; AaruConsole.WriteEvent += System.Console.Write; AaruConsole.ErrorWriteLineEvent += System.Console.Error.WriteLine; Settings.Settings.LoadSettings(); AaruContext ctx; try { ctx = AaruContext.Create(Settings.Settings.LocalDbPath); ctx.Database.Migrate(); } catch (NotSupportedException) { File.Delete(Settings.Settings.LocalDbPath); ctx = AaruContext.Create(Settings.Settings.LocalDbPath); ctx.Database.EnsureCreated(); ctx.Database. ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)"); foreach (string migration in ctx.Database.GetPendingMigrations()) { ctx.Database. ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{migration}', '0.0.0')"); } ctx.SaveChanges(); } // Remove duplicates foreach (var duplicate in ctx.SeenDevices.AsEnumerable() !.GroupBy(a => new { a.Manufacturer, a.Model, a.Revision, a.Bus }).Where(a => a.Count() > 1).Distinct().Select(a => a.Key)) { ctx.RemoveRange(ctx.SeenDevices !. Where(d => d.Manufacturer == duplicate.Manufacturer && d.Model == duplicate.Model && d.Revision == duplicate.Revision && d.Bus == duplicate.Bus).Skip(1)); } // Remove nulls ctx.RemoveRange(ctx.SeenDevices !.Where(d => d.Manufacturer == null && d.Model == null && d.Revision == null)); ctx.SaveChanges(); bool mainDbUpdate = false; if (!File.Exists(Settings.Settings.MainDbPath)) { mainDbUpdate = true; UpdateCommand.DoUpdate(true); } var mainContext = AaruContext.Create(Settings.Settings.MainDbPath); if (mainContext.Database.GetPendingMigrations().Any()) { AaruConsole.WriteLine("New database version, updating..."); try { File.Delete(Settings.Settings.MainDbPath); } catch (Exception) { AaruConsole.ErrorWriteLine("Exception trying to remove old database version, cannot continue..."); AaruConsole.ErrorWriteLine("Please manually remove file at {0}", Settings.Settings.MainDbPath); } UpdateCommand.DoUpdate(true); } if ((args.Length < 1 || args[0].ToLowerInvariant() != "gui") && Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel) { new ConfigureCommand(true, true).Invoke(args); } Statistics.LoadStats(); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var rootCommand = new RootCommand { new Option(new[] { "--verbose", "-v" }, "Shows verbose output.") { Argument = new Argument <bool>(() => false) }, new Option(new[] { "--debug", "-d" }, "Shows debug output from plugins.") { Argument = new Argument <bool>(() => false) } }; rootCommand.Description = $"{_assemblyTitle} {_assemblyVersion?.InformationalVersion}\n{_assemblyCopyright}"; rootCommand.AddCommand(new DatabaseFamily(mainDbUpdate)); rootCommand.AddCommand(new DeviceFamily()); rootCommand.AddCommand(new FilesystemFamily()); rootCommand.AddCommand(new ImageFamily()); rootCommand.AddCommand(new MediaFamily()); rootCommand.AddCommand(new ConfigureCommand(false, false)); rootCommand.AddCommand(new FormatsCommand()); rootCommand.AddCommand(new ListEncodingsCommand()); rootCommand.AddCommand(new ListNamespacesCommand()); rootCommand.AddCommand(new RemoteCommand()); int ret = rootCommand.Invoke(args); Statistics.SaveStats(); return(ret); }
public static int Main(string[] args) { object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); AssemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title; attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); AssemblyVersion = Attribute.GetCustomAttribute(typeof(MainClass).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; AssemblyCopyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; DicConsole.WriteLineEvent += System.Console.WriteLine; DicConsole.WriteEvent += System.Console.Write; DicConsole.ErrorWriteLineEvent += System.Console.Error.WriteLine; Settings.Settings.LoadSettings(); DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath); ctx.Database.Migrate(); ctx.SaveChanges(); bool masterDbUpdate = false; if (!File.Exists(Settings.Settings.MasterDbPath)) { masterDbUpdate = true; UpdateCommand.DoUpdate(true); } DicContext mctx = DicContext.Create(Settings.Settings.MasterDbPath); mctx.Database.Migrate(); mctx.SaveChanges(); if ((args.Length < 1 || args[0].ToLowerInvariant() != "gui") && Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel) { new ConfigureCommand(true, true).Invoke(args); } Statistics.LoadStats(); if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.ShareStats) { Task.Run(() => { Statistics.SubmitStats(); }); } PlatformID currentPlatform = DetectOS.GetRealPlatformID(); CommandSet commands = new CommandSet("DiscImageChef") { $"{AssemblyTitle} {AssemblyVersion?.InformationalVersion}", $"{AssemblyCopyright}", "", "usage: DiscImageChef COMMAND [OPTIONS]", "", "Global options:", { "verbose|v", "Shows verbose output.", b => Verbose = b != null }, { "debug|d", "Shows debug output from plugins.", b => Debug = b != null }, "", "Available commands:", new AnalyzeCommand(), new BenchmarkCommand(), new ChecksumCommand(), new CompareCommand(), new ConfigureCommand(false, false), new ConvertImageCommand(), new CreateSidecarCommand(), new DecodeCommand() }; if (currentPlatform == PlatformID.FreeBSD || currentPlatform == PlatformID.Linux || currentPlatform == PlatformID.Win32NT) { commands.Add(new DeviceInfoCommand()); commands.Add(new DeviceReportCommand()); commands.Add(new DumpMediaCommand()); } commands.Add(new EntropyCommand()); commands.Add(new ExtractFilesCommand()); commands.Add(new FormatsCommand()); commands.Add(new GuiCommand()); commands.Add(new ImageInfoCommand()); if (currentPlatform == PlatformID.FreeBSD || currentPlatform == PlatformID.Linux || currentPlatform == PlatformID.Win32NT) { commands.Add(new ListDevicesCommand()); } commands.Add(new ListEncodingsCommand()); commands.Add(new ListNamespacesCommand()); commands.Add(new ListOptionsCommand()); commands.Add(new LsCommand()); if (currentPlatform == PlatformID.FreeBSD || currentPlatform == PlatformID.Linux || currentPlatform == PlatformID.Win32NT) { commands.Add(new MediaInfoCommand()); commands.Add(new MediaScanCommand()); } commands.Add(new PrintHexCommand()); commands.Add(new StatisticsCommand()); commands.Add(new UpdateCommand(masterDbUpdate)); commands.Add(new VerifyCommand()); int ret = commands.Run(args); Statistics.SaveStats(); return(ret); }
/// <summary> /// Initializes the dump log /// </summary> /// <param name="outputFile">Output log file</param> /// <param name="dev">Device</param> public DumpLog(string outputFile, Device dev) { if (string.IsNullOrEmpty(outputFile)) { return; } logSw = new StreamWriter(outputFile, true); logSw.WriteLine("Start logging at {0}", DateTime.Now); PlatformID platId = DetectOS.GetRealPlatformID(); string platVer = DetectOS.GetVersion(); AssemblyInformationalVersionAttribute assemblyVersion = Attribute.GetCustomAttribute(typeof(DumpLog).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; logSw.WriteLine("################# System information #################"); logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer, Environment.Is64BitOperatingSystem ? 64 : 32); if (DetectOS.IsMono) { logSw.WriteLine("Mono {0}", Version.GetMonoVersion()); } else { logSw.WriteLine(".NET Framework {0}", Environment.Version); } logSw.WriteLine(); logSw.WriteLine("################# Program information ################"); logSw.WriteLine("DiscImageChef {0}", assemblyVersion?.InformationalVersion); logSw.WriteLine("Running in {0}-bit", Environment.Is64BitProcess ? 64 : 32); #if DEBUG logSw.WriteLine("DEBUG version"); #endif logSw.WriteLine("Command line: {0}", Environment.CommandLine); logSw.WriteLine(); logSw.WriteLine("################# Device information #################"); logSw.WriteLine("Manufacturer: {0}", dev.Manufacturer); logSw.WriteLine("Model: {0}", dev.Model); logSw.WriteLine("Firmware revision: {0}", dev.Revision); logSw.WriteLine("Serial number: {0}", dev.Serial); logSw.WriteLine("Removable device: {0}", dev.IsRemovable); logSw.WriteLine("Device type: {0}", dev.Type); logSw.WriteLine("CompactFlash device: {0}", dev.IsCompactFlash); logSw.WriteLine("PCMCIA device: {0}", dev.IsPcmcia); logSw.WriteLine("USB device: {0}", dev.IsUsb); if (dev.IsUsb) { logSw.WriteLine("USB manufacturer: {0}", dev.UsbManufacturerString); logSw.WriteLine("USB product: {0}", dev.UsbProductString); logSw.WriteLine("USB serial: {0}", dev.UsbSerialString); logSw.WriteLine("USB vendor ID: {0:X4}h", dev.UsbVendorId); logSw.WriteLine("USB product ID: {0:X4}h", dev.UsbProductId); } logSw.WriteLine("FireWire device: {0}", dev.IsFireWire); if (dev.IsFireWire) { logSw.WriteLine("FireWire vendor: {0}", dev.FireWireVendorName); logSw.WriteLine("FireWire model: {0}", dev.FireWireModelName); logSw.WriteLine("FireWire GUID: 0x{0:X16}", dev.FireWireGuid); logSw.WriteLine("FireWire vendor ID: 0x{0:X8}", dev.FireWireVendor); logSw.WriteLine("FireWire product ID: 0x{0:X8}", dev.FireWireModel); } logSw.WriteLine(); logSw.WriteLine("######################################################"); logSw.WriteLine(); logSw.WriteLine("################ Dumping progress log ################"); logSw.Flush(); }
public static void Main(string[] args) { object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); assemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title; attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); assemblyVersion = Attribute.GetCustomAttribute(typeof(MainClass).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; assemblyCopyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; PrintCopyright(); if (args.Length != 1) { Console.WriteLine(Localization.Usage); return; } if (!File.Exists(args[0])) { Console.WriteLine(Localization.FileDoesNotExist); return; } FileStream fs; try { fs = File.Open(args[0], FileMode.Open, FileAccess.Read, FileShare.Read); } catch { Console.WriteLine(Localization.FileCannotBeOpened); return; } if (fs.Length > MAX_SIZE) { Console.WriteLine(Localization.FileIsTooBig); return; } Console.WriteLine(Localization.FileName, args[0]); Console.WriteLine(Localization.SearchingFirstFrame); long framePosition = 0; byte[] buffer = new byte[Color.FrameMarker.Length]; byte[] swappedBuffer = new byte[Color.FrameMarker.Length]; bool swapped = false; bool xp = false; byte[] startBuffer = new byte[FrameStart.Length]; byte[] xpBuffer = new byte[Xp.FrameMarker.Length]; byte[] xpSwappedBuffer = new byte[Xp.FrameMarker.Length]; while (framePosition < 19760) { fs.Position = framePosition; fs.Read(startBuffer, 0, startBuffer.Length); if (!startBuffer.SequenceEqual(FrameStart) && !startBuffer.SequenceEqual(SwappedFrameStart)) { framePosition++; continue; } fs.Position = framePosition; fs.Read(buffer, 0, buffer.Length); for (int ab = 8; ab < buffer.Length; ab += 10) { buffer[ab] = 0; } if (buffer.SequenceEqual(Color.FrameMarker)) { break; } fs.Position = framePosition; fs.Read(swappedBuffer, 0, swappedBuffer.Length); for (int ab = 9; ab < swappedBuffer.Length; ab += 10) { swappedBuffer[ab] = 0; } if (swappedBuffer.SequenceEqual(Color.SwappedFrameMarker)) { swapped = true; break; } fs.Position = framePosition; fs.Read(xpBuffer, 0, xpBuffer.Length); for (int i = 0; i < xpBuffer.Length; i++) { xpBuffer[i] &= Xp.FrameMask[i]; } if (xpBuffer.SequenceEqual(Xp.FrameMarker)) { xp = true; break; } fs.Position = framePosition; fs.Read(xpSwappedBuffer, 0, xpSwappedBuffer.Length); for (int i = 0; i < xpSwappedBuffer.Length; i++) { xpSwappedBuffer[i] &= Xp.SwappedFrameMask[i]; } if (xpSwappedBuffer.SequenceEqual(Xp.SwappedFrameMarker)) { swapped = true; xp = true; break; } framePosition++; } if (!buffer.SequenceEqual(Color.FrameMarker) && !swappedBuffer.SequenceEqual(Color.SwappedFrameMarker) && !xpBuffer.SequenceEqual(Xp.FrameMarker) && !xpSwappedBuffer.SequenceEqual(Xp.SwappedFrameMarker)) { Console.WriteLine(Localization.NoFrameFound); return; } Console.WriteLine(Localization.FirstFrameFoundAt, framePosition); Console.WriteLine(framePosition % 2352 == 0 ? Localization.FirstFrameIsAtSectorBoundary : Localization.FirstFrameIsNotAtSectorBoundary); if (xp) { Xp.Decode(args[0], fs, swapped, framePosition); } else { Color.Decode(args[0], fs, swapped, framePosition); } fs.Close(); }
/// <summary> /// Populates the provided metadata map with asembly-level metadata derived /// from custom attributes. /// </summary> /// <remarks> /// <para> /// Currently recognized attributes: /// <list type="bullet"> /// <item><see cref="AssemblyCompanyAttribute" /></item> /// <item><see cref="AssemblyConfigurationAttribute" /></item> /// <item><see cref="AssemblyCopyrightAttribute" /></item> /// <item><see cref="AssemblyDescriptionAttribute" /></item> /// <item><see cref="AssemblyFileVersionAttribute" /></item> /// <item><see cref="AssemblyInformationalVersionAttribute" /></item> /// <item><see cref="AssemblyProductAttribute" /></item> /// <item><see cref="AssemblyTitleAttribute" /></item> /// <item><see cref="AssemblyTrademarkAttribute" /></item> /// <item><see cref="AssemblyVersionAttribute" /></item> /// </list> /// </para> /// </remarks> /// <param name="assembly">The assembly.</param> /// <param name="metadataMap">The metadata map.</param> public static void PopulateMetadataFromAssembly(IAssemblyInfo assembly, PropertyBag metadataMap) { metadataMap.Add(MetadataKeys.CodeBase, assembly.Path); AssemblyCompanyAttribute companyAttribute = AttributeUtils.GetAttribute <AssemblyCompanyAttribute>(assembly, false); if (companyAttribute != null) { AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Company, companyAttribute.Company); } AssemblyConfigurationAttribute configurationAttribute = AttributeUtils.GetAttribute <AssemblyConfigurationAttribute>(assembly, false); if (configurationAttribute != null) { AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Configuration, configurationAttribute.Configuration); } AssemblyCopyrightAttribute copyrightAttribute = AttributeUtils.GetAttribute <AssemblyCopyrightAttribute>(assembly, false); if (copyrightAttribute != null) { AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Copyright, copyrightAttribute.Copyright); } AssemblyDescriptionAttribute descriptionAttribute = AttributeUtils.GetAttribute <AssemblyDescriptionAttribute>(assembly, false); if (descriptionAttribute != null) { AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Description, descriptionAttribute.Description); } AssemblyFileVersionAttribute fileVersionAttribute = AttributeUtils.GetAttribute <AssemblyFileVersionAttribute>(assembly, false); if (fileVersionAttribute != null) { AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.FileVersion, fileVersionAttribute.Version); } AssemblyInformationalVersionAttribute informationalVersionAttribute = AttributeUtils.GetAttribute <AssemblyInformationalVersionAttribute>(assembly, false); if (informationalVersionAttribute != null) { AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.InformationalVersion, informationalVersionAttribute.InformationalVersion); } AssemblyProductAttribute productAttribute = AttributeUtils.GetAttribute <AssemblyProductAttribute>(assembly, false); if (productAttribute != null) { AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Product, productAttribute.Product); } AssemblyTitleAttribute titleAttribute = AttributeUtils.GetAttribute <AssemblyTitleAttribute>(assembly, false); if (titleAttribute != null) { AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Title, titleAttribute.Title); } AssemblyTrademarkAttribute trademarkAttribute = AttributeUtils.GetAttribute <AssemblyTrademarkAttribute>(assembly, false); if (trademarkAttribute != null) { AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Trademark, trademarkAttribute.Trademark); } // Note: AssemblyVersionAttribute cannot be accessed directly via reflection. It gets baked into the assembly name. metadataMap.Add(MetadataKeys.Version, assembly.GetName().Version.ToString()); }
public MainForm() { InitializeComponent(); _assemblyInformationalVersionAttribute = Assembly.GetEntryAssembly().GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; }
private int Run(string[] args) { // Add a default trace listener Trace.AddListener(new SimpleColorConsoleTraceListener { TraceOutputOptions = System.Diagnostics.TraceOptions.None }); // Output version info AssemblyInformationalVersionAttribute versionAttribute = Attribute.GetCustomAttribute(typeof(Program).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; Trace.Information("Wyam version {0}", versionAttribute == null ? "unknown" : versionAttribute.InformationalVersion); // It's not a serious console app unless there's some ASCII art OutputLogo(); // Parse the command line try { bool hasParseArgsErrors; if (!_settings.ParseArgs(args, _preprocessor, out hasParseArgsErrors)) { return(hasParseArgsErrors ? (int)ExitCode.CommandLineError : (int)ExitCode.Normal); } // Was help for the preprocessor directives requested? if (_settings.HelpDirectives) { Console.WriteLine("Available preprocessor directives:"); foreach (IDirective directive in _preprocessor.Directives) { Console.WriteLine(); Console.WriteLine($"{directive.Description}:"); Console.WriteLine(string.Join(", ", directive.DirectiveNames.Select(x => "#" + x))); Console.WriteLine(directive.GetHelpText()); } return((int)ExitCode.Normal); } } catch (Exception ex) { Trace.Error("Error while parsing command line: {0}", ex.Message); if (Trace.Level == System.Diagnostics.SourceLevels.Verbose) { Trace.Error("Stack trace:{0}{1}", Environment.NewLine, ex.StackTrace); } return((int)ExitCode.CommandLineError); } // Fix the root folder and other files DirectoryPath currentDirectory = Environment.CurrentDirectory; _settings.RootPath = _settings.RootPath == null ? currentDirectory : currentDirectory.Combine(_settings.RootPath); _settings.LogFilePath = _settings.LogFilePath == null ? null : _settings.RootPath.CombineFile(_settings.LogFilePath); _settings.ConfigFilePath = _settings.RootPath.CombineFile(_settings.ConfigFilePath ?? "config.wyam"); // Set up the log file if (_settings.LogFilePath != null) { Trace.AddListener(new SimpleFileTraceListener(_settings.LogFilePath.FullPath)); } // Prepare engine metadata if (!_settings.VerifyConfig && _settings.GlobalMetadataArgs != null && _settings.GlobalMetadataArgs.Count > 0) { try { _settings.GlobalMetadata = GlobalMetadataParser.Parse(_settings.GlobalMetadataArgs); } catch (MetadataParseException ex) { Trace.Error("Error while parsing metadata: {0}", ex.Message); if (Trace.Level == System.Diagnostics.SourceLevels.Verbose) { Trace.Error("Stack trace:{0}{1}", Environment.NewLine, ex.StackTrace); } return((int)ExitCode.CommandLineError); } // Not used anymore, release resources. _settings.GlobalMetadataArgs = null; } // Get the engine and configurator EngineManager engineManager = GetEngineManager(); if (engineManager == null) { return((int)ExitCode.CommandLineError); } // Pause if (_settings.Pause) { Trace.Information("Pause requested, hit any key to continue"); Console.ReadKey(); } // Configure and execute if (!engineManager.Configure()) { return((int)ExitCode.ConfigurationError); } if (_settings.VerifyConfig) { Trace.Information("No errors. Exiting."); return((int)ExitCode.Normal); } Trace.Information($"Root path:{Environment.NewLine} {engineManager.Engine.FileSystem.RootPath}"); Trace.Information($"Input path(s):{Environment.NewLine} {string.Join(Environment.NewLine + " ", engineManager.Engine.FileSystem.InputPaths)}"); Trace.Information($"Output path:{Environment.NewLine} {engineManager.Engine.FileSystem.OutputPath}"); if (!engineManager.Execute()) { return((int)ExitCode.ExecutionError); } bool messagePump = false; // Start the preview server IDisposable previewServer = null; if (_settings.Preview) { messagePump = true; try { DirectoryPath previewPath = _settings.PreviewRoot == null ? engineManager.Engine.FileSystem.GetOutputDirectory().Path : engineManager.Engine.FileSystem.GetOutputDirectory(_settings.PreviewRoot).Path; Trace.Information("Preview server listening on port {0} and serving from path {1}", _settings.PreviewPort, previewPath); previewServer = Preview(previewPath); } catch (Exception ex) { Trace.Critical("Error while running preview server: {0}", ex.Message); } } // Start the watchers IDisposable inputFolderWatcher = null; IDisposable configFileWatcher = null; if (_settings.Watch) { messagePump = true; Trace.Information("Watching paths(s) {0}", string.Join(", ", engineManager.Engine.FileSystem.InputPaths)); inputFolderWatcher = new ActionFileSystemWatcher(engineManager.Engine.FileSystem.GetOutputDirectory().Path, engineManager.Engine.FileSystem.GetInputDirectories().Select(x => x.Path), true, "*.*", path => { _changedFiles.Enqueue(path); _messageEvent.Set(); }); if (_settings.ConfigFilePath != null) { Trace.Information("Watching configuration file {0}", _settings.ConfigFilePath); configFileWatcher = new ActionFileSystemWatcher(engineManager.Engine.FileSystem.GetOutputDirectory().Path, new[] { _settings.ConfigFilePath.Directory }, false, _settings.ConfigFilePath.FileName.FullPath, path => { FilePath filePath = new FilePath(path); if (_settings.ConfigFilePath.Equals(filePath)) { _newEngine.Set(); _messageEvent.Set(); } }); } } // Start the message pump if an async process is running ExitCode exitCode = ExitCode.Normal; if (messagePump) { // Start the key listening thread Trace.Information("Hit any key to exit"); var thread = new Thread(() => { Console.ReadKey(); _exit.Set(); _messageEvent.Set(); }) { IsBackground = true }; thread.Start(); // Wait for activity while (true) { _messageEvent.WaitOne(); // Blocks the current thread until a signal if (_exit) { break; } // See if we need a new engine if (_newEngine) { // Get a new engine Trace.Information("Configuration file {0} has changed, re-running", _settings.ConfigFilePath); engineManager.Dispose(); engineManager = GetEngineManager(); // Configure and execute if (!engineManager.Configure()) { exitCode = ExitCode.ConfigurationError; break; } Console.WriteLine($"Root path:{Environment.NewLine} {engineManager.Engine.FileSystem.RootPath}"); Console.WriteLine($"Input path(s):{Environment.NewLine} {string.Join(Environment.NewLine + " ", engineManager.Engine.FileSystem.InputPaths)}"); Console.WriteLine($"Root path:{Environment.NewLine} {engineManager.Engine.FileSystem.OutputPath}"); if (!engineManager.Execute()) { exitCode = ExitCode.ExecutionError; break; } // Clear the changed files since we just re-ran string changedFile; while (_changedFiles.TryDequeue(out changedFile)) { } _newEngine.Unset(); } else { // Execute if files have changed HashSet <string> changedFiles = new HashSet <string>(); string changedFile; while (_changedFiles.TryDequeue(out changedFile)) { if (changedFiles.Add(changedFile)) { Trace.Verbose("{0} has changed", changedFile); } } if (changedFiles.Count > 0) { Trace.Information("{0} files have changed, re-executing", changedFiles.Count); if (!engineManager.Execute()) { exitCode = ExitCode.ExecutionError; break; } } } // Check one more time for exit if (_exit) { break; } Trace.Information("Hit any key to exit"); _messageEvent.Reset(); } // Shutdown Trace.Information("Shutting down"); engineManager.Dispose(); inputFolderWatcher?.Dispose(); configFileWatcher?.Dispose(); previewServer?.Dispose(); } return((int)exitCode); }
public static int Main(string[] args) { object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); _assemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title; attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); _assemblyVersion = Attribute.GetCustomAttribute(typeof(MainClass).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; _assemblyCopyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; AaruConsole.WriteLineEvent += System.Console.WriteLine; AaruConsole.WriteEvent += System.Console.Write; AaruConsole.ErrorWriteLineEvent += System.Console.Error.WriteLine; Settings.Settings.LoadSettings(); var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); ctx.Database.Migrate(); ctx.SaveChanges(); bool masterDbUpdate = false; if (!File.Exists(Settings.Settings.MasterDbPath)) { masterDbUpdate = true; UpdateCommand.DoUpdate(true); } var masterContext = AaruContext.Create(Settings.Settings.MasterDbPath); if (masterContext.Database.GetPendingMigrations().Any()) { AaruConsole.WriteLine("New database version, updating..."); try { File.Delete(Settings.Settings.MasterDbPath); } catch (Exception) { AaruConsole.ErrorWriteLine("Exception trying to remove old database version, cannot continue..."); AaruConsole.ErrorWriteLine("Please manually remove file at {0}", Settings.Settings.MasterDbPath); } UpdateCommand.DoUpdate(true); } if ((args.Length < 1 || args[0].ToLowerInvariant() != "gui") && Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel) { new ConfigureCommand(true, true).Invoke(args); } Statistics.LoadStats(); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Statistics.SaveStats(); var rootCommand = new RootCommand { new Option(new[] { "--verbose", "-v" }, "Shows verbose output.") { Argument = new Argument <bool>(() => false) }, new Option(new[] { "--debug", "-d" }, "Shows debug output from plugins.") { Argument = new Argument <bool>(() => false) } }; rootCommand.Description = $"{_assemblyTitle} {_assemblyVersion?.InformationalVersion}\n{_assemblyCopyright}"; rootCommand.AddCommand(new DatabaseFamily(masterDbUpdate)); rootCommand.AddCommand(new DeviceFamily()); rootCommand.AddCommand(new FilesystemFamily()); rootCommand.AddCommand(new ImageFamily()); rootCommand.AddCommand(new MediaFamily()); rootCommand.AddCommand(new ConfigureCommand(false, false)); rootCommand.AddCommand(new FormatsCommand()); rootCommand.AddCommand(new ListEncodingsCommand()); rootCommand.AddCommand(new ListNamespacesCommand()); rootCommand.AddCommand(new RemoteCommand()); return(rootCommand.Invoke(args)); }
public void CtorTest() { var a = new AssemblyInformationalVersionAttribute("1.2.3.4"); Assert.AreEqual("1.2.3.4", a.InformationalVersion); }
public static string GetVersionInformationString() { string str = ""; object[] attr = typeof(AboutSharpDevelopTabPage).Assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); if (attr.Length == 1) { AssemblyInformationalVersionAttribute aiva = (AssemblyInformationalVersionAttribute)attr[0]; str += "SharpDevelop Version : " + aiva.InformationalVersion + Environment.NewLine; } try { string version = null; using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full")) { if (key != null) { version = key.GetValue("Version") as string; } } if (string.IsNullOrWhiteSpace(version)) { version = Environment.Version.ToString(); } str += ".NET Version : " + version + Environment.NewLine; } catch {} str += "OS Version : " + Environment.OSVersion.ToString() + Environment.NewLine; string cultureName = null; try { cultureName = CultureInfo.CurrentCulture.Name; str += "Current culture : " + CultureInfo.CurrentCulture.EnglishName + " (" + cultureName + ")" + Environment.NewLine; } catch {} try { if (cultureName == null || !cultureName.StartsWith(ResourceService.Language, StringComparison.Ordinal)) { str += "Current UI language : " + ResourceService.Language + Environment.NewLine; } } catch {} try { if (IntPtr.Size != 4) { str += "Running as " + (IntPtr.Size * 8) + " bit process" + Environment.NewLine; } string PROCESSOR_ARCHITEW6432 = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"); if (!string.IsNullOrEmpty(PROCESSOR_ARCHITEW6432)) { if (PROCESSOR_ARCHITEW6432 == "AMD64") { PROCESSOR_ARCHITEW6432 = "x86-64"; } str += "Running under WOW6432, processor architecture: " + PROCESSOR_ARCHITEW6432 + Environment.NewLine; } } catch {} try { if (SystemInformation.TerminalServerSession) { str += "Terminal Server Session" + Environment.NewLine; } if (SystemInformation.BootMode != BootMode.Normal) { str += "Boot Mode : " + SystemInformation.BootMode + Environment.NewLine; } } catch {} str += "Working Set Memory : " + (Environment.WorkingSet / 1024) + "kb" + Environment.NewLine; str += "GC Heap Memory : " + (GC.GetTotalMemory(false) / 1024) + "kb" + Environment.NewLine; return(str); }
public static string GetAssemblyInformationalVersion() { AssemblyInformationalVersionAttribute attribute = typeof(AdalIdHelper).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>(); return((attribute != null) ? attribute.InformationalVersion : string.Empty); }
/// <summary> /// Version associated with the specified Info Version Attribute /// </summary> /// <param name="versionAttr"></param> public SemVer(AssemblyInformationalVersionAttribute versionAttr) : this(versionAttr.InformationalVersion) { }