/// <summary> /// Validation /// </summary> /// <returns>true if valid</returns> public bool IsValid() { if (string.IsNullOrWhiteSpace(SubmissionNumber)) { return(false); } if (string.IsNullOrWhiteSpace(UserUuid)) { return(false); } if (string.IsNullOrWhiteSpace(Region)) { return(false); } if (string.IsNullOrWhiteSpace(Platform)) { return(false); } if (string.IsNullOrWhiteSpace(DeviceVerificationPayload)) { return(false); } if (string.IsNullOrWhiteSpace(AppPackageName)) { return(false); } if (Keys.Any(_ => !_.IsValid())) { return(false); } return(true); }
/// <summary> /// Make sure a certain hitsound with a certain sound is in the <see cref="SampleSchema"/>. /// If it already exists, then it simply returns the index and sampleset of that filename. /// </summary> /// <param name="samples">List of <see cref="SampleGeneratingArgs"/> that represents the sound that has to be made.</param> /// <param name="hitsoundName">Name of the hitsound. For example "hitwhistle" or "slidertick".</param> /// <param name="sampleSet">Sample set for the hitsound for if it adds a new sample to the sample schema.</param> /// <param name="newIndex">Index to start searching from. It will start at this value and go up until a slot is available.</param> /// <param name="newSampleSet">The sample set of the added sample.</param> /// <param name="startIndex">The index of the added sample.</param> /// <returns>True if it added a new entry.</returns> public bool AddHitsound(List <SampleGeneratingArgs> samples, string hitsoundName, SampleSet sampleSet, out int newIndex, out SampleSet newSampleSet, int startIndex = 1) { // Check if our sample schema already has a sample for this var filename = FindFilename(samples, "^(normal|soft|drum)-" + hitsoundName); if (filename != null) { newIndex = HitsoundImporter.GetIndexFromFilename(filename); newSampleSet = HitsoundImporter.GetSamplesetFromFilename(filename); return(false); } // Make a new sample with the same sound as all the samples mixed and add it to the sample schema int index = startIndex; newSampleSet = sampleSet; // Find an index which is not taken in the sample schema while (Keys.Any(o => Regex.IsMatch(o, "^(normal|soft|drum)-" + hitsoundName) && HitsoundImporter.GetIndexFromFilename(o) == index && HitsoundImporter.GetSamplesetFromFilename(o) == sampleSet)) { index++; } newIndex = index; filename = $"{sampleSet.ToString().ToLower()}-{hitsoundName}{(index == 1 ? string.Empty : index.ToInvariant())}"; Add(filename, samples); return(true); }
protected override IEnumerable <Location> PerformGetAll(params Guid[] Keys) { //TODO: Fix this - use cache + Dto List <Location> Result = new List <Location>(); IEnumerable <LocationDto> dtoResults; if (Keys.Any()) { foreach (var key in Keys) { Result.Add(Get(key)); } } else { var sql = new Sql(); sql.Select("*").From <LocationDto>(); dtoResults = Repositories.ThisDb.Fetch <LocationDto>(sql).ToList(); var converter = new DtoConverter(); foreach (var result in dtoResults) { Result.Add(converter.ToLocationEntity(result)); } } return(Result); }
/// <summary> /// Sets the base type of this entity type. /// </summary> /// <param name="baseType">The base entity type.</param> /// <returns>Returns itself so that multiple calls can be chained.</returns> public IEntityTypeConfiguration DerivesFrom(IEntityTypeConfiguration baseType) { if (baseType == null) { throw Error.ArgumentNull("baseType"); } if (!baseType.ClrType.IsAssignableFrom(ClrType) || baseType.ClrType == ClrType) { throw Error.InvalidOperation(SRResources.TypeDoesNotInheritFromBaseType, ClrType.FullName, baseType.ClrType.FullName); } if (Keys.Any()) { throw Error.InvalidOperation(SRResources.CannotDefineKeysOnDerivedTypes, FullName, baseType.FullName); } _baseType = baseType; foreach (PropertyConfiguration property in Properties) { ValidatePropertyNotAlreadyDefinedInBaseTypes(property.PropertyInfo); } foreach (PropertyConfiguration property in this.DerivedProperties()) { ValidatePropertyNotAlreadyDefinedInDerivedTypes(property.PropertyInfo); } return(this); }
/// <summary> /// Validation /// </summary> /// <returns>true if valid</returns> public bool IsValid() { if (string.IsNullOrWhiteSpace(VerificationPayload)) { return(false); } if (string.IsNullOrWhiteSpace(UserUuid)) { return(false); } if ((Regions?.Length ?? 0) == 0) { return(false); } if (string.IsNullOrWhiteSpace(Platform)) { return(false); } if (string.IsNullOrWhiteSpace(DeviceVerificationPayload)) { return(false); } if (string.IsNullOrWhiteSpace(AppPackageName)) { return(false); } if (Keys.Any(_ => !_.IsValid())) { return(false); } return(true); }
public bool CheckSecurity(int orgId, string[] keys, Models.Scope scope = Models.Scope.All, int scopeId = 0) { if (Keys.ContainsKey(orgId)) { if (Keys[orgId].Any(a => (a.Key == "Owner" || a.Key == Security.Keys.OrgFullAccess.ToString()) && a.Enabled == true)) { //full access to organization return(true); } foreach (var key in keys) { if (Keys[orgId].Any(a => a.Key == key)) { var orgkeys = Keys[orgId]; if (scope != Models.Scope.All) { //specific scope return(orgkeys.Any(a => a.Key == key && a.Enabled == true && (a.Scope == Models.Scope.All || (a.Scope == scope && a.ScopeId == scopeId)))); } else { //all scopes return(orgkeys.Any(a => a.Key == key && a.Enabled == true)); } } } } //check if user has full access to Kandu application (if all else fails) if (Keys.Any(a => a.Value.Any(b => (b.Key == "AppOwner" || b.Key == "AppFullAccess") && b.Enabled == true))) { return(true); } return(false); }
/// <summary> /// Imports a keyring from a given stream. /// </summary> /// <param name="stream">Stream to import from</param> public void ImportFromStream(Stream stream) { if (ReadOnly) { throw new Exception("Keyring is read-only."); } var countBuffer = new byte[2]; stream.Read(countBuffer, 0, 2); var count = BitConverter.ToInt16(countBuffer, 0); for (int i = 0; i < count; i++) { var lenBuffer = new byte[4]; stream.Read(lenBuffer, 0, 4); var keyLength = BitConverter.ToInt32(lenBuffer, 0); var keyBuffer = new byte[keyLength]; stream.Read(keyBuffer, 0, keyLength); var newKey = KeyDescriptor.Import(keyBuffer, 0); if (Keys.Any(k => k.Name == newKey.Name)) { continue; } Add(newKey.Name, newKey.KeyData); } if (KeyringChanged != null) { KeyringChanged(); } }
public bool Validate() { // Check for non-unique starts if (Keys.Any(k => Keys.Where(k2 => k2.RollingStart == k.RollingStart).Count() > 1)) { return(false); } // Check for a window of keys > 14 days var startEpoch = Keys.OrderBy(k => k.RollingStart).FirstOrDefault().RollingStart; var endEpoch = Keys.Select(k => k.RollingStart + (k.RollingDuration * 10 * 60)) .OrderBy(k => k).LastOrDefault(); if ((TimeSpan.FromSeconds(endEpoch) - TimeSpan.FromSeconds(startEpoch)).TotalDays >= 15) { return(false); } // Check for overlapping time windows foreach (var k in Keys) { if (Keys.Any(k2 => (k2.RollingStart > k.RollingStart && k2.RollingStart < k.RollingEnd) || (k2.RollingEnd > k.RollingStart && k2.RollingEnd < k.RollingEnd))) { return(false); } } return(true); }
public int GetLatestBlockNumber() { if (!Keys.Any()) { return(0); } return(Keys.Select(GetBlockNumber).Max()); }
/// <inheritdoc /> public bool IsKeyOrAlias(string given) { // clean the key var cleanGiven = ValidKey(given); // do any of the keys matches? return(Keys.Any(a => a == cleanGiven)); }
bool Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider.ContainsPrefix(string prefix) { if (IgnoreCase) { prefix = prefix.ToLower(); } return(Keys.Any(t => t == prefix || t.StartsWith(prefix + ".") || t.StartsWith(prefix + "["))); }
public bool AddMetadata(string key, string value) { if (!Keys.Any(x => x.Equals(key))) { return(false); } this[key] = value; return(true); }
private SqlEngineVersion GetVersion() { if (Keys.Any(k => SqlEngineVersions.GetAllVersions <GenericVersion>().Contains(k))) { return(SqlEngineVersions.GetLatestVersionOfDialect <GenericVersion>()); } return(Keys.Last()); }
/// <summary> /// Compares one properties set to another. /// </summary> /// <param name="other">The other.</param> /// <returns></returns> public bool Equals(Properties other) { if (Count != other.Count) { return(false); } return(!(Keys.Any(k => !other.Keys.Contains(k) || !Equals(this[k], other[k])))); }
public void Add(TKey key, TValue value) { if (Keys != null && Keys.Any(k => key.Equals(key))) { throw new System.Exception("Key already exists"); } Keys.Append(key); Values.Append(value); _customDictionaryData.Add(new CustomDictionary <TKey, TValue>(key, value)); }
public void CopyFrom(IDictionary <string, T1> source) { foreach (var kvp in source) { if (Keys.Any(k => k == kvp.Key)) { this[kvp.Key] = kvp.Value; } } }
/// <summary> /// Sets the base type of this entity type. /// </summary> /// <param name="baseType">The base entity type.</param> /// <returns>Returns itself so that multiple calls can be chained.</returns> public virtual EntityTypeConfiguration DerivesFrom(EntityTypeConfiguration baseType) { if ((Keys.Any() || EnumKeys.Any()) && baseType.Keys().Any()) { throw Error.InvalidOperation(SRResources.CannotDefineKeysOnDerivedTypes, FullName, baseType.FullName); } DerivesFromImpl(baseType); return(this); }
public TValue this[string val] { get { if (Keys.Any(x => x.Name == val)) { return(base[Keys.First(x => x.Name == val)]); } return(null); } }
private void ValidateParameters() { if (Keys.Length < 2) { throw new ArgumentException(string.Format(Resources.RestoreSecurityDomainNotEnoughKey, Common.Constants.MinQuorum)); } if (Keys.Any(key => string.IsNullOrEmpty(key.PublicKey) || string.IsNullOrEmpty(key.PrivateKey))) { throw new ArgumentException(Resources.RestoreSecurityDomainBadKey); } }
public bool InRange(int index) { if (index == 0 && !Keys.Any()) { return(true); } var last = Keys.Count() - 1; return(index > 0 || index <= last); }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { bool KeyChecking(Keys x) { return(x == keyData); } var BACK = new Keys[] { Keys.Escape, Keys.Back }; var UP = new Keys[] { Keys.Up, Keys.W }; var DOWN = new Keys[] { Keys.Down, Keys.S }; var LEFT = new Keys[] { Keys.Left, Keys.A }; var RIGHT = new Keys[] { Keys.Right, Keys.D }; if (LEFT.Any(KeyChecking) || RIGHT.Any(KeyChecking)) { Next_Control(RIGHT.Any(KeyChecking), false); return(true); } else if (UP.Any(KeyChecking) || DOWN.Any(KeyChecking)) { Next_Control(DOWN.Any(KeyChecking), true); return(true); } else if (BACK.Any(KeyChecking) && this.Vertical.Parent.Parent != null) { var prevVertOpt = this.Vertical.Parent.Parent.Parent; prevVertOpt.ToggleSubOptionsVisibility(); this.Vertical.Parent.ToggleSubOptionsVisibility(); prevVertOpt.activeSubOption.control.Focus(); return(true); } else { return(base.ProcessCmdKey(ref msg, keyData)); } }
public string[] ToEncodedStrings() { var helper = new StringEncoderHelper(); helper.Add(TypeName); if (Keys.Any()) { helper.Add(Keys); } return(helper.ToArray()); }
public bool Equals(Dictionary <string, IBencodingType> other) { if (other == null) { return(false); } if (other.Count != Count) { return(false); } return(!Keys.Any(key => !other.ContainsKey(key) || !other[key].Equals(this[key]))); }
// find and extract a command line switch public string ExtractKey(params string[] Keys) { for (int i = 0; i < Count; ++i) { if (Keys.Any(k => k == this[i])) { string Result = this[i]; RemoveAt(i); return(Result); } } return(null); }
/// <summary> /// Gets all entities of type TEntity or a list according to the passed in Guid Keys /// </summary> /// <param name="keys">The keys of the entities to be returned</param> /// <returns>A collection of entities</returns> public IEnumerable <TEntity> GetAll(params Guid[] Keys) { if (Keys.Any()) { var entities = new List <TEntity>(); foreach (var key in Keys) { var entity = _cache.GetCacheItem(GetCacheKey(key)); if (entity != null) { entities.Add((TEntity)entity); } } if (entities.Count().Equals(Keys.Count()) && entities.Any(x => x.Equals(default(TEntity))) == false) { return(entities); } } else { var allEntities = _cache.GetCacheItemsByKeySearch(typeof(TEntity).Name + ".").ToArray(); if (allEntities.Any()) { var query = this.GetBaseQuery(true); var totalCount = PerformCount(query); if (allEntities.Count() == totalCount) { return(allEntities.Select(x => (TEntity)x)); } } } var entityCollection = PerformGetAll(Keys).ToArray(); foreach (var entity in entityCollection) { if (!entity.Equals(default(TEntity))) { var en = entity; _cache.GetCacheItem(GetCacheKey(entity.Key), () => en); } } return(entityCollection); }
private void CheckScriptExists(Script script) { var exists = Keys.Any((k) => k.MatchPublicKey(script)); if (exists) { return; } while (!exists) { this.GenerateNextWalletKey(); exists = Keys.Any((k) => k.MatchPublicKey(script)); } }
private static void CheckRequiredParameters(IDictionary <OmaParameter, string> parameters, side side) { OmaParameter[][] requirements = new[] { new[] { OmaParameter.LNAM, OmaParameter.LDNAM }, new[] { OmaParameter.SPH }, new[] { OmaParameter.LIND }, /*new[] { OmaParameter.BLKD },*/ new[] { OmaParameter.CRIB } }; requirements.Where(Keys => !Keys.Any(Key => parameters.ContainsKey(Key))).ToList().ForEach( Keys => { throw new OmaException("Missing Required Parameter: " + string.Join(",", Keys), null, side, OmaStatusCode.MissingRequiredParameter); }); }
public void Delete() { if (Keys.Any(n => n.GetValue(this, null) == null)) { throw new ArgumentNullException(); } _command.CommandText = String.Format("DELETE FROM {0} WHERE {1}", GetType().Name, String.Join(" AND ", Keys.Select(n => string.Format("{0} = @{0}", n.Name)))); foreach (var i in Keys) { _command.Parameters.AddWithValue(i.Name, i.GetValue(this, null).ToString()); } Connection.Open(); _command.ExecuteNonQuery(); Connection.Close(); }
public void RemoveItemAtKey(TKey key, uint?binaryHashOfKey = null) { int index = GetKeyIndex(key, binaryHashOfKey); if (index == -1) { throw new Exception("Must confirm key exists before deleting value at key."); } Values.RemoveAt(index); Keys.RemoveAt(index); _lastSearchRemembered = false; if (!Keys.Any()) { Keys = null; Values = null; Initialized = false; } }
public string WriteDefaultLine(bool terminate, int fieldNum) { List <string> options = new List <string>(); if (!string.IsNullOrWhiteSpace(Units)) { options.Add($"{{{Units}}}"); } if (HasDefault) { options.Add($"Def: {Default}"); } if (Keys.Any()) { options.Add($"[{string.Join(", ", Keys)}]"); } if (ReferenceList.Any()) { options.Add($"RefList: [{string.Join(", ", ReferenceList)}]"); } if (ReferenceClassList.Any()) { options.Add($"RefClassList: [{string.Join(", ", ReferenceClassList)}]"); } if (ObjectList.Any()) { options.Add($"[{string.Join(", ", ObjectList)}]"); } if (AutoCalculatable) { options.Add("AC"); } if (AutoSizeable) { options.Add("AS"); } if (Required) { options.Add("REQ"); } options.Add($"#{fieldNum}"); return($" {(HasDefault ? Default : "")}{(terminate ? ";" : ",")} ! {Name} {string.Join(", ", options)}\n"); }
public static Boolean HasMovement(Keys[] keys) { return keys.Any(k => IsMovement(k)); }