Types of Services in ASP.NET Core
There are 2 types of services in ASP.NET core.
Before registering services, let’s first know the different methods to register a service.
How to Register a Service with ASP.NET Core Dependency Injection Container?
var builder = WebApplication.CreateBuilder(args);
// ADD FRAMEWORK MVC SERVICES TO THE CONTAINER
builder.Services.AddMvc();
// ADD APPLICATION SERVICES TO THE CONTAINER
builder.Services.Add(new ServiceDescriptor(typeof(ISubjectTypesDA), new SubjectTypesDA())); // BY DEFAULT SINGLETON
builder.Services.Add(new ServiceDescriptor(typeof(ISubjectTypesDA), new SubjectTypesDA(),ServiceLifetime.Singleton)); // SINGLETON
builder.Services.Add(new ServiceDescriptor(typeof(ISubjectTypesDA), new SubjectTypesDA(),ServiceLifetime.Transient)); // TRANSIENT
builder.Services.Add(new ServiceDescriptor(typeof(ISubjectTypesDA), new SubjectTypesDA(),ServiceLifetime.Scoped)); // SCOPED
What is the ServiceDescriptor class in .NET Core?
Extension methods for Registration
// ADD APPLICATION SERVICE TO THE CONTAINER.
services.AddTransient<IEmailSenderBL, EmailSenderBL>(); // TRANSIENT
services.AddScoped<ISubjectTypesBL, SubjectTypesBL>(); // SCOPED
services.AddSingleton<ICPCalculationBL, CPCalculationBL>(); // SINGLETON
There are 3 types of Dependency Injection.
Constructor Injection:
public class CenterController : BaseController
{
private ICenterBL _centerBL;
public CenterController(ICenterBL centerBL) : base(myLoginUser)
{
_centerBL = centerBL;
}
[Authorize]
public IActionResult Index()
{
try
{
var data = _centerBL.GetCenterpageList();
return View(data);
}
catch (Exception EX)
{
throw EX;
}
}
}
Property Injection:
public class AddressController : Controller
{
[Authorize]
public IActionResult Index()
{
var services = this.HttpContext.RequestServices;
IAddressBL _address = (IAddressBL)services.GetService(typeof(IAddressBL));
var data = _address.GetAddressList();
return View(data);
}
}
Method Injection:
public class CommonController: Controller
{
public IActionResult Index([FromServices] IAddressBL _addressBL)
{
var list = _addressBL.GetAddressList();
return View(list);
}
}
Advantages of Dependency Injection
What is CSS? CSS stands for Cascading Style Sheet. We can use it as a scripting language for developing and creating different web pages.It is well like web technology mostly used with HTML and JavaScript. CSS styles are saved in separate files with the .css extension. It is designed to separate content and presentation, like Layout, fonts, and colors. By separating the content (HTML) from its presentation(CSS), web developers can create consistent and visually appealing designs across multiple pages and ensure a better experience. What is SCSS? SCSS stands for sassy Cascading Style Sheets. It is a more advanced and evolved variant of the CSS language.It adds additional functionality to CSS and gives web developers more flexibility and power when creating web designs.SCSS contains file extension as .scss. SCSS is a part of the larger Sass (syntactically Awesome Stylesheets) language, which was created to explore the capabilities of traditional CSS. We can add some extra features to CSS using SCSS, like Variables, Nesting, and many more. using these features, we can write the SCSS in a much simpler and quicker way than writing the standard CSS. Differences between CSS and SCSS: 1. Syntax: Plain text is used for CSS whereas more structured syntax with additional features is used for SCSS. 2. Variables: SCSS allows you to define variables to store commonly used values like font sizes, color, and spacing, whereas CSS does not. CSS example: body{ color: #ffffff; font: $section-font: 'Arial','sans-serif'; font-size: xx-large; padding: 2rem; } SCSS example: $white: #ffffff; $section-font: $section-font: 'Arial', sans-serif; body { color: $white; font: $section-font; font-size: xx-large; padding: 2rem; } 3. Nesting: SCSS language promotes rules that are properly nested whereas regular CSS language does not assign various nested rules. SCSS example: .parent-selector { .child-selector { // Styles for child selector } } .container { width: 100%; h1 { color: blue; font-size: 24px; } } Benefits of Using Nesting in SCSS: 1. Improved Readability: Nesting allows for more organized code structure, making it easier to read and understand the styles. 2. Reduced Repetition: The user can avoid repetitive code by addressing parent elements directly, saving time and effort. 4. Mixins: Mixins are like functions in programming languages, SCSS allows to creation and reuse of code snippets using mixins. CSS example: nav ul { margin: 0; padding: 0; list-style: none; } nav ul li { display: inline-block; margin-left: -2px; margin-right: 2em; } SCSS example: @mixin reset-list { margin: 0; padding: 0; list-style: none; } @mixin vertical-list { @include reset-list; li { display: inline-block; margin: { left: -2px; right: 2em; } } } nav ul { @include vertical-list; } Arguments: Mixins can also take arguments, which allows their behavior to be customized every time they are called. The arguments are specified in the @mixin rule after the mixin's name, as a list of variable names surrounded by parentheses. CSS example: .sidebar { float: left; } [dir=rtl] .sidebar { float: right; } SCSS example: @mixin rtl($property, $ltr-value, $rtl-value) { #{$property}: $ltr-value; [dir=rtl] & { #{$property}: $rtl-value; } } .sidebar { @include rtl(float, left, right); } 5. File Extension: CSS files use the .css file extension, whereas SCSS files use the .scss file extension. 6. Compilation: CSS files are interpreted by web browsers directly, whereas SCSS files must be preprocessed into standard CSS files using a preprocessor such as Sass. 7. Language Used: SCSS is mostly used in the Ruby language while CSS is mostly used in the HTML and JavaScript languages.
After creating a new Apple ID account, You might find that you can't use it with some Applications, iTunes, or the App Store. Not to worry, this is not a permanent issue; we can resolve it in just a few steps. Usually, when you go to the App Store and enter your Apple ID and Passcode to download any Application, you will get one alert in the PopUp like 'This Apple ID Has Not Yet Been Used in The iTunes Store. Basically, this alert stops you from using the iTunes store or the App Store, and gives you messages like: 1. This Apple ID has not yet been used with the App Store. Please review Your Apple Account Information. 2. This Apple Id has not yet been used with the iTunes Store. Tap Review to Sign in, then review your account information. Most people will follow the above instruction and tap on Review and agree to the Term and Conditions or add the Extra information to their Apple Id Account. But, sometimes it's not worth it. To Resolve this issue Just follow the below Steps: 1. Go to the Setting 2. Open the Profile section 3. Click on Media & Purchase 4. You will show one popup, Just click on the continue 5. Just review your Account Details Conclusion: Here conclusion is that you just need to enable Media & Purchase on your device.
Microsoft Announces .NET 5 Microsoft announces that the next release after .Net core 3.0 will be .NET 5. .NET 5 will be the big release in the .NET family. You will able to use it to target Windows, Linux, Android, iOS, macOS, tvOS, watchOS, WebAssembly, and more. Microsoft will introduce new .NET APIs, language features, and runtime capabilities as a part of .NET 5. Microsoft intends to release .NET 5 in November 2020, with the first preview available in the first half of 2020. It will be supported with future updates to Visual Studio 2019, Visual Studio for Mac, and Visual Studio Code. .Net 5 Moves Ahead with .NET Core .NET Core Functionalities: Cross-platform implementation in any device Support all key platform features for .net core, .Net Framework, xamarin Open-source and community-Oriented Support with future updates to Visual Studio Code, Visual Studio 2019, Command Line Interface, and Visual Studio for Mac. Fast, Scalable and High Performance Side-by-side installation Support for platform-specific features like Windows Forms, & WPF on Windows Smarter Deployment & packages Small projects Files Three New major supports for developers Java Interoperability will be available on all Swift and Objective-C Interoperability will be supported on all multiple operating systems CoreFX will be extended to support static compilation of .Net, smaller footprints, and support for more operating systems. The Other Highlights Features Desktop Development with .NET 5 .NET 5 will come up with all key desktop development functionalities and libraries. WPF, Windows Forms, UWP, and xamarin are the four key desktop platforms. Mobile Development with .NET .Net 5 will continue to build cross-platform mobile apps for Android, iOS, tvOS, macOS, and watchOS platforms using Xamarin. Runtime and Language with .Net 5 Mono is the original cross-platform implementation of .NET. It started out as an open-source alternative to .NET Framework and transitioned to targeting mobile devices like Android and iOS devices popular. CoreCLR is runtime used as part of .NET Core. It has been primarily targeted at supporting cloud applications, including the largest services at Microsoft and now is also being used for windows desktop, IOT, and machine learning applications. Cloud Development with .NET 5 The major functionality of .Net 5 is Azure app Development. With the release of the latest version of .Net, developers will continue to develop software with Azure. Game Development with .Net 5 Visual studio 2019 and .Net 5 will support utility, a vital part of .Net gaming to develop games for mobile and other gaming platforms.
I am currently working as a Senior Software Developer at MagnusMinds IT Solution. Having more than 4 years of professional experience. I have knowledge of MVC, .Net, .Net Core, API, C#, jQuery, JavaScript, and Ionic.