بازخوردهای دوره
تزریق خودکار وابستگی‌ها در برنامه‌های ASP.NET MVC
من مطلب بالا را مطالعه کردم و با توجه به مطلب بالا کدهای خودم را به صورت زیر تغییر دادم

لایه Service
namespace ServiceLayer.EFServices
{
    public class TABMPCREWService : ITABMPCREWService
    {
        private IUnitOfWork _uow;
        private IDbSet<TABMPCREWS> _tabmpcrews;

        public TABMPCREWService(IUnitOfWork uow)
        {
            this._uow = uow;
            _tabmpcrews = uow.Set<TABMPCREWS>();
        }

        public int Add(TABMPCREWS personnel)
        {
            int rowEffect = 0;

            _tabmpcrews.Add(personnel);
            rowEffect = _uow.SaveChanges();
            return rowEffect;
        }

    }
}
و اینترفیس
namespace ServiceLayer.Interface
{
    public interface ITABMPCREWService
    {
        int Add(TABMPCREWS personnel);
    }
}
و فایل Global
 protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
            ObjectFactory.Initialize(x =>
            {
                x.For<ITABMPCREWService>().Use<TABMPCREWService>();
               // x.For<IUsersService>().Use<UsersService>();
            });
            ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());
           // initStructureMap();
        }
و
 public class StructureMapControllerFactory  : DefaultControllerFactory
    {
        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            if (controllerType == null)
                throw new InvalidOperationException(string.Format("Page not found: {0}", requestContext.HttpContext.Request.Url.AbsoluteUri.ToString(CultureInfo.InvariantCulture)));
            return ObjectFactory.GetInstance(controllerType) as Controller;
        }
    }
و کد کنترلر
public class HomeController  : Controller
    {
        public readonly ITABMPCREWService aa ;
        public HomeController(ITABMPCREWService tabmpcrewService)
        {
            aa = tabmpcrewService;
        }

        public ActionResult Index()
        {

            TABMPCREWS tt = new TABMPCREWS()
            {
                DTLASTUPDATEDDATE = DateTime.Now,
                INTOTRATE = 122,
                INTRATE = 215,
                VCCODEDESCRIPTION = "fff858699",
                VCCODEVALUE = "fff858699",
                VCLASTUSERID = "fff858699",
                INTCREWCODE = 105652
            };
            aa.Add(tt);


            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
اما زمان اجرا این خطا رو بهم میده و از این خط خطا می‌گیره


نظرات اشتراک‌ها
پیشنهاد رسمی اضافه شدن type unions به زبان #C

این متد را درنظر بگیرید:

public Receipt PlaceOrder(Order order)
{
        var product = _products.SingleOrDefault(p => p.ProductId == order.ProductId);
        
        if (product is null)
        {
            throw new Exception("Product doesn't exist");
        }

        if (product.Cost > order.Payment)
        {
            throw new Exception("Insufficient funds");
        }

        var receipt = new Receipt(++_receiptId, order.Payment);
        _receipts.Add(receipt);
        return receipt;
}

برای استفاده کننده دقیقا مشخص نیست که این متد ممکن است چندین استثناء را هم صادر کند. با وجود type unions، می‌توان مقصود واضح‌تری را ارائه داد:

public (Receipt or PlaceOrderError) PlaceOrder(Order order)

هرچند در این لحظه، شبیه به این‌کار را با استفاده‌ از کتابخانه‌ی OneOf هم انجام می‌دهند و ... TypeScript هم که در اساس توسط قسمت مهمی از تیم #C طراحی شده، مدت‌هاست که به همراه چنین قابلیتی هست.

اشتراک‌ها
پیشنهاد اضافه شدن type به JavaScript

Today we’re excited to announce our support and collaboration on a new Stage 0 proposal to bring optional and erasable type syntax to JavaScript. Because this new syntax wouldn’t change how surrounding code runs, it would effectively act as comments. We think this has the potential to make TypeScript easier and faster to use for development at every scale. We’d like to talk about why we’re pursuing this, and how this proposal works at a high level.

 

پیشنهاد اضافه شدن type به JavaScript
اشتراک‌ها
نحوه توزیع یک Angular component به npm

In this post I’ll quickly explain the minimum you need to know in order to publish an Angular component to npm. By the end of the post you’ll know how your module to: 

  • Be platform independent (i.e. run in Web Workers, Universal).
  • Should be bundled and distributed.
  • Work with the Angular’s Ahead-of-Time compiler.
  • Play well with TypeScript and allow autocompletion and compile-time type checking. 
نحوه توزیع یک Angular component به npm
نظرات مطالب
مهارت‌های تزریق وابستگی‌ها در برنامه‌های NET Core. - قسمت چهارم - پرهیز از الگوی Service Locator در برنامه‌های وب
یک نکته‌ی تکمیلی: امکان تزریق وابستگی‌های سرویس‌های سفارشی، در سازنده‌ی کلاس Startup برنامه‌های وب


اگر به سازنده‌ی پیش‌فرض کلاس Startup یک برنامه‌ی وب دقت کنید، چنین تزریق وابستگی در قالب ابتدایی آن وجود دارد:
public class Startup 
{ 
   public Startup(IConfiguration configuration) 
   { 
       Configuration = configuration; 
   }
در اینجا ممکن است چند سؤال مطرح شوند:
الف) چه سرویس‌های پیش‌فرض دیگری را نیز می‌توان در اینجا تزریق کرد؟
ب) آیا می‌توان سرویس‌های سفارشی تهیه شده‌ی توسط خودمان را نیز در اینجا تزریق کرد؟

الف) بر روی ابتدای متد ConfigureServices کلاس Startup یک break-point را قرار دهید. لیست پارامتر services آن، شامل سرویس‌های پیش‌فرضی است که قابلیت تزریق وابستگی‌ها را در سازنده‌ی این کلاس دارند و بیش از 40 کلاس هستند.

ب) برای این منظور به فایل Program.cs مراجعه کرده و سرویس سفارشی خود را به صورت زیر، توسط متد ConfigureServices آن، اضافه کنید:
using CoreIocServices;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;

namespace CoreIocSample02
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
            .ConfigureServices(serviceCollection =>
            {
                serviceCollection.AddScoped<ISomeService, SomeService>();
            })
            .UseStartup<Startup>();
    }
}
اکنون ISomeService سفارشی ما قابلیت تزریق در سازنده‌ی کلاس Startup را نیز پیدا کرده‌است (علاوه بر سایر نقاط برنامه):
namespace CoreIocSample02
{
    public class Startup
    {
        private readonly ISomeService _someService;

        public Startup(IConfiguration configuration, ISomeService someService)
        {
            Configuration = configuration;
            _someService = someService;
        }

        public IConfiguration Configuration { get; }