This commit is contained in:
2025-05-05 14:45:58 +03:00
parent 0fb4058186
commit 90dd893f3e
43 changed files with 2501 additions and 63 deletions

View File

@@ -33,6 +33,7 @@ sealed partial class MainMenu
FileExtensionTest = new Button();
OsInfoBtn = new Button();
actionStateSerializerTestBtn = new Button();
stringExtensionTestButton = new Button();
SuspendLayout();
//
// CountValueTest
@@ -77,7 +78,7 @@ sealed partial class MainMenu
//
// actionStateSerializerTestBtn
//
actionStateSerializerTestBtn.Location = new Point(12, 254);
actionStateSerializerTestBtn.Location = new Point(12, 242);
actionStateSerializerTestBtn.Name = "actionStateSerializerTestBtn";
actionStateSerializerTestBtn.Size = new Size(335, 51);
actionStateSerializerTestBtn.TabIndex = 4;
@@ -85,11 +86,22 @@ sealed partial class MainMenu
actionStateSerializerTestBtn.UseVisualStyleBackColor = true;
actionStateSerializerTestBtn.Click += actionStateSerializerTestBtn_Click;
//
// stringExtensionTestButton
//
stringExtensionTestButton.Location = new Point(12, 299);
stringExtensionTestButton.Name = "stringExtensionTestButton";
stringExtensionTestButton.Size = new Size(335, 51);
stringExtensionTestButton.TabIndex = 5;
stringExtensionTestButton.Text = "Тест расширения класса string";
stringExtensionTestButton.UseVisualStyleBackColor = true;
stringExtensionTestButton.Click += stringExtensionTestButton_Click;
//
// MainMenu
//
AutoScaleDimensions = new SizeF(10F, 21F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(361, 327);
ClientSize = new Size(361, 361);
Controls.Add(stringExtensionTestButton);
Controls.Add(actionStateSerializerTestBtn);
Controls.Add(OsInfoBtn);
Controls.Add(FileExtensionTest);
@@ -98,7 +110,10 @@ sealed partial class MainMenu
Font = new Font("Times New Roman", 14.25F);
FormBorderStyle = FormBorderStyle.FixedSingle;
Margin = new Padding(4);
MaximizeBox = false;
MinimizeBox = false;
Name = "MainMenu";
ShowIcon = false;
StartPosition = FormStartPosition.CenterScreen;
Text = "Главное меню";
ResumeLayout(false);
@@ -111,4 +126,5 @@ sealed partial class MainMenu
private Button FileExtensionTest;
private Button OsInfoBtn;
private Button actionStateSerializerTestBtn;
private Button stringExtensionTestButton;
}

View File

@@ -1,4 +1,6 @@
namespace demo;
using demo.TestForms;
namespace demo;
public sealed partial class MainMenu: Form
{
public MainMenu ()
@@ -35,4 +37,10 @@ public sealed partial class MainMenu: Form
ActionStateSerialize form = new();
form.ShowDialog();
}
private void stringExtensionTestButton_Click (object sender, EventArgs e)
{
StringExtensionTest form = new();
form.ShowDialog();
}
}

View File

@@ -0,0 +1,92 @@
namespace demo.TestForms;
sealed partial class ActionStateSerialize
{
/// <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 ()
{
textBox1 = new TextBox();
textBox2 = new TextBox();
label1 = new Label();
button1 = new Button();
SuspendLayout();
//
// textBox1
//
textBox1.Location = new Point(24, 12);
textBox1.Name = "textBox1";
textBox1.Size = new Size(209, 23);
textBox1.TabIndex = 0;
//
// textBox2
//
textBox2.Location = new Point(312, 6);
textBox2.Multiline = true;
textBox2.Name = "textBox2";
textBox2.Size = new Size(463, 225);
textBox2.TabIndex = 1;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(24, 65);
label1.Name = "label1";
label1.Size = new Size(38, 15);
label1.TabIndex = 2;
label1.Text = "label1";
//
// button1
//
button1.Location = new Point(24, 111);
button1.Name = "button1";
button1.Size = new Size(75, 23);
button1.TabIndex = 3;
button1.Text = "button1";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// ActionStateSerialize
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 250);
Controls.Add(button1);
Controls.Add(label1);
Controls.Add(textBox2);
Controls.Add(textBox1);
Name = "ActionStateSerialize";
Text = "Тест сериализации ActionState";
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox1;
private TextBox textBox2;
private Label label1;
private Button button1;
}

View File

@@ -0,0 +1,34 @@
using anbs_cp.Classes;
namespace demo.TestForms;
public sealed partial class ActionStateSerialize: Form
{
public ActionStateSerialize ()
{
InitializeComponent();
}
private void button1_Click (object sender, EventArgs e)
{
DemoClass demoClass = new()
{
Name = textBox1.Text.Length > 0 ? textBox1.Text : string.Empty
};
ActionState<DemoClass> state = new()
{
Value = demoClass
};
state.AddError("ОШИБКА, ШЕФ!");
textBox2.Text = state.Serialize();
ActionState<DemoClass> state2 = new();
state2.Deserialize(textBox2.Text);
label1.Text = state2.Value?.Name ?? "НЕТ ЗНАЧЕНИЯ";
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>

147
demo/TestForms/CountValueTest.Designer.cs generated Normal file
View File

@@ -0,0 +1,147 @@
namespace demo.TestForms;
sealed partial class CountValueTest
{
/// <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.InsertDataLabel = new System.Windows.Forms.Label();
this.InsertDataBox = new System.Windows.Forms.TextBox();
this.ResultLabel = new System.Windows.Forms.Label();
this.CalculateButton = new System.Windows.Forms.Button();
this.SelectFormatterLabel = new System.Windows.Forms.Label();
this.SelectFormatterBox = new System.Windows.Forms.ComboBox();
this.calculateConvButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// InsertDataLabel
//
this.InsertDataLabel.AutoSize = true;
this.InsertDataLabel.Location = new System.Drawing.Point(12, 66);
this.InsertDataLabel.Name = "InsertDataLabel";
this.InsertDataLabel.Size = new System.Drawing.Size(341, 17);
this.InsertDataLabel.TabIndex = 0;
this.InsertDataLabel.Text = "&Введите любое целочисленное значение:";
//
// InsertDataBox
//
this.InsertDataBox.Location = new System.Drawing.Point(12, 86);
this.InsertDataBox.Name = "InsertDataBox";
this.InsertDataBox.Size = new System.Drawing.Size(457, 24);
this.InsertDataBox.TabIndex = 1;
this.InsertDataBox.TextChanged += new System.EventHandler(this.InsertDataBox_TextChanged);
//
// ResultLabel
//
this.ResultLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.ResultLabel.Location = new System.Drawing.Point(0, 143);
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(478, 79);
this.ResultLabel.TabIndex = 2;
this.ResultLabel.Text = "&Вставьте любое целочисленное значение в поле выше и нажмите кнопку \"Вычислить\", " +
"чтобы увидеть результат...";
this.ResultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// CalculateButton
//
this.CalculateButton.Location = new System.Drawing.Point(12, 116);
this.CalculateButton.Name = "CalculateButton";
this.CalculateButton.Size = new System.Drawing.Size(234, 23);
this.CalculateButton.TabIndex = 3;
this.CalculateButton.Text = "В&ычислить обработчиком";
this.CalculateButton.UseVisualStyleBackColor = true;
this.CalculateButton.Click += new System.EventHandler(this.CalculateButton_Click);
//
// SelectFormatterLabel
//
this.SelectFormatterLabel.AutoSize = true;
this.SelectFormatterLabel.Location = new System.Drawing.Point(12, 9);
this.SelectFormatterLabel.Name = "SelectFormatterLabel";
this.SelectFormatterLabel.Size = new System.Drawing.Size(188, 17);
this.SelectFormatterLabel.TabIndex = 4;
this.SelectFormatterLabel.Text = "В&ыберете обработчик:";
//
// SelectFormatterBox
//
this.SelectFormatterBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.SelectFormatterBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.SelectFormatterBox.FormattingEnabled = true;
this.SelectFormatterBox.Items.AddRange(new object[] {
"Обработчик счёта",
"Обработчик размера файла"});
this.SelectFormatterBox.Location = new System.Drawing.Point(12, 29);
this.SelectFormatterBox.Name = "SelectFormatterBox";
this.SelectFormatterBox.Size = new System.Drawing.Size(457, 25);
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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(478, 222);
this.Controls.Add(this.calculateConvButton);
this.Controls.Add(this.SelectFormatterBox);
this.Controls.Add(this.SelectFormatterLabel);
this.Controls.Add(this.CalculateButton);
this.Controls.Add(this.ResultLabel);
this.Controls.Add(this.InsertDataBox);
this.Controls.Add(this.InsertDataLabel);
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 = "CountValueTest";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Тест модуля форматирования строки";
this.Load += new System.EventHandler(this.CountValueTest_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label InsertDataLabel;
private TextBox InsertDataBox;
private Label ResultLabel;
private Button CalculateButton;
private Label SelectFormatterLabel;
private ComboBox SelectFormatterBox;
private Button calculateConvButton;
}

View File

@@ -0,0 +1,56 @@
using anbs_cp.Classes;
using anbs_cp.Interfaces;
namespace demo.TestForms;
public sealed partial class CountValueTest: Form
{
public CountValueTest ()
{
InitializeComponent();
}
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(),
1 => new FileSizeFormatter(),
_ => new CountFormatter(),
};
ResultLabel.Text = formatter.Format(value);
}
private void CountValueTest_Load (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),
_ => new CountConverter(CountConverter.DefaultNames).Convert(value)
};
}
}

