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 APIService : IAPIService | |
{ | |
private readonly Lazy<ILogger> _logger; | |
public APIService() | |
{ | |
_logger = Services.log; | |
} | |
public string UserId { get; private set; } |
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public static class Services | |
{ | |
public static Lazy<ILogger> log = new Lazy<ILogger>(() => | |
{ | |
return new UserIdUnityLogger(api); | |
}); |
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
using System; | |
public class Lazy<T> { | |
public Lazy(Func<T> factory) | |
{ | |
if (factory == null) | |
{ | |
throw new ArgumentNullException("Lazy<T> doesn't accept null factory"); | |
} |
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
using System; | |
public static class Services | |
{ | |
public static IAPIService api { get { return _api.Value; } } | |
public static bool isOffline { get; set; } | |
private static Lazy<IAPIService> _api = new Lazy<IAPIService>(() => isOffline | |
? (IAPIService)new OfflineAPIService() | |
: new APIService()); |
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 APIService { | |
public virtual string UserId { | |
get { | |
return _userId; | |
} | |
} | |
public virtual void Login() | |
{ | |
// send request to server here |
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 static class Services | |
{ | |
public static bool isOffline | |
{ | |
get; set; | |
} | |
} | |
public class APIService | |
{ |
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 static class Services | |
{ | |
public static AdService ads { get; set; } | |
public static APIService api { get; set; } | |
// tons of other services | |
public static AnalyticsService analytics { get; set; } | |
} | |
public class Loader : MonoBehaviour { | |
private void Awake() |
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
using System; | |
public class Logger | |
{ | |
public void Info(string msg) | |
{ | |
Console.WriteLine(msg); | |
} | |
} |
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
using System.Console; | |
public class Test | |
{ | |
public Test() | |
{ | |
Console.WriteLine("Let's test it"); | |
} | |
} |
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
{ | |
"generatedBy": "Microsoft.NET.Sdk.Functions-1.0.0.0", | |
"configurationSource": "attributes", | |
"bindings": [ | |
{ | |
"type": "eventHubTrigger", | |
"path": "default", | |
"connection": "EventHub", | |
"name": "myEventHubMessage" | |
} |