My Auto Mapper

MyAutoMapper is a dotnet library. The Map<T>() method compares common properties in 2 different classes without serialization using reflection and assigns common named values. To add it to the project, the following command can be preferred using nuget services <strong> NuGet\Install-Package MyAutoMapper -Version 2.0.0.0.1 </strong> Here is an example of comparing an anonymous object with a defined class. <code> var result1 = new { naME = "first name", suRName = "last name", age = 2 }.Map<Person>(); </code> <div style="text-align: center;"><a href="https://github.com/meto260/MyAutoMapper" class="btn btn-primary">Github</a></div>

My String Extensions

I have collected my most used string algorithms under a single class. Kurulum için : <strong>NuGet\Install-Package MyStringExtensions -Version 1.0.0</strong> <div style="text-align: center;"><a href="https://github.com/meto260/MyStringExtensions" class="btn btn-primary">Github</a></div> Örnek kod: <code> string sourceText = "++a little Bunny raBBit waNdering in a huge Forest"; Console.WriteLine(sourceText.Cut(5)); //Output: "++a l" </code>

MVC Windows Service

Without IIS or Nginx, we can publish our dotnet web application as a windows or linux service. Although it can be done in previous versions, the example I will give is made with dotnet6. I will use an MVC example for speed. Necessary nuget libraries: For Windows -> Microsoft.Extensions.Hosting.WindowsServices For Linux -> Microsoft.Extensions.Hosting.Systemd <code> var webApplicationOptions = new WebApplicationOptions() { ContentRootPath = AppContext.BaseDirectory, Args = args, ApplicationName = System.Diagnostics.Process.GetCurrentProcess().ProcessName }; var builder = WebApplication.CreateBuilder(webApplicationOptions); builder.Services.AddControllersWithViews(); //builder.Host.UseWindowsService(); //windows için //builder.Host.UseSystemd(); //linux için var app = builder.Build(); if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseStaticFiles(); app.UseCors(c=> c.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); app.Run(); </code> To run as a Windows service; sc.exe create "HttpWorker" binpath="C:\...\Release\net6.0\publish\HttpWorker.exe" sc.exe stop "HttpWorker" sc.exe delete "HttpWorker" I am not giving an example of Linux service setup, it may vary depending on the Linux operating system.

Web3 Registering a Cargo Shipment

Solidity; \n <code> contract gonderitakip { struct gonderi { uint256 id; string timespan; string consignor; string consignee; string code; string ReceiverAddress; string lastTransportPoint; string email; uint256 contact_phone; } mapping(uint256 => gonderi) gonderiler; uint256[] internal gonderiIds; function set(uint256 id, string memory timespan, string memory consignor, string memory consignee, string memory code, string memory ReceiverAddress, string memory lastTransportPoint, string memory email, uint256 contact_phone) public { gonderi storage newG = gonderiler[id]; newG.timespan = timespan; newG.consignor = consignor; newG.consignee = consignee; newG.code = code; newG.ReceiverAddress = ReceiverAddress; newG.lastTransportPoint = lastTransportPoint; newG.email = email; newG.contact_phone = contact_phone; gonderiIds.push(id); } function get(uint256 id) public view returns (uint256, string memory, string memory, string memory, string memory, string memory, string memory, string memory, uint256){ gonderi storage s = gonderiler[id]; return (s.id, s.timespan, s.consignor, s.consignee, s.code, s.ReceiverAddress, s.lastTransportPoint, s.email, s.contact_phone); } } contract gonderitakip { struct gonderi { uint256 id; string timespan; string consignor; string consignee; string code; string ReceiverAddress; string lastTransportPoint; string email; uint256 contact_phone; } mapping(uint256 => gonderi) gonderiler; uint256[] internal gonderiIds; function set(uint256 id, string memory timespan, string memory consignor, string memory consignee, string memory code, string memory ReceiverAddress, string memory lastTransportPoint, string memory email, uint256 contact_phone) public { gonderi storage newG = gonderiler[id]; newG.timespan = timespan; newG.consignor = consignor; newG.consignee = consignee; newG.code = code; newG.ReceiverAddress = ReceiverAddress; newG.lastTransportPoint = lastTransportPoint; newG.email = email; newG.contact_phone = contact_phone; gonderiIds.push(id); } function get(uint256 id) public view returns (uint256, string memory, string memory, string memory, string memory, string memory, string memory, string memory, uint256){ gonderi storage s = gonderiler[id]; return (s.id, s.timespan, s.consignor, s.consignee, s.code, s.ReceiverAddress, s.lastTransportPoint, s.email, s.contact_phone); } } contract gonderitakip { struct gonderi { uint256 id; string timespan; string consignor; string consignee; string code; string ReceiverAddress; string lastTransportPoint; string email; uint256 contact_phone; } mapping(uint256 => gonderi) gonderiler; uint256[] internal gonderiIds; function set(uint256 id, string memory timespan, string memory consignor, string memory consignee, string memory code, string memory ReceiverAddress, string memory lastTransportPoint, string memory email, uint256 contact_phone) public { gonderi storage newG = gonderiler[id]; newG.timespan = timespan; newG.consignor = consignor; newG.consignee = consignee; newG.code = code; newG.ReceiverAddress = ReceiverAddress; newG.lastTransportPoint = lastTransportPoint; newG.email = email; newG.contact_phone = contact_phone; gonderiIds.push(id); } function get(uint256 id) public view returns (uint256, string memory, string memory, string memory, string memory, string memory, string memory, string memory, uint256){ gonderi storage s = gonderiler[id]; return (s.id, s.timespan, s.consignor, s.consignee, s.code, s.ReceiverAddress, s.lastTransportPoint, s.email, s.contact_phone); } } </code> JS; \n <code> const web3 = new Web3(window.ethereum); const contract_adr='0xbBc7Aad82'; const abi = "abijson"; const contract = new web3.eth.Contract(JSON.parse(abi), contract_adr); async function connect() { await window.ethereum.enable(); web3.eth.accounts = await web3.eth.getAccounts(); web3.eth.defaultAccount = web3.eth.accounts[0]; } async function getFunc(){ let request = await contract.methods.get(10).call(); console.log(request); } async function setFunc(){ contract.methods.set( 10, '2022-01-27', 'metin yakar', 'A Müşterisi', 'GDR2022001RD', 'Turkey, Ankara, Çankaya', 'Bolu 2 Nolu Transfer Merkezi', 'test@metinyakar.net', 5551234567 ).send({from:web3.eth.defaultAccount}); } </code>

Old Blog

<a href="https://web.archive.org/web/20220518203106/http://www.metinyakar.net/wp/">Go to archive</a>