/
diev
/
PropertySystem
Обзор
Документация
Войти
/
diev
/
PropertySystem
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
CleanProperties/Program.cs
126 строк
4 KB
Dmitrii Evdokimov
Add passing of exception
14 дек 2023, 11:53
14 дек 2023, 11:53
c701a57
Код
Авторство
О чём код?
#region License /* Copyright 2022-2023 Dmitrii Evdokimov Open source software Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #endregion using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Text; using Diev.Extensions.Log; using Microsoft.Extensions.Configuration; namespace CleanProperties; public class Program { private const string _appSettings = "appsettings.json"; //public ProgramSettings Settings { get; set; } static int Main(string[] args) { int result; #if !DEBUG try { #endif Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); string curDirectory = Directory.GetCurrentDirectory(); string appDirectory = Path.GetDirectoryName(Environment.ProcessPath) ?? curDirectory; IConfiguration config = new ConfigurationBuilder() .SetBasePath(curDirectory) .AddJsonFile(Path.Combine(appDirectory, _appSettings), true, false) .AddJsonFile(_appSettings, true, false) //CurrentDirectory .Build(); Logger.Reset(); result = Worker.DoAction(args, config); #if !DEBUG } catch (Exception e) { Logger.LastError(e); result = 1; } //if (Debugger.IsAttached) //{ // Console.WriteLine(); // Console.Write("Press any key to exit..."); // Console.ReadKey(true); //} #endif return result; } public static void Usage() { var assembly = Assembly.GetExecutingAssembly(); var app = Path.GetFileNameWithoutExtension(Environment.ProcessPath); var info = @$"{app} v{assembly.GetName().Version} {assembly.GetCustomAttributes<AssemblyDescriptionAttribute>().FirstOrDefault()?.Description} Usage: {app} OPTIONS Filename OPTIONS: -? Help. -enum [Filter] Enumerate all properties optionally filtered (starting with) by the 'Filter' value. -get Property Get the value for the 'Property' defined by its Canonical Name. -set Property Value Set the 'Value' for the 'Property'. -info Property Get a schema information on the 'Property'. 'Filename' may be a 'Directory' also (recursively): -check Check properties for possible personal data. -clean Clean properties with possible personal data. -batch Process by {_appSettings}, not Filename. Examples: {app} -enum foo.docx {app} -enum System.Photo foo.jpg {app} -get System.Author foo.jpg {app} -set System.Author ""Jane Smith;John Smith"" foo.docx {app} -set System.Photo.MeteringMode 2 foo.jpg {app} -set System.Photo.DateTaken ""4/27/2023 12:03:02"" foo.jpg {app} -check C:\TEMP {app} -clean foo.docx {app} -info System.Author OS: {Environment.OSVersion} NET: {Environment.Version} Settings: ""{Path.Combine(Directory.GetCurrentDirectory(), _appSettings)}"" Log: ""{Logger.FileName}"" Press any key to exit..."; Console.WriteLine(info); Console.ReadKey(true); } }