Compare commits
3 Commits
4a8e1a987b
...
oldrelease
Author | SHA1 | Date | |
---|---|---|---|
878ff89f98 | |||
|
25281888c4 | ||
|
f40ec83545 |
11
README.md
11
README.md
@@ -1,10 +1,7 @@
|
|||||||
# anbsoftware_componentspack
|
# Что такое ANB Software Components Pack?
|
||||||
some classes that extend the capabilities of the C # language
|
ANB Software Components Pack - набор полезных классов C#, которые расширяют возможности языка.
|
||||||
|
Они могут использоваться в приложенях для ОС Widows и серверов на базе этой ОС.
|
||||||
|
|
||||||
# Welcome to ANB Software Components Pack!
|
# Лицензия
|
||||||
|
|
||||||
You are on the component set «ANB» page. Thanks for your interest in the project
|
|
||||||
|
|
||||||
# License
|
|
||||||
|
|
||||||
MIIT
|
MIIT
|
||||||
|
@@ -1,63 +0,0 @@
|
|||||||
using anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс ошибки
|
|
||||||
/// </summary>
|
|
||||||
public sealed class ActionError: IActionError
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Критичность ошибки:
|
|
||||||
/// при некритичных ошибках продолжение выполнения операции возможно,
|
|
||||||
/// а при критичных -- нет
|
|
||||||
/// </summary>
|
|
||||||
public bool IsCritical { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Объект ошибки
|
|
||||||
/// </summary>
|
|
||||||
public object Object { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сообщение об ошибке
|
|
||||||
/// </summary>
|
|
||||||
public string Message { get; set; }
|
|
||||||
|
|
||||||
#region Конструкторы
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор по умолчанию
|
|
||||||
/// </summary>
|
|
||||||
public ActionError ()
|
|
||||||
{
|
|
||||||
IsCritical = true;
|
|
||||||
Object = "Not Implemented";
|
|
||||||
Message = "Not Implemented";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор с 2 параметрами
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message">Сообщение</param>
|
|
||||||
/// <param name="isCritical">Критичность ошибки</param>
|
|
||||||
public ActionError (string message, bool isCritical = true)
|
|
||||||
{
|
|
||||||
IsCritical = isCritical;
|
|
||||||
Object = "";
|
|
||||||
Message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор с 3 параметрами
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="eObject">Объект ошибки</param>
|
|
||||||
/// <param name="message">Сообщение</param>
|
|
||||||
/// <param name="isCritical">Критичность ошибки</param>
|
|
||||||
public ActionError (object eObject, string message, bool isCritical = true)
|
|
||||||
{
|
|
||||||
IsCritical = isCritical;
|
|
||||||
Object = eObject;
|
|
||||||
Message = message;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
@@ -1,49 +0,0 @@
|
|||||||
using anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс предупреждения
|
|
||||||
/// </summary>
|
|
||||||
public sealed class ActionInfo: IActionInfo
|
|
||||||
{
|
|
||||||
#region Конструкторы
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор по умолчанию
|
|
||||||
/// </summary>
|
|
||||||
public ActionInfo ()
|
|
||||||
{
|
|
||||||
IsStatusInfo = false;
|
|
||||||
Object = string.Empty;
|
|
||||||
Message = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="eObject">Объект</param>
|
|
||||||
/// <param name="message">Сообщение</param>
|
|
||||||
/// <param name="isStatus">Является статусной информацией?</param>
|
|
||||||
public ActionInfo (string eObject, string message, bool isStatus = false)
|
|
||||||
{
|
|
||||||
IsStatusInfo = isStatus;
|
|
||||||
Object = eObject;
|
|
||||||
Message = message;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Реализация интерфейса
|
|
||||||
/// <summary>
|
|
||||||
/// Объект
|
|
||||||
/// </summary>
|
|
||||||
public object Object { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Сообщение
|
|
||||||
/// </summary>
|
|
||||||
public string Message { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Статусная информация (например, начало работы)
|
|
||||||
/// </summary>
|
|
||||||
public bool IsStatusInfo { get; init; }
|
|
||||||
#endregion
|
|
||||||
}
|
|
@@ -1,316 +0,0 @@
|
|||||||
using anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Состояние действия
|
|
||||||
///
|
|
||||||
/// Обновлено 2023.01.121.1:
|
|
||||||
/// * Заменены интерфейсы IAction* на соответствующие классы
|
|
||||||
/// </summary>
|
|
||||||
public sealed class ActionState
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public ActionState ()
|
|
||||||
{
|
|
||||||
Info = new();
|
|
||||||
Warnings = new();
|
|
||||||
Errors = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Список информации
|
|
||||||
/// </summary>
|
|
||||||
public List<ActionInfo> Info { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Список предупреждений
|
|
||||||
/// </summary>
|
|
||||||
public List<ActionWarning> Warnings { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Список ошибок
|
|
||||||
/// </summary>
|
|
||||||
public List<ActionError> Errors { get; }
|
|
||||||
|
|
||||||
#region Методы
|
|
||||||
|
|
||||||
#region Очистка
|
|
||||||
/// <summary>
|
|
||||||
/// Очищает список ошибок
|
|
||||||
/// </summary>
|
|
||||||
public void ClearErrors ()
|
|
||||||
{
|
|
||||||
Errors.Clear();
|
|
||||||
Errors.TrimExcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Очищает список предупреждений
|
|
||||||
/// </summary>
|
|
||||||
public void ClearWarnings ()
|
|
||||||
{
|
|
||||||
Warnings.Clear();
|
|
||||||
Warnings.TrimExcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Очищает список информации
|
|
||||||
/// </summary>
|
|
||||||
public void ClearInfo ()
|
|
||||||
{
|
|
||||||
Info.Clear();
|
|
||||||
Info.TrimExcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Очищает все списки
|
|
||||||
/// </summary>
|
|
||||||
public void Clear ()
|
|
||||||
{
|
|
||||||
ClearInfo();
|
|
||||||
ClearWarnings();
|
|
||||||
ClearErrors();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Добавление ошибки
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление ошибки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="error">Ошибка</param>
|
|
||||||
// ReSharper disable once MemberCanBeMadeStatic.Global
|
|
||||||
// ReSharper disable once FunctionRecursiveOnAllPaths
|
|
||||||
public void AddError (ActionError error) => Errors.Add(error);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавляет ошибки в список
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="errors">Список ошибок</param>
|
|
||||||
public void AddErrors(IEnumerable<ActionError> errors) => Errors.AddRange(errors);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление ошибки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="critical">Является ли ошибка критической</param>
|
|
||||||
public void AddError (bool critical = true)
|
|
||||||
{
|
|
||||||
//Создаю ошибку
|
|
||||||
ActionError error = new("", critical);
|
|
||||||
|
|
||||||
//Добавляю ошибку
|
|
||||||
AddError(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление ошибки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message">Сообщение об ошибке</param>
|
|
||||||
/// <param name="critical">Является ли ошибка критической</param>
|
|
||||||
public void AddError (string message, bool critical = true)
|
|
||||||
{
|
|
||||||
//Создаю ошибку
|
|
||||||
ActionError error = new(message, critical);
|
|
||||||
|
|
||||||
//Добавляю ошибку
|
|
||||||
AddError(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление ошибки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="errorObject">Объект ошибки</param>
|
|
||||||
/// <param name="message">Сообщение об ошибке</param>
|
|
||||||
/// /// <param name="critical">Является ли ошибка критической</param>
|
|
||||||
public void AddError (string errorObject, string message, bool critical = true)
|
|
||||||
{
|
|
||||||
//Создаю ошибку
|
|
||||||
ActionError error = new(errorObject, message, critical);
|
|
||||||
|
|
||||||
//Добавляю ошибку
|
|
||||||
AddError(error);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Добавление предупреждения
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление предупреждения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="warning">Предупреждение</param>
|
|
||||||
public void AddWarning (ActionWarning warning) => Warnings.Add(warning);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление предупреждений
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="warnings">Список предупреждений</param>
|
|
||||||
public void AddWarnings(IEnumerable<ActionWarning> warnings) => Warnings.AddRange(warnings);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление предупреждение
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message">Текст предупреждения</param>
|
|
||||||
/// <param name="warningObject">Объект предупреждения</param>
|
|
||||||
public void AddWarning (string message, string warningObject = "")
|
|
||||||
{
|
|
||||||
//Создаю предупреждение
|
|
||||||
ActionWarning warning = new(warningObject, message);
|
|
||||||
|
|
||||||
//Добавляю предупреждение
|
|
||||||
AddWarning(warning);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Добавление информации
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление информации
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info">Информация</param>
|
|
||||||
public void AddInfo (ActionInfo info) => Info.Add(info);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление информации
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="infos">Список информации</param>
|
|
||||||
public void AddInfos (IEnumerable<ActionInfo> infos) => Info.AddRange(infos);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление информации
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message">Текст информации</param>
|
|
||||||
/// <param name="infoObject">Объект информации</param>
|
|
||||||
public void AddInfo (string message, string infoObject = "")
|
|
||||||
{
|
|
||||||
//Создаю информацию
|
|
||||||
ActionInfo info = new(infoObject, message);
|
|
||||||
|
|
||||||
//Добавляю информацию
|
|
||||||
AddInfo(info);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Печать
|
|
||||||
/// <summary>
|
|
||||||
/// Печать списка ошибок
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="formatList">Формат списка</param>
|
|
||||||
/// <param name="formatItem">Формат элемента списка</param>
|
|
||||||
/// <returns>Список ошибок в текстовой форме</returns>
|
|
||||||
public string PrintErrorList (string formatList, string formatItem)
|
|
||||||
{
|
|
||||||
string elements =
|
|
||||||
#pragma warning disable CS8625
|
|
||||||
Errors.Aggregate<IActionError, string>(null, (current, error) => current + error.PrintMessage(formatItem));
|
|
||||||
#pragma warning restore CS8625
|
|
||||||
|
|
||||||
return string.Format(formatList, elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Печать списка предупреждений
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="formatList">Формат списка</param>
|
|
||||||
/// <param name="formatItem">Формат элемента списка</param>
|
|
||||||
/// <returns>Список предупреждений в текстовой форме</returns>
|
|
||||||
public string PrintWarningList (string formatList, string formatItem)
|
|
||||||
{
|
|
||||||
string elements =
|
|
||||||
#pragma warning disable CS8625
|
|
||||||
Warnings.Aggregate<IActionWarning, string>(null,
|
|
||||||
#pragma warning restore CS8625
|
|
||||||
(current, warning) => current + warning.PrintMessage(formatItem));
|
|
||||||
|
|
||||||
return string.Format(formatList, elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Печать списка информации
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="formatList">Формат списка</param>
|
|
||||||
/// <param name="formatItem">Формат элемента списка</param>
|
|
||||||
/// <returns>Список информации в текстовой форме</returns>
|
|
||||||
public string PrintInfoList (string formatList, string formatItem)
|
|
||||||
{
|
|
||||||
string elements =
|
|
||||||
#pragma warning disable CS8625
|
|
||||||
Info.Aggregate<IActionInfo, string>(null, (current, info) => current + info.PrintMessage(formatItem));
|
|
||||||
#pragma warning restore CS8625
|
|
||||||
|
|
||||||
return string.Format(formatList, elements);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Проверка на наличие
|
|
||||||
/// <summary>
|
|
||||||
/// Проверяет, есть ли ошибки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ignoreNonCritical">Игнорировать не критические</param>
|
|
||||||
/// <returns>Наличие ошибок</returns>
|
|
||||||
public bool HasErrors (bool ignoreNonCritical = false) =>
|
|
||||||
ignoreNonCritical ? Errors.Any(static error => error.IsCritical) : Errors.Any();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверяет, есть ли предупреждения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ignoreInformWarning">Игнорировать информационные предупреждения</param>
|
|
||||||
/// <returns>Наличие предупреждений</returns>
|
|
||||||
public bool HasWarnings (bool ignoreInformWarning = false) => ignoreInformWarning
|
|
||||||
? Warnings.Any(static warning => !warning.IsInformWarning)
|
|
||||||
: Warnings.Any();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверяет, есть ли сообщения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ignoreStatus">Игнорировать статусные сообщения</param>
|
|
||||||
/// <returns>Наличие сообщений</returns>
|
|
||||||
public bool HasInfo (bool ignoreStatus) => ignoreStatus ? Info.Any(static info => !info.IsStatusInfo) : Info.Any();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Успешно ли завершилось
|
|
||||||
/// </summary>
|
|
||||||
public bool IsSuccess (bool ignoreNonCriticalErrors = false) =>
|
|
||||||
!HasErrors(ignoreNonCriticalErrors) && !HasWarnings(true);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Количество сообщений
|
|
||||||
/// <summary>
|
|
||||||
/// Количество ошибок
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ignoreNonCritical">Игнорировать не критические</param>
|
|
||||||
/// <returns>Количество ошибок</returns>
|
|
||||||
public int ErrorsCount (bool ignoreNonCritical = false) =>
|
|
||||||
ignoreNonCritical ? Errors.Count(static error => error.IsCritical) : Errors.Count;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Количество предупреждений
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ignoreInformWarning">Игнорировать информационные предупреждения</param>
|
|
||||||
/// <returns>Количество предупреждений</returns>
|
|
||||||
public int WarningsCount (bool ignoreInformWarning = false) => ignoreInformWarning
|
|
||||||
? Warnings.Count(static warning => !warning.IsInformWarning)
|
|
||||||
: Warnings.Count;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Количество информационных сообщений
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ignoreStatus">Игнорировать статусные сообщения</param>
|
|
||||||
/// <returns>Количество информационных сообщений</returns>
|
|
||||||
public int InfoCount (bool ignoreStatus) => ignoreStatus ? Info.Count(static info => !info.IsStatusInfo) : Info.Count;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Добавление другого состояния
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавляет другое состояние (например, результат другого действия, который возвращает <see cref="ActionState"/>).
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="state">Запись состояния</param>
|
|
||||||
public void AddState(ActionState state)
|
|
||||||
{
|
|
||||||
AddErrors(state.Errors);
|
|
||||||
AddWarnings(state.Warnings);
|
|
||||||
AddInfos(state.Info);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#endregion
|
|
||||||
}
|
|
@@ -1,49 +0,0 @@
|
|||||||
using anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс предупреждения
|
|
||||||
/// </summary>
|
|
||||||
public sealed class ActionWarning: IActionWarning
|
|
||||||
{
|
|
||||||
#region Конструкторы
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор по умолчанию
|
|
||||||
/// </summary>
|
|
||||||
public ActionWarning ()
|
|
||||||
{
|
|
||||||
IsInformWarning = false;
|
|
||||||
Object = string.Empty;
|
|
||||||
Message = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="eObject">Объект</param>
|
|
||||||
/// <param name="message">Сообщение</param>
|
|
||||||
/// <param name="isInform">Является ли информирующим предупреждением</param>
|
|
||||||
public ActionWarning (string eObject, string message, bool isInform = false)
|
|
||||||
{
|
|
||||||
IsInformWarning = isInform;
|
|
||||||
Object = eObject;
|
|
||||||
Message = message;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Реализация интерфейса
|
|
||||||
/// <summary>
|
|
||||||
/// Объект
|
|
||||||
/// </summary>
|
|
||||||
public object Object { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Сообщение
|
|
||||||
/// </summary>
|
|
||||||
public string Message { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Информирующее предупреждение возникает для предупреждения ВОЗМОЖНОЙ ошибки в дальнейшей эксплуатации и не влияет на текущую операцию.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsInformWarning { get; init; }
|
|
||||||
#endregion
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конвертер количества элементов
|
|
||||||
/// </summary>
|
|
||||||
public sealed class CountConverter : ValueConverter
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Имена размеров файлов по умолчанию
|
|
||||||
/// </summary>
|
|
||||||
public static readonly string[] DefaultNames = {"", "тыс.", "млн."};
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор класса
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="valueNames">Массив имён размерностей</param>
|
|
||||||
/// <param name="decimalPlace">Знаков после запятой (0, 1, 2)</param>
|
|
||||||
public CountConverter (string[] valueNames, byte decimalPlace = 0) : base(valueNames, 1000, decimalPlace)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,50 +0,0 @@
|
|||||||
using anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Форматирует число элементов в понятную строку
|
|
||||||
/// </summary>
|
|
||||||
public sealed class CountFormatter : IValueFormatter
|
|
||||||
{
|
|
||||||
#region Cвойства класса
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имена чисел (тысяч, миллионов, миллиардов и т.п.)
|
|
||||||
/// </summary>
|
|
||||||
public string[] CountNames { get; set; } = { "", "тыс.", "млн.", "млрд." };
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Знаков после запятой
|
|
||||||
/// </summary>
|
|
||||||
public byte DecimalPlaces { get; set; } = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Делители чисел
|
|
||||||
/// </summary>
|
|
||||||
public long[] Delimeters { get; set; } = { 1000, 1000000, 1000000000 };
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Реализация интерфейса
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Реализация интерфейса
|
|
||||||
/// </summary>
|
|
||||||
public string[] ValueNames
|
|
||||||
{
|
|
||||||
get => CountNames;
|
|
||||||
set => CountNames = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Реализация интерфейса
|
|
||||||
/// </summary>
|
|
||||||
public long[] MaxSizes
|
|
||||||
{
|
|
||||||
get => Delimeters;
|
|
||||||
set => Delimeters = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
@@ -1,51 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
|
|
||||||
using gfoidl.Base64;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes.Encrypt;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс для шифровки строк
|
|
||||||
/// </summary>
|
|
||||||
public static class StringEncrypt
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Метод для шифрования строки <paramref name="text"/>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="text">Строка, которая должна быть зашифрована</param>
|
|
||||||
/// <returns>Этот статический метод возвращает зашифрованную строку <paramref name="text"/></returns>
|
|
||||||
public static string Encrypt (string text)
|
|
||||||
{
|
|
||||||
byte[] byteText = Encoding.UTF8.GetBytes(text);
|
|
||||||
return Base64.Url.Encode(byteText);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Метод для шифрования массива строк <paramref name="bytes"/>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="bytes">Массив строк</param>
|
|
||||||
/// <returns>Этот статический метод возвращает зашифрованную строку из массива <paramref name="bytes"/></returns>
|
|
||||||
public static string EncryptBytes (byte[] bytes) => Base64.Url.Encode(bytes);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Метод для дешифрования строки <paramref name="text"/>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="text">Строка, которая должна быть дешифрована</param>
|
|
||||||
/// <returns>Этот статический метод возвращает дешифрованную строку <paramref name="text"/></returns>
|
|
||||||
public static string Decrypt (string text)
|
|
||||||
{
|
|
||||||
string guidBase64Url = text.Replace('+', '-').Replace('/', '_').TrimEnd('=');
|
|
||||||
return Encoding.UTF8.GetString(Base64.Url.Decode(guidBase64Url));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Метод для дешифрования в массив byte
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="text">Строка, которая должна быть дешифрована</param>
|
|
||||||
/// <returns>Этот статический метод возвращает дешифрованный массива byte[]</returns>
|
|
||||||
public static byte[] DecryptBytes (string text)
|
|
||||||
{
|
|
||||||
string guidBase64Url = text.Replace('+', '-').Replace('/', '_').TrimEnd('=');
|
|
||||||
return Base64.Url.Decode(guidBase64Url);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,37 +0,0 @@
|
|||||||
namespace anbs_cp.Classes.Exceptions;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-исключение для переименования папок/файлов
|
|
||||||
/// </summary>
|
|
||||||
public sealed class RenameException : Exception
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Имя файла/папки
|
|
||||||
/// </summary>
|
|
||||||
public string FileName { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Описание ошибки
|
|
||||||
/// </summary>
|
|
||||||
public string? ErrorMessage { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName">Имя файла/папки</param>
|
|
||||||
/// <param name="errorMessage">Описание ошибки</param>
|
|
||||||
public RenameException(string fileName, string? errorMessage) : base(GetMessage(fileName, errorMessage ?? string.Empty))
|
|
||||||
{
|
|
||||||
FileName = fileName;
|
|
||||||
ErrorMessage = errorMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение текстового представление ошибки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName">Имя файла/папки</param>
|
|
||||||
/// <param name="errorMessage">Описание ошибки</param>
|
|
||||||
/// <returns>Текстовое представление ошибки</returns>
|
|
||||||
private static string GetMessage(string fileName, string errorMessage) =>
|
|
||||||
$"При переименовании файла/папки {fileName} возникла следующая ошибка: {errorMessage}";
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
using System.Security.Cryptography;
|
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс -- расширение для класса File
|
|
||||||
/// </summary>
|
|
||||||
public static class FileExtension
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Получает MIME-тип файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Имя файла</param>
|
|
||||||
/// <returns>MIME-тип файла</returns>
|
|
||||||
public static string MIMEType (string filename) =>
|
|
||||||
MimeTypes.GetMimeType(filename);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получает MIME-тип файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="file">Загружаемый файл</param>
|
|
||||||
/// <returns>MIME-тип файла</returns>
|
|
||||||
public static string MIMEType (IFormFile file) =>
|
|
||||||
file.ContentType;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Размер файла в байтах
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName">Полное имя и путь к файлу</param>
|
|
||||||
/// <returns>Размер файла в байтах</returns>
|
|
||||||
public static long FileSize(string fileName)
|
|
||||||
{
|
|
||||||
FileInfo fileInfo = new (fileName);
|
|
||||||
|
|
||||||
return fileInfo.Length;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,67 +0,0 @@
|
|||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс для работы с хэшем файла
|
|
||||||
/// </summary>
|
|
||||||
public sealed class FileHash
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Получение md5-хэша файла.
|
|
||||||
/// Взято с https://stackoverflow.com/a/24031467/16469671
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName">Имя файла</param>
|
|
||||||
/// <returns>Массив хэша</returns>
|
|
||||||
public FileHash (string fileName)
|
|
||||||
{
|
|
||||||
using MD5 md5 = MD5.Create();
|
|
||||||
using FileStream stream = File.OpenRead(fileName);
|
|
||||||
Hash = md5.ComputeHash(stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение md5-хэша загружаемого файла.
|
|
||||||
/// Взято с https://stackoverflow.com/a/67081012/16469671
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="file">Загружаемый файл</param>
|
|
||||||
/// <returns>Массив хэша</returns>
|
|
||||||
public FileHash (IFormFile file)
|
|
||||||
{
|
|
||||||
using MD5 md5 = MD5.Create();
|
|
||||||
using StreamReader streamReader = new(file.OpenReadStream());
|
|
||||||
Hash = md5.ComputeHash(streamReader.BaseStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Простой конструктор
|
|
||||||
/// </summary>
|
|
||||||
public FileHash ()
|
|
||||||
{
|
|
||||||
Hash = new byte[] { };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Хэш файла
|
|
||||||
/// </summary>
|
|
||||||
public byte[] Hash { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод в строку
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Строка хэша файла</returns>
|
|
||||||
public override string ToString () => BitConverter.ToString(Hash).Replace("-", "").ToLowerInvariant();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конвертирует строку в хэш
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">Строка</param>
|
|
||||||
public void FromString (string value)
|
|
||||||
{
|
|
||||||
UTF8Encoding utf8 = new();
|
|
||||||
Hash = utf8.GetBytes(value);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конвертер размеров файлов
|
|
||||||
/// </summary>
|
|
||||||
public sealed class FileSizeConverter : ValueConverter
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Имена размеров файлов по умолчанию
|
|
||||||
/// </summary>
|
|
||||||
public static readonly string[] DefaultNames = {"байт", "Кб", "Мб", "Гб", "Тб"};
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор класса
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="valueNames">Массив имён размерностей</param>
|
|
||||||
/// <param name="decimalPlace">Знаков после запятой (0, 1, 2)</param>
|
|
||||||
public FileSizeConverter (string[] valueNames, byte decimalPlace = 2) : base(valueNames, 1024, decimalPlace)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,71 +0,0 @@
|
|||||||
using anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Форматирует размер файла/папки в понятную строку
|
|
||||||
/// </summary>
|
|
||||||
public class FileSizeFormatter : IValueFormatter
|
|
||||||
{
|
|
||||||
#region Cвойства класса
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имена размеров (байт, килобайт, мегабайт, гигабайт и террабайт)
|
|
||||||
/// </summary>
|
|
||||||
public string[] SizeNames { get; set; } = { "Байт", "Кб", "Мб", "Гб", "Тб" };
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Знаков после запятой
|
|
||||||
/// </summary>
|
|
||||||
public byte DecimalPlaces { get; set; } = 2;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Максимально байт (далее идут Кбайты)
|
|
||||||
/// </summary>
|
|
||||||
public long ByteMax { get; set; } = 1024;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Максимально Кбайт (далее идут Мбайты)
|
|
||||||
/// </summary>
|
|
||||||
public long KByteMax { get; set; } = 1048576;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Максимально Мбайт (далее идут Гбайты)
|
|
||||||
/// </summary>
|
|
||||||
public long MByteMax { get; set; } = 1073741824;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Максимально Гбайт (далее идут Тбайты)
|
|
||||||
/// </summary>
|
|
||||||
public long GByteMax { get; set; } = 1099511627776;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Реализация интерфейса
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Реализация интерфейса
|
|
||||||
/// </summary>
|
|
||||||
public string[] ValueNames
|
|
||||||
{
|
|
||||||
get => SizeNames;
|
|
||||||
set => SizeNames = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Реализация интерфейса
|
|
||||||
/// </summary>
|
|
||||||
public long[] MaxSizes
|
|
||||||
{
|
|
||||||
get => new[] { ByteMax, KByteMax, MByteMax, GByteMax };
|
|
||||||
set
|
|
||||||
{
|
|
||||||
ByteMax = value[0];
|
|
||||||
KByteMax = value[1];
|
|
||||||
MByteMax = value[2];
|
|
||||||
GByteMax = value[3];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
@@ -1,147 +0,0 @@
|
|||||||
using anbs_cp.Classes.Exceptions;
|
|
||||||
using anbs_cp.Enums;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, добавляющий реализацию некоторых методов Delphi, которые упрощают работу в C#.
|
|
||||||
/// </summary>
|
|
||||||
public static class LikeDelphi
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Аналог функции IncludeTrailingBackslash
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">Путь, к которому нужно добавить slash</param>
|
|
||||||
/// <returns>Путь со slash в конце</returns>
|
|
||||||
public static string IncludeTrailingBackslash (string path)
|
|
||||||
{
|
|
||||||
//По умолчанию сохраняем путь
|
|
||||||
string result = path;
|
|
||||||
|
|
||||||
//Если последний символ не "\", то добавим "\" в конце
|
|
||||||
if (path[^1] != '\\')
|
|
||||||
result = $@"{path}\";
|
|
||||||
|
|
||||||
//Вернём результат
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Парсер строки в множество строк
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="str">Строка, которую нужно разбить</param>
|
|
||||||
/// <param name="delimiter">Символ-делитель строки</param>
|
|
||||||
/// <returns>Массив строк</returns>
|
|
||||||
public static List<string> ParseString (string str, char delimiter) => str.Split(delimiter).ToList();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Переименовываю файл
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="oldName">Старое имя файла (с полным путём)</param>
|
|
||||||
/// <param name="newName">Новое имя файла (с полным путём)</param>
|
|
||||||
/// <param name="ifExist">Что делать, если существует</param>
|
|
||||||
/// <exception cref="RenameException">Если <paramref name="ifExist" /> имеет значение <value>RaiseException</value>, то генерируется ошибка переименования файла</exception>
|
|
||||||
public static void RenameFile (string oldName, string newName,
|
|
||||||
EOnExistAction ifExist = EOnExistAction.RaiseException)
|
|
||||||
{
|
|
||||||
//Если целевой файл существует
|
|
||||||
if (File.Exists(newName))
|
|
||||||
switch (ifExist)
|
|
||||||
{
|
|
||||||
//Возбуждать исключение
|
|
||||||
case EOnExistAction.RaiseException:
|
|
||||||
throw new RenameException(newName, "Файл уже существует!");
|
|
||||||
//Прерываю
|
|
||||||
case EOnExistAction.Abort:
|
|
||||||
return;
|
|
||||||
//Игнорирую и перезаписываю файл
|
|
||||||
case EOnExistAction.Ignore:
|
|
||||||
break;
|
|
||||||
//Только для папок (для файлов равносилен RaiseException)
|
|
||||||
case EOnExistAction.RaiseExceptionIfNotEmpty:
|
|
||||||
throw new RenameException(newName, "Файл уже существует!");
|
|
||||||
//Только для папок (для файлов равносилен Abort)
|
|
||||||
case EOnExistAction.AbortIfNotEmpty:
|
|
||||||
return;
|
|
||||||
//по умолчанию - RaiseException
|
|
||||||
default:
|
|
||||||
throw new RenameException(newName, "Файл уже существует!");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Перемещаю файл
|
|
||||||
File.Move(oldName, newName, true);
|
|
||||||
|
|
||||||
//Если начальный файл существует
|
|
||||||
if (File.Exists(oldName))
|
|
||||||
//- удаляю его
|
|
||||||
File.Delete(oldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление папки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dir">Папка</param>
|
|
||||||
public static void RemoveDir (string dir) => Directory.Delete(dir, true);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверяет папку на пустоту
|
|
||||||
/// Оригинальный ответ от OwenGlendower (https://www.cyberforum.ru/windows-forms/thread1995240.html)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dir">Проверяемая папка</param>
|
|
||||||
/// <returns>Пуста (<value>true</value>) или не пуста (<value>false</value>) папка <see cref="dir"/></returns>
|
|
||||||
public static bool IsDirEmpty (string dir) => !Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories).Any();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Переименовывает папку
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="oldName">Старое имя папки (с полным путём)</param>
|
|
||||||
/// <param name="newName">Новое имя папки (с полным путём)</param>
|
|
||||||
/// <param name="ifExist">Что делать, если существует</param>
|
|
||||||
/// <exception cref="RenameException">Если <paramref name="ifExist" /> имеет значение <value>RaiseException</value>, то генерируется ошибка переименования папки</exception>
|
|
||||||
public static void RenameDir (string oldName, string newName,
|
|
||||||
EOnExistAction ifExist = EOnExistAction.RaiseException)
|
|
||||||
{
|
|
||||||
//Если целевая папка существует
|
|
||||||
if (Directory.Exists(newName))
|
|
||||||
{
|
|
||||||
switch (ifExist)
|
|
||||||
{
|
|
||||||
//Возбуждать исключение
|
|
||||||
case EOnExistAction.RaiseException:
|
|
||||||
throw new RenameException(newName, "Папка уже существует!");
|
|
||||||
//Прерывать
|
|
||||||
case EOnExistAction.Abort:
|
|
||||||
return;
|
|
||||||
//Игнорировать и перезаписывать папку
|
|
||||||
case EOnExistAction.Ignore:
|
|
||||||
break;
|
|
||||||
//Возбуждать исключение, если не пустая
|
|
||||||
case EOnExistAction.RaiseExceptionIfNotEmpty:
|
|
||||||
if (!IsDirEmpty(newName))
|
|
||||||
throw new RenameException(newName, "Папка уже существует и не пуста!");
|
|
||||||
|
|
||||||
break;
|
|
||||||
//Прерывать, если не пустая
|
|
||||||
case EOnExistAction.AbortIfNotEmpty:
|
|
||||||
if (!IsDirEmpty(newName))
|
|
||||||
return;
|
|
||||||
|
|
||||||
break;
|
|
||||||
//по умолчанию - RaiseException
|
|
||||||
default:
|
|
||||||
throw new RenameException(newName, "Папка уже существует!");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Удаляю целевую папку
|
|
||||||
RemoveDir(newName);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Перемещаю папку
|
|
||||||
Directory.Move(oldName, newName);
|
|
||||||
|
|
||||||
//Если начальная папка существует
|
|
||||||
if (Directory.Exists(oldName))
|
|
||||||
//- удаляю его
|
|
||||||
RemoveDir(oldName);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,402 +0,0 @@
|
|||||||
using System.Management;
|
|
||||||
using System.Net.NetworkInformation;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
|
|
||||||
using anbs_cp.Classes.OsInfos;
|
|
||||||
using anbs_cp.Enums;
|
|
||||||
using anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация о системе
|
|
||||||
/// </summary>
|
|
||||||
public static class OsInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
static OsInfo ()
|
|
||||||
{
|
|
||||||
Windows = GetWindowsInfo();
|
|
||||||
Processors = GetProcessors();
|
|
||||||
RAM = GetRAMs();
|
|
||||||
Videos = GetVideoAdapterInfos();
|
|
||||||
Drives = GetDriveInfos();
|
|
||||||
Net = GetNet();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация о Windows
|
|
||||||
/// </summary>
|
|
||||||
public static IOsWindowsInfo Windows { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Список с информацией о процессоре(-ах)
|
|
||||||
/// </summary>
|
|
||||||
public static List<IOsProcessorInfo> Processors { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Количество оперативной памяти в байтах
|
|
||||||
/// </summary>
|
|
||||||
public static ulong RAM { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Видеоадаптеры
|
|
||||||
/// </summary>
|
|
||||||
public static List<IOsVideoAdapterInfo> Videos { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Диски
|
|
||||||
/// </summary>
|
|
||||||
public static List<IOsDriveInfo> Drives { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сеть
|
|
||||||
/// </summary>
|
|
||||||
public static List<IOsNetInfo> Net { get; set; }
|
|
||||||
|
|
||||||
#region Служебные методы
|
|
||||||
/// <summary>
|
|
||||||
/// Получает информацию о Windows
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static IOsWindowsInfo GetWindowsInfo () =>
|
|
||||||
new OsWindowsInfo
|
|
||||||
{
|
|
||||||
Version = Environment.OSVersion.ToString(),
|
|
||||||
Is64 = Environment.Is64BitOperatingSystem,
|
|
||||||
PcName = Environment.MachineName,
|
|
||||||
WindowsFolder = Environment.SystemDirectory
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение процессоров
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Список информации о процессорах</returns>
|
|
||||||
private static List<IOsProcessorInfo> GetProcessors ()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Создаю результирующий список
|
|
||||||
List<IOsProcessorInfo> processorsList = new();
|
|
||||||
|
|
||||||
//Создаю классы менеджмента
|
|
||||||
ManagementClass management = new("Win32_Processor");
|
|
||||||
ManagementObjectCollection collection = management.GetInstances();
|
|
||||||
|
|
||||||
//Получаю число процессоров
|
|
||||||
int processorsCount = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["ProcessorId"].Value.ToString()).Count();
|
|
||||||
|
|
||||||
//Перебираю массив данных
|
|
||||||
for (int ind = 0; ind < processorsCount; ind++)
|
|
||||||
{
|
|
||||||
//Создаю элемент информации о процессоре
|
|
||||||
OsProcessorInfo processor = new()
|
|
||||||
{
|
|
||||||
Caption = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Caption"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
Description = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Description"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
DeviceId = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["DeviceID"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
Manufacturer = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Manufacturer"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
MaxClockSpeed = TypeConverter.StrToInt(collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a =>
|
|
||||||
a.Properties["MaxClockSpeed"].Value.ToString())
|
|
||||||
.ElementAtOrDefault(ind) ??
|
|
||||||
"0"),
|
|
||||||
Name = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Name"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
NumberOfCores = TypeConverter.StrToInt(collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a =>
|
|
||||||
a.Properties["NumberOfCores"].Value.ToString())
|
|
||||||
.ElementAtOrDefault(ind) ??
|
|
||||||
"0"),
|
|
||||||
NumberOfLogicalProcessors = TypeConverter.StrToInt(collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["NumberOfLogicalProcessors"].Value.ToString())
|
|
||||||
.ElementAtOrDefault(ind) ?? "0")
|
|
||||||
};
|
|
||||||
|
|
||||||
//Добавляю в список
|
|
||||||
processorsList.Add(processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Возвращаю список
|
|
||||||
return processorsList;
|
|
||||||
}
|
|
||||||
catch (NullReferenceException)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение общее количество оперативной памяти
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Список информации о количестве оперативной памяти</returns>
|
|
||||||
private static ulong GetRAMs ()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Создаю классы менеджмента
|
|
||||||
ManagementClass management = new("Win32_ComputerSystem");
|
|
||||||
ManagementObjectCollection collection = management.GetInstances();
|
|
||||||
|
|
||||||
//Получаю результат
|
|
||||||
return TypeConverter.StrToUInt64(collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["TotalPhysicalMemory"].Value.ToString()).FirstOrDefault() ?? "0");
|
|
||||||
}
|
|
||||||
catch (NullReferenceException)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получает список видеоадаптеров
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Список информации о видеоадаптерах</returns>
|
|
||||||
private static List<IOsVideoAdapterInfo> GetVideoAdapterInfos ()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Создаю результирующий список
|
|
||||||
List<IOsVideoAdapterInfo> videosList = new();
|
|
||||||
|
|
||||||
//Создаю классы менеджмента
|
|
||||||
ManagementClass management = new("Win32_VideoController");
|
|
||||||
ManagementObjectCollection collection = management.GetInstances();
|
|
||||||
|
|
||||||
//Получаю число адаптеров
|
|
||||||
int count = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["DeviceID"].Value.ToString()).Count();
|
|
||||||
|
|
||||||
//Перебираю массив данных
|
|
||||||
for (int ind = 0; ind < count; ind++)
|
|
||||||
{
|
|
||||||
//Создаю элемент информации об адаптере
|
|
||||||
OsVideoAdapterInfo adapter = new()
|
|
||||||
{
|
|
||||||
Caption = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Caption"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
Description = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Description"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
DeviceId = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["DeviceID"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
AdapterRAM = TypeConverter.StrToInt(collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["AdapterRAM"].Value.ToString()).ElementAtOrDefault(ind) ?? "0"),
|
|
||||||
DriverDate = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["DriverDate"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
Name = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Name"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
CurrentResolution = (TypeConverter.StrToInt(collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["CurrentHorizontalResolution"].Value.ToString()).ElementAtOrDefault(ind) ?? "0"),
|
|
||||||
TypeConverter.StrToInt(collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["CurrentVerticalResolution"].Value.ToString())
|
|
||||||
.ElementAtOrDefault(ind) ?? "0")),
|
|
||||||
SystemName = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["SystemName"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
DriverVersion = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["DriverVersion"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
InstalledDisplayDrivers = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["InstalledDisplayDrivers"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
VideoProcessor = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["VideoProcessor"].Value.ToString()).ElementAtOrDefault(ind)
|
|
||||||
};
|
|
||||||
|
|
||||||
//Добавляю в список
|
|
||||||
videosList.Add(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Возвращаю список
|
|
||||||
return videosList;
|
|
||||||
}
|
|
||||||
catch (NullReferenceException)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получает список дисков
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Список информации о дисках</returns>
|
|
||||||
private static List<IOsDriveInfo> GetDriveInfos ()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Создаю результат
|
|
||||||
List<IOsDriveInfo> result = new();
|
|
||||||
|
|
||||||
//Добавление всех HDD/SSD дисков
|
|
||||||
result.AddRange(GetHDDs());
|
|
||||||
|
|
||||||
//Добавление всех CD/DVD/BD дисков
|
|
||||||
result.AddRange(GetCDRom());
|
|
||||||
|
|
||||||
//Вывожу список
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
catch (NullReferenceException)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получаю список HDD/SSD дисков
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Информация обо всех HDD/SSD дисках</returns>
|
|
||||||
private static List<IOsDriveInfo> GetHDDs ()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Создаю результирующий список
|
|
||||||
List<IOsDriveInfo> driveList = new();
|
|
||||||
|
|
||||||
//Создаю классы менеджмента
|
|
||||||
ManagementClass management = new("Win32_DiskDrive");
|
|
||||||
ManagementObjectCollection collection = management.GetInstances();
|
|
||||||
|
|
||||||
//Получаю число адаптеров
|
|
||||||
int count = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["DeviceID"].Value.ToString()).Count();
|
|
||||||
|
|
||||||
//Перебираю массив данных
|
|
||||||
for (int ind = 0; ind < count; ind++)
|
|
||||||
{
|
|
||||||
//Создаю элемент информации об адаптере
|
|
||||||
OsDriveInfo drive = new()
|
|
||||||
{
|
|
||||||
Type = EDriveType.DtHardDisc,
|
|
||||||
Caption = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Caption"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
Description = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Description"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
DeviceId = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["DeviceID"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
Name = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Name"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
TotalSize = TypeConverter.StrToUInt64(collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Size"].Value.ToString()).ElementAtOrDefault(ind) ?? "0"),
|
|
||||||
Model = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Model"].Value.ToString()).ElementAtOrDefault(ind)
|
|
||||||
};
|
|
||||||
|
|
||||||
//Добавляю в список
|
|
||||||
driveList.Add(drive);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Возвращаю список
|
|
||||||
return driveList;
|
|
||||||
}
|
|
||||||
catch (NullReferenceException)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получаю список CD/DVD/BD дисков
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Информация обо всех CD/DVD/BD дисках</returns>
|
|
||||||
private static List<IOsDriveInfo> GetCDRom ()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Создаю результирующий список
|
|
||||||
List<IOsDriveInfo> driveList = new();
|
|
||||||
|
|
||||||
//Создаю классы менеджмента
|
|
||||||
ManagementClass management = new("Win32_CDROMDrive");
|
|
||||||
ManagementObjectCollection collection = management.GetInstances();
|
|
||||||
|
|
||||||
//Получаю число адаптеров
|
|
||||||
int count = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["DeviceID"].Value.ToString()).Count();
|
|
||||||
|
|
||||||
//Перебираю массив данных
|
|
||||||
for (int ind = 0; ind < count; ind++)
|
|
||||||
{
|
|
||||||
//Создаю элемент информации об адаптере
|
|
||||||
OsDriveInfo drive = new()
|
|
||||||
{
|
|
||||||
Type = EDriveType.DtCDRom,
|
|
||||||
Caption = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Caption"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
Description = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Description"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
DeviceId = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["DeviceID"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
Name = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Name"].Value.ToString()).ElementAtOrDefault(ind),
|
|
||||||
//Ставится 0, чтобы не проверять корректность загрузки и читаемость диска, а также избежать удлинения получения информации
|
|
||||||
TotalSize = 0,
|
|
||||||
Model = collection.Cast<ManagementObject>()
|
|
||||||
.Select(static a => a.Properties["Manufacturer"].Value.ToString()).ElementAtOrDefault(ind)
|
|
||||||
};
|
|
||||||
|
|
||||||
//Добавляю в список
|
|
||||||
driveList.Add(drive);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Возвращаю список
|
|
||||||
return driveList;
|
|
||||||
}
|
|
||||||
catch (NullReferenceException)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получаю информацию о сети интернет
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Информация о сети интернет</returns>
|
|
||||||
private static List<IOsNetInfo> GetNet ()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Создаю результирующий список
|
|
||||||
List<IOsNetInfo> netList = new();
|
|
||||||
|
|
||||||
//Получаю информацию о всех сетевых интерфейсах
|
|
||||||
foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
|
|
||||||
{
|
|
||||||
//Создаю элемент
|
|
||||||
OsNetInfo netInfo = new()
|
|
||||||
{
|
|
||||||
Name = adapter.Name,
|
|
||||||
Description = adapter.Description,
|
|
||||||
MacAddress = adapter.OperationalStatus == OperationalStatus.Up
|
|
||||||
? adapter.GetPhysicalAddress().ToString()
|
|
||||||
: null
|
|
||||||
};
|
|
||||||
|
|
||||||
//Получаю IP-адрес
|
|
||||||
foreach (UnicastIPAddressInformation info in adapter.GetIPProperties().UnicastAddresses.Where(
|
|
||||||
static info =>
|
|
||||||
info.Address.AddressFamily == AddressFamily.InterNetwork && info.IsDnsEligible))
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(netInfo.IPAddress))
|
|
||||||
netInfo.IPAddress += ";";
|
|
||||||
netInfo.IPAddress += info.Address.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Добавляю адаптер
|
|
||||||
netList.Add(netInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Возвращаю список
|
|
||||||
return netList;
|
|
||||||
}
|
|
||||||
catch (NullReferenceException)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
@@ -1,59 +0,0 @@
|
|||||||
using anbs_cp.Enums;
|
|
||||||
using anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация о дисках
|
|
||||||
/// </summary>
|
|
||||||
public class OsDriveInfo : IOsDriveInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public OsDriveInfo()
|
|
||||||
{
|
|
||||||
Type = EDriveType.DtHardDisc;
|
|
||||||
Caption = null;
|
|
||||||
Description = null;
|
|
||||||
DeviceId = null;
|
|
||||||
Name = null;
|
|
||||||
Model = null;
|
|
||||||
TotalSize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Тип диска
|
|
||||||
/// </summary>
|
|
||||||
public EDriveType Type { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Заголовок
|
|
||||||
/// </summary>
|
|
||||||
public string? Caption { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Описание
|
|
||||||
/// </summary>
|
|
||||||
public string? Description { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Идентификатор устройства
|
|
||||||
/// </summary>
|
|
||||||
public string? DeviceId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имя устройства
|
|
||||||
/// </summary>
|
|
||||||
public string? Name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Модель
|
|
||||||
/// </summary>
|
|
||||||
public string? Model { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Общий размер
|
|
||||||
/// </summary>
|
|
||||||
public ulong TotalSize { get; set; }
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
using anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация об интернет-соединении
|
|
||||||
/// </summary>
|
|
||||||
public sealed class OsNetInfo: IOsNetInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Заголовок
|
|
||||||
/// </summary>
|
|
||||||
public string? Caption { get => Name; set => _ = value; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Описание
|
|
||||||
/// </summary>
|
|
||||||
public string? Description { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Идентификатор устройства
|
|
||||||
/// </summary>
|
|
||||||
public string? DeviceId { get => Name; set => _ = value; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имя устройства
|
|
||||||
/// </summary>
|
|
||||||
public string? Name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// IP-адрес
|
|
||||||
/// </summary>
|
|
||||||
public string? IPAddress { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// MAC-адрес
|
|
||||||
/// </summary>
|
|
||||||
public string? MacAddress { get; set; }
|
|
||||||
}
|
|
@@ -1,64 +0,0 @@
|
|||||||
using anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс информации о процессоре
|
|
||||||
/// </summary>
|
|
||||||
public sealed class OsProcessorInfo : IOsProcessorInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public OsProcessorInfo()
|
|
||||||
{
|
|
||||||
Caption = null;
|
|
||||||
Description = null;
|
|
||||||
DeviceId = null;
|
|
||||||
Manufacturer = null;
|
|
||||||
MaxClockSpeed = 0;
|
|
||||||
Name = null;
|
|
||||||
NumberOfCores = 0;
|
|
||||||
NumberOfLogicalProcessors = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Заголовок
|
|
||||||
/// </summary>
|
|
||||||
public string? Caption { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Описание
|
|
||||||
/// </summary>
|
|
||||||
public string? Description { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Идентификатор процессора в системе
|
|
||||||
/// </summary>
|
|
||||||
public string? DeviceId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Производитель
|
|
||||||
/// </summary>
|
|
||||||
public string? Manufacturer { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Максимальная тактовая частота
|
|
||||||
/// </summary>
|
|
||||||
public int MaxClockSpeed { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имя процессора
|
|
||||||
/// </summary>
|
|
||||||
public string? Name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Число ядер
|
|
||||||
/// </summary>
|
|
||||||
public int NumberOfCores { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Число потоков
|
|
||||||
/// </summary>
|
|
||||||
public int NumberOfLogicalProcessors { get; set; }
|
|
||||||
}
|
|
@@ -1,82 +0,0 @@
|
|||||||
using anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация о видеокарте
|
|
||||||
/// </summary>
|
|
||||||
internal sealed class OsVideoAdapterInfo : IOsVideoAdapterInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public OsVideoAdapterInfo()
|
|
||||||
{
|
|
||||||
AdapterRAM = 0;
|
|
||||||
Caption = null;
|
|
||||||
CurrentResolution = (0, 0);
|
|
||||||
Description = null;
|
|
||||||
DeviceId = null;
|
|
||||||
DriverDate = null;
|
|
||||||
DriverVersion = null;
|
|
||||||
InstalledDisplayDrivers = null;
|
|
||||||
Name = null;
|
|
||||||
SystemName = null;
|
|
||||||
VideoProcessor = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Память
|
|
||||||
/// </summary>
|
|
||||||
public int AdapterRAM { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Заголовок
|
|
||||||
/// </summary>
|
|
||||||
public string? Caption { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Текущее разрешение
|
|
||||||
/// </summary>
|
|
||||||
public (int, int) CurrentResolution { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Описание
|
|
||||||
/// </summary>
|
|
||||||
public string? Description { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Идентификатор устройства
|
|
||||||
/// </summary>
|
|
||||||
public string? DeviceId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Дата установки драйвера
|
|
||||||
/// </summary>
|
|
||||||
public string? DriverDate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Версия драйвера
|
|
||||||
/// </summary>
|
|
||||||
public string? DriverVersion { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Название драйверов
|
|
||||||
/// </summary>
|
|
||||||
public string? InstalledDisplayDrivers { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имя
|
|
||||||
/// </summary>
|
|
||||||
public string? Name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имя в системе
|
|
||||||
/// </summary>
|
|
||||||
public string? SystemName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Видео процессор
|
|
||||||
/// </summary>
|
|
||||||
public string? VideoProcessor { get; set; }
|
|
||||||
}
|
|
@@ -1,62 +0,0 @@
|
|||||||
using anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация о Windows
|
|
||||||
/// </summary>
|
|
||||||
public sealed class OsWindowsInfo : IOsWindowsInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
///</summary>
|
|
||||||
public OsWindowsInfo()
|
|
||||||
{
|
|
||||||
Version = null;
|
|
||||||
Is64 = true;
|
|
||||||
PcName = null;
|
|
||||||
WindowsFolder = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Версия
|
|
||||||
/// </summary>
|
|
||||||
public string? Version { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 64-разрядная ОС
|
|
||||||
/// </summary>
|
|
||||||
public bool Is64 { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имя компьютера
|
|
||||||
/// </summary>
|
|
||||||
public string? PcName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Путь к папке Windows
|
|
||||||
/// </summary>
|
|
||||||
public string? WindowsFolder { get; set; }
|
|
||||||
|
|
||||||
#region Реализация интерфейса IBasicInfo
|
|
||||||
/// <summary>
|
|
||||||
/// Заголовок
|
|
||||||
/// </summary>
|
|
||||||
public string? Caption { get => Version; set => _= value; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Описание
|
|
||||||
/// </summary>
|
|
||||||
public string? Description { get => Version; set => _= value; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Идентификатор
|
|
||||||
/// </summary>
|
|
||||||
public string? DeviceId { get => Version; set => _= value; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имя
|
|
||||||
/// </summary>
|
|
||||||
public string? Name { get => Version; set => _= value; }
|
|
||||||
#endregion
|
|
||||||
}
|
|
@@ -1,133 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс перевода одинаковых свойств из класса TF в класс T.
|
|
||||||
/// Оригинальные автор(-ы): keenthinker и Avtandil Kavrelishvili.
|
|
||||||
/// Улучшения: А. Н. Бабаев
|
|
||||||
/// URL: https://stackoverflow.com/questions/20410234/how-to-automatically-map-the-values-between-instances-of-two-different-classes-i
|
|
||||||
/// </summary>
|
|
||||||
public static class SimpleMapper
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Перевод одинаковых свойств из класса F в класс TT.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="from">Экземпляр класса F</param>
|
|
||||||
/// <param name="to">Ссылка на экземпляр класса T</param>
|
|
||||||
/// <param name="mode">Тип сопоставления</param>
|
|
||||||
/// <param name="list">Список параметров для сопоставления</param>
|
|
||||||
/// <typeparam name="TF">Класс-родитель</typeparam>
|
|
||||||
/// <typeparam name="T">Класс-приемник</typeparam>
|
|
||||||
public static void MapEx<TF, T>(TF from, ref T to, MapMode mode, List<string> list)
|
|
||||||
{
|
|
||||||
//Копирую поля
|
|
||||||
Type typeOfA = typeof(TF);
|
|
||||||
Type typeOfB = typeof(T);
|
|
||||||
foreach (FieldInfo fieldOfA in typeOfA.GetFields())
|
|
||||||
{
|
|
||||||
//Проверяем выполнение условия и прерываем, если не выполняется
|
|
||||||
if (!CheckCondition<TF>(fieldOfA.Name, fieldOfA.GetValue(from), mode, list))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
//Получаем FieldInfo для b по имени поля a
|
|
||||||
FieldInfo? fieldOfB = typeOfB.GetField(fieldOfA.Name);
|
|
||||||
|
|
||||||
//Присваиваю поля типа B значение поля типа A
|
|
||||||
fieldOfB?.SetValue(to, fieldOfA.GetValue(from));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Копирую свойства
|
|
||||||
foreach (PropertyInfo propertyOfA in typeOfA.GetProperties())
|
|
||||||
{
|
|
||||||
//Проверяем выполнение условия и прерываем, если не выполняется
|
|
||||||
if (!CheckCondition<TF>(propertyOfA.Name, propertyOfA.GetValue(from), mode, list))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
//Получаем PropertyInfo для b по имени свойства a
|
|
||||||
PropertyInfo? propertyOfB = typeOfB.GetProperty(propertyOfA.Name);
|
|
||||||
//Присваиваю свойству типа B значение свойства типа A
|
|
||||||
propertyOfB?.SetValue(to, propertyOfA.GetValue(from));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перевод одинаковых свойств из класса F в класс TT (режим "сопоставление всех параметров").
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="from">Параметр класса F</param>
|
|
||||||
/// <typeparam name="TF">Класс-родитель</typeparam>
|
|
||||||
/// <typeparam name="T">Класс-приемник</typeparam>
|
|
||||||
/// <returns>Элемент класса T</returns>
|
|
||||||
public static T Map<TF, T>(TF from)
|
|
||||||
{
|
|
||||||
//Создаю элемент
|
|
||||||
// ReSharper disable once NullableWarningSuppressionIsUsed
|
|
||||||
T result = (T)Activator.CreateInstance(typeof(T))!;
|
|
||||||
//Сопоставляю по принципу "сопоставление всех параметров"
|
|
||||||
MapEx(from, ref result, MapMode.MapFull, new());
|
|
||||||
//Вывожу в результат
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка выполнения условия
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="itemName">Имя элемента</param>
|
|
||||||
/// <param name="itemValue">Значение элемента</param>
|
|
||||||
/// <param name="mode">Режим проверки</param>
|
|
||||||
/// <param name="list">Список игнорирования/добавления</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static bool CheckCondition<T>(string itemName, object? itemValue, MapMode mode, ICollection<string> list)
|
|
||||||
{
|
|
||||||
//Если режим "Только список" и поля нет в списке,
|
|
||||||
//либо режим "Только не в списке" и поле есть в списке
|
|
||||||
//или режим "Только не пустые" и значение поля пустое,
|
|
||||||
//или режим "Только не по умолчанию" и значение по умолчанию
|
|
||||||
//то пропускаем
|
|
||||||
bool result =
|
|
||||||
mode switch
|
|
||||||
{
|
|
||||||
MapMode.MapFull => true,
|
|
||||||
MapMode.MapNotNull => itemValue != null,
|
|
||||||
MapMode.MapByList => list.Contains(itemName),
|
|
||||||
MapMode.MapIgnoreList => !list.Contains(itemName),
|
|
||||||
MapMode.MapNotDefault => itemValue != default,
|
|
||||||
MapMode.MapNotNullOrDefault => !Equals(itemValue, default(T)),
|
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null)
|
|
||||||
};
|
|
||||||
|
|
||||||
//Возвращаем результат
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перечисление типов сопоставления
|
|
||||||
/// </summary>
|
|
||||||
public enum MapMode
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Сопоставление всех параметров
|
|
||||||
/// </summary>
|
|
||||||
MapFull = 0,
|
|
||||||
/// <summary>
|
|
||||||
/// Сопоставление не пустых параметров
|
|
||||||
/// </summary>
|
|
||||||
MapNotNull = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// Сопоставление по списку
|
|
||||||
/// </summary>
|
|
||||||
MapByList = 2,
|
|
||||||
/// <summary>
|
|
||||||
/// Сопоставление исключая список
|
|
||||||
/// </summary>
|
|
||||||
MapIgnoreList = 3,
|
|
||||||
/// <summary>
|
|
||||||
/// Сопоставление параметров, которые не равны значению по умолчанию
|
|
||||||
/// </summary>
|
|
||||||
MapNotDefault = 4,
|
|
||||||
/// <summary>
|
|
||||||
/// Сопоставление не пустых параметров, которые не равны значению по умолчанию (NotNull и NotDefault одновременно)
|
|
||||||
/// </summary>
|
|
||||||
MapNotNullOrDefault = 5,
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,90 +0,0 @@
|
|||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс проверки временного интервала
|
|
||||||
/// </summary>
|
|
||||||
public static class TimestampValidator
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка попадания в заданный интервал (в мс)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timestamp">Временной интервал</param>
|
|
||||||
/// <param name="checkedStamp">Проверяемый временной интервал</param>
|
|
||||||
/// <param name="deltaMs">Временная дельта в миллисекундах</param>
|
|
||||||
/// <returns>
|
|
||||||
/// Попал ли <paramref name="checkedStamp" /> в промежуток <paramref name="timestamp" /> +
|
|
||||||
/// <paramref name="deltaMs" />
|
|
||||||
/// </returns>
|
|
||||||
public static bool Validate(long timestamp, long checkedStamp, ulong deltaMs) =>
|
|
||||||
new TimeSpan(timestamp) + TimeSpan.FromMilliseconds(deltaMs) > new TimeSpan(checkedStamp);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка попадания текущего времени в заданный интервал (в мс)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timestamp">Временной интервал</param>
|
|
||||||
/// <param name="deltams">Временная дельта в миллисекундах</param>
|
|
||||||
/// <returns>Попадает ли текущее время в промежуток <paramref name="timestamp" /> + <paramref name="deltams" /></returns>
|
|
||||||
public static bool ValidateNow(long timestamp, ulong deltams) =>
|
|
||||||
Validate(timestamp, DateTime.UtcNow.Ticks, deltams);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка временного интервала (в сек)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timestamp">Временной интервал</param>
|
|
||||||
/// <param name="checkedstamp">Проверяемый временной интервал</param>
|
|
||||||
/// <param name="deltasec">Временная дельта в секундах</param>
|
|
||||||
/// <returns>Попал ли <see cref="checkedstamp" /> в промежуток</returns>
|
|
||||||
public static bool ValidateFromSec(long timestamp, long checkedstamp, ulong deltasec) =>
|
|
||||||
Validate(timestamp, checkedstamp, checked(deltasec * 1000UL));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка попадания текущего времени в заданный интервал (в сек)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timestamp">Временной интервал</param>
|
|
||||||
/// <param name="deltasec">Временная дельта в секундах</param>
|
|
||||||
/// <returns>Попадает ли текущее время в промежуток <paramref name="timestamp" /> + <paramref name="deltasec" /></returns>
|
|
||||||
public static bool ValidateFromSecNow(long timestamp, ulong deltasec) =>
|
|
||||||
ValidateFromSec(timestamp, DateTime.UtcNow.Ticks, deltasec);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка временного интервала (в мин)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timestamp">Временной интервал</param>
|
|
||||||
/// <param name="checkedstamp">Проверяемый временной интервал</param>
|
|
||||||
/// <param name="deltamin">Временная дельта в минутах</param>
|
|
||||||
/// <returns>
|
|
||||||
/// Попал ли <see cref="checkedstamp" /> в промежуток <paramref name="timestamp" /> + <paramref name="deltamin" />
|
|
||||||
/// </returns>
|
|
||||||
public static bool ValidateFromMin(long timestamp, long checkedstamp, ulong deltamin) =>
|
|
||||||
Validate(timestamp, checkedstamp, checked(deltamin * 60000UL));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка попадания текущего времени в заданный интервал (в мин)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timestamp">Временной интервал</param>
|
|
||||||
/// <param name="deltamin">Временная дельта в минутах</param>
|
|
||||||
/// <returns>Попадает ли текущее время в промежуток <paramref name="timestamp" /> + <paramref name="deltamin" /></returns>
|
|
||||||
public static bool ValidateFromMinNow(long timestamp, ulong deltamin) =>
|
|
||||||
ValidateFromMin(timestamp, DateTime.UtcNow.Ticks, deltamin);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка временного интервала (в час)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timestamp">Временной интервал</param>
|
|
||||||
/// <param name="checkedstamp">Проверяемый временной интервал</param>
|
|
||||||
/// <param name="deltahr">Временная дельта в часах</param>
|
|
||||||
/// <returns>
|
|
||||||
/// Попал ли <see cref="checkedstamp" /> в промежуток <paramref name="timestamp" /> + <paramref name="deltahr" />
|
|
||||||
/// </returns>
|
|
||||||
public static bool ValidateFromHour(long timestamp, long checkedstamp, ulong deltahr) =>
|
|
||||||
Validate(timestamp, checkedstamp, checked(deltahr * 3600000UL));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка попадания текущего времени в заданный интервал (в час)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timestamp">Временной интервал</param>
|
|
||||||
/// <param name="deltahr">Временная дельта в часах</param>
|
|
||||||
/// <returns>Попадает ли текущее время в промежуток <paramref name="timestamp" /> + <paramref name="deltahr" /></returns>
|
|
||||||
public static bool ValidateFromHourNow(long timestamp, ulong deltahr) =>
|
|
||||||
ValidateFromHour(timestamp, DateTime.UtcNow.Ticks, deltahr);
|
|
||||||
}
|
|
@@ -1,137 +0,0 @@
|
|||||||
using System.Text.Encodings.Web;
|
|
||||||
using Microsoft.AspNetCore.Html;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конвертер типов на манер Delphi
|
|
||||||
/// </summary>
|
|
||||||
public static class TypeConverter
|
|
||||||
{
|
|
||||||
#region Конвертация числа в строку
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразование int в string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AInt">Число</param>
|
|
||||||
/// <returns>Строка</returns>
|
|
||||||
public static string IntToStr(int AInt) => AInt.ToString();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразование uint в string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AInt">Число</param>
|
|
||||||
/// <returns>Строка</returns>
|
|
||||||
public static string IntToStr(uint AInt) => AInt.ToString();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразование long в string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AInt">Число</param>
|
|
||||||
/// <returns>Строка</returns>
|
|
||||||
public static string IntToStr(long AInt) => AInt.ToString();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразование ulong в string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AInt">Число</param>
|
|
||||||
/// <returns>Строка</returns>
|
|
||||||
public static string IntToStr(ulong AInt) => AInt.ToString();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразование byte в string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AInt">Число</param>
|
|
||||||
/// <returns>Строка</returns>
|
|
||||||
public static string IntToStr(byte AInt) => AInt.ToString();
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Конвертация строки в число
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразование строки в число
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AStr">Строка</param>
|
|
||||||
/// <param name="ADefault">Значение по умолчанию (по умолчанию, 0)</param>
|
|
||||||
/// <returns>Число</returns>
|
|
||||||
public static int StrToInt(string AStr, int ADefault = 0)
|
|
||||||
{
|
|
||||||
if (!int.TryParse(AStr, out int result)) result = ADefault;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразование строки в число
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AStr">Строка</param>
|
|
||||||
/// <param name="ADefault">Значение по умолчанию (по умолчанию, 0)</param>
|
|
||||||
/// <returns>Число</returns>
|
|
||||||
public static uint StrToUInt(string AStr, uint ADefault = 0)
|
|
||||||
{
|
|
||||||
if (!uint.TryParse(AStr, out uint result)) result = ADefault;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразование строки в число
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AStr">Строка</param>
|
|
||||||
/// <param name="ADefault">Значение по умолчанию (по умолчанию, 0)</param>
|
|
||||||
/// <returns>Число</returns>
|
|
||||||
public static long StrToInt64(string AStr, long ADefault = 0)
|
|
||||||
{
|
|
||||||
if (!long.TryParse(AStr, out long result)) result = ADefault;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразование строки в число
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AStr">Строка</param>
|
|
||||||
/// <param name="ADefault">Значение по умолчанию (по умолчанию, 0)</param>
|
|
||||||
/// <returns>Число</returns>
|
|
||||||
public static ulong StrToUInt64(string AStr, ulong ADefault = 0)
|
|
||||||
{
|
|
||||||
if (!ulong.TryParse(AStr, out ulong result)) result = ADefault;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразование строки в число
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="AStr">Строка</param>
|
|
||||||
/// <param name="ADefault">Значение по умолчанию (по умолчанию, 0)</param>
|
|
||||||
/// <returns>Число</returns>
|
|
||||||
public static byte StrToByte(string AStr, byte ADefault = 0)
|
|
||||||
{
|
|
||||||
if (!byte.TryParse(AStr, out byte result)) result = ADefault;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Конвернтация IHtmlContent
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразует тип <see cref="IHtmlContent"/> в строку <see cref="string"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="content">Значение, которое нужно преобразовать.</param>
|
|
||||||
/// <returns><see cref="string"/></returns>
|
|
||||||
public static string HtmlContentToString(IHtmlContent content)
|
|
||||||
{
|
|
||||||
//Создаём writer
|
|
||||||
using StringWriter writer = new();
|
|
||||||
//Конвертируем IHtmlContent в string
|
|
||||||
content.WriteTo(writer, HtmlEncoder.Default);
|
|
||||||
//Возвращаем результат
|
|
||||||
return writer.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Преобразует строку <see cref="string"/> в тип <see cref="IHtmlContent"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="content">Значение, которое нужно преобразовать.</param>
|
|
||||||
/// <returns><see cref="IHtmlContent"/></returns>
|
|
||||||
public static IHtmlContent StringToHtmlContent(string content) => new HtmlContentBuilder().AppendHtml(content);
|
|
||||||
#endregion
|
|
||||||
}
|
|
@@ -1,87 +0,0 @@
|
|||||||
using anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
namespace anbs_cp.Classes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Абстрактный класс конвертера величин для отображения (улучшенный аналог ValueFormatter)
|
|
||||||
/// </summary>
|
|
||||||
public abstract class ValueConverter: IValueConverter
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="valueNames">Массив имён размерностей</param>
|
|
||||||
/// <param name="divider">Делитель</param>
|
|
||||||
/// <param name="decimalPlaces">Число знаков после запятой</param>
|
|
||||||
protected ValueConverter (string[] valueNames, long divider, byte decimalPlaces)
|
|
||||||
{
|
|
||||||
ValueNames = valueNames;
|
|
||||||
Divider = divider;
|
|
||||||
DecimalPlaces = (byte)(decimalPlaces < 3 ? decimalPlaces : 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Реализация интерфейса
|
|
||||||
/// <summary>
|
|
||||||
/// Массив имён размерностей
|
|
||||||
/// </summary>
|
|
||||||
public string[] ValueNames { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Делитель
|
|
||||||
/// </summary>
|
|
||||||
public long Divider { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Знаков после запятой (0, 1, 2)
|
|
||||||
/// </summary>
|
|
||||||
public byte DecimalPlaces { get; init; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Методы
|
|
||||||
/// <summary>
|
|
||||||
/// Функция конвертирования в строку
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">Значение</param>
|
|
||||||
/// <returns>Конвертирование значение в строку</returns>
|
|
||||||
public string Convert (long value)
|
|
||||||
{
|
|
||||||
//Получаю разделенное значение
|
|
||||||
(decimal, int) result = DivideIt(value, 0);
|
|
||||||
|
|
||||||
//Преобразую значение в строку
|
|
||||||
string resultValue = DecimalPlaces switch {
|
|
||||||
0 => $"{result.Item1:F0}",
|
|
||||||
1 => $"{result.Item1:F1}",
|
|
||||||
_ => $"{result.Item1:F2}"
|
|
||||||
};
|
|
||||||
|
|
||||||
//Возвращаю результат
|
|
||||||
return $"{resultValue} {ValueNames[result.Item2]}";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Рекурсивная функция деления
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">Число</param>
|
|
||||||
/// <param name="count">Счётчик вызова рекурсии</param>
|
|
||||||
/// <returns>Число в остатке и количество вызовов рекурсии</returns>
|
|
||||||
private (decimal, int) DivideIt (decimal value, int count)
|
|
||||||
{
|
|
||||||
//Если счёт уже больше количества названий
|
|
||||||
if (count > ValueNames.Length)
|
|
||||||
return (value, count);
|
|
||||||
|
|
||||||
//Если частное уже меньше делителя, то прерываем цикл
|
|
||||||
if (value < Divider)
|
|
||||||
return (value, count);
|
|
||||||
|
|
||||||
//Увеличиваем счётчик...
|
|
||||||
count++;
|
|
||||||
|
|
||||||
//... и продолжаем цикл
|
|
||||||
return DivideIt(value / Divider, count);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
34
anbs_cp/CountFormatter.cs
Normal file
34
anbs_cp/CountFormatter.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
namespace anbs_cp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Форматирует число элементов в понятную строку
|
||||||
|
/// </summary>
|
||||||
|
public class CountFormatter : IValueFormatter
|
||||||
|
{
|
||||||
|
#region Cвойства класса
|
||||||
|
/// <summary>
|
||||||
|
/// Имена чисел (тысяч, миллионов, миллиардов и т.п.)
|
||||||
|
/// </summary>
|
||||||
|
public string[] CountNames { get; set; } = { "", "тыс.", "млн.", "млрд." };
|
||||||
|
/// <summary>
|
||||||
|
/// Знаков после запятой
|
||||||
|
/// </summary>
|
||||||
|
public byte DecimalPlaces { get; set; } = 1;
|
||||||
|
/// <summary>
|
||||||
|
/// Делители чисел
|
||||||
|
/// </summary>
|
||||||
|
public long[] Delimeters { get; set; } = { 1000, 1000000, 1000000000 };
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Реализация интерфейса
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса
|
||||||
|
/// </summary>
|
||||||
|
public string[] ValueNames { get => CountNames; set => CountNames = value; }
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса
|
||||||
|
/// </summary>
|
||||||
|
public long[] MaxSizes { get => Delimeters; set => Delimeters = value; }
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@@ -1,17 +0,0 @@
|
|||||||
namespace anbs_cp.Enums;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Тип носителя
|
|
||||||
/// </summary>
|
|
||||||
public enum EDriveType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// HDD/SSD/M2
|
|
||||||
/// </summary>
|
|
||||||
DtHardDisc = 0,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Диск CD/DVD/BD
|
|
||||||
/// </summary>
|
|
||||||
DtCDRom = 1
|
|
||||||
}
|
|
@@ -1,32 +0,0 @@
|
|||||||
namespace anbs_cp.Enums;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Действия при операции переименования, если файл существует
|
|
||||||
/// </summary>
|
|
||||||
public enum EOnExistAction
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Возбуждать исключение
|
|
||||||
/// </summary>
|
|
||||||
RaiseException = 0,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Прервать операцию
|
|
||||||
/// </summary>
|
|
||||||
Abort = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Продолжить операцию
|
|
||||||
/// </summary>
|
|
||||||
Ignore = 2,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Возбуждать исключение, если папка не пуста (только для папок)
|
|
||||||
/// </summary>
|
|
||||||
RaiseExceptionIfNotEmpty = 3,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Прервать операцию, если папка не пуста (только для папок)
|
|
||||||
/// </summary>
|
|
||||||
AbortIfNotEmpty = 4
|
|
||||||
}
|
|
56
anbs_cp/FileSizeFormatter.cs
Normal file
56
anbs_cp/FileSizeFormatter.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
namespace anbs_cp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Форматирует размер файла/папки в понятную строку
|
||||||
|
/// </summary>
|
||||||
|
public class FileSizeFormatter : IValueFormatter
|
||||||
|
{
|
||||||
|
#region Cвойства класса
|
||||||
|
/// <summary>
|
||||||
|
/// Имена размеров (байт, килобайт, мегабайт, гигабайт и террабайт)
|
||||||
|
/// </summary>
|
||||||
|
public string[] SizeNames { get; set; } = { "Байт", "Кб", "Мб", "Гб", "Тб" };
|
||||||
|
/// <summary>
|
||||||
|
/// Знаков после запятой
|
||||||
|
/// </summary>
|
||||||
|
public byte DecimalPlaces { get; set; } = 2;
|
||||||
|
/// <summary>
|
||||||
|
/// Максимально байт (далее идут Кбайты)
|
||||||
|
/// </summary>
|
||||||
|
public long ByteMax { get; set; } = 1024;
|
||||||
|
/// <summary>
|
||||||
|
/// Максимально Кбайт (далее идут Мбайты)
|
||||||
|
/// </summary>
|
||||||
|
public long KByteMax { get; set; } = 1048576;
|
||||||
|
/// <summary>
|
||||||
|
/// Максимально Мбайт (далее идут Гбайты)
|
||||||
|
/// </summary>
|
||||||
|
public long MByteMax { get; set; } = 1073741824;
|
||||||
|
/// <summary>
|
||||||
|
/// Максимально Гбайт (далее идут Тбайты)
|
||||||
|
/// </summary>
|
||||||
|
public long GByteMax { get; set; } = 1099511627776;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Реализация интерфейса
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса
|
||||||
|
/// </summary>
|
||||||
|
public string[] ValueNames { get => SizeNames; set => SizeNames = value; }
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса
|
||||||
|
/// </summary>
|
||||||
|
public long[] MaxSizes
|
||||||
|
{
|
||||||
|
get => new long[] { ByteMax, KByteMax, MByteMax, GByteMax };
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ByteMax = value[0];
|
||||||
|
KByteMax = value[1];
|
||||||
|
MByteMax = value[2];
|
||||||
|
GByteMax = value[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
82
anbs_cp/IValueFormatter.cs
Normal file
82
anbs_cp/IValueFormatter.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
namespace anbs_cp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Форматирует размерности в понятную строку
|
||||||
|
/// </summary>
|
||||||
|
public interface IValueFormatter
|
||||||
|
{
|
||||||
|
|
||||||
|
#region Определения интерфейса
|
||||||
|
/// <summary>
|
||||||
|
/// Имена размерностей
|
||||||
|
/// </summary>
|
||||||
|
public string[] ValueNames { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Знаков после запятой
|
||||||
|
/// </summary>
|
||||||
|
public byte DecimalPlaces { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Максимальные размеры (массив ulong[4])
|
||||||
|
/// </summary>
|
||||||
|
public long[] MaxSizes { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Методы интерфейса
|
||||||
|
/// <summary>
|
||||||
|
/// Форматирование размерности
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">Размерность, требующая форматирования</param>
|
||||||
|
/// <returns>Форматированная размерность (например, 20 Мб)</returns>
|
||||||
|
public string Format(long value)
|
||||||
|
{
|
||||||
|
//Левая граница
|
||||||
|
long leftnum;
|
||||||
|
//Правая граница
|
||||||
|
long rightnum;
|
||||||
|
|
||||||
|
for (int i = 0; i <= MaxSizes.Length; i++)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
leftnum = 0;
|
||||||
|
else
|
||||||
|
leftnum = MaxSizes[i - 1];
|
||||||
|
|
||||||
|
if (i == MaxSizes.Length)
|
||||||
|
rightnum = long.MaxValue;
|
||||||
|
else
|
||||||
|
rightnum = MaxSizes[i];
|
||||||
|
|
||||||
|
if ((value >= leftnum) && (value < rightnum))
|
||||||
|
return $"{FormatValue(value, leftnum)} {ValueNames[i]}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.ToString();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Деление числа на число с DecimalPlaces знаками после запятой
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dividend">Делимое число</param>
|
||||||
|
/// <param name="divider">Число-делитель</param>
|
||||||
|
/// <returns>Частное (с DecimalPlaces знаками после запятой)</returns>
|
||||||
|
private string FormatValue(long dividend, long divider)
|
||||||
|
{
|
||||||
|
if (divider == 0)
|
||||||
|
{
|
||||||
|
return $"{dividend}";
|
||||||
|
}
|
||||||
|
|
||||||
|
long delim = 1;
|
||||||
|
|
||||||
|
for (int i = 0; i <= DecimalPlaces; i++)
|
||||||
|
{
|
||||||
|
delim *= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
decimal value = Math.Round((decimal)(dividend * delim / divider)) / delim;
|
||||||
|
|
||||||
|
return $"{value}";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@@ -1,14 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс ошибки
|
|
||||||
/// </summary>
|
|
||||||
public interface IActionError : IActionStateMessage
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Критичность ошибки:
|
|
||||||
/// при некритичных ошибках продолжение выполнения операции возможно,
|
|
||||||
/// а при критичных -- нет
|
|
||||||
/// </summary>
|
|
||||||
public bool IsCritical { get; init; }
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс для информации по статусу
|
|
||||||
/// </summary>
|
|
||||||
public interface IActionInfo : IActionStateMessage
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Статусная информация (например, начало работы)
|
|
||||||
/// </summary>
|
|
||||||
public bool IsStatusInfo { get; init; }
|
|
||||||
}
|
|
@@ -1,24 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс сообщения состояния
|
|
||||||
/// </summary>
|
|
||||||
public interface IActionStateMessage
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Объект сообщения
|
|
||||||
/// </summary>
|
|
||||||
public object Object { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Текст сообщения
|
|
||||||
/// </summary>
|
|
||||||
public string Message { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Функция вывода сообщения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="format">Строка-форматирование (например, «[{0}] - {1}»)</param>
|
|
||||||
/// <returns>Отформатированную строка</returns>
|
|
||||||
public string PrintMessage (string format) => string.Format (format, Object, Message);
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс предупреждения
|
|
||||||
/// </summary>
|
|
||||||
public interface IActionWarning : IActionStateMessage
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Информирующее предупреждение возникает для предупреждения ВОЗМОЖНОЙ ошибки в дальнейшей эксплуатации и не влияет на текущую операцию.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsInformWarning { get; init; }
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс ключа
|
|
||||||
/// </summary>
|
|
||||||
public interface IEncryptKey
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Ключ
|
|
||||||
/// </summary>
|
|
||||||
public byte[] Key { get; set; }
|
|
||||||
}
|
|
@@ -1,22 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс конвертера величин для отображения (улучшенный аналог IValueFormatter)
|
|
||||||
/// </summary>
|
|
||||||
public interface IValueConverter
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Массив имён размерностей
|
|
||||||
/// </summary>
|
|
||||||
public string[] ValueNames { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Делитель
|
|
||||||
/// </summary>
|
|
||||||
public long Divider { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Знаков после запятой (0, 1, 2)
|
|
||||||
/// </summary>
|
|
||||||
public byte DecimalPlaces { get; init; }
|
|
||||||
}
|
|
@@ -1,74 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Форматирует размерности в понятную строку
|
|
||||||
/// </summary>
|
|
||||||
public interface IValueFormatter
|
|
||||||
{
|
|
||||||
#region Определения интерфейса
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имена размерностей
|
|
||||||
/// </summary>
|
|
||||||
public string[] ValueNames { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Знаков после запятой
|
|
||||||
/// </summary>
|
|
||||||
public byte DecimalPlaces { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Максимальные размеры (массив ulong[4])
|
|
||||||
/// </summary>
|
|
||||||
public long[] MaxSizes { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Методы интерфейса
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Форматирование размерности
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">Размерность, требующая форматирования</param>
|
|
||||||
/// <returns>Форматированная размерность (например, 20 Мб)</returns>
|
|
||||||
public string Format(long value)
|
|
||||||
{
|
|
||||||
//Левая граница
|
|
||||||
long leftnum;
|
|
||||||
//Правая граница
|
|
||||||
long rightnum;
|
|
||||||
|
|
||||||
for (int i = 0; i <= MaxSizes.Length; i++)
|
|
||||||
{
|
|
||||||
leftnum = i == 0 ? 0 : MaxSizes[i - 1];
|
|
||||||
|
|
||||||
rightnum = i == MaxSizes.Length ? long.MaxValue : MaxSizes[i];
|
|
||||||
|
|
||||||
if (value >= leftnum && value < rightnum)
|
|
||||||
return $"{FormatValue(value, leftnum)} {ValueNames[i]}";
|
|
||||||
}
|
|
||||||
|
|
||||||
return value.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Деление числа на число с DecimalPlaces знаками после запятой
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dividend">Делимое число</param>
|
|
||||||
/// <param name="divider">Число-делитель</param>
|
|
||||||
/// <returns>Частное (с DecimalPlaces знаками после запятой)</returns>
|
|
||||||
private string FormatValue(long dividend, long divider)
|
|
||||||
{
|
|
||||||
if (divider == 0) return $"{dividend}";
|
|
||||||
|
|
||||||
long delim = 1;
|
|
||||||
|
|
||||||
for (int i = 0; i <= DecimalPlaces; i++) delim *= 10;
|
|
||||||
|
|
||||||
decimal value = Math.Round((decimal)(dividend * delim / divider)) / delim;
|
|
||||||
|
|
||||||
return $"{value}";
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
@@ -1,27 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Базовые параметры устройства
|
|
||||||
/// </summary>
|
|
||||||
public interface IOsBasicInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Заголовок
|
|
||||||
/// </summary>
|
|
||||||
public string? Caption { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Описание
|
|
||||||
/// </summary>
|
|
||||||
public string? Description { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Идентификатор устройства
|
|
||||||
/// </summary>
|
|
||||||
public string? DeviceId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имя устройства
|
|
||||||
/// </summary>
|
|
||||||
public string? Name { get; set; }
|
|
||||||
}
|
|
@@ -1,24 +0,0 @@
|
|||||||
using anbs_cp.Enums;
|
|
||||||
|
|
||||||
namespace anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация о дисках
|
|
||||||
/// </summary>
|
|
||||||
public interface IOsDriveInfo : IOsBasicInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Тип диска
|
|
||||||
/// </summary>
|
|
||||||
public EDriveType Type { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Модель
|
|
||||||
/// </summary>
|
|
||||||
public string? Model { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Общий размер
|
|
||||||
/// </summary>
|
|
||||||
public ulong TotalSize { get; set; }
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация об интернет-соединении
|
|
||||||
/// </summary>
|
|
||||||
public interface IOsNetInfo: IOsBasicInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// IP-адрес
|
|
||||||
/// </summary>
|
|
||||||
public string? IPAddress { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// MAC-адрес
|
|
||||||
/// </summary>
|
|
||||||
public string? MacAddress { get; set; }
|
|
||||||
}
|
|
@@ -1,31 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация о процессоре
|
|
||||||
/// </summary>
|
|
||||||
public interface IOsProcessorInfo : IOsBasicInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Заголовок
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Производитель
|
|
||||||
/// </summary>
|
|
||||||
public string? Manufacturer { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Максимальная тактовая частота
|
|
||||||
/// </summary>
|
|
||||||
public int MaxClockSpeed { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Число ядер
|
|
||||||
/// </summary>
|
|
||||||
public int NumberOfCores { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Число потоков
|
|
||||||
/// </summary>
|
|
||||||
public int NumberOfLogicalProcessors { get; set; }
|
|
||||||
}
|
|
@@ -1,42 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация о видеокарте
|
|
||||||
/// </summary>
|
|
||||||
public interface IOsVideoAdapterInfo : IOsBasicInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Память
|
|
||||||
/// </summary>
|
|
||||||
public int AdapterRAM { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Текущее разрешение
|
|
||||||
/// </summary>
|
|
||||||
public (int, int) CurrentResolution { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Дата установки драйвера
|
|
||||||
/// </summary>
|
|
||||||
public string? DriverDate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Версия драйвера
|
|
||||||
/// </summary>
|
|
||||||
public string? DriverVersion { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Название драйверов
|
|
||||||
/// </summary>
|
|
||||||
public string? InstalledDisplayDrivers { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имя в системе
|
|
||||||
/// </summary>
|
|
||||||
public string? SystemName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Видео процессор
|
|
||||||
/// </summary>
|
|
||||||
public string? VideoProcessor { get; set; }
|
|
||||||
}
|
|
@@ -1,27 +0,0 @@
|
|||||||
namespace anbs_cp.Interfaces.OsInfos;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Информация о Windows
|
|
||||||
/// </summary>
|
|
||||||
public interface IOsWindowsInfo: IOsBasicInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Версия
|
|
||||||
/// </summary>
|
|
||||||
public string? Version { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 64-разрядная ОС
|
|
||||||
/// </summary>
|
|
||||||
public bool Is64 { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Имя компьютера
|
|
||||||
/// </summary>
|
|
||||||
public string? PcName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Путь к папке Windows
|
|
||||||
/// </summary>
|
|
||||||
public string? WindowsFolder { get; set; }
|
|
||||||
}
|
|
48
anbs_cp/LikeDelphi.cs
Normal file
48
anbs_cp/LikeDelphi.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
namespace anbs_cp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Класс, добавляющий реализацию некоторых методов Delphi, которые упрощают работу в C#.
|
||||||
|
/// </summary>
|
||||||
|
public static class LikeDelphi
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Аналог функции IncludeTrailingBackslash
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Путь, к которому нужно добавить slash</param>
|
||||||
|
/// <returns>Путь со slash в конце</returns>
|
||||||
|
public static string IncludeTrailingBackslash(string path)
|
||||||
|
{
|
||||||
|
string result = path;
|
||||||
|
int Index = path.Length - 1;
|
||||||
|
if (path[Index] != '\\')
|
||||||
|
{
|
||||||
|
result = $"{path}\\";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Парсер строки в множество строк
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="astring">Строка, которую нужно разбить</param>
|
||||||
|
/// <param name="delim">Символ-делитель строки</param>
|
||||||
|
/// <returns>Массив строк</returns>
|
||||||
|
public static List<string> ParseString(string astring, char delim)
|
||||||
|
{
|
||||||
|
int from = -1;
|
||||||
|
int to;
|
||||||
|
List<string> result = new();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
from++;
|
||||||
|
to = astring.IndexOf(delim, from);
|
||||||
|
if (to <= 0)
|
||||||
|
to = astring.Length;
|
||||||
|
if (from != to)
|
||||||
|
result.Add(astring[from..(to-from)]);
|
||||||
|
from = to;
|
||||||
|
} while (to != astring.Length);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
114
anbs_cp/TypeConverter.cs
Normal file
114
anbs_cp/TypeConverter.cs
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
namespace anbs_cp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Конвертер типов на манер Delphi
|
||||||
|
/// </summary>
|
||||||
|
public static class TypeConverter
|
||||||
|
{
|
||||||
|
#region Конвертация числа в строку
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразование int в string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AInt">Число</param>
|
||||||
|
/// <returns>Строка</returns>
|
||||||
|
public static string IntToStr(int AInt) => AInt.ToString();
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразование uint в string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AInt">Число</param>
|
||||||
|
/// <returns>Строка</returns>
|
||||||
|
public static string IntToStr(uint AInt) => AInt.ToString();
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразование long в string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AInt">Число</param>
|
||||||
|
/// <returns>Строка</returns>
|
||||||
|
public static string IntToStr(long AInt) => AInt.ToString();
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразование ulong в string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AInt">Число</param>
|
||||||
|
/// <returns>Строка</returns>
|
||||||
|
public static string IntToStr(ulong AInt) => AInt.ToString();
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразование byte в string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AInt">Число</param>
|
||||||
|
/// <returns>Строка</returns>
|
||||||
|
public static string IntToStr(byte AInt) => AInt.ToString();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Конвертация строки в число
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразование строки в число
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AStr">Строка</param>
|
||||||
|
/// <param name="ADefault">Значение по умолчанию (по умолчанию, 0)</param>
|
||||||
|
/// <returns>Число</returns>
|
||||||
|
public static int StrToInt(string AStr, int ADefault = 0)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(AStr, out int result))
|
||||||
|
{
|
||||||
|
result = ADefault;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразование строки в число
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AStr">Строка</param>
|
||||||
|
/// <param name="ADefault">Значение по умолчанию (по умолчанию, 0)</param>
|
||||||
|
/// <returns>Число</returns>
|
||||||
|
public static uint StrToUInt(string AStr, uint ADefault = 0)
|
||||||
|
{
|
||||||
|
if (!uint.TryParse(AStr, out uint result))
|
||||||
|
{
|
||||||
|
result = ADefault;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразование строки в число
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AStr">Строка</param>
|
||||||
|
/// <param name="ADefault">Значение по умолчанию (по умолчанию, 0)</param>
|
||||||
|
/// <returns>Число</returns>
|
||||||
|
public static long StrToInt64(string AStr, long ADefault = 0)
|
||||||
|
{
|
||||||
|
if (!long.TryParse(AStr, out long result))
|
||||||
|
{
|
||||||
|
result = ADefault;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразование строки в число
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AStr">Строка</param>
|
||||||
|
/// <param name="ADefault">Значение по умолчанию (по умолчанию, 0)</param>
|
||||||
|
/// <returns>Число</returns>
|
||||||
|
public static ulong StrToUInt64(string AStr, ulong ADefault = 0)
|
||||||
|
{
|
||||||
|
if (!ulong.TryParse(AStr, out ulong result))
|
||||||
|
{
|
||||||
|
result = ADefault;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Преобразование строки в число
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AStr">Строка</param>
|
||||||
|
/// <param name="ADefault">Значение по умолчанию (по умолчанию, 0)</param>
|
||||||
|
/// <returns>Число</returns>
|
||||||
|
public static byte StrToByte(string AStr, byte ADefault = 0)
|
||||||
|
{
|
||||||
|
if (!byte.TryParse(AStr, out byte result))
|
||||||
|
{
|
||||||
|
result = ADefault;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@@ -1,8 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<Version>2023.212.0</Version>
|
<Version>1.20211111.0</Version>
|
||||||
<Authors>Alexander Babaev</Authors>
|
<Authors>Alexander Babaev</Authors>
|
||||||
<Product>ANB Software Components Pack</Product>
|
<Product>ANB Software Components Pack</Product>
|
||||||
<Description>Library of some useful functions in C# language.</Description>
|
<Description>Library of some useful functions in C# language.</Description>
|
||||||
@@ -12,45 +12,25 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<SignAssembly>True</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<PackageProjectUrl>https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/GoodBoyAlex/anbsoftware_componentspack</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack</RepositoryUrl>
|
<RepositoryUrl>https://github.com/GoodBoyAlex/anbsoftware_componentspack</RepositoryUrl>
|
||||||
<AssemblyVersion></AssemblyVersion>
|
<AssemblyVersion>1.2021.1111</AssemblyVersion>
|
||||||
<FileVersion></FileVersion>
|
<FileVersion>1.2021.1111</FileVersion>
|
||||||
<PackageId>ANBSoftware.ComponentsPack</PackageId>
|
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
|
||||||
<AnalysisLevel>6.0</AnalysisLevel>
|
|
||||||
<RepositoryType>git</RepositoryType>
|
|
||||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<WarningLevel>7</WarningLevel>
|
<WarningLevel>2</WarningLevel>
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||||
<DebugType>none</DebugType>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
<WarningLevel>7</WarningLevel>
|
<WarningLevel>2</WarningLevel>
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||||
<DebugType>none</DebugType>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="gfoidl.Base64" Version="2.0.0" />
|
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop" Version="17.0.31902.203" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.2.0" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop" Version="17.4.33103.184" />
|
|
||||||
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0" />
|
|
||||||
<PackageReference Include="MimeTypes" Version="2.4.0">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="System.Text.Encodings.Web" Version="7.0.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Enums\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
|
||||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp110</s:String></wpf:ResourceDictionary>
|
|
@@ -1,21 +0,0 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CD/@EntryIndexedValue">CD</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HD/@EntryIndexedValue">HD</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HDD/@EntryIndexedValue">HDD</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RA/@EntryIndexedValue">RA</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RAM/@EntryIndexedValue">RAM</s:String>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=anbs/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Glendower/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0412_0435_0440_043D_0451_043C/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0412_0438_0434_0435_043E_043A_0430_0440_0442_0430/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_041F_0430_0440_0441_0435_0440/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0421_043E_0437_0434_0430_0451_043C/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0432_0432_0435_0434_0451_043D/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0432_0438_0434_0435_043E_043A_0430_0440_0442_0435/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0434_0435_0448_0438_0444_0440_043E_0432_0430_043D_0438_044F/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0438_043C_0451_043D/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_043F_0443_0442_0451_043C/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0441_0447_0451_0442/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0441_0447_0451_0442_0447_0438_043A/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0445_044D_0448_0430/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0445_044D_0448_0435_043C/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
|
113
demo/CountValueTest.Designer.cs
generated
113
demo/CountValueTest.Designer.cs
generated
@@ -1,40 +1,39 @@
|
|||||||
namespace demo;
|
namespace demo
|
||||||
|
|
||||||
sealed partial class CountValueTest
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
partial class CountValueTest
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose (bool disposing)
|
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
components.Dispose();
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent ()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.InsertDataLabel = new System.Windows.Forms.Label();
|
this.InsertDataLabel = new System.Windows.Forms.Label();
|
||||||
this.InsertDataBox = new System.Windows.Forms.TextBox();
|
this.InsertDataBox = new System.Windows.Forms.TextBox();
|
||||||
this.ResultLabel = new System.Windows.Forms.Label();
|
this.ResultLabel = new System.Windows.Forms.Label();
|
||||||
this.CalculateButton = new System.Windows.Forms.Button();
|
this.CalculateButton = new System.Windows.Forms.Button();
|
||||||
this.SelectFormatterLabel = new System.Windows.Forms.Label();
|
this.SelectFormatterLabel = new System.Windows.Forms.Label();
|
||||||
this.SelectFormatterBox = new System.Windows.Forms.ComboBox();
|
this.SelectFormatterBox = new System.Windows.Forms.ComboBox();
|
||||||
this.calculateConvButton = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// InsertDataLabel
|
// InsertDataLabel
|
||||||
@@ -42,17 +41,16 @@ sealed partial class CountValueTest
|
|||||||
this.InsertDataLabel.AutoSize = true;
|
this.InsertDataLabel.AutoSize = true;
|
||||||
this.InsertDataLabel.Location = new System.Drawing.Point(12, 66);
|
this.InsertDataLabel.Location = new System.Drawing.Point(12, 66);
|
||||||
this.InsertDataLabel.Name = "InsertDataLabel";
|
this.InsertDataLabel.Name = "InsertDataLabel";
|
||||||
this.InsertDataLabel.Size = new System.Drawing.Size(341, 17);
|
this.InsertDataLabel.Size = new System.Drawing.Size(197, 17);
|
||||||
this.InsertDataLabel.TabIndex = 0;
|
this.InsertDataLabel.TabIndex = 0;
|
||||||
this.InsertDataLabel.Text = "&Введите любое целочисленное значение:";
|
this.InsertDataLabel.Text = "&Insert any int value:";
|
||||||
//
|
//
|
||||||
// InsertDataBox
|
// InsertDataBox
|
||||||
//
|
//
|
||||||
this.InsertDataBox.Location = new System.Drawing.Point(12, 86);
|
this.InsertDataBox.Location = new System.Drawing.Point(12, 86);
|
||||||
this.InsertDataBox.Name = "InsertDataBox";
|
this.InsertDataBox.Name = "InsertDataBox";
|
||||||
this.InsertDataBox.Size = new System.Drawing.Size(457, 24);
|
this.InsertDataBox.Size = new System.Drawing.Size(246, 24);
|
||||||
this.InsertDataBox.TabIndex = 1;
|
this.InsertDataBox.TabIndex = 1;
|
||||||
this.InsertDataBox.TextChanged += new System.EventHandler(this.InsertDataBox_TextChanged);
|
|
||||||
//
|
//
|
||||||
// ResultLabel
|
// ResultLabel
|
||||||
//
|
//
|
||||||
@@ -61,19 +59,19 @@ sealed partial class CountValueTest
|
|||||||
this.ResultLabel.Margin = new System.Windows.Forms.Padding(5);
|
this.ResultLabel.Margin = new System.Windows.Forms.Padding(5);
|
||||||
this.ResultLabel.Name = "ResultLabel";
|
this.ResultLabel.Name = "ResultLabel";
|
||||||
this.ResultLabel.Padding = new System.Windows.Forms.Padding(5);
|
this.ResultLabel.Padding = new System.Windows.Forms.Padding(5);
|
||||||
this.ResultLabel.Size = new System.Drawing.Size(478, 79);
|
this.ResultLabel.Size = new System.Drawing.Size(270, 79);
|
||||||
this.ResultLabel.TabIndex = 2;
|
this.ResultLabel.TabIndex = 2;
|
||||||
this.ResultLabel.Text = "&Вставьте любое целочисленное значение в поле выше и нажмите кнопку \"Вычислить\", " +
|
this.ResultLabel.Text = "&Insert any int value to insert box above and press \"Calculate\" button to see res" +
|
||||||
"чтобы увидеть результат...";
|
"ult...";
|
||||||
this.ResultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.ResultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
//
|
//
|
||||||
// CalculateButton
|
// CalculateButton
|
||||||
//
|
//
|
||||||
this.CalculateButton.Location = new System.Drawing.Point(12, 116);
|
this.CalculateButton.Location = new System.Drawing.Point(81, 116);
|
||||||
this.CalculateButton.Name = "CalculateButton";
|
this.CalculateButton.Name = "CalculateButton";
|
||||||
this.CalculateButton.Size = new System.Drawing.Size(234, 23);
|
this.CalculateButton.Size = new System.Drawing.Size(103, 23);
|
||||||
this.CalculateButton.TabIndex = 3;
|
this.CalculateButton.TabIndex = 3;
|
||||||
this.CalculateButton.Text = "В&ычислить обработчиком";
|
this.CalculateButton.Text = "Calc&ulate";
|
||||||
this.CalculateButton.UseVisualStyleBackColor = true;
|
this.CalculateButton.UseVisualStyleBackColor = true;
|
||||||
this.CalculateButton.Click += new System.EventHandler(this.CalculateButton_Click);
|
this.CalculateButton.Click += new System.EventHandler(this.CalculateButton_Click);
|
||||||
//
|
//
|
||||||
@@ -82,9 +80,9 @@ sealed partial class CountValueTest
|
|||||||
this.SelectFormatterLabel.AutoSize = true;
|
this.SelectFormatterLabel.AutoSize = true;
|
||||||
this.SelectFormatterLabel.Location = new System.Drawing.Point(12, 9);
|
this.SelectFormatterLabel.Location = new System.Drawing.Point(12, 9);
|
||||||
this.SelectFormatterLabel.Name = "SelectFormatterLabel";
|
this.SelectFormatterLabel.Name = "SelectFormatterLabel";
|
||||||
this.SelectFormatterLabel.Size = new System.Drawing.Size(188, 17);
|
this.SelectFormatterLabel.Size = new System.Drawing.Size(161, 17);
|
||||||
this.SelectFormatterLabel.TabIndex = 4;
|
this.SelectFormatterLabel.TabIndex = 4;
|
||||||
this.SelectFormatterLabel.Text = "В&ыберете обработчик:";
|
this.SelectFormatterLabel.Text = "&Select formatter:";
|
||||||
//
|
//
|
||||||
// SelectFormatterBox
|
// SelectFormatterBox
|
||||||
//
|
//
|
||||||
@@ -92,29 +90,18 @@ sealed partial class CountValueTest
|
|||||||
this.SelectFormatterBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
this.SelectFormatterBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||||
this.SelectFormatterBox.FormattingEnabled = true;
|
this.SelectFormatterBox.FormattingEnabled = true;
|
||||||
this.SelectFormatterBox.Items.AddRange(new object[] {
|
this.SelectFormatterBox.Items.AddRange(new object[] {
|
||||||
"Обработчик счёта",
|
"CountFormatter",
|
||||||
"Обработчик размера файла"});
|
"FileSizeFormatter"});
|
||||||
this.SelectFormatterBox.Location = new System.Drawing.Point(12, 29);
|
this.SelectFormatterBox.Location = new System.Drawing.Point(12, 29);
|
||||||
this.SelectFormatterBox.Name = "SelectFormatterBox";
|
this.SelectFormatterBox.Name = "SelectFormatterBox";
|
||||||
this.SelectFormatterBox.Size = new System.Drawing.Size(457, 25);
|
this.SelectFormatterBox.Size = new System.Drawing.Size(246, 25);
|
||||||
this.SelectFormatterBox.TabIndex = 5;
|
this.SelectFormatterBox.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// calculateConvButton
|
|
||||||
//
|
|
||||||
this.calculateConvButton.Location = new System.Drawing.Point(252, 116);
|
|
||||||
this.calculateConvButton.Name = "calculateConvButton";
|
|
||||||
this.calculateConvButton.Size = new System.Drawing.Size(217, 23);
|
|
||||||
this.calculateConvButton.TabIndex = 6;
|
|
||||||
this.calculateConvButton.Text = "&Вычислить конвертером";
|
|
||||||
this.calculateConvButton.UseVisualStyleBackColor = true;
|
|
||||||
this.calculateConvButton.Click += new System.EventHandler(this.calculateConvButton_Click);
|
|
||||||
//
|
|
||||||
// CountValueTest
|
// CountValueTest
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(478, 222);
|
this.ClientSize = new System.Drawing.Size(270, 222);
|
||||||
this.Controls.Add(this.calculateConvButton);
|
|
||||||
this.Controls.Add(this.SelectFormatterBox);
|
this.Controls.Add(this.SelectFormatterBox);
|
||||||
this.Controls.Add(this.SelectFormatterLabel);
|
this.Controls.Add(this.SelectFormatterLabel);
|
||||||
this.Controls.Add(this.CalculateButton);
|
this.Controls.Add(this.CalculateButton);
|
||||||
@@ -128,20 +115,20 @@ sealed partial class CountValueTest
|
|||||||
this.Name = "CountValueTest";
|
this.Name = "CountValueTest";
|
||||||
this.ShowIcon = false;
|
this.ShowIcon = false;
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "Тест модуля форматирования строки";
|
this.Text = "Formatter Test Unit";
|
||||||
this.Load += new System.EventHandler(this.CountValueTest_Load);
|
this.Load += new System.EventHandler(this.CountValueTest_Load);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label InsertDataLabel;
|
||||||
|
private TextBox InsertDataBox;
|
||||||
|
private Label ResultLabel;
|
||||||
|
private Button CalculateButton;
|
||||||
|
private Label SelectFormatterLabel;
|
||||||
|
private ComboBox SelectFormatterBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label InsertDataLabel;
|
|
||||||
private TextBox InsertDataBox;
|
|
||||||
private Label ResultLabel;
|
|
||||||
private Button CalculateButton;
|
|
||||||
private Label SelectFormatterLabel;
|
|
||||||
private ComboBox SelectFormatterBox;
|
|
||||||
private Button calculateConvButton;
|
|
||||||
}
|
}
|
@@ -1,56 +1,42 @@
|
|||||||
using anbs_cp.Classes;
|
using anbs_cp;
|
||||||
using anbs_cp.Interfaces;
|
namespace demo
|
||||||
|
|
||||||
namespace demo;
|
|
||||||
|
|
||||||
public sealed partial class CountValueTest: Form
|
|
||||||
{
|
{
|
||||||
public CountValueTest ()
|
public partial class CountValueTest : Form
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
public CountValueTest()
|
||||||
}
|
|
||||||
|
|
||||||
private void CalculateButton_Click (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(InsertDataBox.Text))
|
|
||||||
return;
|
|
||||||
|
|
||||||
long value = TypeConverter.StrToInt64(InsertDataBox.Text);
|
|
||||||
IValueFormatter formatter = SelectFormatterBox.SelectedIndex switch
|
|
||||||
{
|
{
|
||||||
0 => new CountFormatter(),
|
InitializeComponent();
|
||||||
1 => new FileSizeFormatter(),
|
}
|
||||||
_ => new CountFormatter(),
|
|
||||||
};
|
|
||||||
ResultLabel.Text = formatter.Format(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CountValueTest_Load (object sender, EventArgs e)
|
private void CalculateButton_Click(object sender, EventArgs e)
|
||||||
{
|
|
||||||
SelectFormatterBox.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InsertDataBox_TextChanged (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ulong value = TypeConverter.StrToUInt64(InsertDataBox.Text);
|
|
||||||
|
|
||||||
if (value > long.MaxValue)
|
|
||||||
InsertDataBox.Text = long.MaxValue.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculateConvButton_Click (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(InsertDataBox.Text))
|
|
||||||
return;
|
|
||||||
|
|
||||||
long value = TypeConverter.StrToInt64(InsertDataBox.Text);
|
|
||||||
|
|
||||||
ResultLabel.Text = SelectFormatterBox.SelectedIndex switch
|
|
||||||
{
|
{
|
||||||
0 => new CountConverter(CountConverter.DefaultNames).Convert(value),
|
|
||||||
1 => new FileSizeConverter(FileSizeConverter.DefaultNames).Convert(value),
|
if (string.IsNullOrEmpty(InsertDataBox.Text))
|
||||||
_ => new CountConverter(CountConverter.DefaultNames).Convert(value)
|
return;
|
||||||
};
|
|
||||||
|
IValueFormatter formatter;
|
||||||
|
|
||||||
|
long value = TypeConverter.StrToInt64(InsertDataBox.Text);
|
||||||
|
|
||||||
|
switch (SelectFormatterBox.SelectedIndex)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
formatter = new CountFormatter();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
formatter = new FileSizeFormatter();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
formatter = new CountFormatter();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultLabel.Text = formatter.Format(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CountValueTest_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectFormatterBox.SelectedIndex = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
125
demo/FileHashAndMimeTypeTest.Designer.cs
generated
125
demo/FileHashAndMimeTypeTest.Designer.cs
generated
@@ -1,125 +0,0 @@
|
|||||||
namespace demo;
|
|
||||||
|
|
||||||
sealed partial class FileHashAndMimeType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose (bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent ()
|
|
||||||
{
|
|
||||||
this.ResultLabel = new System.Windows.Forms.Label();
|
|
||||||
this.SelectFileLabel = new System.Windows.Forms.Label();
|
|
||||||
this.fileNameEdt = new System.Windows.Forms.TextBox();
|
|
||||||
this.ViewButton = new System.Windows.Forms.Button();
|
|
||||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
|
||||||
this.topPanel = new System.Windows.Forms.Panel();
|
|
||||||
this.topPanel.SuspendLayout();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// ResultLabel
|
|
||||||
//
|
|
||||||
this.ResultLabel.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.ResultLabel.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.ResultLabel.Margin = new System.Windows.Forms.Padding(5);
|
|
||||||
this.ResultLabel.Name = "ResultLabel";
|
|
||||||
this.ResultLabel.Padding = new System.Windows.Forms.Padding(5);
|
|
||||||
this.ResultLabel.Size = new System.Drawing.Size(412, 428);
|
|
||||||
this.ResultLabel.TabIndex = 2;
|
|
||||||
this.ResultLabel.Text = "В&ыберете файл (введите ипя файла с полным путём вверху или с помощью диалога, на" +
|
|
||||||
"жав \"Обзор\")...";
|
|
||||||
this.ResultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
|
||||||
//
|
|
||||||
// SelectFileLabel
|
|
||||||
//
|
|
||||||
this.SelectFileLabel.AutoSize = true;
|
|
||||||
this.SelectFileLabel.Location = new System.Drawing.Point(3, 11);
|
|
||||||
this.SelectFileLabel.Name = "SelectFileLabel";
|
|
||||||
this.SelectFileLabel.Size = new System.Drawing.Size(134, 17);
|
|
||||||
this.SelectFileLabel.TabIndex = 4;
|
|
||||||
this.SelectFileLabel.Text = "В&ыберете файл:";
|
|
||||||
//
|
|
||||||
// fileNameEdt
|
|
||||||
//
|
|
||||||
this.fileNameEdt.Location = new System.Drawing.Point(3, 38);
|
|
||||||
this.fileNameEdt.Name = "fileNameEdt";
|
|
||||||
this.fileNameEdt.Size = new System.Drawing.Size(288, 24);
|
|
||||||
this.fileNameEdt.TabIndex = 5;
|
|
||||||
this.fileNameEdt.TextChanged += new System.EventHandler(this.fileNameEdt_TextChanged);
|
|
||||||
//
|
|
||||||
// ViewButton
|
|
||||||
//
|
|
||||||
this.ViewButton.Location = new System.Drawing.Point(297, 39);
|
|
||||||
this.ViewButton.Name = "ViewButton";
|
|
||||||
this.ViewButton.Size = new System.Drawing.Size(103, 23);
|
|
||||||
this.ViewButton.TabIndex = 3;
|
|
||||||
this.ViewButton.Text = "&Обзор";
|
|
||||||
this.ViewButton.UseVisualStyleBackColor = true;
|
|
||||||
this.ViewButton.Click += new System.EventHandler(this.ViewButton_Click);
|
|
||||||
//
|
|
||||||
// openFileDialog
|
|
||||||
//
|
|
||||||
this.openFileDialog.AddToRecent = false;
|
|
||||||
this.openFileDialog.Filter = "Все файлы|*.*";
|
|
||||||
this.openFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog_FileOk);
|
|
||||||
//
|
|
||||||
// topPanel
|
|
||||||
//
|
|
||||||
this.topPanel.Controls.Add(this.SelectFileLabel);
|
|
||||||
this.topPanel.Controls.Add(this.ViewButton);
|
|
||||||
this.topPanel.Controls.Add(this.fileNameEdt);
|
|
||||||
this.topPanel.Dock = System.Windows.Forms.DockStyle.Top;
|
|
||||||
this.topPanel.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.topPanel.Name = "topPanel";
|
|
||||||
this.topPanel.Size = new System.Drawing.Size(412, 74);
|
|
||||||
this.topPanel.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// FileHashAndMimeType
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(412, 428);
|
|
||||||
this.Controls.Add(this.topPanel);
|
|
||||||
this.Controls.Add(this.ResultLabel);
|
|
||||||
this.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
|
||||||
this.MaximizeBox = false;
|
|
||||||
this.MinimizeBox = false;
|
|
||||||
this.Name = "FileHashAndMimeType";
|
|
||||||
this.ShowIcon = false;
|
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
|
||||||
this.Text = "Получение хэша и MIME-типа файла";
|
|
||||||
this.topPanel.ResumeLayout(false);
|
|
||||||
this.topPanel.PerformLayout();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private Label ResultLabel;
|
|
||||||
private Label SelectFileLabel;
|
|
||||||
private TextBox fileNameEdt;
|
|
||||||
private Button ViewButton;
|
|
||||||
private OpenFileDialog openFileDialog;
|
|
||||||
private Panel topPanel;
|
|
||||||
}
|
|
@@ -1,42 +0,0 @@
|
|||||||
using anbs_cp.Classes;
|
|
||||||
// ReSharper disable LocalizableElement
|
|
||||||
|
|
||||||
namespace demo;
|
|
||||||
|
|
||||||
public sealed partial class FileHashAndMimeType: Form
|
|
||||||
{
|
|
||||||
public FileHashAndMimeType ()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ViewButton_Click (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
openFileDialog.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GetFileHashAndMimeType()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(fileNameEdt.Text))
|
|
||||||
{
|
|
||||||
ResultLabel.Text = "<22><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string fileHash = new FileHash(fileNameEdt.Text).ToString();
|
|
||||||
string fileType = FileExtension.MIMEType(fileNameEdt.Text);
|
|
||||||
|
|
||||||
ResultLabel.Text =
|
|
||||||
$"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>\r\n{fileNameEdt.Text}\r\n<><6E><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>:\r\n{fileHash}\r\n<><6E><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>:\r\n{fileType}";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openFileDialog_FileOk (object sender, System.ComponentModel.CancelEventArgs e)
|
|
||||||
{
|
|
||||||
fileNameEdt.Text = openFileDialog.FileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fileNameEdt_TextChanged (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
GetFileHashAndMimeType();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
102
demo/MainMenu.Designer.cs
generated
102
demo/MainMenu.Designer.cs
generated
@@ -1,102 +0,0 @@
|
|||||||
namespace demo;
|
|
||||||
|
|
||||||
sealed partial class MainMenu
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose (bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent ()
|
|
||||||
{
|
|
||||||
this.CountValueTest = new System.Windows.Forms.Button();
|
|
||||||
this.SimpleMapperTest = new System.Windows.Forms.Button();
|
|
||||||
this.FileExtensionTest = new System.Windows.Forms.Button();
|
|
||||||
this.OsInfoBtn = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// CountValueTest
|
|
||||||
//
|
|
||||||
this.CountValueTest.Location = new System.Drawing.Point(12, 12);
|
|
||||||
this.CountValueTest.Name = "CountValueTest";
|
|
||||||
this.CountValueTest.Size = new System.Drawing.Size(337, 53);
|
|
||||||
this.CountValueTest.TabIndex = 0;
|
|
||||||
this.CountValueTest.Text = "Новый тест модуля форматирования строки";
|
|
||||||
this.CountValueTest.UseVisualStyleBackColor = true;
|
|
||||||
this.CountValueTest.Click += new System.EventHandler(this.button1_Click);
|
|
||||||
//
|
|
||||||
// SimpleMapperTest
|
|
||||||
//
|
|
||||||
this.SimpleMapperTest.Location = new System.Drawing.Point(12, 71);
|
|
||||||
this.SimpleMapperTest.Name = "SimpleMapperTest";
|
|
||||||
this.SimpleMapperTest.Size = new System.Drawing.Size(335, 51);
|
|
||||||
this.SimpleMapperTest.TabIndex = 1;
|
|
||||||
this.SimpleMapperTest.Text = "Новый тест модуля SimpleMapper";
|
|
||||||
this.SimpleMapperTest.UseVisualStyleBackColor = true;
|
|
||||||
this.SimpleMapperTest.Click += new System.EventHandler(this.SimpleMapperTest_Click);
|
|
||||||
//
|
|
||||||
// FileExtensionTest
|
|
||||||
//
|
|
||||||
this.FileExtensionTest.Location = new System.Drawing.Point(12, 128);
|
|
||||||
this.FileExtensionTest.Name = "FileExtensionTest";
|
|
||||||
this.FileExtensionTest.Size = new System.Drawing.Size(335, 51);
|
|
||||||
this.FileExtensionTest.TabIndex = 2;
|
|
||||||
this.FileExtensionTest.Text = "Новый тест модуля FileExtension";
|
|
||||||
this.FileExtensionTest.UseVisualStyleBackColor = true;
|
|
||||||
this.FileExtensionTest.Click += new System.EventHandler(this.FileExtensionTest_Click);
|
|
||||||
//
|
|
||||||
// OsInfoBtn
|
|
||||||
//
|
|
||||||
this.OsInfoBtn.Location = new System.Drawing.Point(12, 185);
|
|
||||||
this.OsInfoBtn.Name = "OsInfoBtn";
|
|
||||||
this.OsInfoBtn.Size = new System.Drawing.Size(335, 51);
|
|
||||||
this.OsInfoBtn.TabIndex = 3;
|
|
||||||
this.OsInfoBtn.Text = "Информация о системе";
|
|
||||||
this.OsInfoBtn.UseVisualStyleBackColor = true;
|
|
||||||
this.OsInfoBtn.Click += new System.EventHandler(this.OsInfoBtn_Click);
|
|
||||||
//
|
|
||||||
// MainMenu
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(361, 252);
|
|
||||||
this.Controls.Add(this.OsInfoBtn);
|
|
||||||
this.Controls.Add(this.FileExtensionTest);
|
|
||||||
this.Controls.Add(this.SimpleMapperTest);
|
|
||||||
this.Controls.Add(this.CountValueTest);
|
|
||||||
this.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.Name = "MainMenu";
|
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
|
||||||
this.Text = "Главное меню";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button CountValueTest;
|
|
||||||
private Button SimpleMapperTest;
|
|
||||||
private Button FileExtensionTest;
|
|
||||||
private Button OsInfoBtn;
|
|
||||||
}
|
|
@@ -1,32 +0,0 @@
|
|||||||
namespace demo;
|
|
||||||
public sealed partial class MainMenu: Form
|
|
||||||
{
|
|
||||||
public MainMenu ()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void button1_Click (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CountValueTest formCountValueTest = new();
|
|
||||||
formCountValueTest.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SimpleMapperTest_Click (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
SampleMapperTest formSampleMapperTest = new();
|
|
||||||
formSampleMapperTest.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FileExtensionTest_Click (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
FileHashAndMimeType formTest = new();
|
|
||||||
formTest.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OsInfoBtn_Click (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
OsInfoFrm formTest = new();
|
|
||||||
formTest.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
65
demo/OsInfoFrm.Designer.cs
generated
65
demo/OsInfoFrm.Designer.cs
generated
@@ -1,65 +0,0 @@
|
|||||||
namespace demo;
|
|
||||||
|
|
||||||
sealed partial class OsInfoFrm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose (bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent ()
|
|
||||||
{
|
|
||||||
this.textBox = new System.Windows.Forms.TextBox();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// textBox
|
|
||||||
//
|
|
||||||
this.textBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.textBox.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.textBox.Multiline = true;
|
|
||||||
this.textBox.Name = "textBox";
|
|
||||||
this.textBox.Size = new System.Drawing.Size(1029, 510);
|
|
||||||
this.textBox.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// OsInfoFrm
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(1029, 510);
|
|
||||||
this.Controls.Add(this.textBox);
|
|
||||||
this.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
|
||||||
this.MaximizeBox = false;
|
|
||||||
this.MinimizeBox = false;
|
|
||||||
this.Name = "OsInfoFrm";
|
|
||||||
this.Text = "Информация о системе";
|
|
||||||
this.Load += new System.EventHandler(this.OsInfoFrm_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private TextBox textBox;
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
using anbs_cp.Classes;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace demo;
|
|
||||||
public sealed partial class OsInfoFrm: Form
|
|
||||||
{
|
|
||||||
public OsInfoFrm ()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OsInfoFrm_Load (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
textBox.Text = @"Процессор(ы) | ";
|
|
||||||
textBox.Text += JsonConvert.SerializeObject(OsInfo.Processors);
|
|
||||||
textBox.Text += @"Оперативная память | ";
|
|
||||||
textBox.Text += JsonConvert.SerializeObject(OsInfo.RAM);
|
|
||||||
textBox.Text += @"Видеокарта | ";
|
|
||||||
textBox.Text += JsonConvert.SerializeObject(OsInfo.Videos);
|
|
||||||
textBox.Text += @"Диски | ";
|
|
||||||
textBox.Text += JsonConvert.SerializeObject(OsInfo.Drives);
|
|
||||||
textBox.Text += @"Windows | ";
|
|
||||||
textBox.Text += JsonConvert.SerializeObject(OsInfo.Windows);
|
|
||||||
textBox.Text += @"Net | ";
|
|
||||||
textBox.Text += JsonConvert.SerializeObject(OsInfo.Net);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@@ -1,14 +1,15 @@
|
|||||||
namespace demo;
|
namespace demo
|
||||||
|
|
||||||
internal static class Program
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
internal static class Program
|
||||||
/// The main entry point for the application.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
|
||||||
static void Main ()
|
|
||||||
{
|
{
|
||||||
ApplicationConfiguration.Initialize();
|
/// <summary>
|
||||||
Application.Run(new MainMenu());
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
Application.Run(new CountValueTest());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
189
demo/SampleMapperTest.Designer.cs
generated
189
demo/SampleMapperTest.Designer.cs
generated
@@ -1,189 +0,0 @@
|
|||||||
namespace demo;
|
|
||||||
|
|
||||||
sealed partial class SampleMapperTest
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose (bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent ()
|
|
||||||
{
|
|
||||||
this.DemoBoolEdt = new System.Windows.Forms.CheckBox();
|
|
||||||
this.DemoStringEdt = new System.Windows.Forms.TextBox();
|
|
||||||
this.DemoIntEdt = new System.Windows.Forms.NumericUpDown();
|
|
||||||
this.DemoDateTimeEdt = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.MapBtn = new System.Windows.Forms.Button();
|
|
||||||
this.ResultArea = new System.Windows.Forms.TextBox();
|
|
||||||
this.DemoStringLabel = new System.Windows.Forms.Label();
|
|
||||||
this.DemoIntLabel = new System.Windows.Forms.Label();
|
|
||||||
this.DemoDateTimeLabel = new System.Windows.Forms.Label();
|
|
||||||
this.MapModeEdit = new System.Windows.Forms.ComboBox();
|
|
||||||
this.MapModeLabel = new System.Windows.Forms.Label();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.DemoIntEdt)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// DemoBoolEdt
|
|
||||||
//
|
|
||||||
this.DemoBoolEdt.AutoSize = true;
|
|
||||||
this.DemoBoolEdt.Location = new System.Drawing.Point(32, 144);
|
|
||||||
this.DemoBoolEdt.Name = "DemoBoolEdt";
|
|
||||||
this.DemoBoolEdt.Size = new System.Drawing.Size(65, 25);
|
|
||||||
this.DemoBoolEdt.TabIndex = 0;
|
|
||||||
this.DemoBoolEdt.Text = "Bool";
|
|
||||||
this.DemoBoolEdt.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// DemoStringEdt
|
|
||||||
//
|
|
||||||
this.DemoStringEdt.Location = new System.Drawing.Point(32, 42);
|
|
||||||
this.DemoStringEdt.Name = "DemoStringEdt";
|
|
||||||
this.DemoStringEdt.Size = new System.Drawing.Size(737, 29);
|
|
||||||
this.DemoStringEdt.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// DemoIntEdt
|
|
||||||
//
|
|
||||||
this.DemoIntEdt.Location = new System.Drawing.Point(32, 109);
|
|
||||||
this.DemoIntEdt.Name = "DemoIntEdt";
|
|
||||||
this.DemoIntEdt.Size = new System.Drawing.Size(737, 29);
|
|
||||||
this.DemoIntEdt.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// DemoDateTimeEdt
|
|
||||||
//
|
|
||||||
this.DemoDateTimeEdt.CustomFormat = "dd.MM.yyyy HH:mm:ss";
|
|
||||||
this.DemoDateTimeEdt.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.DemoDateTimeEdt.Location = new System.Drawing.Point(32, 193);
|
|
||||||
this.DemoDateTimeEdt.Name = "DemoDateTimeEdt";
|
|
||||||
this.DemoDateTimeEdt.Size = new System.Drawing.Size(737, 29);
|
|
||||||
this.DemoDateTimeEdt.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// MapBtn
|
|
||||||
//
|
|
||||||
this.MapBtn.Location = new System.Drawing.Point(32, 306);
|
|
||||||
this.MapBtn.Name = "MapBtn";
|
|
||||||
this.MapBtn.Size = new System.Drawing.Size(737, 57);
|
|
||||||
this.MapBtn.TabIndex = 5;
|
|
||||||
this.MapBtn.Text = "СВЯЗАТЬ";
|
|
||||||
this.MapBtn.UseVisualStyleBackColor = true;
|
|
||||||
this.MapBtn.Click += new System.EventHandler(this.MapBtn_Click);
|
|
||||||
//
|
|
||||||
// ResultArea
|
|
||||||
//
|
|
||||||
this.ResultArea.Dock = System.Windows.Forms.DockStyle.Right;
|
|
||||||
this.ResultArea.Location = new System.Drawing.Point(819, 0);
|
|
||||||
this.ResultArea.Multiline = true;
|
|
||||||
this.ResultArea.Name = "ResultArea";
|
|
||||||
this.ResultArea.ReadOnly = true;
|
|
||||||
this.ResultArea.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
|
||||||
this.ResultArea.Size = new System.Drawing.Size(332, 378);
|
|
||||||
this.ResultArea.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// DemoStringLabel
|
|
||||||
//
|
|
||||||
this.DemoStringLabel.AutoSize = true;
|
|
||||||
this.DemoStringLabel.Location = new System.Drawing.Point(32, 18);
|
|
||||||
this.DemoStringLabel.Name = "DemoStringLabel";
|
|
||||||
this.DemoStringLabel.Size = new System.Drawing.Size(54, 21);
|
|
||||||
this.DemoStringLabel.TabIndex = 7;
|
|
||||||
this.DemoStringLabel.Text = "String";
|
|
||||||
//
|
|
||||||
// DemoIntLabel
|
|
||||||
//
|
|
||||||
this.DemoIntLabel.AutoSize = true;
|
|
||||||
this.DemoIntLabel.Location = new System.Drawing.Point(32, 85);
|
|
||||||
this.DemoIntLabel.Name = "DemoIntLabel";
|
|
||||||
this.DemoIntLabel.Size = new System.Drawing.Size(30, 21);
|
|
||||||
this.DemoIntLabel.TabIndex = 8;
|
|
||||||
this.DemoIntLabel.Text = "Int";
|
|
||||||
//
|
|
||||||
// DemoDateTimeLabel
|
|
||||||
//
|
|
||||||
this.DemoDateTimeLabel.AutoSize = true;
|
|
||||||
this.DemoDateTimeLabel.Location = new System.Drawing.Point(32, 169);
|
|
||||||
this.DemoDateTimeLabel.Name = "DemoDateTimeLabel";
|
|
||||||
this.DemoDateTimeLabel.Size = new System.Drawing.Size(81, 21);
|
|
||||||
this.DemoDateTimeLabel.TabIndex = 9;
|
|
||||||
this.DemoDateTimeLabel.Text = "DateTime";
|
|
||||||
//
|
|
||||||
// MapModeEdit
|
|
||||||
//
|
|
||||||
this.MapModeEdit.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.MapModeEdit.FormattingEnabled = true;
|
|
||||||
this.MapModeEdit.Items.AddRange(new object[] {
|
|
||||||
"Full",
|
|
||||||
"Not null",
|
|
||||||
"Not default",
|
|
||||||
"Not null or default"});
|
|
||||||
this.MapModeEdit.Location = new System.Drawing.Point(32, 254);
|
|
||||||
this.MapModeEdit.Name = "MapModeEdit";
|
|
||||||
this.MapModeEdit.Size = new System.Drawing.Size(737, 29);
|
|
||||||
this.MapModeEdit.TabIndex = 10;
|
|
||||||
//
|
|
||||||
// MapModeLabel
|
|
||||||
//
|
|
||||||
this.MapModeLabel.AutoSize = true;
|
|
||||||
this.MapModeLabel.Location = new System.Drawing.Point(32, 230);
|
|
||||||
this.MapModeLabel.Name = "MapModeLabel";
|
|
||||||
this.MapModeLabel.Size = new System.Drawing.Size(167, 21);
|
|
||||||
this.MapModeLabel.TabIndex = 11;
|
|
||||||
this.MapModeLabel.Text = "Режим связывания:";
|
|
||||||
//
|
|
||||||
// SampleMapperTest
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(1151, 378);
|
|
||||||
this.Controls.Add(this.MapModeLabel);
|
|
||||||
this.Controls.Add(this.MapModeEdit);
|
|
||||||
this.Controls.Add(this.DemoDateTimeLabel);
|
|
||||||
this.Controls.Add(this.DemoIntLabel);
|
|
||||||
this.Controls.Add(this.DemoStringLabel);
|
|
||||||
this.Controls.Add(this.ResultArea);
|
|
||||||
this.Controls.Add(this.MapBtn);
|
|
||||||
this.Controls.Add(this.DemoDateTimeEdt);
|
|
||||||
this.Controls.Add(this.DemoIntEdt);
|
|
||||||
this.Controls.Add(this.DemoStringEdt);
|
|
||||||
this.Controls.Add(this.DemoBoolEdt);
|
|
||||||
this.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(4);
|
|
||||||
this.Name = "SampleMapperTest";
|
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
|
||||||
this.Text = "Тест класса SampleMapper";
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.DemoIntEdt)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private CheckBox DemoBoolEdt;
|
|
||||||
private TextBox DemoStringEdt;
|
|
||||||
private NumericUpDown DemoIntEdt;
|
|
||||||
private DateTimePicker DemoDateTimeEdt;
|
|
||||||
private Button MapBtn;
|
|
||||||
private TextBox ResultArea;
|
|
||||||
private Label DemoStringLabel;
|
|
||||||
private Label DemoIntLabel;
|
|
||||||
private Label DemoDateTimeLabel;
|
|
||||||
private ComboBox MapModeEdit;
|
|
||||||
private Label MapModeLabel;
|
|
||||||
}
|
|
@@ -1,71 +0,0 @@
|
|||||||
using anbs_cp.Classes;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace demo;
|
|
||||||
public sealed partial class SampleMapperTest: Form
|
|
||||||
{
|
|
||||||
public SampleMapperTest ()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapBtn_Click (object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Demo1Class demo1 = new()
|
|
||||||
{
|
|
||||||
DemoString = DemoStringEdt.Text,
|
|
||||||
DemoInt = (int)DemoIntEdt.Value,
|
|
||||||
DemoBool = DemoBoolEdt.Checked,
|
|
||||||
DemoDateTime = DemoDateTimeEdt.Value
|
|
||||||
};
|
|
||||||
|
|
||||||
Demo1Class demo2 = new()
|
|
||||||
{
|
|
||||||
DemoInt = 20220224,
|
|
||||||
DemoBool = true,
|
|
||||||
DemoDateTime = default
|
|
||||||
};
|
|
||||||
|
|
||||||
string serialize1 = JsonConvert.SerializeObject(demo2);
|
|
||||||
|
|
||||||
SimpleMapper.MapMode mode = MapModeEdit.SelectedIndex switch
|
|
||||||
{
|
|
||||||
0 => SimpleMapper.MapMode.MapFull,
|
|
||||||
1 => SimpleMapper.MapMode.MapNotNull,
|
|
||||||
2 => SimpleMapper.MapMode.MapNotDefault,
|
|
||||||
3 => SimpleMapper.MapMode.MapNotNullOrDefault,
|
|
||||||
_ => SimpleMapper.MapMode.MapFull
|
|
||||||
};
|
|
||||||
|
|
||||||
SimpleMapper.MapEx(demo1, ref demo2, mode, new List<string>());
|
|
||||||
|
|
||||||
string serialize2 = JsonConvert.SerializeObject(demo2);
|
|
||||||
|
|
||||||
// ReSharper disable once LocalizableElement
|
|
||||||
ResultArea.Text = $"Класс Demo2 до связывания:\r\n{serialize1}\r\nи после:\r\n{serialize2}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class Demo1Class
|
|
||||||
{
|
|
||||||
public string? DemoString { get; set; }
|
|
||||||
|
|
||||||
public int DemoInt { get; set; }
|
|
||||||
|
|
||||||
public bool DemoBool { get; set; }
|
|
||||||
|
|
||||||
public DateTime DemoDateTime { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Demo2Class
|
|
||||||
{
|
|
||||||
public string? DemoString { get; set; }
|
|
||||||
|
|
||||||
public int DemoInt { get; set; }
|
|
||||||
|
|
||||||
public bool DemoBool { get; set; }
|
|
||||||
|
|
||||||
public DateTime DemoDateTime { get; set; }
|
|
||||||
|
|
||||||
public string? DemoStringNotMapped { get; set; }
|
|
||||||
}
|
|
@@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@@ -2,34 +2,15 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Configurations>Release;Debug.CNF</Configurations>
|
<Configurations>Release;Debug.CNF</Configurations>
|
||||||
<StartupObject>demo.Program</StartupObject>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.CNF|AnyCPU'">
|
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\anbs_cp\anbs_cp.csproj" />
|
<ProjectReference Include="..\anbs_cp\anbs_cp.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="FileHashAndMimeTypeTest.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@@ -1,2 +0,0 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
|
||||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp100</s:String></wpf:ResourceDictionary>
|
|
Reference in New Issue
Block a user