public void ReplaceHttpClient_HttpClientUriAndTimeoutWereSet() { //Arrange var services = new ServiceCollection(); services.AddDbContext <IKSqlDBContext, KSqlDBContext>(c => { c.UseKSqlDb(TestParameters.KsqlDBUrl); c.ReplaceHttpClient <IHttpClientFactory, HttpClientFactory>(httpClient => { httpClient.Timeout = TimeSpan.FromMinutes(5); }).AddHttpMessageHandler(_ => Mock.Of <DelegatingHandler>()); }); var provider = services.BuildServiceProvider(); //Act var httpClientFactory = provider.GetRequiredService <IHttpClientFactory>(); var httpClient = httpClientFactory.CreateClient(); //Assert httpClient.Timeout.Should().Be(TimeSpan.FromMinutes(5)); httpClient.BaseAddress !.OriginalString.Should().Be(TestParameters.KsqlDBUrl); }
private void Update(EvaluationContext context) { var content = OriginalString.GetValue(context); if (string.IsNullOrEmpty(content)) { Result.Value = string.Empty; return; } //const string pattern = @"(-)(\d+)(-)"; var pattern = SearchPattern.GetValue(context); var replace = Replace.GetValue(context).Replace("\\n", "\n"); try { Result.Value = Regex.Replace(content, pattern, replace, RegexOptions.Multiline | RegexOptions.Singleline); } catch (Exception) { Log.Error($"'{pattern}' is an incorrect search pattern", SymbolChildId); } }
public void RetrieveViaSQSReceiver() { var services = new ServiceCollection(); services.Configure <SQSReceiverOptions>(options => { }); services.AddSQSReceiver("myReceiver", options => { options.QueueUrl = new Uri("http://example.com"); options.Region = "us-west-2"; options.MaxMessages = 5; options.AutoAcknowledge = false; options.WaitTimeSeconds = 123; options.UnpackSNS = true; options.TerminateMessageVisibilityTimeoutOnRollback = true; }, false); var serviceProvider = services.BuildServiceProvider(); var receiver = serviceProvider.GetRequiredService <IReceiver>(); var sqsReceiver = receiver.Should().BeOfType <SQSReceiver>().Subject; sqsReceiver.Name.Should().Be("myReceiver"); sqsReceiver.QueueUrl !.OriginalString.Should().Be("http://example.com"); sqsReceiver.SQSClient.Config.RegionEndpoint.Should().Be(RegionEndpoint.USWest2); sqsReceiver.MaxMessages.Should().Be(5); sqsReceiver.AutoAcknwoledge.Should().BeFalse(); sqsReceiver.WaitTimeSeconds.Should().Be(123); sqsReceiver.UnpackSNS.Should().BeTrue(); sqsReceiver.TerminateMessageVisibilityTimeoutOnRollback.Should().BeTrue(); }
private void GetPictureUri() { string origin = OriginalString; if (origin.EndsWith(".jpg") || origin.EndsWith(".png") || origin.EndsWith(".png") || origin.EndsWith(".gif") || origin.EndsWith(".bmp") || origin.EndsWith(".tiff") || origin.EndsWith(".ico")) { PictureUri = this; } else if (Host == "imgur.com") { if (OriginalString.IndexOf("imgur.com/a/") == -1) { Match match = new Regex("imgur.com/").Match(OriginalString); if (match.Success) { string ID = OriginalString.Substring(match.Index + match.Length); if (ID != "") { PictureUri = new Uri("http://i.imgur.com/" + ID + ".png"); } } } } else if (Host == "i.imgur.com") { string str = OriginalString; if (str.IndexOf("i.imgur.com/a/") == -1) { Match match = new Regex("i.imgur.com/").Match(str); if (match.Success) { string ID = OriginalString.Substring(match.Index + match.Length); if (ID != "") { PictureUri = new Uri("http://i.imgur.com/" + ID + ".png"); } } } } }
protected override MutableObject Mutate(MutableObject mutable) { foreach (var entry in Scope.GetEntries(mutable)) { var stringToRemove = StringToRemoveField.GetValue(entry); var stringToTrim = OriginalString.GetValue(entry); var trimmedString = stringToTrim.TrimStart(stringToRemove); TargetString.SetValue(trimmedString, entry); } return(mutable); }
public override string ToString() { if (IsAbsoluteUri) { return(base.ToString()); } int index = OriginalString.IndexOfAny(_qf); if (index < 0) { return(((ParentPath == null) ? BaseName : ParentPath + "/" + BaseName) + Extension); } return(((ParentPath == null) ? BaseName : ParentPath + "/" + BaseName) + Extension + OriginalString.Substring(index)); }
protected override void Execute(CodeActivityContext executionContext) { // Get the input paramaters String originalString = OriginalString.Get <String>(executionContext); String comparitor = ComparisonString.Get <String>(executionContext); // Compare the inputted owner to comparison string then return true or false if (originalString.Equals(comparitor)) { EqualsString.Set(executionContext, true); } else { EqualsString.Set(executionContext, false); } }
private string RebuildFromOrigin() { string result = ""; string[] origin = OriginalString.Split(); long value; for (int i = 0; i < origin.Length; i++) { string word = origin[i].Replace(",", ""); if (Int64.TryParse(word, out value)) { origin[i] = numberToText.Convert(word); } } result = string.Join(" ", origin); return(result); }
public void CreateClient_BaseAddressWasSet() { //Arrange var httpClient = new HttpClient() { BaseAddress = new Uri(TestParameters.KsqlDBUrl) }; var httpClientFactory = new HttpClientFactory(httpClient); //Act var receivedHttpClient = httpClientFactory.CreateClient(); //Assert receivedHttpClient.Should().BeSameAs(httpClient); receivedHttpClient.Should().BeOfType <HttpClient>(); receivedHttpClient.BaseAddress !.OriginalString.Should().BeEquivalentTo(TestParameters.KsqlDBUrl); }
public static void SetLanguage(string language) { var dictionaryList = Current.Resources.MergedDictionaries .Select(res => (ResourceInclude)res) .ToList(); var resDictName = string.Format(@"Strings.{0}.axaml", language); var resDict = dictionaryList .FirstOrDefault(d => d.Source !.OriginalString.Contains(resDictName)); if (resDict == null) { resDict = dictionaryList.FirstOrDefault(d => d.Source !.OriginalString.Contains("Strings.axaml")); } if (resDict != null) { Current.Resources.MergedDictionaries.Remove(resDict); Current.Resources.MergedDictionaries.Add(resDict); } }
public override int GetHashCode() { unchecked { var hashCode = value.GetHashCode(); hashCode = (hashCode * 397) ^ duration.GetHashCode(); hashCode = (hashCode * 397) ^ OnVelocity.GetHashCode(); hashCode = (hashCode * 397) ^ OffVelocity.GetHashCode(); hashCode = (hashCode * 397) ^ IsPercussionNote.GetHashCode(); hashCode = (hashCode * 397) ^ IsRest.GetHashCode(); hashCode = (hashCode * 397) ^ IsStartOfTie.GetHashCode(); hashCode = (hashCode * 397) ^ IsEndOfTie.GetHashCode(); hashCode = (hashCode * 397) ^ IsFirstNote.GetHashCode(); hashCode = (hashCode * 397) ^ IsMelodicNote.GetHashCode(); hashCode = (hashCode * 397) ^ IsHarmonicNote.GetHashCode(); hashCode = (hashCode * 397) ^ IsDurationExplicitlySet.GetHashCode(); hashCode = (hashCode * 397) ^ IsOctaveExplicitlySet.GetHashCode(); hashCode = (hashCode * 397) ^ OriginalString.GetHashCode(); return(hashCode); } }
public static void SetTheme() { var light = Current.Resources.MergedDictionaries .Select(res => (ResourceInclude)res) .FirstOrDefault(d => d.Source !.OriginalString.Contains("LightTheme")); var dark = Current.Resources.MergedDictionaries .Select(res => (ResourceInclude)res) .FirstOrDefault(d => d.Source !.OriginalString.Contains("DarkTheme")); if (Core.Util.Preferences.Default.Theme == 0) { Current.Resources.MergedDictionaries.Remove(light); Current.Resources.MergedDictionaries.Add(light); } else { Current.Resources.MergedDictionaries.Remove(dark); Current.Resources.MergedDictionaries.Add(dark); } ThemeManager.LoadTheme(); }
public void RetrieveViaReloadingReceiver() { var reloadingReceiverType = Type.GetType("RockLib.Messaging.DependencyInjection.ReloadingReceiver`1, RockLib.Messaging", true)? .MakeGenericType(typeof(SQSReceiverOptions)); var services = new ServiceCollection(); services.Configure <SQSReceiverOptions>(options => { }); services.AddSQSReceiver("myReceiver", options => { options.QueueUrl = new Uri("http://example.com"); options.Region = "us-west-2"; options.MaxMessages = 5; options.AutoAcknowledge = false; options.WaitTimeSeconds = 123; options.UnpackSNS = true; options.TerminateMessageVisibilityTimeoutOnRollback = true; }, true); var serviceProvider = services.BuildServiceProvider(); var receiver = serviceProvider.GetRequiredService <IReceiver>(); receiver.Should().BeOfType(reloadingReceiverType); var sqsReceiver = (SQSReceiver)receiver.Unlock().Receiver; sqsReceiver.Name.Should().Be("myReceiver"); sqsReceiver.QueueUrl !.OriginalString.Should().Be("http://example.com"); sqsReceiver.SQSClient.Config.RegionEndpoint.Should().Be(RegionEndpoint.USWest2); sqsReceiver.MaxMessages.Should().Be(5); sqsReceiver.AutoAcknwoledge.Should().BeFalse(); sqsReceiver.WaitTimeSeconds.Should().Be(123); sqsReceiver.UnpackSNS.Should().BeTrue(); sqsReceiver.TerminateMessageVisibilityTimeoutOnRollback.Should().BeTrue(); }
/// <summary> /// Evaluates the binding. /// </summary> public object Evaluate(Controls.DotvvmBindableObject control, DotvvmProperty property) { if (Delegate != null) { return(ExecDelegate(control, true)); } if (!OriginalString.Contains(".")) { throw new Exception("Invalid resource name! Use Namespace.ResourceType.ResourceKey!"); } // parse expression var expressionText = OriginalString.Trim(); var lastDotPosition = expressionText.LastIndexOf(".", StringComparison.Ordinal); var resourceType = expressionText.Substring(0, lastDotPosition); var resourceKey = expressionText.Substring(lastDotPosition + 1); // find the resource manager var resourceManager = cachedResourceManagers.GetOrAdd(resourceType, GetResourceManager); // return the value return(resourceManager.GetString(resourceKey)); }
public override int GetHashCode() { return(OriginalString != null?OriginalString.GetHashCode() : 0); }
public Uri GetUriWithParameters(string query, int siteNumber = 1) { string formatedString = OriginalString.Replace(Query, WebUtility.UrlEncode(query)).Replace(SiteNumber, siteNumber.ToString()); return(new Uri(formatedString)); }
public override CodeceptAction Modify(CodeceptAction action) { //throw new NotImplementedException(); bool isFound = false; foreach (string head in HeaderString) { if (action.Script.StartsWith(head)) { isFound = true; break; } } var JSONObj = new Dictionary <string, string>(); if (isFound) { var target = ExtractSelector(action); //waitForElement({id:'usernamebox'},45) //{id:'inputEmail1'}, '*****@*****.**' //var split = target.Split(new string[] { ")." }, StringSplitOptions.None); var split = target.Split(','); //wait for use square barcket var sqr = split[0]; var prefix1 = string.Empty; if (sqr.StartsWith("'//")) { prefix1 = string.Format("waitByXPath({0},5);I.wait(1)", sqr); } else if (sqr.StartsWith("{xpath:")) { var orig = sqr; sqr = target; //{ xpath: "//*[@id="main - wrap"]/div[2]/div[1]/div[1]/div[2]/div[4]/div"} //sqr = BaiTextFilterClassLibrary.Helper.XpathHandleQuotes(sqr); ==> '{xpath:"//*[@id="main-wrap"]/div[2]/div[1]/div[1]/div[2]/div[4]/div"}' //var JSONObj = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(sqr); try { //JSONObj = JsonConvert.DeserializeObject<Dictionary<string, string>>(sqr); JSONObj = JsonConvert.DeserializeObject <Dictionary <string, string> >(sqr); } catch (Exception) { sqr = sqr.Replace("=\"", "='"); sqr = sqr.Replace("\"]", "']"); JSONObj = JsonConvert.DeserializeObject <Dictionary <string, string> >(sqr); } var xpath = JSONObj["xpath"]; sqr = string.Format("{0}", xpath); sqr = BaiTextFilterClassLibrary.Helper.XpathHandleQuotes(sqr); prefix1 = string.Format("waitByXPath({0},5);I.wait(1)", sqr); #region MAYBE NOT NEEDED ////{"xpath":"(//input[@value=''])[2]"}, 5 //string[] delimeter = new string[] { "])" }; //var split0 = sqr.Split(delimeter, StringSplitOptions.None); ////{"xpath":"(//input[@value=''])[2] //var sqr1 = split0[0]; //delimeter = new string[] { "//" }; //var split1 = sqr1.Split(delimeter, StringSplitOptions.None); //var sqr2 = ""; //if (split1.Length > 1) //{ // //input[@value=''])[2] // sqr2 = split1[1]; // sqr = "//" + sqr2 + "]"; //} //else //{ // //TIP: xpath // //{xpath:"/html/body/div[6]/div[2]/div[1]/div[1]/div[2]/div[4]/div"} // // should transform to ==>> '//html/body/div[6]/div[2]/div[1]/div[1]/div[2]/div[4]/div' // // var JSONObj = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(sqr); // // var xpath = JSONObj["xpath"]; // sqr = string.Format("{0}", xpath); // //I.waitByXPath('//html/body/div[6]/div[2]/div[1]/div[1]/div[2]/div[4]/div',5) //} //sqr = BaiTextFilterClassLibrary.Helper.XpathHandleQuotes(sqr); //prefix1 = string.Format("waitByXPath({0},5);I.wait(1)", sqr); #endregion } else if (sqr.StartsWith("{")) { var sqrContent = sqr.Substring(1, sqr.Length - 2); sqrContent = sqrContent.Replace(":", "="); sqrContent = sqrContent.Replace("'", "\""); sqrContent = "'[" + sqrContent + "]'"; sqr = sqrContent; prefix1 = string.Format("waitByElement({0})", sqr); } else { // var prefix1 =string.Format("waitForElement({0},45)",split[0]); prefix1 = string.Format("waitForElement({0},45)", sqr); } //var prefix1 =string.Format("waitByElement({0})",split[0]); //retry({ retries: 3, maxTimeout: 3000 }).click({id:'usernamebox'} var prefix2 = @"retry({ retries: 3, maxTimeout: 3000 })";//string.Format("retry({ retries: 3, maxTimeout: 3000 })"); //fillField({id:'usernamebox'} OriginalString = action.Script; var newScript = string.Empty; if (IsSemanticLocator(target)) { if (OriginalString.StartsWith("mouseClick(")) //mousceclick(posxy) { newScript = string.Format("{0}", OriginalString); //wait is handle by click codecept } else //click('login'); { //newScript = string.Format("{0}.see({1});I.{2};I.wait({3});", prefix2, target, OriginalString, DefaultWait); newScript = string.Format("{0};I.wait({1});", OriginalString, DefaultWait); } } else { newScript = string.Format("{0};I.{1}.{2};I.wait({3})", prefix1, prefix2, OriginalString, DefaultWait); } Console.WriteLine(newScript); action.Script = newScript; } return(action); }
public override int GetHashCode() { return(OriginalString.GetHashCode()); }
public OffsetString(OriginalString orig, int offset) { this.orig = orig; this.offset = offset; }
public override bool Equals(object obj) { return(OriginalString.Equals((obj as OM2MUri).OriginalString)); }
private void parseComponents(string url) { if (isRelativeRestUrl(url) || isAbsoluteRestUrl(url)) { var uri = new Uri(url, UriKind.RelativeOrAbsolute); string localPath = uri.IsAbsoluteUri ? uri.LocalPath : url; var components = localPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); int count = components.Length; if (count < 2) { return; // unparseable } var history = -1; for (var index = 0; index < count; index++) { if (components[index] == TransactionBuilder.HISTORY) { history = index; } } if (history > -1 && history == count - 1) { return; // illegal use, there's just a _history component, but no version id } int resourceTypePos = (history > -1) ? history - 2 : count - 2; ResourceType = components[resourceTypePos]; Id = components[resourceTypePos + 1]; if (uri.IsAbsoluteUri) { var baseUri = url.Substring(0, url.IndexOf(ResourceType + "/" + Id)); if (!baseUri.EndsWith("/")) { baseUri += "/"; } BaseUri = new Uri(baseUri, UriKind.Absolute); } if (history != -1 && count >= 4 && history < count - 1) { VersionId = components[history + 1]; } Form = uri.IsAbsoluteUri ? ResourceIdentityForm.AbsoluteRestUrl : ResourceIdentityForm.RelativeRestUrl; } else if (isUrn(url)) { int lastSep = 8; if (url.StartsWith("urn:uuid:")) { lastSep = 8; } if (url.StartsWith("urn:oid:")) { lastSep = 7; } BaseUri = new Uri(url.Substring(0, lastSep + 1), UriKind.Absolute); Id = OriginalString.Substring(lastSep + 1); Form = ResourceIdentityForm.Urn; } else if (isLocal(url)) { Id = OriginalString.Substring(1); // strip '#' Form = ResourceIdentityForm.Local; } }
/// <summary> /// Evaluates the binding. /// </summary> public object Evaluate(Controls.DotvvmBindableObject control, DotvvmProperty property) { if (Delegate != null) { return(ExecDelegate(control, true)); } // parse expression string resourceType = ""; // check value var expressionText = OriginalString?.Trim(); if (string.IsNullOrWhiteSpace(expressionText)) { throw new Exception("Resource binding contains empty string."); } GetDirectives(control); // check directives combination if (!string.IsNullOrWhiteSpace(ResourceTypeDirectiveValue) && !string.IsNullOrWhiteSpace(ResourceNamespaceDirectiveValue)) { throw new Exception("@resourceType and @resourceNamespace directives cannot be used in the same time!"); } // check type directive string resourceKey = ""; if (!string.IsNullOrWhiteSpace(ResourceTypeDirectiveValue)) { if (!ResourceTypeDirectiveValue.Contains(",")) { throw new Exception($"Assembly of resource type '{expressionText}' was not recognized. Specify make sure the directive value is in format: Assembly, Namespace.ResourceType"); } if (!ResourceTypeDirectiveValue.Contains(".")) { throw new Exception($"Resource {expressionText} was not found. Specify make sure the directive value is in format: Assembly, Namespace.ResourceType"); } if (!expressionText.Contains(".")) { resourceType = ResourceTypeDirectiveValue; resourceKey = expressionText; } else { var lastDotPosition = expressionText.LastIndexOf(".", StringComparison.Ordinal); resourceType = expressionText.Substring(0, lastDotPosition); resourceKey = expressionText.Substring(lastDotPosition + 1); } } else if (!string.IsNullOrWhiteSpace(ResourceNamespaceDirectiveValue)) { if (ResourceNamespaceDirectiveValue.Contains(",")) { throw new Exception($"@resourceNamespace {ResourceNamespaceDirectiveValue} contains unexpected charachter ','"); } if (expressionText.Contains(".")) { var lastDotPosition = expressionText.LastIndexOf(".", StringComparison.Ordinal); resourceType = expressionText.Substring(0, lastDotPosition); resourceKey = expressionText.Substring(lastDotPosition + 1); } else { throw new Exception($"Resource '{expressionText}' does not specify resource class or resource key. Make sure that format of expression is: OptionalNamespace.ResourceType.ResourceKey"); } } else { if (expressionText.Contains(".")) { var lastDotPosition = expressionText.LastIndexOf(".", StringComparison.Ordinal); resourceType = expressionText.Substring(0, lastDotPosition); resourceKey = expressionText.Substring(lastDotPosition + 1); } else { throw new Exception($"Resource '{expressionText}' does not specify resource class or resource key. Make sure that format of expression is: Namespace.ResourceType.ResourceKey"); } } // find the resource manager var resourceManager = cachedResourceManagers.GetOrAdd(resourceType, GetResourceManager); if (resourceManager == null) { resourceManager = cachedResourceManagers.GetOrAdd(ResourceNamespaceDirectiveValue + "." + resourceType, GetResourceManager); } if (resourceManager == null) { throw new Exception($"The resource file '{resourceType}' was not found! Make sure that your resource file has Access Modifier set to Public or Internal."); } // return the value var value = resourceManager.GetString(resourceKey); if (value == null) { throw new Exception($"Resource '{expressionText}' was not found."); } return(value); }
private string ResolvePrimaryServiceRoot(string RequestUri, FhirUri fhirUri) { string RequestRelativePath; if (RequestUri.StripHttp().ToLower().StartsWith(fhirUri.PrimaryServiceRootServers !.OriginalString.StripHttp().ToLower())) { //If the request URL starts with our known servers root then cut it off and return relative part , job done. fhirUri.IsRelativeToServer = true; RequestUri = RequestUri.StripHttp(); string PrimaryServiceRootServers = fhirUri.PrimaryServiceRootServers !.OriginalString.StripHttp(); RequestRelativePath = RequestUri.Substring(PrimaryServiceRootServers.Count(), RequestUri.Count() - PrimaryServiceRootServers.Count()); if (RequestRelativePath.StartsWith("/")) { RequestRelativePath = RequestRelativePath.TrimStart('/'); } return(RequestRelativePath); }