Last active
April 27, 2022 15:30
-
-
Save mattbrailsford/2d2e041a314c4c7a50d62d4693c47c7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UmbracoSurfaceControllerDependencies | |
{ | |
#if NET | |
public IUmbracoContextAccessor UmbracoContextAccessor { get; set; } | |
public IUmbracoDatabaseFactory DatabaseFactory { get; set; } | |
public ServiceContext Services { get; set; } | |
public AppCaches AppCaches { get; set; } | |
public IProfilingLogger ProfilingLogger { get; set; } | |
public IPublishedUrlProvider PublishedUrlProvider { get; set; } | |
public UmbracoSurfaceControllerDependencies(IUmbracoContextAccessor umbracoContextAccessor, | |
IUmbracoDatabaseFactory databaseFactory, | |
ServiceContext services, | |
AppCaches appCaches, | |
IProfilingLogger profilingLogger, | |
IPublishedUrlProvider publishedUrlProvider) | |
{ | |
UmbracoContextAccessor = umbracoContextAccessor; | |
DatabaseFactory = databaseFactory; | |
Services = services; | |
AppCaches = appCaches; | |
ProfilingLogger = profilingLogger; | |
PublishedUrlProvider = publishedUrlProvider; | |
} | |
#else | |
// v8 Doesn't actually need deps so it can just be blank | |
// but if it did, you'd define the props + constructor for those | |
// dependencies in the same way as above | |
// | |
// public SomeType1 Dependency1 { get; set; } | |
// public SomeType2 Dependency2 { get; set; } | |
// | |
// public UmbracoSurfaceControllerDependencies(SomeType1 dep1, SomeType2 dep2) | |
// { | |
// Dependency1 = dep2; | |
// Dependency2 = dep2; | |
// } | |
#endif | |
} | |
public abstract class PolyfillSurfaceController : SurfaceController | |
{ | |
public AltSurfaceController(UmbracoSurfaceControllerDependencies deps) | |
#if NET | |
: base(deps.UmbracoContextAccessor, deps.DatabaseFactory, deps.Services, deps.AppCaches, deps.PprofilingLogger, deps.PublishedUrlProvider) | |
#else | |
// v8 doesnt have deps, but if it did, you call the base constructore passing the v8 deps from | |
// the deps object in the same was as the .NET Core base constructor | |
// : base(deps.Dependency1, deps.Dependency2) | |
#endif | |
{ | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Surface controllers in v8 and v9 would then become just as follows | |
public class MySurfaceController : PolyfillSurfaceController | |
{ | |
public MySurfaceController(UmbracoSurfaceControllerDependencies deps) | |
: base(deps) | |
{ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment