namespace zero.Core.Api { public class AppScope : IAppScope where T : IAppAwareBackofficeApi { T Api; IApplicationContext AppContext; public AppScope(T api, IApplicationContext appContext) { Api = api; AppContext = appContext; } /// public T Current { get { Api.Scope.AppId = AppContext.AppId; Api.Scope.Global = false; return Api; } } /// public T Global { get { Api.Scope.AppId = null; Api.Scope.Global = true; return Api; } } /// public T Shared { get { Api.Scope.AppId = Constants.Database.SharedAppId; Api.Scope.Global = false; return Api; } } /// public T App(string id) { Api.Scope.AppId = id; Api.Scope.Global = false; return Api; } } public interface IAppScope where T : IAppAwareBackofficeApi { /// /// Get Api with automatically resolved application /// T Current { get; } /// /// Get Api which has its scoped set to all applications (including shared) /// T Global { get; } /// /// Get Api with scope set to only shared entities /// T Shared { get; } /// /// Get Api with scope set to the requested app id /// T App(string id); } }