Skip to content

Instantly share code, notes, and snippets.

View anjankant's full-sized avatar
🎯
Focusing

Anjan Kant anjankant

🎯
Focusing
View GitHub Profile
@anjankant
anjankant / disable-Tag-Helper-at-the-element-level
Created October 12, 2022 17:50
disable Tag Helper at the element level
<!span asp-validation-for="phone" class="divPhone"></!span>
@anjankant
anjankant / tag-helper-in-NET-Core
Created October 12, 2022 17:49
tag helper in ASP.NET Core
//HTML Helper
@Html.TextBoxFor(model => model.CompanyName, new { @class = "form-control", placeholder = "Enter Your Company Name" })
//content with tag helper
<input asp-for="CompanyName" placeholder="Enter Your Company Name" class="form-control" />
//Equivalent HTML
<input placeholder="Enter Your Company Name" class="form-control" id="CompanyName" name="CompanyName" value="" type="text">
@anjankant
anjankant / enable-Session-in-NET-Core
Created October 12, 2022 17:48
enable Session in ASP.NET Core
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
......
.......
services.AddSession();
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
@anjankant
anjankant / middleware-to-the-ASP-NET-Core-pipeline
Created October 12, 2022 17:47
middleware to the ASP.NET Core pipeline
public void Configure(IApplicationBuilder app)
{
app.Map("/path1", Middleware1);
app.Map("/path2", Middleware2);
}
@anjankant
anjankant / startup-class-in-NET-core
Created October 12, 2022 17:46
startup class in ASP.NET core
public class TC
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<TestClass>();
@anjankant
anjankant / Single-Responsibility-Principle
Created September 30, 2022 14:41
The Single Responsibility Principle explaining with example
public interface IOrders
{
void SaveOrders(string OrderNo);
string GetOrder(string OrderNo);
void CancelOrder(string OrderNo);
}
public class Order : IOrders
{
public void SaveOrders(string OrderNo)
{
@anjankant
anjankant / gist:a6e3e490b3eff1429444e8d1fdf4b707
Created September 30, 2022 14:28
Liskov Substitution Principle in C# with Examples
using System;
public class Program
{
public static void Main()
{
Car car = new Mercedes();
Console.WriteLine(string.Concat("Mercedes Car Color is: ",car.ListColor()));
car = new Wolkswagen();
Console.WriteLine(string.Concat("Wokswagen Car Color is: ",car.ListColor()));
@anjankant
anjankant / Dependency-Invarsion-Principle
Created September 30, 2022 13:20
DIP through IoC utilizing an injection developer
public Interface IEmployee
{
void SaveEmployee();
}
public class Employee
{
IEmployee _employee;
public EmployeeStatistics(IEmployee Employee)
{
@anjankant
anjankant / Interface-Segregation-Principle
Last active September 30, 2022 14:58
The ISP is a right definition of a subtyping association, named strong behavioral subtyping
public interface IClass
{
void Classes();
}
public interface ISubjects
{
void Subjects();
}
@anjankant
anjankant / Open-Closed-Principle-Part-I
Created September 27, 2022 11:14
Open Closed Principle - Solid Design Pattern C#
public class Account
{
public decimal CalculateInterest { get; set; }
public decimal CalculateInterest(string accountType)
{
if (accountType == "Regular")
{
// do here regular account type logic
}