View File

@@ -0,0 +1,60 @@
<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>

View File

@@ -0,0 +1,125 @@
namespace demo.TestForms;
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;
}

View File

@@ -0,0 +1,44 @@
using anbs_cp.Classes;
using anbs_cp.Extensions;
// ReSharper disable LocalizableElement
namespace demo.TestForms;
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();
}
}

View File

@@ -0,0 +1,63 @@
<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>

65
demo/TestForms/OsInfoFrm.Designer.cs generated Normal file
View File

@@ -0,0 +1,65 @@
namespace demo.TestForms;
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;
}

View File

@@ -0,0 +1,27 @@
using anbs_cp.Classes;
using anbs_cp.OsInfo.Classes;
namespace demo.TestForms;
public sealed partial class OsInfoFrm: Form
{
public OsInfoFrm ()
{
InitializeComponent();
}
private void OsInfoFrm_Load (object sender, EventArgs e)
{
textBox.Text = @"Процессор(ы) | ";
textBox.Text += new SysTextSerializer().Serialize(OsInfo.Processors);
textBox.Text += @"Оперативная память | ";
textBox.Text += new SysTextSerializer().Serialize(OsInfo.RAM);
textBox.Text += @"Видеокарта | ";
textBox.Text += new SysTextSerializer().Serialize(OsInfo.Videos);
textBox.Text += @"Диски | ";
textBox.Text += new SysTextSerializer().Serialize(OsInfo.Drives);
textBox.Text += @"Windows | ";
textBox.Text += new SysTextSerializer().Serialize(OsInfo.Windows);
textBox.Text += @"Net | ";
textBox.Text += new SysTextSerializer().Serialize(OsInfo.Net);
}
}

View File

@@ -0,0 +1,60 @@
<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>

View File

@@ -0,0 +1,189 @@
namespace demo.TestForms;
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;
}

View File

@@ -0,0 +1,70 @@
using anbs_cp.Classes;
namespace demo.TestForms;
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 = new SysTextSerializer().Serialize(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 = new SysTextSerializer().Serialize(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; }
}

View File

@@ -0,0 +1,60 @@
<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>

View File

