public ConfigurationImpl() { persistenceDriver = new CompositePersistenceDriver(new RAMPersistenceDriver(), new List <IPersistenceDriver>()); permissionsManager = new PermissionsManagerImpl(); persistenceDriver.ReadOnlyPersistenceDrivers.Add(new EmbbedXMLDocumentPersistenceDriver()); }// END Constructor
public DroidImagePickerService( IPermissionsManager permissionsManager, IContextProvider contextProvider) { _permissionsManager = permissionsManager; _contextProvider = contextProvider; }
/// <summary> /// Initializes a new instance of the <see cref="ItemsManager"/> class. /// </summary> public ItemsManager() { this.roleController = RoleController.Instance; this.fileManager = FileManager.Instance; this.assetManager = AssetManager.Instance; this.permissionsManager = PermissionsManager.Instance; }
public AuthorizeTagHelper( IAuthorizationService authorizationService, IPermissionsManager <Permission> permissionManager) { _authorizationService = authorizationService; _permissionManager = permissionManager; }
public PermissionsPageViewModel(IPermissionsManager permissionsManager) { Photos = new PermissionViewModel <PhotosPermission>(permissionsManager); Camera = new PermissionViewModel <CameraPermission>(permissionsManager); Storage = new PermissionViewModel <StoragePermission>(permissionsManager); LocationInUse = new PermissionViewModel <LocationWhenInUsePermission>(permissionsManager); LocationAlways = new PermissionViewModel <LocationAlwaysPermission>(permissionsManager); }
public GetOrderByIdQueryHandler(IDbContext context, IOrdersDomainService ordersDomainService, IPermissionsManager permissionsManager) { _context = context; _ordersDomainService = ordersDomainService; _permissionsManager = permissionsManager; }
public ModeratorPermissionsHandler( IPermissionsManager <ModeratorPermission> permissionsManager, IModeratorStore <Moderator> moderatorStore, IPlatoUserStore <User> userStore, IContextFacade contextFacade) { _permissionsManager = permissionsManager; _moderatorStore = moderatorStore; _contextFacade = contextFacade; _userStore = userStore; }
public AdminViewProvider( UserManager <User> userManager, IPlatoRoleStore platoRoleStore, RoleManager <Role> roleManager, IPermissionsManager <Permission> permissionsManager, IAuthorizationService authorizationService, IDummyClaimsPrincipalFactory <User> claimsPrincipalFactory) { _userManager = userManager; _platoRoleStore = platoRoleStore; _roleManager = roleManager; _permissionsManager = permissionsManager; _authorizationService = authorizationService; _claimsPrincipalFactory = claimsPrincipalFactory; }
public AdminViewProvider( IStringLocalizer <AdminViewProvider> stringLocalizer, IPermissionsManager <ModeratorPermission> permissionsManager, IAuthorizationService authorizationService, IHttpContextAccessor httpContextAccessor, IModeratorStore <Moderator> moderatorStore, IPlatoUserStore <User> userStore) { _request = httpContextAccessor.HttpContext.Request; _permissionsManager = permissionsManager; _authorizationService = authorizationService; _moderatorStore = moderatorStore; _userStore = userStore; T = stringLocalizer; }
public PaymentTermController(IPermissionsManager permissionsManager, IPaymentTermQueryService paymentTermQueryService, IPaymentTermCommandService PaymentTermCommandServic, IInvoiceQueryService InvoiceQueryService, IContactsQueryService contactsQueryService, ICashbookSettings cashbookSettings, ICashbookQueryService cashbookQueryService, ICompanyQueryService companyQueryService) { _permissionsManager = permissionsManager; _paymentTermQueryService = paymentTermQueryService; _paymentTermCommandService = PaymentTermCommandServic; _invoiceQueryService = InvoiceQueryService; _contactsQueryService = contactsQueryService; _cashbookSettings = cashbookSettings; _cashbookQueryService = cashbookQueryService; _companyQueryService = companyQueryService; }
public static T New <T>(string name, IStore store = null, IResource parent = null, IPermissionsManager manager = null) { var res = Activator.CreateInstance(typeof(T)) as IResource; Put(res, name, store, parent, null, 0, manager); return((T)res); }
//public static async AsyncReply<T> Push<T>(string path, T resource) where T : IResource //{ // await Put(path, resource); // return resource; //} /// <summary> /// Put a resource in the warehouse. /// </summary> /// <param name="name">Resource name.</param> /// <param name="resource">Resource instance.</param> /// <param name="store">IStore that manages the resource. Can be null if the resource is a store.</param> /// <param name="parent">Parent resource. if not presented the store becomes the parent for the resource.</param> public static async AsyncReply <T> Put <T>(string name, T resource, IStore store = null, IResource parent = null, TypeTemplate customTemplate = null, ulong age = 0, IPermissionsManager manager = null, object attributes = null) where T : IResource { if (resource.Instance != null) { throw new Exception("Resource has a store."); } var path = name.TrimStart('/').Split('/'); if (path.Length > 1) { if (parent != null) { throw new Exception("Parent can't be set when using path in instance name"); } parent = await Warehouse.Get <IResource>(string.Join("/", path.Take(path.Length - 1))); if (parent == null) { throw new Exception("Can't find parent"); } store = store ?? parent.Instance.Store; } var instanceName = path.Last(); var resourceReference = new WeakReference <IResource>(resource); if (store == null) { // assign parent's store as a store if (parent != null) { // assign parent as a store if (parent is IStore) { store = (IStore)parent; List <WeakReference <IResource> > list; if (stores.TryGetValue(store, out list)) { lock (((ICollection)list).SyncRoot) list.Add(resourceReference); } //stores[store].Add(resourceReference); } else { store = parent.Instance.Store; List <WeakReference <IResource> > list; if (stores.TryGetValue(store, out list)) { lock (((ICollection)list).SyncRoot) list.Add(resourceReference); } } } // assign self as a store (root store) else if (resource is IStore) { store = (IStore)resource; } else { throw new Exception("Can't find a store for the resource."); } } resource.Instance = new Instance(resourceCounter++, instanceName, resource, store, customTemplate, age); if (attributes != null) { resource.Instance.SetAttributes(Map <string, object> .FromObject(attributes)); } if (manager != null) { resource.Instance.Managers.Add(manager); } if (store == parent) { parent = null; } try { if (resource is IStore) { stores.TryAdd(resource as IStore, new List <WeakReference <IResource> >()); } if (!await store.Put(resource)) { throw new Exception("Store failed to put the resource"); } //return default(T); if (parent != null) { await parent.Instance.Store.AddChild(parent, resource); await store.AddParent(resource, parent); } var t = resource.GetType(); Global.Counters["T-" + t.Namespace + "." + t.Name]++; resources.TryAdd(resource.Instance.Id, resourceReference); if (warehouseIsOpen) { await resource.Trigger(ResourceTrigger.Initialize); if (resource is IStore) { await resource.Trigger(ResourceTrigger.Open); } } if (resource is IStore) { StoreConnected?.Invoke(resource as IStore); } } catch (Exception ex) { Warehouse.Remove(resource); throw ex; } return(resource); }
/// <summary> /// Get a resource by its path. /// Resource path is sperated by '/' character, e.g. "system/http". /// </summary> /// <param name="path"></param> /// <returns>Resource instance.</returns> public static async AsyncReply <T> Get <T>(string path, object attributes = null, IResource parent = null, IPermissionsManager manager = null) where T : IResource { //var rt = new AsyncReply<IResource>(); // Should we create a new store ? if (urlRegex.IsMatch(path)) { var url = urlRegex.Split(path); if (Protocols.ContainsKey(url[1])) { if (!warehouseIsOpen) { await Open(); } var handler = Protocols[url[1]]; var store = await handler(url[2], attributes); try { //await Put(store, url[2], null, parent, null, 0, manager, attributes); if (url[3].Length > 0 && url[3] != "") { return((T)await store.Get(url[3])); } else { return((T)store); } } catch (Exception ex) { Warehouse.Remove(store); throw ex; } } // store.Get(url[3]).Then(r => // { // rt.Trigger(r); // }).Error(e => // { // Warehouse.Remove(store); // rt.TriggerError(e); // }); // else // rt.Trigger(store); // store.Trigger(ResourceTrigger.Open).Then(x => // { // warehouseIsOpen = true; // await Put(store, url[2], null, parent, null, 0, manager, attributes); // if (url[3].Length > 0 && url[3] != "") // store.Get(url[3]).Then(r => // { // rt.Trigger(r); // }).Error(e => // { // Warehouse.Remove(store); // rt.TriggerError(e); // }); // else // rt.Trigger(store); // }).Error(e => // { // rt.TriggerError(e); // //Warehouse.Remove(store); // }); // return rt; //} } //await Query(path).Then(rs => //{ // // rt.TriggerError(new Exception()); // if (rs != null && rs.Length > 0) // rt.Trigger(rs.First()); // else // rt.Trigger(null); //}); //return rt; var res = await Query(path); if (res.Length == 0) { return(default(T)); } else { return((T)res.First()); } }
public PermissionViewModel(IPermissionsManager permissionsManager) { _permissionsManager = permissionsManager; RequestPermissionCommand = new AsyncCommand(RequestPermission); }
public PermissionsPageViewModel(IPermissionsManager permissionsManager) { CheckAllCommand = new AsyncCommand <EventArgs>(CheckAll); Photos = new PermissionViewModel <PhotosPermission>(permissionsManager); }
public PermissionsViewModel(INavigationManager <PageIndex> navigationManager, IPermissionsManager permissionsManager) { _navigationManager = navigationManager; _permissionsManager = permissionsManager; }
public static async AsyncReply <IResource> New(Type type, string name = null, IStore store = null, IResource parent = null, IPermissionsManager manager = null, object attributes = null, object properties = null) { type = ResourceProxy.GetProxy(type); /* * if (arguments != null) * { * var constructors = type.GetConstructors(System.Reflection.BindingFlags.Public); * * foreach(var constructor in constructors) * { * var pi = constructor.GetParameters(); * if (pi.Length == constructor.le) * } * * // cast arguments * ParameterInfo[] pi = fi.GetParameters(); * * object[] args = new object[pi.Length]; * * for (var i = 0; i < pi.Length; i++) * { * if (pi[i].ParameterType == typeof(DistributedConnection)) * { * args[i] = this; * } * else if (namedArgs.ContainsKey(pi[i].Name)) * { * args[i] = DC.CastConvert(namedArgs[pi[i].Name], pi[i].ParameterType); * } * } * * constructors[0]. * } */ var res = Activator.CreateInstance(type) as IResource; if (properties != null) { var ps = Map <string, object> .FromObject(properties); foreach (var p in ps) { var pi = type.GetProperty(p.Key, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); if (pi != null) { if (pi.CanWrite) { try { pi.SetValue(res, p.Value); } catch (Exception ex) { Global.Log(ex); } } } else { var fi = type.GetField(p.Key, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); if (fi != null) { try { fi.SetValue(res, p.Value); } catch (Exception ex) { Global.Log(ex); } } } } } if (store != null || parent != null || res is IStore) { //if (!await Put(name, res, store, parent, null, 0, manager, attributes)) // return null; await Put(name, res, store, parent, null, 0, manager, attributes); } return(res); }
public static async AsyncReply <T> New <T>(string name, IStore store = null, IResource parent = null, IPermissionsManager manager = null, object attributes = null, object properties = null) where T : IResource { return((T)(await New(typeof(T), name, store, parent, manager, attributes, properties))); }
public virtual void Init() { _pm = new PermissionsManager <FakeSubject, FakeObject, Role>(); }
/// <summary> /// Initializes a new instance of the <see cref="SearchController"/> class. /// </summary> public SearchController() { this.permissionsManager = PermissionsManager.Instance; }
/// <summary> /// Put a resource in the warehouse. /// </summary> /// <param name="resource">Resource instance.</param> /// <param name="name">Resource name.</param> /// <param name="store">IStore that manages the resource. Can be null if the resource is a store.</param> /// <param name="parent">Parent resource. if not presented the store becomes the parent for the resource.</param> public static void Put(IResource resource, string name, IStore store = null, IResource parent = null, ResourceTemplate customTemplate = null, ulong age = 0, IPermissionsManager manager = null) { resource.Instance = new Instance(resourceCounter++, name, resource, store, customTemplate, age); if (manager != null) { resource.Instance.Managers.Add(manager); } if (store == parent) { parent = null; } if (parent == null) { if (!(resource is IStore)) { store.Instance.Children.Add(resource); } } else { parent.Instance.Children.Add(resource); } if (resource is IStore) { stores.Add(resource as IStore); StoreConnected?.Invoke(resource as IStore, name); } else { store.Put(resource); } resources.Add(resource.Instance.Id, resource); if (!storeIsOpen) { resource.Trigger(ResourceTrigger.Initialize); } }