2020年5月23日 星期六

libphonenumber-csharp

https://github.com/twcclegg/libphonenumber-csharp

檢查電話號碼格式是否正確
還會顯示分類:FIXED_LINE、MOBILE、VOIP(070門號)、TOLL_FREE(080門號)

DEMO:
https://libphonenumber.appspot.com

Java原版:
https://github.com/google/libphonenumber

ref:
https://www.twilio.com/blog/validating-phone-numbers-effectively-with-c-and-the-net-frameworks

https://medium.com/frochu/libphonenumber-example-app-f60680faa599 

InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor' while attempting to activate

 寫.NET Core遇到Unable to resolve service for type通常是忘記註冊物件給DI容器

 Startup.cs的ConfigureServices(IServiceCollection services)加入以下這一行
            //TagsHelper使用
            services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();


錯誤訊息:
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor' while attempting to activate

IList和IEnumerable的比較

自己通常使用IEnumerable<T>
但還是會有需要用到IList<T>的時候

http://trufflepenne.blogspot.com/2013/04/ilistienumerable.html

https://stackoverflow.com/questions/376708/ilist-vs-ienumerable-for-collections-on-entities