private void searchfield_Loaded(object sender, RoutedEventArgs e) { defaultOperator = Operator; isSetDefaultOperator = true; DisplayName = GetDisplayName(); Binding binding = new Binding("IsFocused") { Source = this, Mode = BindingMode.OneWay }; SetBinding(IsGetFocusProperty, binding); BindingExpression bindingExpression = this.GetBindingExpression(TextProperty); Binding textBinding = new Binding("Text") { Source = this, Mode = BindingMode.TwoWay, UpdateSourceTrigger = bindingExpression?.ParentBinding?.UpdateSourceTrigger ?? UpdateSourceTrigger.Default }; textbox.SetBinding(CustomTextBox.TextProperty, textBinding); }
public static bool SwitchFunzioni(Message messaggio) { if (messaggio.Text == null) { return(true); } var comando = StringOperator.PurgeString(messaggio.Text); if (ModulesManager.CheckModules(comando, messaggio)) { return(true); } if (AnalizzatoreFrase.ListaAudioImmensa(comando, messaggio, ContGiulio)) { return(true); } if (AnalizzatoreFrase.Switch(messaggio, comando, ContOffese, ContPaolo, ContPerle)) //controllo sulla prima parola { return(true); } if (comando.Any(x => AnalizzatoreFrase.Contiene(messaggio, x, ContSofferenza, ContPano))) { return(true); } return(false); }
public static void linkToBackup(string file) { Directory.CreateDirectory(Path.Combine(BackupDir, StringOperator.GetRootChar(file), StringOperator.GetDirectoryNameExceptRoot(file))); FileOperator.MkLinkOption option; bool isFile; if (File.Exists(file)) { option = FileOperator.MkLinkOption.HardLink; isFile = true; } else if (Directory.Exists(file)) { option = FileOperator.MkLinkOption.Junction; isFile = false; } else { Console.WriteLine("ファーwww"); throw new FileNotFoundException(); } string linkDirectory = Path.Combine(BackupDir, StringOperator.GetRootChar(file), StringOperator.GetFileNameExceptRoot(file)); string originalDirectory = file; bool noerror = FileOperator.MkLink(linkDirectory, originalDirectory, option).CheckNoError(); //いちいちトランザクション生成して遅いらしいけど、暫定。 if (noerror) { (new SQLDataBase("sync.db")).InsertToDB(new SQLDataBase.FilesTable(isFile, linkDirectory, originalDirectory)); } }
//================================================================================= Methods public static Operator GetOperator(StringOperator op) { switch (op) { case StringOperator.Equal: return(Operator.Equal); case StringOperator.NotEqual: return(Operator.NotEqual); case StringOperator.LessThan: return(Operator.LessThan); case StringOperator.GreaterThan: return(Operator.GreaterThan); case StringOperator.LessThanOrEqual: return(Operator.LessThanOrEqual); case StringOperator.GreaterThanOrEqual: return(Operator.GreaterThanOrEqual); case StringOperator.StartsWith: return(Operator.StartsWith); case StringOperator.EndsWith: return(Operator.EndsWith); case StringOperator.Contains: return(Operator.Contains); default: throw new NotImplementedException(String.Format(CultureInfo.CurrentCulture, SR.Exceptions.Search.Msg_UnknownStringOperator_1, op)); } }
//================================================================================= Methods public static Operator GetOperator(StringOperator op) { switch (op) { case StringOperator.Equal: return Operator.Equal; case StringOperator.NotEqual: return Operator.NotEqual; case StringOperator.LessThan: return Operator.LessThan; case StringOperator.GreaterThan: return Operator.GreaterThan; case StringOperator.LessThanOrEqual: return Operator.LessThanOrEqual; case StringOperator.GreaterThanOrEqual: return Operator.GreaterThanOrEqual; case StringOperator.StartsWith: return Operator.StartsWith; case StringOperator.EndsWith: return Operator.EndsWith; case StringOperator.Contains: return Operator.Contains; default: throw new NotImplementedException(String.Format(CultureInfo.CurrentCulture, SR.Exceptions.Search.Msg_UnknownStringOperator_1, op)); } }
public static IQueryable <T> FilterByString <T>(this IQueryable <T> query, Expression <Func <T, string> > propertySelector, StringOperator operand, string value) { ParameterExpression parameterExpression = null; var memberExpression = GetMemberExpression(propertySelector.Body, out parameterExpression); var dynamicExpression = Expression.Call(memberExpression, miTL); Expression constExp = Expression.Constant(value.ToLower()); switch (operand) { case StringOperator.StartsWith: dynamicExpression = Expression.Call(dynamicExpression, miS, constExp); break; case StringOperator.Contains: dynamicExpression = Expression.Call(dynamicExpression, miC, constExp); break; case StringOperator.EndsWith: dynamicExpression = Expression.Call(dynamicExpression, miE, constExp); break; } var pred = Expression.Lambda <Func <T, bool> >(dynamicExpression, new[] { parameterExpression }); return(query.Where(pred)); }
private static void SetRule(string prop, StringOperator op, string value, IWebElement row) { row.FindElement(By.CssSelector(".rule-prop option[value={0}]".FormatWith(prop))).Click(); row.FindElement(By.CssSelector(".rule-operator option[value={0}]".FormatWith(op))).Click(); row.FindElement(By.CssSelector(".rule-val")).Clear(); row.FindElement(By.CssSelector(".rule-val")).SendKeys(value); }
/// <summary> /// 删除指定分组的Jobs /// </summary> /// <param name="group">Job分组名称</param> /// <param name="compareWith">分组名称匹配规则</param> /// <returns>true if all of the Jobs were found and deleted, false if one or more were not</returns> public static async Task <bool> DeleteJobsAsync(string group, StringOperator compareWith) { GroupMatcher <JobKey> matcher; if (Equals(compareWith, StringOperator.Contains)) { matcher = GroupMatcher <JobKey> .GroupContains(group); } else if (Equals(compareWith, StringOperator.EndsWith)) { matcher = GroupMatcher <JobKey> .GroupEndsWith(group); } else if (Equals(compareWith, StringOperator.Equality)) { matcher = GroupMatcher <JobKey> .GroupEquals(group); } else if (Equals(compareWith, StringOperator.StartsWith)) { matcher = GroupMatcher <JobKey> .GroupStartsWith(group); } else { matcher = GroupMatcher <JobKey> .AnyGroup(); } return(await GetScheduler().DeleteJobs((await GetScheduler().GetJobKeys(matcher)).ToList())); }
public StringCondition(Property property, bool not, StringOperator op, object value, bool ignoreCase) : base(property, not) { this.m_Operator = op; this.m_Value = new PropertyValue(property.Type, value); this.m_IgnoreCase = ignoreCase; }
public StringExpression(PropertyType property, StringOperator op, StringAttribute value) { if (property == null) throw new ArgumentNullException("property"); if (property.DataType != DataType.String) throw GetWrongPropertyDataTypeException("property", DataType.String); _binExp = new BinaryExpression(property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value)); }
public StringExpression(StringAttribute property, StringOperator op, PropertyType value) { if (value == null) throw new ArgumentNullException("value"); if (value.DataType != DataType.String) throw GetWrongPropertyDataTypeException("value", DataType.String); _binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), value); }
/// <summary> /// Initializes a new instance of the <see cref="StringExpression"/> class. /// </summary> /// <param name="stringOperator">The string operator.</param> /// <param name="fieldName">The field name.</param> /// <param name="componentIndex">The component index.</param> /// <param name="value">The value.</param> /// <param name="ignoreCase">A flag indicating whether it's case and accent sensitive or not.</param> public StringExpression(StringOperator stringOperator, FieldName fieldName, int?componentIndex, string value, bool ignoreCase) { StringOperator = stringOperator; FieldName = fieldName; ComponentIndex = componentIndex; Value = value; IgnoreCase = ignoreCase; }
public static StringCriteria String(string value, StringOperator @operator, bool ignoreEmpty = true) { if (ignoreEmpty && string.IsNullOrEmpty(value)) { value = null; } return(new StringCriteria(value, @operator)); }
public StringExpression(StringAttribute property, StringOperator op, PropertyType value) { if (value == null) { throw new ArgumentNullException("value"); } if (value.DataType != DataType.String) { throw GetWrongPropertyDataTypeException("value", DataType.String); } _binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), value); }
public StringExpression(PropertyType property, StringOperator op, StringAttribute value) { if (property == null) { throw new ArgumentNullException("property"); } if (property.DataType != DataType.String) { throw GetWrongPropertyDataTypeException("property", DataType.String); } _binExp = new BinaryExpression(property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value)); }
public void AddRule(string issueId, string prop, StringOperator op, string value) { GoTo("issue/" + new Issue() { Id = issueId }.FriendlyId); _webDriver.FindElement(By.CssSelector(".tabs a[data-val=rules]")).Click(); _webDriver.FindElement(By.CssSelector("#rules a.add")).Click(); var newRow = _webDriver.FindElement(By.CssSelector("#rules .new-rule")); SetRule(prop, op, value, newRow); }
public static void ValidateStringExpression( Expression expression, FieldName expectedFieldName, StringOperator expectedStringOperator, string expectedValue, bool expectedIgnoreCase) { StringExpression stringExpression = Assert.IsType <StringExpression>(expression); Assert.Equal(expectedStringOperator, stringExpression.StringOperator); Assert.Equal(expectedFieldName, stringExpression.FieldName); Assert.Equal(expectedValue, stringExpression.Value); Assert.Equal(expectedIgnoreCase, stringExpression.IgnoreCase); }
public override bool IsMatch(Error error) { var ruleValue = TreatValue(Value); var valuesFromError = GetValuesFromError(error); if (ruleValue.IsNullOrEmpty()) { return(valuesFromError.Any(v => v.IsNullOrEmpty())); } return(valuesFromError.Any(v => { if (v == null) { return false; } switch (StringOperator) { case StringOperator.StartsWith: return v.StartsWith(ruleValue); case StringOperator.DoesNotEqual: return v != ruleValue; case StringOperator.Contains: return v.Contains(ruleValue); case StringOperator.DoesNotContain: return !v.Contains(ruleValue); case StringOperator.EndsWith: return v.EndsWith(ruleValue); case StringOperator.Equals: return v == ruleValue; case StringOperator.RegexMatches: return Regex.IsMatch(v, ruleValue); default: throw new ErrorditeUnexpectedValueException("StringOperator", StringOperator.ToString()); } })); }
private bool StringSearchPredicate(string str1, string str2, StringOperator op) { switch (op) { case StringOperator.Contains: return(str1.Contains(str2)); case StringOperator.ContainsIgnoreCase: return(str1.Contains(str2, StringComparison.InvariantCultureIgnoreCase)); case StringOperator.Exactmatch: return(str1 == str2); case StringOperator.ExactmatchIgnoreCase: return(String.Compare(str1, str2, true) == 0); default: return(false); } }
public static void ComandoPunnisci(Message messaggio, string[] comando) { var user = -1; switch (comando.Length) { case 0: case 1: case 2: Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "mi dispiace ma devi inserire la corretta sintassi per un adeguato funzionamento del comando punnisci \n \r " + "Sintassi corretta: punnisci [nome/cognome/usrname/nomecognome] [nome/cognome/username/nomecognome da punnire] " + "Esempio: punnisci username giulioguidotti"); return; case 3: user = GetUser(comando, messaggio); if (user.Equals(-1)) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "oops qualcosa è andato storto"); return; } return; case 4: StatManager.GetUserIdByNameSurname(comando[2], comando[3]); return; } try { if (StringOperator.Contains(comando, new[] { "cosimo", "chellini" }, 1)) { user = messaggio.From.Id; } Istance.Bot.Istance.KickChatMemberAsync(messaggio.Chat.Id, user); } catch (Exception) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Mi dispiace ma non sono riuscito a punnirlo"); } }
public Argument Evaluate() { if (!Arguments[0].CanEvaluate || !Arguments[2].CanEvaluate) { throw new CodeblockOperatorException("The codeblock arguments can not be empty."); } object l = Arguments[0].Evaluateble.Evaluate().Value; object r = Arguments[2].Evaluateble.Evaluate().Value; // Get the types of the arguments ArgumentType lType = ArgumentTypeHelper.FromObject(l); ArgumentType rType = ArgumentTypeHelper.FromObject(r); // Ensure the arguments don't have different types if (lType != rType) { throw new CodeblockOperatorException("The codeblock arguments must have the same type."); } // Use the left argument to see which type the comparison should take IComparisonTypeOperator comparisonOperator; ComparisonOperator operation = (ComparisonOperator)Arguments[1].Evaluateble.Evaluate().Value; switch (lType) { case ArgumentType.Number: comparisonOperator = new NumberOperator(); break; case ArgumentType.String: comparisonOperator = new StringOperator(); break; case ArgumentType.Boolean: comparisonOperator = new BooleanOperator(); break; default: throw new CodeblockOperatorException($"No valid operator found for argument type {lType}."); } object result = EvaluateOperation(l, r, comparisonOperator, operation); return(new Argument(result, ResultingType)); }
public static bool Evaluate(this StringOperator @operator, string?value, string?comparisonValue) { @operator.Validate(nameof(@operator)); var isOdd = ((int)@operator) % 2 == 1; return(EvaluateInternal(isOdd ? @operator + 1 : @operator) ^ isOdd); bool EvaluateInternal(StringOperator effectiveOperator) { return(effectiveOperator switch { StringOperator.Equals => string.Equals(value, comparisonValue, StringComparison.OrdinalIgnoreCase), StringOperator.EqualsExact => string.Equals(value, comparisonValue, StringComparison.Ordinal), StringOperator.Contains => comparisonValue == null || (value == null ? comparisonValue.Length == 0 : value.IndexOf(comparisonValue, StringComparison.OrdinalIgnoreCase) >= 0), StringOperator.StartsWith => comparisonValue == null || (value == null ? comparisonValue.Length == 0 : value.StartsWith(comparisonValue, StringComparison.OrdinalIgnoreCase)), StringOperator.EndsWith => comparisonValue == null || (value == null ? comparisonValue.Length == 0 : value.EndsWith(comparisonValue, StringComparison.OrdinalIgnoreCase)), StringOperator.EqualInLength => (value?.Length ?? 0) == (comparisonValue?.Length ?? 0), StringOperator.ShorterThan => (value?.Length ?? 0) < (comparisonValue?.Length ?? 0), StringOperator.LongerThan => (value?.Length ?? 0) > (comparisonValue?.Length ?? 0), _ => throw new NotSupportedException($"StringOperator of {@operator} is not supported"), }); }
public bool Check(string[] comando) { if (CheckAll) { foreach (var condition in Conditions) { if (!StringOperator.Contains(comando, condition.Phrases.ToArray(), condition.ConditionCounter)) { return(false); } } return(true); } foreach (var condition in Conditions) { if (StringOperator.Contains(comando, condition.Phrases.ToArray(), condition.ConditionCounter)) { return(true); } } return(false); }
public StringQuery(string value, StringOperator op) { Value = value; Operator = op; }
public static bool ListaAudioImmensa(string[] comando, Message messaggio, int contGiulio) { if (StringOperator.Contains(comando, new[] { "enrico", "papi" }, 1)) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/Audio/mooseca.ogg"); return(true); } if (StringOperator.Contains(comando, new[] { "chi" })) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Sto cazzo"); return(true); } if (StringOperator.Contains(comando, new[] { "cecche", "lex" }, 2)) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Dura lex."); return(true); } if (StringOperator.Contains(comando, new[] { "dura", "lex" }, 2)) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Cecche lex."); return(true); } if (StringOperator.Contains(comando, new[] { "dio", "città", "immensità" }, 2)) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/dioCitta.ogg"); return(true); } if (StringOperator.Contains(comando, new[] { "pooh", "puh", "pu", "poo" }, 1)) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/dioCitta.ogg"); return(true); } if (StringOperator.Contains(comando, new[] { "seghe", "porno", "ettore", "disperazione" }, 2)) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/pornoettore.ogg"); return(true); } if (StringOperator.Contains(comando, new[] { "senza", "internet" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/senzainternet.ogg"); return(true); } if (StringOperator.Contains(comando, new[] { "ennio", "morricone", "si", "vola", "130", "centotrenta", "autostrada" }, 2)) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/siVola.ogg"); return(true); } if (StringOperator.Contains(comando, new[] { "fai", "soffrire", "giulio" })) { GeneratoreSofferenza4Giulio.CreaSofferenza(messaggio, Istance.Bot.Istance, new Random().Next(0, contGiulio)); return(true); } if (StringOperator.Contains(comando, new[] { "stasera", "non", "posso" })) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Bravo " + messaggio.From.FirstName + " tradisci così Lattana nel momento del bisogno?"); return(true); } if (StringOperator.Contains(comando, new[] { "stasera", "nonci" })) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Bravo " + messaggio.From.FirstName + " tradisci così Lattana nel momento del bisogno?"); return(true); } if (StringOperator.Contains(comando, new[] { "io", "non", "posso" })) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Bravo " + messaggio.From.FirstName + " tradisci così Lattana nel momento del bisogno?"); return(true); } if (StringOperator.Contains(comando, new[] { "stasera", "non", "posso" })) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Bravo " + messaggio.From.FirstName + " tradisci così Lattana nel momento del bisogno?"); return(true); } if (StringOperator.Contains(comando, new[] { "non", "vengo" })) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Bravo " + messaggio.From.FirstName + " tradisci così Lattana nel momento del bisogno?"); return(true); } if (StringOperator.Contains(comando, new[] { "bruto", "bruhuto", "brutto", "briuto", "non" }, 2)) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "le belo"); return(true); } if (StringOperator.Contains(comando, new[] { "non", "ci", "sono" })) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Bravo " + messaggio.From.FirstName + " tradisci così Lattana nel momento del bisogno?"); return(true); } if (StringOperator.Contains(comando, new[] { "cazzo", "duro", "ritto" }, 2)) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/cazzo%20duro.mp3"); Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/cazzo%20duro.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "sito", "nazista" })) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Questo è il sito dove potete vedere tutte le info sui nostri progetti https://goo.gl/e8Lpu7"); return(true); } if (StringOperator.Contains(comando, new[] { "problema", "se", "stasera", "veniamo", "da", "te", "giulio", "non", "c'è" }, 8)) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "Volentieri, tanto lui sarà dalla silvia a fare il denutrito"); return(true); } if (StringOperator.Contains(comando, new[] { "buono", "brutto", "cattivo" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/buono%20brutto%20e%20cattivo.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "sticker", "normali" })) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "1) https://goo.gl/AsLTH2 \r\n" + "2) https://goo.gl/kV18vp \r\n" + "3) https://goo.gl/APXoRo \r\n" + "4) https://goo.gl/9q1qYy \r\n" ); return(true); } if (StringOperator.Contains(comando, new[] { "sticker", "porno" })) { Istance.Bot.Istance.SendTextMessageAsync(messaggio.Chat.Id, "https://goo.gl/zR1jTT"); return(true); } if (StringOperator.Contains(comando, new[] { "don", "matteo" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/don%20matteo%2C%20donma%2C%20domma.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "cazzo", "duro" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/cazzo%20duro.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "ceci", "na", "pa", "pe", "une", "pipe" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/ceci%20na%20pa%20pe%20une%20pipe.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "ceci", "nes", "pas", "une", "pip" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/ceci%20nes%20pas%20une%20pip.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "ceci", "nes", "pas", "une", "pipe" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/ceci%20nes%20pas%20une%20pipe.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "cazzo", "ritto" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/cazzo%20duro.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "faccie", "culo" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/cosi%20si%20dice%20faccia%20di%20culo.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "faccia", "culo" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/faccia%20di%20culo.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "non", "fare", "la", "merda" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/giano%20non%20fare%20la%20merda.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "giochi", "di", "sabato" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/giochi%20di%20sabato.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "era", "l'ora" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/finalmente%2C%20alleluia.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "non", "mi", "riesce" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/non%20mi%20riesce%20mandare%20gli%20audi.mp3"); //Models.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, "http://nazista.altervista.org/ogg/non_mi_riesce_mandare_gli_audi.ogg", 0, true); return(true); } if (StringOperator.Contains(comando, new[] { "come", "stai" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/roito%20della%20natura%2C%20guarda%20come%20tu%20stai.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "va", "bene" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/scossa%2C%20va%20bene.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "la", "spezza" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/spezarsela%2C%20spezzatela%2C%20se%20la%20spezza.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "cazzo", "dici" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/checazzodici" + new Random().Next(1, 4) + ".mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "tornato", "internet" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/internet{new Random().Next(1, 3)}.ogg"); return(true); } if (StringOperator.Contains(comando, new[] { "cazzo", "dicendo" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/checazzodici" + new Random().Next(1, 4) + ".mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "cascano", "braccia" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/checazzodici3.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "cascare", "braccia" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/checazzodici3.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "dove", "vai" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/dove%20vai.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "non", "vai" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/dove%20vai.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "dove", "andando" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/dove%20vai.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "non", "vado" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/dove%20vai.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "non", "vo" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/dove%20vai.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "ci", "vado" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/dove%20vai.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "ci", "vo" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/dove%20vai.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "schifo", "immagini" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/fanno%20cagare%20quelle%20immagini.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "merda", "immagini" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/fanno%20cagare%20quelle%20immagini.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "vomitare", "immagini" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/fanno%20cagare%20quelle%20immagini.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "non", "sanno", "di", "niente" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/fanno%20cagare%20quelle%20immagini.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "non", "sanno", "di", "nulla" })) { Istance.Bot.Istance.SendVoiceAsync(messaggio.Chat.Id, $"{UrlBase}/audi/fanno%20cagare%20quelle%20immagini.mp3"); return(true); } if (StringOperator.Contains(comando, new[] { "me", "il", "cazzo" })) { Istance.Bot.Istance.SendVideoNoteAsync(messaggio.Chat.Id, $"{UrlBase}/VideoNote/meIlCazzo.mp4"); return(true); } if (StringOperator.Contains(comando, new[] { "camera", "caffè" })) { Istance.Bot.Istance.SendVideoNoteAsync(messaggio.Chat.Id, $"{UrlBase}/VideoNote/sega.mp4"); return(true); } if (StringOperator.Contains(comando, new[] { "yo", "bitch", "biatch", "biach" })) { Istance.Bot.Istance.SendVideoNoteAsync(messaggio.Chat.Id, $"{UrlBase}/VideoNote/yoBitch.mp4"); return(true); } if (StringOperator.Contains(comando, new[] { "weekend", "weekends" }, 1) || StringOperator.Contains(comando, new[] { "week", "end", "ends" })) { Istance.Bot.Istance.SendVideoNoteAsync(messaggio.Chat.Id, $"{UrlBase}/VideoNote/weekEnd.mp4"); return(true); } return(false); }
public TicketResponseQuery WithBody(string value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, StringOperator @operator = StringOperator.Exact, StringDirection direction = StringDirection.SourceToExpected) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case StringOperator.Exact: switch (direction) { case StringDirection.SourceToExpected: case StringDirection.ExpectedToSource: case StringDirection.TwoWay: Entities = Entities.Where(tr => tr.Body == value); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.Contains: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(tr => tr.Body.Contains(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(tr => value.Contains(tr.Body)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(tr => tr.Body.Contains(value) || value.Contains(tr.Body)); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.StartsWith: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(tr => tr.Body.StartsWith(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(tr => value.StartsWith(tr.Body)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(tr => tr.Body.StartsWith(value) || value.StartsWith(tr.Body)); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.EndsWith: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(tr => tr.Body.EndsWith(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(tr => value.EndsWith(tr.Body)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(tr => tr.Body.EndsWith(value) || value.EndsWith(tr.Body)); return(this); default: throw new NotSupportedEnumException(direction); } default: throw new NotSupportedEnumException(@operator); } }
public NewsletterSubscriptionQuery WithEmail(string value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, StringOperator @operator = StringOperator.Exact, StringDirection direction = StringDirection.SourceToExpected) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case StringOperator.Exact: switch (direction) { case StringDirection.SourceToExpected: case StringDirection.ExpectedToSource: case StringDirection.TwoWay: Entities = Entities.Where(ns => ns.Email == value); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.Contains: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(ns => ns.Email.Contains(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(ns => value.Contains(ns.Email)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(ns => ns.Email.Contains(value) || value.Contains(ns.Email)); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.StartsWith: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(ns => ns.Email.StartsWith(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(ns => value.StartsWith(ns.Email)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(ns => ns.Email.StartsWith(value) || value.StartsWith(ns.Email)); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.EndsWith: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(ns => ns.Email.EndsWith(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(ns => value.EndsWith(ns.Email)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(ns => ns.Email.EndsWith(value) || value.EndsWith(ns.Email)); return(this); default: throw new NotSupportedEnumException(direction); } default: throw new NotSupportedEnumException(@operator); } }
public StringExpression(StringAttribute property, StringOperator op, StringAttribute value) { _binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value)); }
protected DatabaseStringOperator(StringOperator stringOperator) { DependentStringOperator = ServiceLocator.Instance.Database.GetStringOperator(stringOperator); }
public EmailAccountQuery WithPassword(string value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, StringOperator @operator = StringOperator.Exact, StringDirection direction = StringDirection.SourceToExpected) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case StringOperator.Exact: switch (direction) { case StringDirection.SourceToExpected: case StringDirection.ExpectedToSource: case StringDirection.TwoWay: Entities = Entities.Where(ea => ea.Password == value); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.Contains: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(ea => ea.Password.Contains(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(ea => value.Contains(ea.Password)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(ea => ea.Password.Contains(value) || value.Contains(ea.Password)); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.StartsWith: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(ea => ea.Password.StartsWith(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(ea => value.StartsWith(ea.Password)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(ea => ea.Password.StartsWith(value) || value.StartsWith(ea.Password)); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.EndsWith: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(ea => ea.Password.EndsWith(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(ea => value.EndsWith(ea.Password)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(ea => ea.Password.EndsWith(value) || value.EndsWith(ea.Password)); return(this); default: throw new NotSupportedEnumException(direction); } default: throw new NotSupportedEnumException(@operator); } }
private static Expression ParseStringExpression(XmlNode node, XmlNamespaceManager nsmgr, SchemaRoot schema) { StringOperator op = ParseStringOperator(node); object leftValue = ParseLeftValue(node, nsmgr, schema); object rightValue = ParseRightValue(node, nsmgr, schema); PropertyType leftProp = leftValue as PropertyType; if (leftProp != null) { if (rightValue == null) { return(new StringExpression(leftProp, op, (string)null)); } PropertyType rightProp = rightValue as PropertyType; if (rightProp != null) { return(new StringExpression(leftProp, op, rightProp)); } string rightString = rightValue as String; if (rightString != null) { return(new StringExpression(leftProp, op, rightString)); } try { StringAttribute rightAttr = (StringAttribute)rightValue; return(new StringExpression(leftProp, op, rightAttr)); } catch (Exception e) //rethrow { throw new ApplicationException(String.Concat("Unrecognized StringAttribute: '", rightValue, "'. Source: ", node.OuterXml), e); } } else { StringAttribute leftAttr = (StringAttribute)leftValue; if (rightValue == null) { return(new StringExpression(leftAttr, op, (string)null)); } PropertyType rightProp = rightValue as PropertyType; if (rightProp != null) { return(new StringExpression(leftAttr, op, rightProp)); } string rightString = rightValue as String; if (rightString != null) { return(new StringExpression(leftAttr, op, rightString)); } try { StringAttribute rightAttr = (StringAttribute)rightValue; return(new StringExpression(leftAttr, op, rightAttr)); } catch (Exception e) //rethrow { throw new ApplicationException(String.Concat("Unrecognized StringAttribute: '", rightValue, "'. Source: ", node.OuterXml), e); } } }
public StringCondition( Property property, bool not, StringOperator op, object value, bool ignoreCase ) : base( property, not ) { m_Operator = op; m_Value = new PropertyValue( property.Type, value ); m_IgnoreCase = ignoreCase; }
public StringCriteriaAttribute(StringOperator @operator, bool ignoreEmpty = true) { Operator = @operator; IgnoreEmpty = ignoreEmpty; }
public BannedIpQuery WithIpAddress(string value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, StringOperator @operator = StringOperator.Exact, StringDirection direction = StringDirection.SourceToExpected) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case StringOperator.Exact: switch (direction) { case StringDirection.SourceToExpected: case StringDirection.ExpectedToSource: case StringDirection.TwoWay: Entities = Entities.Where(bi => bi.IpAdrress == value); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.Contains: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(bi => bi.IpAdrress.Contains(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(bi => value.Contains(bi.IpAdrress)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(bi => bi.IpAdrress.Contains(value) || value.Contains(bi.IpAdrress)); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.StartsWith: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(bi => bi.IpAdrress.StartsWith(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(bi => value.StartsWith(bi.IpAdrress)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(bi => bi.IpAdrress.StartsWith(value) || value.StartsWith(bi.IpAdrress)); return(this); default: throw new NotSupportedEnumException(direction); } case StringOperator.EndsWith: switch (direction) { case StringDirection.SourceToExpected: Entities = Entities.Where(bi => bi.IpAdrress.EndsWith(value)); return(this); case StringDirection.ExpectedToSource: Entities = Entities.Where(bi => value.EndsWith(bi.IpAdrress)); return(this); case StringDirection.TwoWay: Entities = Entities.Where(bi => bi.IpAdrress.EndsWith(value) || value.EndsWith(bi.IpAdrress)); return(this); default: throw new NotSupportedEnumException(direction); } default: throw new NotSupportedEnumException(@operator); } }
/// <summary> /// Initializes the operator resolver. /// </summary> /// <returns>The operator resolver.</returns> private static OperatorResolver InitOperatorResolver() { Mock <OperatorResolver> opResolverMock = new Mock <OperatorResolver>(); IExpressionFactory exprFactory = new ExpressionFactory( ModelResolvers.ExprResolver, ModelResolvers.RuleExprResolver, ModelResolvers.JoinExprResolver, opResolverMock.Object); JoinApplyMeasuresOperator joinApplyMeasuresOp = new JoinApplyMeasuresOperator( exprFactory, ModelResolvers.DsResolver); opResolverMock.Setup(o => o(It.IsAny <string>())) .Returns((string key) => { IOperatorDefinition op; if (key.In("count", "min", "max", "median", "sum", "avg", "stddev_pop", "stddev_samp", "var_pop", "var_samp")) { op = new AggrFunctionOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "aggr") { op = new AggrOperator(); } else if (key.In("first_value", "last_value", "lag", "rank", "ratio_to_report", "lead")) { op = new AnalyticFunctionOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key.In("+", "-", "*", "/")) { op = new ArithmeticOperator(joinApplyMeasuresOp); } else if (key == "between") { op = new BetweenOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key.In("and", "or", "xor", "not")) { op = new BooleanOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "calc") { op = new CalcOperator(ModelResolvers.DsResolver); } else if (key == "check_datapoint") { op = new CheckDatapointOperator(ModelResolvers.DsResolver, exprFactory); } else if (key.In("=", "<>", "<", "<=", ">", ">=")) { op = new ComparisonOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "comp") { op = new ComponentOperator(ModelResolvers.DsResolver, new ComponentTypeInference(ModelResolvers.DsResolver)); } else if (key == "const") { op = new ConstantOperator(ModelResolvers.DsResolver); } else if (key == "current_date") { op = new CurrentDateOperator(ModelResolvers.DsResolver); } else if (key == "exists_in") { op = new ExistsInOperator(ModelResolvers.DsResolver); } else if (key == "get") { op = new GetOperator(new Mock <IDataModelProvider>().Object); // operator tests should mock IDataModel implementation } else if (key == "if") { op = new IfThenElseOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key.In("in", "not_in")) { op = new InOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "isnull") { op = new IsNullOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "join") { op = new JoinOperator(ModelResolvers.DsResolver); } else if (key.In("keep", "drop")) { op = new KeepDropOperator(ModelResolvers.DsResolver); } else if (key == "match_characters") { op = new MatchCharactersOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "#") { op = new MembershipOperator(); } else if (key.In("ceil", "floor", "abs", "exp", "ln", "sqrt", "mod", "round", "power", "log", "trunc")) { op = new NumericOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "nvl") { op = new NvlOperator(joinApplyMeasuresOp); } else if (key == "opt") { op = new OptionalOperator(ModelResolvers.DsResolver); } else if (key == "period_indicator") { op = new PeriodIndicatorOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver, exprFactory); } else if (key == "pivot") { op = new PivotOperator(ModelResolvers.DsResolver); } else if (key == "ref") { op = new ReferenceOperator(); } else if (key == "rename") { op = new RenameOperator(ModelResolvers.DsResolver); } else if (key.In("union", "intersect", "setdiff", "symdiff")) { op = new SetOperator(); } else if (key.In("||", "trim", "rtrim", "ltrim", "upper", "lower", "substr", "replace", "instr", "length")) { op = new StringOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "sub") { op = new SubspaceOperator(ModelResolvers.DsResolver); } else if (key.In("fill_time_series", "flow_to_stock", "stock_to_flow", "timeshift", "time_agg")) { op = new TimeOperator(); } else if (key.In("plus", "minus")) { op = new UnaryArithmeticOperator(joinApplyMeasuresOp); } else if (key == "unpivot") { op = new UnpivotOperator(ModelResolvers.DsResolver); } // --- else if (key == "calcExpr") { op = new CalcExprOperator(ModelResolvers.DsResolver); } else if (key == "collection") { op = new CollectionOperator(ModelResolvers.DsResolver); } else if (key == "datasetClause") { op = new DatasetClauseOperator(); } else if (key == "group") { op = new GroupOperator(ModelResolvers.DsResolver); } else if (key == "order") { op = new OrderOperator(ModelResolvers.DsResolver); } else if (key == "partition") { op = new PartitionOperator(ModelResolvers.DsResolver); } else if (key == "renameExpr") { op = new RenameExprOperator(ModelResolvers.DsResolver); } else if (key == "subExpr") { op = new SubspaceExprOperator(); } else if (key == "when") { op = new WhenOperator(); } else { throw new InvalidOperationException("Operator not found"); } op.Symbol = key; return(op); }); return(opResolverMock.Object); }