@@ -0,0 +1,125 @@
namespace demo.TestForms;
partial class StringExtensionTest
{
/// <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 ()
{
stringInputLabel = new Label();
stringInput = new TextBox();
replaceInput = new TextBox();
replaceInputLabel = new Label();
resultLabel = new Label();
doItButton = new Button();
SuspendLayout();
//
// stringInputLabel
//
stringInputLabel.AutoSize = true;
stringInputLabel.Location = new Point(12, 9);
stringInputLabel.Name = "stringInputLabel";
stringInputLabel.Size = new Size(119, 17);
stringInputLabel.TabIndex = 0;
stringInputLabel.Text = "&Введите строку:";
//
// stringInput
//
stringInput.Location = new Point(12, 29);
stringInput.Name = "stringInput";
stringInput.Size = new Size(1005, 26);
stringInput.TabIndex = 1;
//
// replaceInput
//
replaceInput.Location = new Point(12, 89);
replaceInput.Multiline = true;
replaceInput.Name = "replaceInput";
replaceInput.Size = new Size(1005, 307);
replaceInput.TabIndex = 2;
//
// replaceInputLabel
//
replaceInputLabel.AutoSize = true;
replaceInputLabel.Location = new Point(12, 69);
replaceInputLabel.Name = "replaceInputLabel";
replaceInputLabel.Size = new Size(235, 17);
replaceInputLabel.TabIndex = 3;
replaceInputLabel.Text = "&Введите массив замен (что=чем):";
//
// resultLabel
//
resultLabel.Dock = DockStyle.Bottom;
resultLabel.Location = new Point(0, 454);
resultLabel.Name = "resultLabel";
resultLabel.Padding = new Padding(10);
resultLabel.Size = new Size(1025, 184);
resultLabel.TabIndex = 4;
resultLabel.Text = "&Введите данные и нажмите кнопку «Преобразовать», чтобы увидеть здесь резкльтат...";
//
// doItButton
//
doItButton.Location = new Point(12, 402);
doItButton.Name = "doItButton";
doItButton.Size = new Size(1005, 43);
doItButton.TabIndex = 5;
doItButton.Text = "&Преобразовать";
doItButton.UseVisualStyleBackColor = true;
doItButton.Click += doItButton_Click;
//
// StringExtensionTest
//
AutoScaleDimensions = new SizeF(9F, 17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1025, 638);
Controls.Add(doItButton);
Controls.Add(resultLabel);
Controls.Add(replaceInputLabel);
Controls.Add(replaceInput);
Controls.Add(stringInput);
Controls.Add(stringInputLabel);
Font = new Font("XO Thames", 12F, FontStyle.Regular, GraphicsUnit.Point, 204);
FormBorderStyle = FormBorderStyle.Fixed3D;
Margin = new Padding(4, 3, 4, 3);
MaximizeBox = false;
MinimizeBox = false;
Name = "StringExtensionTest";
ShowIcon = false;
ShowInTaskbar = false;
StartPosition = FormStartPosition.CenterScreen;
Text = "Тест расширения класса string";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label stringInputLabel;
private TextBox stringInput;
private TextBox replaceInput;
private Label replaceInputLabel;
private Label resultLabel;
private Button doItButton;
}

View File

@@ -0,0 +1,47 @@
using anbs_cp.Classes;
using anbs_cp.Extensions;
namespace demo.TestForms;
public partial class StringExtensionTest: Form
{
public StringExtensionTest ()
{
InitializeComponent();
}
private void doItButton_Click (object sender, EventArgs e)
{
if (stringInput.Text.IsNullOrWhiteSpace())
{
resultLabel.Text = @"Ошибка! Не заполнено поле ввода строки на замену!";
return;
}
if (replaceInput.Text.IsNullOrWhiteSpace())
{
resultLabel.Text = @"Ошибка! Не заполнено поле ввода списка замен!";
return;
}
string[] lines = replaceInput.Text.ReplaceLineEndings(";").Split(';');
KeyValueOrderedList<string> replaceList = [];
foreach (string line in lines)
{
string[] splitLine = line.Split('=');
if (splitLine.Length < 2)
continue;
string key = splitLine[0];
string value = splitLine[1];
replaceList.Add(new(key, value));
}
resultLabel.Text = stringInput.Text.Format(replaceList, StringComparison.CurrentCultureIgnoreCase);
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>

View File

@@ -24,9 +24,7 @@
</ItemGroup>
<ItemGroup>
<Compile Update="FileHashAndMimeTypeTest.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="TestForms\FileHashAndMimeTypeTest.cs" />
</ItemGroup>
</Project>