Skip to content

Instantly share code, notes, and snippets.

View takahirohonda's full-sized avatar

Takahiro Honda takahirohonda

View GitHub Profile
@takahirohonda
takahirohonda / svg-sizing-not-working-for-iphone-1.html
Created January 31, 2020 07:18
svg-sizing-not-working-for-iphone-1.html
<!-- icon.svg has with and viewbox attributes. They should work fine -->
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="250px"
viewBox="0 0 1952.00 734.93"
enable-background="new 0 0 1952.00 734.93"
xml:space="preserve">
...
</svg>
@takahirohonda
takahirohonda / MockClassForExtensionsTests.cs
Created December 17, 2019 10:35
ServiceCollectionExtensionTests - MockClasses
using ApplicationCore.Extensions;
namespace UnitTests.ApplicationCore.Extensions
{
[Service(typeof(IMockClassForExtensionsTestsA), Lifetime.Transient)]
public class MockClassForExtensionsTestsA : IMockClassForExtensionsTestsA
{ }
public interface IMockClassForExtensionsTestsA
{ }
@takahirohonda
takahirohonda / ServiceCollectionExtensionTests.cs
Created December 17, 2019 10:30
ServiceCollectionExtensionTests.cs
using Xunit;
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using ApplicationCore.Extensions;
namespace UnitTests.ApplicationCore.Extensions
{
public class ServiceCollectionExtensionsTest
{
private readonly IServiceCollection _serviceCollection;
@takahirohonda
takahirohonda / Using Attribute DI example.cs
Last active December 16, 2019 09:38
Using Attribute - ASP.NET Core DI
// Add attribute
// Interface for the class & Lifetime
// (1) Scoped
[Service(typeof(IAppsRepository), Lifetime.Scoped)]
public class AppsRepository : IAppsRepository
{
...
}
// (2) Transient
@takahirohonda
takahirohonda / Startup - out-of-the-box way.cs
Last active December 16, 2019 09:26
Startup - ASP.NET DI Out of the box way
public void ConfigureServices(IServiceCollection services)
{
// Add dependencies manually
services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>));
services.AddScoped(typeof(IEfRepository<>), typeof(EfRepository<>));
services.AddScoped<IAppsRepository, AppsRepository>();
services.AddScoped<IAppReviewRepository, AppReviewRepository>();
services.AddScoped<IAppCategoryRespository, AppCategoryRespository>();
...
public void ConfigureServices(IServiceCollection services)
{
// Add dependencies with extension methods
services.AddClassesWithServiceAttribute("ApplicationCore");
services.AddClassesWithServiceAttribute("Infrastructure");
services.AddClassesWithServiceAttribute("Web");
// AddMvc for controllers
services.AddMvc()
}
@takahirohonda
takahirohonda / ServiceCollectionExtensions.cs
Last active December 16, 2019 09:18
ServiceCollectionExtensions - ASP.NET Core DI
/*
* Based on Habitat
* https://github.com/Sitecore/Habitat/tree/master/src/Foundation/DependencyInjection/code
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
@takahirohonda
takahirohonda / ServicveAttribute.cs
Created December 16, 2019 09:12
ServicveAttribute - ASP.NET Core DI
using System;
namespace ApplicationCore.Extensions
{
public enum Lifetime
{
Transient,
Singleton,
Scoped
}
@takahirohonda
takahirohonda / releasing-multiple-pwas-to-googleplay-by-using-a-single-github-page-root-2.json
Created November 10, 2019 02:47
releasing-multiple-pwas-to-googleplay-by-using-a-single-github-page-root-2.json
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.mydatahack.firstapp",
"sha256_cert_fingerprints":
["sha from app sigining in GooglePlay console for 1st app"]
}
},
{
@takahirohonda
takahirohonda / releasing-multiple-pwas-to-googleplay-by-using-a-single-github-page-root-1.xml
Created November 10, 2019 02:44
releasing-multiple-pwas-to-googleplay-by-using-a-single-github-page-root-1.xml
<!-- For the first app -->
<resources>
<string name="app_name">My First App</string>
<string name="asset_statements">
[{
\"relation\": [\"delegate_permission/common.handle_all_urls\"],
\"target\": {
\"namespace\": \"web\",
\"site\": \"https://mygithubusername.github.io\"}
}]