public ICommandResult Handle(CreateAccessKeyCommand command) { command.Validate(); if (Invalid) { return(new GenericCommandResult(false, "Admin inválido", command.Notifications)); } var admin = _adminRepository.GetAdmin(command.Admin); if (admin == null) { return(new GenericCommandResult(false, "Admin inválido", command.Notifications)); } var key = new KeyAccess(); key.GenerateKeyAccess(); key.ValidateKey(); _keyAccessRepository.Create(key); return(new GenericCommandResult(true, "Chave gerada com sucesso", key)); }
public Download this[string key, KeyAccess access] { get { try { Lock(); switch (access) { case KeyAccess.FileHash: return(m_DownloadID[m_FileHash[key]]); case KeyAccess.OnceHashedFileHash: return(m_DownloadID[m_OnceHashedFileHash[key]]); case KeyAccess.TwiceHashedFileHash: return(m_DownloadID[m_TwiceHashedFileHash[key]]); case KeyAccess.ThriceHashedFileHash: return(m_DownloadID[m_ThriceHashedFileHash[key]]); default: return(m_DownloadID[key]); } } finally { Unlock(); } } set { throw new NotSupportedException(); } }
public bool ContainsKey(string key, KeyAccess access) { try { Lock(); switch (access) { case KeyAccess.FileHash: return(m_FileHash.ContainsKey(key)); case KeyAccess.OnceHashedFileHash: return(m_OnceHashedFileHash.ContainsKey(key)); case KeyAccess.TwiceHashedFileHash: return(m_TwiceHashedFileHash.ContainsKey(key)); case KeyAccess.ThriceHashedFileHash: return(m_ThriceHashedFileHash.ContainsKey(key)); default: return(m_DownloadID.ContainsKey(key)); } } finally { Unlock(); } }
public static extern int RegOpenKeyEx ( UIntPtr hkey, String lpSubKey, uint ulOptions, KeyAccess samDesired, ref UIntPtr phkResult );
public static extern int RegCreateKeyEx ( UIntPtr hkey, String lpSubKey, uint Reserved, StringBuilder lpClass, uint dwOptions, KeyAccess samDesired, IntPtr lpSecurityAttributes, ref UIntPtr phkResult, ref uint lpdwDisposition );
public object GetValue(object target) { var type = target.GetType(); object value = null; if (KeyAccess.HasAccessFor(type)) { var key = KeyAccess.GetId(target, type); var metadata = MetadataProvider.GetMetadata(key); value = Getter(metadata); } return(value); }
public void SetValue(object target, object value) { var type = target.GetType(); if (!KeyAccess.HasAccessFor(type)) { return; } var key = KeyAccess.GetId(target, type); var metadata = MetadataProvider.GetMetadata(key); Setter(metadata, value); }
public bool TryGetValue(string key, KeyAccess access, out Download download) { try { Lock(); string downloadID; switch (access) { case KeyAccess.FileHash: if (m_FileHash.TryGetValue(key, out downloadID)) { return(m_DownloadID.TryGetValue(downloadID, out download)); } download = null; return(false); case KeyAccess.OnceHashedFileHash: if (m_OnceHashedFileHash.TryGetValue(key, out downloadID)) { return(m_DownloadID.TryGetValue(downloadID, out download)); } download = null; return(false); case KeyAccess.TwiceHashedFileHash: if (m_TwiceHashedFileHash.TryGetValue(key, out downloadID)) { return(m_DownloadID.TryGetValue(downloadID, out download)); } download = null; return(false); case KeyAccess.ThriceHashedFileHash: if (m_ThriceHashedFileHash.TryGetValue(key, out downloadID)) { return(m_DownloadID.TryGetValue(downloadID, out download)); } download = null; return(false); default: return(m_DownloadID.TryGetValue(key, out download)); } } finally { Unlock(); } }
public int IndexOfKey(string key, KeyAccess access) { try { Lock(); string downloadID; switch (access) { case KeyAccess.FileHash: if (m_FileHash.TryGetValue(key, out downloadID)) { return(m_DownloadID.IndexOfKey(downloadID)); } return(-1); case KeyAccess.OnceHashedFileHash: if (m_OnceHashedFileHash.TryGetValue(key, out downloadID)) { return(m_DownloadID.IndexOfKey(downloadID)); } return(-1); case KeyAccess.TwiceHashedFileHash: if (m_TwiceHashedFileHash.TryGetValue(key, out downloadID)) { return(m_DownloadID.IndexOfKey(downloadID)); } return(-1); case KeyAccess.ThriceHashedFileHash: if (m_ThriceHashedFileHash.TryGetValue(key, out downloadID)) { return(m_DownloadID.IndexOfKey(downloadID)); } return(-1); default: return(m_DownloadID.IndexOfKey(key)); } } finally { Unlock(); } }
public SharedFile this[string key, KeyAccess access] { get { try { Lock(); switch (access) { case KeyAccess.OnceHashedFileHash: return(m_FileHash[m_OnceHashedFileHash[key]]); case KeyAccess.TwiceHashedFileHash: return(m_FileHash[m_TwiceHashedFileHash[key]]); case KeyAccess.ThriceHashedFileHash: return(m_FileHash[m_ThriceHashedFileHash[key]]); default: return(m_FileHash[key]); } } finally { Unlock(); } } set { try { Lock(); if (access != KeyAccess.FileHash) { throw new NotSupportedException(); } m_FileHash[key] = value; } finally { Unlock(); } } }
public bool TryGetValue(string key, KeyAccess access, out SharedFile sharedFile) { try { Lock(); string fileHash; switch (access) { case KeyAccess.OnceHashedFileHash: if (m_OnceHashedFileHash.TryGetValue(key, out fileHash)) { return(m_FileHash.TryGetValue(fileHash, out sharedFile)); } sharedFile = null; return(false); case KeyAccess.TwiceHashedFileHash: if (m_TwiceHashedFileHash.TryGetValue(key, out fileHash)) { return(m_FileHash.TryGetValue(fileHash, out sharedFile)); } sharedFile = null; return(false); case KeyAccess.ThriceHashedFileHash: if (m_ThriceHashedFileHash.TryGetValue(key, out fileHash)) { return(m_FileHash.TryGetValue(fileHash, out sharedFile)); } sharedFile = null; return(false); default: return(m_FileHash.TryGetValue(key, out sharedFile)); } } finally { Unlock(); } }
public static extern int RegOpenKeyEx ( UIntPtr hkey, String lpSubKey, uint ulOptions, KeyAccess samDesired, ref UIntPtr phkResult );
public static extern int RegCreateKeyEx ( UIntPtr hkey, String lpSubKey, uint Reserved, StringBuilder lpClass, uint dwOptions, KeyAccess samDesired, IntPtr lpSecurityAttributes, ref UIntPtr phkResult, ref uint lpdwDisposition );
public void Update(KeyAccess keyAccess) { _context.Entry(keyAccess).State = EntityState.Modified; _context.SaveChanges(); }
public void Create(KeyAccess keyAccess) { _context.KeyAccess.Add(keyAccess); _context.SaveChanges(); }
public void AddKeyAccess(KeyAccess keyAccess) { KeyAccess = keyAccess; KeyAccess.HasUser(); }