public override async Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, ParameterInfo parameter, object value, IServiceProvider services) { if (Type != null) { if (!Type.IsAssignableFrom(parameter.Type)) { return(PreconditionResult.FromError($"{GetType().Name} can only be used on {Type.Name} parameters. Not {parameter.Type}.")); } } else { if (!Types.Any(test => test.IsAssignableFrom(parameter.Type))) { return(PreconditionResult.FromError($"{GetType().Name} can only be used on set types. {parameter.Type} is not one of them.")); } } Value = value; Context = context; ParameterInfo = parameter; Services = services; if (value != null) { Player player = ChatCraft.Instance.GetPlayer(context.User); if (MeetsCondition(player, value)) { return(PreconditionResult.FromSuccess()); } } return(PreconditionResult.FromError(GetError())); }
public virtual NameValueCollection ToNameValueCollection() { if (Start.HasValue) { Nv.Add("start", Start.Value.ToIso8601()); } if (End.HasValue) { Nv.Add("end", End.Value.ToIso8601()); } if (Tags != null && Tags.Any()) { Nv.Add("tags", string.Join(",", Tags)); } if (Mailboxes != null && Mailboxes.Any()) { Nv.Add("mailboxes", string.Join(",", Mailboxes)); } if (Types != null && Types.Any()) { Nv.Add("folders", string.Join(",", Types)); } if (Folders != null && Folders.Any()) { Nv.Add("types", string.Join(",", Folders)); } return(Nv); }
public bool HasType(Type pluginType) { if (pluginType == null) { throw new ArgumentNullException(nameof(pluginType)); } return(Types.Any(pt => pt == pluginType)); }
internal override Uri ToUri() { ValidateRequest(); var qsb = new Internal.QueryStringBuilder(); qsb.Append("query", Uri.EscapeDataString(Query.ToLowerInvariant())) .Append("sensor", (Sensor.Value.ToString().ToLowerInvariant())); if (Location != null) { qsb.Append("location", Location.GetAsUrlParameter()); } if (Radius.HasValue) { qsb.Append("radius", Radius.Value.ToString()); } if (!string.IsNullOrEmpty(Language)) { qsb.Append("language", Language.ToLowerInvariant()); } if (Minprice.HasValue) { qsb.Append("minprice", Minprice.Value.ToString()); } if (Maxprice.HasValue) { qsb.Append("maxprice", Maxprice.Value.ToString()); } if (OpenNow.HasValue) { qsb.Append("opennow", OpenNow.Value.ToString().ToLowerInvariant()); } if (!string.IsNullOrEmpty(PageToken)) { qsb.Append("pagetoken", PageToken); } if ((Types != null && Types.Any())) { qsb.Append("types", TypesToUri()); } if (ZagatSelected) { qsb.Append("zagatselected"); } var url = "textsearch/json?" + qsb.ToString(); return(new Uri(url, UriKind.Relative)); }
internal override Uri ToUri() { ValidateRequest(); var qsb = new Internal.QueryStringBuilder(); qsb.Append("input", Input.ToLowerInvariant()) .Append("sensor", (Sensor.Value.ToString().ToLowerInvariant())) .Append("key", Licencekey.ToString()); if (Offset > 0) { qsb.Append("offset", Offset.ToString()); } if (Location != null) { qsb.Append("location", Location.GetAsUrlParameter()); } if (Radius.HasValue) { qsb.Append("radius", (Radius.Value.ToString().ToLowerInvariant())); } if (!string.IsNullOrEmpty(Language)) { qsb.Append("language", Language.ToLowerInvariant()); } if ((Types != null && Types.Any())) { qsb.Append("types", TypesToUri()); } if (!string.IsNullOrEmpty(Components)) { qsb.Append(string.Format("components=country:{0}", Components.ToLowerInvariant())); } if (CitysOnly & !Regions) { qsb.Append("types", "(cities)"); } if (Regions & !CitysOnly) { qsb.Append("types", "(regions)"); } var url = "autocomplete/json?" + qsb.ToString(); var returnUrl = new Uri(url, UriKind.Relative).ToString(); return(new Uri(url, UriKind.Relative)); }
public void InitializeArrayVariable(DataType dataType, string name, int length) { if (!(dataType is RefType type)) { throw new ArgumentException($"{nameof(dataType)} needs to be a reference type"); } if (!DataTypes.Types[DataTypes.arrayTypes].Any(x => x.Name == dataType.Name)) { throw new InvalidOperationException($"{dataType.Name} is in an array type."); } if (!Types.Any(x => x.Name == type.Name)) { throw new InvalidOperationException($"{dataType.Name} is not in the list of available types."); } if (Variables.Any(x => x.Name == name)) { throw new InvalidOperationException($"Variable with name {name} already exists"); } var variable = new Variable { Name = name, Type = dataType, Value = NextAvailableHeap.ToString() }; var valueType = GetValueTypeFromArray(dataType.Name); for (int i = 0; i < length; i++) { var variableOnHeap = new Variable { Name = $"{name}[{i}]", Type = valueType, Value = valueType.Defaultvalue, Parent = variable }; variable.Variables.Add(variableOnHeap); Ram.SetVariable(NextAvailableHeap, variableOnHeap); NextAvailableHeap++; } Ram.SetVariable(NextAvailableStack, variable); Variables.Add(variable); NextAvailableStack++; SourceCode.Add($"{dataType.Name} {name} = new {valueType.Name}[{length}];"); }
public override string ToString() { var sb = new StringBuilder(); sb.AppendLine("AutoDI Settings:"); sb.AppendLine($" Behavior(s): {Behavior}"); sb.AppendLine($" AutoInit: {AutoInit}"); sb.AppendLine($" GenerateRegistrations: {GenerateRegistrations}"); sb.AppendLine($" DebugLogLevel: {DebugLogLevel}"); sb.AppendLine($" DebugExceptions: {DebugExceptions}"); sb.Append(" Included Assemblies: "); if (Assemblies.Any()) { sb.AppendLine(); foreach (MatchAssembly assembly in Assemblies) { sb.AppendLine($" {assembly}"); } } else { sb.AppendLine("<none>"); } sb.Append(" Maps: "); if (Maps.Any()) { sb.AppendLine(); foreach (Map map in Maps) { sb.AppendLine($" {map}"); } } else { sb.AppendLine("<none>"); } sb.Append(" Type Lifetimes: "); if (Types.Any()) { sb.AppendLine(); foreach (MatchType type in Types) { sb.AppendLine($" {type}"); } } else { sb.AppendLine("<none>"); } return(sb.ToString()); }
protected override GpsVerType Parse(PropertyItem pi) { if (Types.Any(x => CheckLength(pi.Value.Length, x, Length))) { var value = ReadBytes(pi.Value); return(new GpsVerType { First = value[0], Second = value[1], Third = value[2], Fourth = value[3] }); } else { return(default);
/// <summary> /// Получить экземпляр по типу. /// </summary> /// <typeparam name="T">Тип клиента.</typeparam> /// <returns>Экземпляр клиента.</returns> public T GetInstance <T>() where T : ClientBase <T> { var clientType = typeof(T); if (Types.Any(x => x == clientType)) { return((T)ServiceProvider.GetService(clientType)); } return(null); }
public void InitializeCustumTypeVariable(RefType customType, string name) { if (!(customType is RefType type)) { throw new ArgumentException($"{nameof(customType)} needs to be a reference type"); } if (!DataTypes.Types[DataTypes.customTypes].Any(x => x.Name == customType.Name)) { throw new InvalidOperationException($"{customType.Name} is in an array type."); } if (!Types.Any(x => x.Name == type.Name)) { throw new InvalidOperationException($"{customType.Name} is not in the list of available types."); } if (Variables.Any(x => x.Name == name)) { throw new InvalidOperationException($"Variable with name {name} already exists"); } var variable = new Variable { Name = name, Type = customType, Value = NextAvailableHeap.ToString() }; foreach (var property in customType.Properties) { var variableOnHeap = new Variable { Name = $"{name}.{property.Name}", Type = property.Type, Value = property.Type.Defaultvalue, Parent = variable }; variable.Variables.Add(variableOnHeap); Ram.SetVariable(NextAvailableHeap, variableOnHeap); NextAvailableHeap++; } Ram.SetVariable(NextAvailableStack, variable); Variables.Add(variable); NextAvailableStack++; SourceCode.Add($"{customType.Name} {name} = new {customType.Name}();"); }
private ValidationResult validateValue(object item, ValidationContext context) { if (IsOpen == false && item != null) { if (!Types.Any(type => type.GetTypeInfo().IsAssignableFrom(item.GetType().GetTypeInfo()))) { return(DotNetAttributeValidation.BuildResult(context, "Value is of type {0}, which is not an allowed choice", item.GetType())); } } return(ValidationResult.Success); }
public bool IsShield(ShipInfo ship) { lock (Types) if (Types.Any(_ => _.ID == ship.ShipCargoType)) { return(true); } lock (Ships) if (Ships.Any(_ => _.ID == ship.MMSI)) { return(true); } return(false); }
/// <summary> /// Write Source /// </summary> /// <param name="writer"></param> internal override void WriteSource(System.IO.StreamWriter writer, TsGeneratorOptions options, TsWriteInformation info) { //write base stuff base.WriteSource(writer, options.Clone(options.IndentString, false), info); //sec check if (info.ForType != TsElementTypes.Class) { throw new Exception("TsCodeMemberProperty can only be defined for class"); } if (!Types.Any()) { throw new Exception("TsCodeMemberProperty type not defined"); } //prepare source var source = options.GetPreLineIndentString(info.Depth); //add attributres if (Attributes != TsMemberAttributes.None) { source += TsMemberAttributeMappings.TypeMappings[Attributes] + TsDomConstants.ATTRIBUTE_SEPEARATOR; } //if there is no setter and getter this is a bit useless if (!HasSet && !HasGet) { throw new Exception("TsCodeMemberProperty there is no setter and getter for MemberProperty" + Name); } //if we have a getter write getter if (HasGet) { var getSource = source + string.Format(TsDomConstants.GETTER_FORMAT, Name, GetTypeSource()) + TsDomConstants.STATEMENT_BRACKET_BEGIN; //write begin line writer.WriteLine(getSource); //write statemetns GetStatements.ToList().ForEach(el => el.WriteSource(writer, options, info.Clone(info.Depth + 1))); //write end source writer.WriteLine(GetStatementEnd(options, info.Depth)); } //as setter if (HasSet) { var setSource = source + string.Format(TsDomConstants.SETTER_FORMAT, Name, SetParameterName, GetTypeSource()) + TsDomConstants.STATEMENT_BRACKET_BEGIN; //write begin line writer.WriteLine(setSource); //write statemetns SetStatements.ToList().ForEach(el => el.WriteSource(writer, options, info.Clone(info.Depth + 1))); //write end source writer.WriteLine(GetStatementEnd(options, info.Depth)); } }
internal override Uri ToUri() { ValidateRequest(); var qsb = new Internal.QueryStringBuilder(); qsb.Append("location", Location.GetAsUrlParameter()) .Append("sensor", (Sensor.Value.ToString().ToLowerInvariant())) .Append("radius", (Radius.Value.ToString().ToLowerInvariant())); if (!string.IsNullOrEmpty(Keyword)) { qsb.Append("keyword", Keyword.ToString().ToLowerInvariant()); } if (Minprice.HasValue) { qsb.Append("minprice", Minprice.Value.ToString()); } if (Maxprice.HasValue) { qsb.Append("maxprice", Maxprice.Value.ToString()); } if (!string.IsNullOrEmpty(Name)) { qsb.Append("name", Name.ToString().ToLowerInvariant()); } if (OpenNow.HasValue) { qsb.Append("opennow", OpenNow.Value.ToString().ToLowerInvariant()); } if ((Types != null && Types.Any())) { qsb.Append("types", TypesToUri()); } if (ZagatSelected) { qsb.Append("zagatselected"); } var url = "radarsearch/json?" + qsb.ToString(); return(new Uri(url, UriKind.Relative)); }
public override Uri ToUri() { ValidateRequest(); var qsb = new Internal.QueryStringBuilder(); qsb.Append("input", Input.ToLowerInvariant()); if (Offset > 0) { qsb.Append("offset", Offset.ToString()); } if (Location != null) { qsb.Append("location", Location.GetAsUrlParameter()); } if (Radius.HasValue) { qsb.Append("radius", (Radius.Value.ToString().ToLowerInvariant())); } if (!string.IsNullOrEmpty(Language)) { qsb.Append("language", Language.ToLowerInvariant()); } if ((Types != null && Types.Any())) { qsb.Append("types", TypesToUri()); } if (!string.IsNullOrEmpty(Components)) { qsb.Append(string.Format("components=country:{0}", Components.ToLowerInvariant())); } if (!string.IsNullOrEmpty(SessionToken)) { qsb.Append("sessiontoken", SessionToken); } var url = "autocomplete/json?" + qsb.ToString(); return(new Uri(url, UriKind.Relative)); }
public override bool ConditionOn( IServiceCollection services, ServiceDescriptor serviceDescriptor, IConfiguration rootConfiguration, IHostEnvironment hostEnvironment) { switch (ConditionType) { case ConditionType.ALL: return(Types.All(services.AnyService)); case ConditionType.ANY: return(Types.Any(services.AnyService)); default: throw new IndexOutOfRangeException($"Error condition type {ConditionType} on {serviceDescriptor.ImplementationType}"); } }
public override string ToString() { var s = new StringBuilder(); s.Append("Current: ").Append(Access.ToString()); if (Types.Any()) { s.Append(" Types: | "); foreach (var connectionType in Types) { s.Append(connectionType.ToString()).Append(" | "); } } return(s.ToString()); }
public void InitializeValueVariable(DataType dataType, string name, string value) { if (!(dataType is ValueType type)) { throw new ArgumentException($"{nameof(dataType)} needs to be a value type"); } if (!Types.Any(x => x.Name == type.Name)) { throw new InvalidOperationException($"{dataType.Name} is not in the list of available types."); } if (Variables.Any(x => x.Name == name)) { throw new InvalidOperationException($"Variable with name {name} already exists"); } var variable = new Variable { Name = name, Type = dataType, Value = value == string.Empty ? dataType.Defaultvalue : value }; Ram.SetVariable(NextAvailableStack, variable); Variables.Add(variable); NextAvailableStack++; if (dataType.Equals(DataTypes.String)) { SourceCode.Add($"{dataType.Name} {name} = \"{value}\";"); } else if (dataType.Equals(DataTypes.Bool)) { SourceCode.Add($"{dataType.Name} {name} = {(value == "0" ? "false" : "true")};"); } else { SourceCode.Add($"{dataType.Name} {name} = {value};"); } }
private void RefreshFilter() { if (RootMap != null) { if (RootMap.ExportJobs.Count > 0) { StatusDescriptor.SuspendNotifications(); StatusDescriptor.Clear(); if (Statuses.Any()) { foreach (var status in Statuses) { StatusDescriptor.DistinctFilter.AddDistinctValue(status); } } else { StatusDescriptor.DistinctFilter.AddDistinctValue(ExportStatus.Unknown); } StatusDescriptor.ResumeNotifications(); TypeDescriptor.SuspendNotifications(); TypeDescriptor.Clear(); if (Types.Any()) { foreach (var type in Types) { TypeDescriptor.DistinctFilter.AddDistinctValue(type); } } else { TypeDescriptor.DistinctFilter.AddDistinctValue(ExportType.Unknown); } TypeDescriptor.ResumeNotifications(); } IsBusy = false; } }
private void SetConstantLists() { if (!CurrencyList.Any()) { CurrencyList.Add(new Currency() { Name = "Рубль РФ", Value = "RUR" }); CurrencyList.Add(new Currency() { Name = "Доллар США", Value = "USD" }); CurrencyList.Add(new Currency() { Name = "Евро", Value = "EUR" }); } if (!Types.Any()) { Types.Add(new AccountTypes() { Name = AccountType.Cash.ToString(), Value = "Наличные средства" }); Types.Add(new AccountTypes() { Name = AccountType.Card.ToString(), Value = "Банковская карта" }); Types.Add(new AccountTypes() { Name = AccountType.BankAccount.ToString(), Value = "Банковский счёт" }); } }
protected override void ProcessRecord() { var queries = new Dictionary <string, string>(); if (Types != null && Types.Any()) { List <string> types = Types.ToList().ConvertAll <string>(x => x.ToString().First().ToString().ToLower() + x.ToString().Substring(1)); queries.Add("taskTypes", string.Join(",", types)); } if (Ids != null && Ids.Any()) { queries.Add("taskIds", string.Join(",", Ids)); } if (StartTime.HasValue) { queries.Add("startTimeUsecs", StartTime.ToString()); } if (EndTime.HasValue) { queries.Add("endTimeUsecs", EndTime.ToString()); } var queryString = string.Empty; if (queries.Any()) { queryString = "?" + string.Join("&", queries.Select(q => $"{q.Key}={q.Value}")); } var url = $"/public/restore/tasks{queryString}"; var result = Session.ApiClient.Get <IEnumerable <RestoreTask> >(url); WriteObject(result, true); }
protected bool ProcessFlags() { return(Types.Count == 0 || Settings.DumpFormat == DumpFormatType.SniffDataOnly || Types.Any(sqlOutput => SQLEnabledFlags.HasAnyFlagBit(sqlOutput))); }
public bool IsTypeSupported(EntityType type) { return(Types.Length == 0 || Types.Any(t => t.Check(type))); }
internal override Uri ToUri() { ValidateRequest(); var qsb = new Internal.QueryStringBuilder(); qsb.Append("location", Location.GetAsUrlParameter()) .Append("sensor", (Sensor.Value.ToString().ToLowerInvariant())); if (RankBy.GetValueOrDefault(Maps.RankBy.Prominence) != Maps.RankBy.Distance) { // Note that radius must not be included if rankby=distance qsb.Append("radius", Radius.ToString()); } else { qsb.Append("rankby", RankBy.Value.ToString().ToLowerInvariant()); } if (!string.IsNullOrEmpty(Keyword)) { qsb.Append("keyword", Keyword.ToString().ToLowerInvariant()); } if (!string.IsNullOrEmpty(Name)) { qsb.Append("name", Name.ToString().ToLowerInvariant()); } if ((Types != null && Types.Any())) { qsb.Append("types", TypesToUri()); } if (!string.IsNullOrEmpty(Language)) { qsb.Append("language", Language.ToLowerInvariant()); } if (Minprice.HasValue) { qsb.Append("minprice", Minprice.Value.ToString()); } if (Maxprice.HasValue) { qsb.Append("maxprice", Maxprice.Value.ToString()); } if (OpenNow.HasValue) { qsb.Append("opennow", OpenNow.Value.ToString().ToLowerInvariant()); } if (!string.IsNullOrEmpty(PageToken)) { qsb.Append("pagetoken", PageToken); } if (ZagatSelected) { qsb.Append("zagatselected"); } var url = "nearbysearch/json?" + qsb.ToString(); return(new Uri(url, UriKind.Relative)); }
protected override void ValidateRequest() { base.ValidateRequest(); if (Location == null) { throw new InvalidOperationException("Location property is not set"); } if (RankBy != null && RankBy != Maps.RankBy.Distance) { if (!Radius.HasValue) { throw new ArgumentException("Radius property is not set."); } } else if (RankBy != null && RankBy == Maps.RankBy.Distance) { if (string.IsNullOrEmpty(Keyword) && string.IsNullOrEmpty(Name) && (Types == null || !Types.Any())) { throw new ArgumentException("Atleast one of Keyword, Name or Types must be supplied."); } } }
private bool IsA(string type) { // Most of the time, a card is of one type. // Check first the main type for optimization : return(Type == type || Types.Any(t => t == type)); }
public bool HasType(IType type) { return(Types.Any(t => t == type)); }
public bool HasType(string name) { return(Types.Any(t => t.Name == name)); }
public override void DumpCondition(LuaTextWriter output) { if (Inverted) { output.Write("not ("); } void WriteFilter() { output.WriteStartFunction("ability"); output.Write("if ability.Category ~= "); output.WriteValue(Category); output.Write(" then return false end\n"); if (NotTypes.Any()) { output.Write("if ability.IsAnyType("); output.WriteValues(NotTypes); output.Write(") then return false end\n"); } foreach (var name in NotNames) { output.Write("if ability.Name == "); output.WriteValue(name); output.Write(" then return false end\n"); } if (Types.Any()) { output.Write("if ability.IsAnyType("); output.WriteValues(Types); output.Write(") then return true end\n"); } foreach (var name in Names) { output.Write("if ability.Name == "); output.WriteValue(name); output.Write(" then return true end\n"); } output.Write("return false\n"); output.WriteEndFunction(); } if (Count == 1) { output.Write("character.HasAnyAbility("); WriteFilter(); output.Write(")"); } else { output.Write(Count.ToString()); output.Write(" <= character.CountAbilities("); WriteFilter(); output.Write(")"); } if (Inverted) { output.Write(")"); } }
public bool IsTypeOf(Type type) { return(type != null && Types != null && Types.Any(t => type.TypeEquals(t, IncludeChildTypes))); }