public MatterDetail(SplitController split, Finder finder) : base(UITableViewStyle.Grouped, null, true) { this.split = split; this.finder = finder; // Autorotate = true; deviceType = DeviceTypeUtil.getDeviceType (); setButtons (); BuildInterface (); // var model = UIDevice.CurrentDevice.Model.ToString (); var name = UIDevice.CurrentDevice.Name.ToString (); RectangleF rec = UIScreen.MainScreen.Bounds; Console.WriteLine ("Device", "Name: " + name + " model: " + model + " Screen Width: " + rec.Width + " Height: " + rec.Height); // if (searchResult != null) { if (matter == null) { GetMatterDetails (); } else { enableButtons (); } } }
public IList<Pattern> GetPatternsFor(Insulin insulin, Meal meal, Sugar currentBefore = null) { var patterns = new List<Pattern>(); finder = factories.Finder; settings = factories.Settings; searchedInsulin = insulin; searchedMeal = meal; searchedItems = meal.NormalizedItems(); searchedSugarBefore = currentBefore; foreach (var testMeal in factories.Meals.Where(m => m != searchedMeal)) { var mealHasMatch = testMeal.Items.Any(item => searchedItems.Any(searchedItem => item.ProductId == searchedItem.ProductId && item.Unit == searchedItem.Unit)); if (mealHasMatch) foreach (var item in testMeal.NormalizedItems()) foreach (var searchedItem in searchedItems) if (item.ProductId == searchedItem.ProductId && item.Unit == searchedItem.Unit) { this.searchedItem = searchedItem; this.item = item; this.meal = testMeal; if (ConsiderPattern()) patterns.Add(BuildPattern()); } } return patterns; }
public static void Main (string[] args) { Finder finder = new Finder (); string teststr = "abcd"; char[] testchar = teststr.ToCharArray (); finder.FindPermutation (testchar); }
static void decode_path(Finder f, long path_id) { path_units = f.GetPathUnits(path_id); //Console.WriteLine("Path units : {0}", path_units); //Console.ReadLine(); long count = f.GetPathCurveCount(path_id); //Console.Write("Number of Path Curves: "); //Console.WriteLine(count); for (long i = 0; i < count; ++i) { //include else statement for GetPathArc and code for it as well bool isArc; long cve_id = f.GetPathCurveNext(path_id, i, out isArc); if(!isArc) { long count2 = f.GetPathPolylinePointCount(cve_id); for (int j = 0; j < count2; ++j) { double x, y, z; f.GetPathPolylinePointNext(cve_id, j, out x, out y, out z); if (happenedOnce) { calc_min_max_vertices(x, y, z); } else { xmin = xmax = x; ymin = ymax = y; zmin = zmax = z; happenedOnce = true; } } } //NEED LOGIC TO HANDLE ARCS AND COMPUTE X,Y,Z //MAXES AND MINS FROM THE DATA //(for now ignore arcs says Professor Hardwick) else { /*double x; double y; double z; double cx; double cy; double cz; double radius; bool ccw; f.GetPathArc(cve_id, out x, out y, out z, out cx, out cy, out cz, out radius, out ccw);*/ //How do i figure out where the arc exists? I only have the end point. //(Maybe use last point from polyline code as starting point?) Console.WriteLine("isArc"); //This readline is here to halt the output so that //I can see if one of these arcs ever exists in any //of my test cases. //Console.ReadLine(); } } }
public void Returns_Furthest_Two_For_Four_People() { var list = new List<Person>() { greg, mike, sarah, sue }; var finder = new Finder(list); var result = finder.Find(FindType.FurthestAge); Assert.Same(sue, result.YongerPerson); Assert.Same(sarah, result.OlderPerson); }
public void Returns_Closest_Two_For_Two_People() { var list = new List<Person>() { sue, greg }; var finder = new Finder(list); var result = finder.Find(FindType.MinimumDiff); Assert.Same(sue, result.Person1); Assert.Same(greg, result.Person2); }
public void Returns_Empty_Results_When_Given_Empty_List() { var list = new List<Person>(); var finder = new Finder(list); var result = finder.Find(By.Closest); Assert.Null(result.Younger); Assert.Null(result.Older); }
public void Returns_Empty_Results_When_Given_Empty_List() { var list = new List<Person>(); var finder = new Finder(list); var result = finder.Find(FindThe.Closest); Assert.Null(result.Person1); Assert.Null(result.Person2); }
public void Returns_Closest_Two_For_Two_People() { var list = new List<Person>() { sue, greg }; var finder = new Finder(list); var result = finder.Find(ResultType.Closest); Assert.Same(sue, result.PersonOne); Assert.Same(greg, result.PersonTwo); }
public void Returns_Furthest_Two_For_Two_People() { var list = new List<Person>() { greg, mike }; var finder = new Finder(list); var result = finder.Find(ResultType.Furthest); Assert.Same(greg, result.PersonOne); Assert.Same(mike, result.PersonTwo); }
public void ReturnsFurthestTwoForTwoPeople() { var list = new List<Person> { greg, mike }; var finder = new Finder(list); var result = finder.Find(FinderType.Furthest); Assert.Same(greg, result.YoungerPerson); Assert.Same(mike, result.OlderPerson); }
public void Returns_Empty_Results_When_Given_One_Person() { var list = new List<Thing>() { sue }; var finder = new Finder(list); var result = finder.Find(FT.One); Assert.Null(result.P1); Assert.Null(result.P2); }
public void ReturnsClosestTwoForTwoPeople() { var list = new List<Person> { sue, greg }; var finder = new Finder(list); var result = finder.Find(FinderType.Closest); Assert.Same(sue, result.YoungerPerson); Assert.Same(greg, result.OlderPerson); }
public void Returns_Furthest_Two_For_Four_People() { var list = new List<Thing>() { greg, mike, sarah, sue }; var finder = new Finder(list); var result = finder.Find(FT.Two); Assert.AreEqual(sue, result.P1); Assert.AreEqual(sarah, result.P2); }
public void Returns_Closest_Two_For_Two_People() { var list = new List<Person>() { sue, greg }; var finder = new Finder(list); var result = finder.FindRelationship(FT.One); Assert.Same(sue, result.Person1); Assert.Same(greg, result.Person2); }
public void Returns_Furthest_Two_For_Two_People() { var list = new List<Person>() { greg, mike }; var finder = new Finder(list); var result = finder.FindRelationship(FT.Two); Assert.Same(greg, result.Person1); Assert.Same(mike, result.Person2); }
public void Returns_Empty_Results_When_Given_One_Person() { var list = new List<Person>() { sue }; var finder = new Finder(list); var result = finder.FindRelationship(FT.One); Assert.Null(result.Person1); Assert.Null(result.Person2); }
public void ReturnsEmptyResultsWhenGivenOnePerson() { var list = new List<Person> { sue }; var finder = new Finder(list); var result = finder.Find(FinderType.Closest); Assert.Null(result.YoungerPerson); Assert.Null(result.OlderPerson); }
public void Returns_Empty_Results_When_Given_One_Person() { var list = new List<Person>() { sue }; var finder = new Finder(list); var result = finder.Find(FindType.MinimumDiff); Assert.Null(result.Person1); Assert.Null(result.Person2); }
public void Returns_Closest_Two_For_Two_People() { var list = new List<Thing>() { sue, greg }; var finder = new Finder(list); var result = finder.Find(FT.One); Assert.Same(sue, result.P1); Assert.Same(greg, result.P2); }
public void Returns_Furthest_Two_For_Two_People() { var list = new List<Person>() { greg, mike }; var finder = new Finder(list); var result = finder.Find(FindType.MaximumDiff); Assert.Same(greg, result.Person1); Assert.Same(mike, result.Person2); }
public void Returns_Furthest_Two_For_Two_People() { var list = new List<Thing>() { greg, mike }; var finder = new Finder(list); var result = finder.Find(FT.Two); Assert.Same(greg, result.P1); Assert.Same(mike, result.P2); }
public void Returns_Closest_Two_For_Four_People() { var list = new List<Person>() { greg, mike, sarah, sue }; var finder = new Finder(list); var result = finder.Find(By.Closest); Assert.Same(sue, result.Younger); Assert.Same(greg, result.Older); }
public void Returns_Empty_Results_When_Given_One_Person() { var list = new List<Person>() { sue }; var finder = new Finder(list); var result = finder.Find(ResultType.Closest); Assert.Null(result.PersonOne); Assert.Null(result.PersonTwo); }
public void Returns_Furthest_Two_For_Two_People() { var list = new List<Person>() { greg, mike }; var finder = new Finder(list); var result = finder.Find(FindType.FurthestInAge); Assert.Same(greg, result.OlderPerson); Assert.Same(mike, result.YoungerPerson); }
public void Returns_Furthest_Two_For_Four_People() { var list = new List<Thing>() { greg, mike, sarah, sue }; var finder = new Finder(list); var result = finder.FindFurthest(); Assert.Same(sue, result.Oldest); Assert.Same(sarah, result.Youngest); }
/// <summary> /// Enumerates the elements of the list that satisfy f /// </summary> public static IEnumerable<String> FilterList(List<String> list, Finder f) { foreach (String s in list) { if (f(s)) { yield return s; } } }
public void Returns_Closest_Two_For_Four_People() { var list = new List<Thing>() { greg, mike, sarah, sue }; var finder = new Finder(list); var result = finder.Find(FT.One); Assert.AreSame(sue, result.P1); Assert.AreSame(greg, result.P2); }
public void Returns_Empty_Results_When_Given_One_Person() { var list = new List<Person>() { sue }; var finder = new Finder(list); var result = finder.Find(FindType.ClosestInAge); Assert.Null(result.OlderPerson); Assert.Null(result.YoungerPerson); }
public void Returns_Closest_Two_For_Two_People() { var list = new List<Person>() { sue, greg }; var finder = new Finder(list); var result = finder.Find(FindType.ClosestInAge); Assert.Same(sue, result.OlderPerson); Assert.Same(greg, result.YoungerPerson); }
private void Start() { game = Finder.GetGameController(); }
private List <Cell> findResourcesForDwelling(Dictionary <Resource, int> missingTreasury, Cell dwelling, Resource resource, List <Cell> finderCells) { var subCellType = new SubCellType(); switch (resource) { case Resource.Ebony: subCellType = SubCellType.ResourceEbony; break; case Resource.Iron: subCellType = SubCellType.ResourceIron; break; case Resource.Glass: subCellType = SubCellType.ResourceGlass; break; } var resultCellsList = new List <Cell>(); var foundedCells = finderCells.Where(o => (o.CellType.SubCellType == SubCellType.ResourceGold && o.ResourcesValue > 0) && !o.Value.Equals(Single.MaxValue) && !resultCellsList.Contains(o)).OrderBy(o => o.Value).ToList(); for (int i = 0; i < foundedCells.Count && missingTreasury[Resource.Gold] > 0; i++) { var cell = foundedCells.ElementAt(i); resultCellsList.Add(cell); missingTreasury[Resource.Gold] = missingTreasury[Resource.Gold] - cell.ResourcesValue; } if (resource != Resource.Gold) { foundedCells = finderCells.Where(o => (o.CellType.SubCellType == subCellType || o.ResourcesValue > 0) && !o.Value.Equals(Single.MaxValue) && !resultCellsList.Contains(o)).OrderBy(o => o.Value).ToList(); for (int i = 0; i < foundedCells.Count && missingTreasury[resource] > 0; i++) { var cell = foundedCells.ElementAt(i); resultCellsList.Add(cell); missingTreasury[resource] = missingTreasury[resource] - cell.ResourcesValue; } } var cellPath = new List <Cell>(); if (resultCellsList.Count <= 0) { return(cellPath); } cellPath.AddRange(_finder.GetSmartPath(SensorData.Location.CreateCell(), resultCellsList[0])); for (int y = 1; y < resultCellsList.Count; y++) { var finderNew = new Finder(finderCells, resultCellsList[y]); cellPath.AddRange(finderNew.GetSmartPath(resultCellsList[y - 1], resultCellsList[y])); } var finderToEnd = new Finder(finderCells, resultCellsList[resultCellsList.Count - 1]); cellPath.AddRange(finderToEnd.GetSmartPath(resultCellsList[resultCellsList.Count - 1], dwelling)); return(cellPath); }
public virtual Image WinFormImage(string primaryIdentification, IActionListener actionListener) { AutomationElement element = Finder.Descendant(SearchCriteria.ByAutomationId(primaryIdentification).AutomationCondition); return(new Image(element, actionListener)); }
public IFoundPeak CalcPeak(int startIndex, int endIndex) { return(Finder.GetPeak(startIndex, endIndex)); }
public async override Task OnReceiveActivity(IBotContext context) { // IMAGE var image = context.Get <ImageRecognizeResult>(ImageMiddleware.ImageRecognizerResultKey); if (image != null) { await context.SendActivity("Thaks for sending me a photo!\nLet's see..."); var keyword = image.PrimaryKeyword(); var finder = new Finder(); var result = await finder.SearchWithKeywordAsync(keyword); if (result != null) { SearcherFeedbackState = true; var activity = createReply(context, result); await context.SendActivity(activity); await context.SendActivity("Did you find what you ware looking for?"); return; } } if ((context.Request.Type == ActivityTypes.Message) && (context.Request.AsMessageActivity().Text.Length > 0)) { var message = context.Request.AsMessageActivity(); var qnamaker = new QnaMaker(); // If there is an active topic, let it handle this turn until it completes. if (HasActiveTopic) { await ActiveTopic.OnReceiveActivity(context); return; } if (!SearcherFeedbackState) { await context.SendActivity("Got it!"); } // CHIT var chitchater = new ChitChater(); var answer = await chitchater.SearchChitChat(message.Text); if (answer != null) { await context.SendActivity(answer); return; } // Feedback if (SearcherFeedbackState) { SearcherFeedbackState = false; var feedbacker = new Feedbacker(); var feedback = await feedbacker.SearchAsync(message.Text); if (feedback == Feedbacker.INTENT.FEEDBACK_NEGATIVE) { await context.SendActivity("Sorry, but could you try agein using another term?"); return; } else if (feedback == Feedbacker.INTENT.FEEDBACK_POSITIVE) { await context.SendActivity("No problem!"); return; } // Not reterun and continue next line when you get NOEN intent. } // SelectQuestion if (SelectQuestionState) { if (int.TryParse(message.Text, out i) && (i < 4)) { var selectquestion = questionlist[i]; var selectanswer = await qnamaker.SearchQnaMaker(selectquestion); await context.SendActivity(selectanswer.First().Answer); SelectQuestionState = false; SearcherFeedbackState = true; return; } else if (turn < maxturn) { await context.SendActivity("Sorry,but please input number(1 - 4)"); turn += 1; return; } else { SelectQuestionState = false; await context.SendActivity("too many attempts"); await context.SendActivity("OK! You may change your mind."); return; } } // QnA qnamaker = new QnaMaker(); var queryresults = await qnamaker.SearchQnaMaker(message.Text); if (queryresults != null) { if (queryresults.First().Questions.Count() == 1) { SearcherFeedbackState = true; await context.SendActivity(queryresults.First().Answer); return; } else { SelectQuestionState = true; SearcherFeedbackState = true; var messages = "Did you mean? Please input number(1 - 4)"; foreach (var q in queryresults.First().Questions.Select((value, index) => new { value, index })) { if (q.index > 2) { messages += "\n\n" + "\n\n" + (q.index + 1) + ".None of adove"; questionlist.Add(queryresults.First().Questions[q.index]); break; } messages += "\n\n" + "\n\n" + (q.index + 1) + "." + queryresults.First().Questions[q.index].ToString(); questionlist.Add(queryresults.First().Questions[q.index]); } await context.SendActivity(messages); return; } } // Search var finder = new Finder(); var result = await finder.SearchAsync(message.Text); if (result != null) { SearcherFeedbackState = true; var activity = createReply(context, result); await context.SendActivity(activity); await context.SendActivity("Did you find what you ware looking for?"); return; } await context.SendActivity("Sorry, but I didn't understand that. Could you try saying that another way?"); } }
public void FindNextMethod_NumberIsNegative_ArgumentException() { int number = -5; Assert.Throws <ArgumentOutOfRangeException>(() => Finder.FindNextBiggerNumber(number)); }
public int Run(string[] args) { DosErrorLevel dosErrorLevel; _options = new CommandLineOptions(); if (!CommandLine.Parser.Default.ParseArguments(args, _options)) { Console.ReadKey(); Environment.Exit(1); } var validationResultList = new List <ValidationResult>(); validationResultList.Add(ValidationUtils.IsDirValid(_options.Dir, "dir")); validationResultList.Add(ValidationUtils.IsNotEmpty(_options.FileMask, "fileMask")); validationResultList.Add(ValidationUtils.IsNotEmpty(_options.FindText, "find")); validationResultList.Add(ValidationUtils.IsNotEmpty(_options.FindText, "find")); if (_options.IsFindTextHasRegEx) { validationResultList.Add(ValidationUtils.IsValidRegExp(_options.FindText, "find")); } if (!(String.IsNullOrEmpty(_options.AlwaysUseEncoding))) { validationResultList.Add(ValidationUtils.IsValidEncoding(_options.AlwaysUseEncoding, "alwaysUseEncoding")); } if (!(String.IsNullOrEmpty(_options.DefaultEncodingIfNotDetected))) { validationResultList.Add(ValidationUtils.IsValidEncoding(_options.DefaultEncodingIfNotDetected, "alwaysUseEncoding")); } if (_options.UseEscapeChars) { validationResultList.Add(ValidationUtils.IsValidEscapeSequence(_options.FindText, "find")); if (!String.IsNullOrEmpty(_options.ReplaceText)) { validationResultList.Add(ValidationUtils.IsValidEscapeSequence(_options.ReplaceText, "replace")); } } if (!String.IsNullOrEmpty(_options.LogFile)) { var fs1 = new FileStream(_options.LogFile, FileMode.Create); var sw1 = new StreamWriter(fs1); Console.SetOut(sw1); } Console.WriteLine(""); if (validationResultList.Any(vr => !vr.IsSuccess)) { foreach (var validationResult in validationResultList) { if (!validationResult.IsSuccess) { Console.WriteLine(String.Format("{0}: {1}", validationResult.FieldName, validationResult.ErrorMessage)); } } Console.WriteLine(""); dosErrorLevel = DosErrorLevel.FatalError; } else { dosErrorLevel = DosErrorLevel.Success; bool hasRegEx = _options.IsFindTextHasRegEx; if (_options.ReplaceText == null) { var finder = new Finder(); finder.Dir = _options.Dir; finder.IncludeSubDirectories = _options.IncludeSubDirectories; finder.FileMask = _options.FileMask; finder.ExcludeFileMask = _options.ExcludeFileMask; finder.FindText = CommandLineUtils.DecodeText(_options.FindText, false, hasRegEx, _options.UseEscapeChars); finder.IsCaseSensitive = _options.IsCaseSensitive; finder.FindTextHasRegEx = hasRegEx; finder.SkipBinaryFileDetection = _options.SkipBinaryFileDetection; finder.IncludeFilesWithoutMatches = _options.IncludeFilesWithoutMatches; finder.AlwaysUseEncoding = Utils.GetEncodingByName(_options.AlwaysUseEncoding); finder.DefaultEncodingIfNotDetected = Utils.GetEncodingByName(_options.DefaultEncodingIfNotDetected); finder.UseEscapeChars = _options.UseEscapeChars; finder.IsSilent = _options.Silent; finder.FileProcessed += OnFinderFileProcessed; var findResult = finder.Find(); if (_options.SetErrorLevelIfAnyFileErrors) { if (findResult.Stats.Files.FailedToRead > 0) { dosErrorLevel = DosErrorLevel.ErrorsInSomeFiles; } } } else { var replacer = new Replacer(); replacer.Dir = _options.Dir; replacer.IncludeSubDirectories = _options.IncludeSubDirectories; replacer.FileMask = _options.FileMask; replacer.ExcludeFileMask = _options.ExcludeFileMask; replacer.FindText = CommandLineUtils.DecodeText(_options.FindText, false, hasRegEx, _options.UseEscapeChars); replacer.IsCaseSensitive = _options.IsCaseSensitive; replacer.FindTextHasRegEx = _options.IsFindTextHasRegEx; replacer.SkipBinaryFileDetection = _options.SkipBinaryFileDetection; replacer.IncludeFilesWithoutMatches = _options.IncludeFilesWithoutMatches; replacer.ReplaceText = CommandLineUtils.DecodeText(_options.ReplaceText, true, _options.IsFindTextHasRegEx, _options.UseEscapeChars); replacer.AlwaysUseEncoding = Utils.GetEncodingByName(_options.AlwaysUseEncoding); replacer.DefaultEncodingIfNotDetected = Utils.GetEncodingByName(_options.DefaultEncodingIfNotDetected); replacer.UseEscapeChars = _options.UseEscapeChars; replacer.IsSilent = _options.Silent; replacer.FileProcessed += OnReplacerFileProcessed; var replaceResult = replacer.Replace(); if (_options.SetErrorLevelIfAnyFileErrors) { if (replaceResult.Stats.Files.FailedToRead > 0 || replaceResult.Stats.Files.FailedToWrite > 0) { dosErrorLevel = DosErrorLevel.ErrorsInSomeFiles; } } } } if (!String.IsNullOrEmpty(_options.LogFile)) { Console.Out.Close(); } #if (DEBUG) Console.ReadLine(); #endif return((int)dosErrorLevel); }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public override ValueTask <TEntity> FindAsync(object[] keyValues, CancellationToken cancellationToken) => Finder.FindAsync(keyValues, cancellationToken);
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public override ValueTask <TEntity> FindAsync(params object[] keyValues) => Finder.FindAsync(keyValues);
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public override TEntity Find(params object[] keyValues) => Finder.Find(keyValues);
public void Test2() { string c = Finder.FindFirstRecurring("abcdef"); Assert.True(string.IsNullOrWhiteSpace(c)); }
public void SetUpFinderTests() { finder = new Finder(); }
/// <summary> /// <para> /// Queries the database for copies of the values of the tracked entity as they currently /// exist in the database. If the entity is not found in the database, then null is returned. /// </para> /// <para> /// Note that changing the values in the returned dictionary will not update the values /// in the database. /// </para> /// <para> /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure /// that any asynchronous operations have completed before calling another method on this context. /// </para> /// </summary> /// <param name="cancellationToken"> /// A <see cref="CancellationToken" /> to observe while waiting for the task to complete. /// </param> /// <returns> /// A task that represents the asynchronous operation. The task result contains the store values, /// or null if the entity does not exist in the database. /// </returns> public virtual async Task <PropertyValues> GetDatabaseValuesAsync(CancellationToken cancellationToken = default(CancellationToken)) { var values = await Finder.GetDatabaseValuesAsync(InternalEntry, cancellationToken); return(values == null ? null : new ArrayPropertyValues(InternalEntry, values)); }
private async void Install(object sender, EventArgs e) { try { string[] directories = Finder.FindDirectoryWhichExists(INSTALLING_PATH, BUS_EXT); List <string> files = new List <string>(); foreach (string toadd in HofInstallList.CheckedItems) { files.Add($@"{HOF_PATH}\{toadd}"); } int size = directories.Length * files.Count; InstallingProgress.Visible = true; InstallingProgress.Maximum = size; Size = new Size(638, 600); foreach (string directory in directories) { foreach (string file in files) { try { await Task.Run(() => { File.Copy(file, $@"{directory}\{Path.GetFileName(file)}", true); InstallingProgress.Value += 1; }); } catch (Exception) { string title = "Error!"; string message = "Unknown error"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(message, title, buttons, MessageBoxIcon.Error); } } } if (InstallingProgress.Value == size) { OMSI omsi = new OMSI() { Opacity = 0 }; omsi.StatusLbl.Text = "Installing was successful!"; omsi.StatusPctr.Image = Resources.Success; omsi.Show(); for (int i = 0; i < 10; i++) { Thread.Sleep(25); Opacity -= 0.1; } for (int i = 0; i < 10; i++) { Thread.Sleep(25); omsi.Opacity += 0.1; } Close(); } else { OMSI omsi = new OMSI() { Opacity = 0 }; omsi.StatusLbl.Text = "Something went wrong..."; omsi.StatusPctr.Image = Resources.Wrong; omsi.Show(); for (int i = 0; i < 10; i++) { Thread.Sleep(25); Opacity -= 0.1; } for (int i = 0; i < 10; i++) { Thread.Sleep(25); omsi.Opacity += 0.1; } Close(); } } catch (Exception) { string title = "Error!"; string message = "This application need to exists in root folder of OMSI. Reinstall the OMSI2 Tools or try start this app as administrator."; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(message, title, buttons, MessageBoxIcon.Error); } }
public MutexController() { sorter = new Sorter <T>(this); finder = new Finder <T>(); }
private void CreateListener(Finder finder) { _finder = finder; _finder.FileProcessed += OnFinderFileProcessed; }
public void SetExplicitPeakBounds(PeakBounds peakBounds) { Finder = Crawdads.NewCrawdadPeakFinder(); Finder.SetChromatogram(Times, Intensities); RawPeaks = new [] { Finder.GetPeak(TimeToIndex(peakBounds.StartTime), TimeToIndex(peakBounds.EndTime)) }; }
private void Start() { levelLoader = Finder.GetLevelLoader(); }
public virtual UIItemCollection CreateAll(SearchCriteria searchCriteria, IActionListener actionListener) { return(new UIItemCollection(Finder.Descendants(searchCriteria.AutomationSearchCondition), actionListener, searchCriteria.CustomItemType)); }
protected override IndentationResult?GetDesiredIndentationWorker( SyntaxToken token, TextLine previousLine, int lastNonWhitespacePosition) { // okay, now check whether the text we found is trivia or actual token. if (token.Span.Contains(lastNonWhitespacePosition)) { // okay, it is a token case, do special work based on type of last token on previous line return(GetIndentationBasedOnToken(token)); } else { // there must be trivia that contains or touch this position Contract.Assert(token.FullSpan.Contains(lastNonWhitespacePosition)); // okay, now check whether the trivia is at the beginning of the line var firstNonWhitespacePosition = previousLine.GetFirstNonWhitespacePosition(); if (!firstNonWhitespacePosition.HasValue) { return(IndentFromStartOfLine(0)); } var trivia = Tree.GetRoot(CancellationToken).FindTrivia(firstNonWhitespacePosition.Value, findInsideTrivia: true); if (trivia.Kind() == SyntaxKind.None || this.LineToBeIndented.LineNumber > previousLine.LineNumber + 1) { // If the token belongs to the next statement and is also the first token of the statement, then it means the user wants // to start type a new statement. So get indentation from the start of the line but not based on the token. // Case: // static void Main(string[] args) // { // // A // // B // // $$ // return; // } var containingStatement = token.GetAncestor <StatementSyntax>(); if (containingStatement != null && containingStatement.GetFirstToken() == token) { var position = GetCurrentPositionNotBelongToEndOfFileToken(LineToBeIndented.Start); return(IndentFromStartOfLine(Finder.GetIndentationOfCurrentPosition(Tree, token, position, CancellationToken))); } // If the token previous of the base token happens to be a Comma from a separation list then we need to handle it different // Case: // var s = new List<string> // { // """", // """",/*sdfsdfsdfsdf*/ // // dfsdfsdfsdfsdf // // $$ // }; var previousToken = token.GetPreviousToken(); if (previousToken.IsKind(SyntaxKind.CommaToken)) { return(GetIndentationFromCommaSeparatedList(previousToken)); } else if (!previousToken.IsKind(SyntaxKind.None)) { // okay, beginning of the line is not trivia, use the last token on the line as base token return(GetIndentationBasedOnToken(token)); } } // this case we will keep the indentation of this trivia line // this trivia can't be preprocessor by the way. return(GetIndentationOfLine(previousLine)); } }
/// <summary> /// string.Formatのラッピング. /// </summary> /// <param name="finder"></param> /// <param name="args"></param> /// <returns></returns> public string Format(Finder finder, params object[] args) { return(string.Format(Get(finder), args)); }
public override IndentationResult?GetDesiredIndentation() { var indentStyle = OptionSet.GetOption(FormattingOptions.SmartIndent, LanguageNames.CSharp); if (indentStyle == FormattingOptions.IndentStyle.None) { return(null); } // find previous line that is not blank var previousLine = GetPreviousNonBlankOrPreprocessorLine(); // it is beginning of the file, there is no previous line exists. // in that case, indentation 0 is our base indentation. if (previousLine == null) { return(IndentFromStartOfLine(0)); } // okay, now see whether previous line has anything meaningful var lastNonWhitespacePosition = previousLine.GetLastNonWhitespacePosition(); if (!lastNonWhitespacePosition.HasValue) { return(null); } // there is known parameter list "," parse bug. if previous token is "," from parameter list, // FindToken will not be able to find them. var token = Tree.GetRoot(CancellationToken).FindToken(lastNonWhitespacePosition.Value); if (token.IsKind(SyntaxKind.None) || indentStyle == FormattingOptions.IndentStyle.Block) { return(GetIndentationOfLine(previousLine)); } // okay, now check whether the text we found is trivia or actual token. if (token.Span.Contains(lastNonWhitespacePosition.Value)) { // okay, it is a token case, do special work based on type of last token on previous line return(GetIndentationBasedOnToken(token)); } else { // there must be trivia that contains or touch this position Contract.Assert(token.FullSpan.Contains(lastNonWhitespacePosition.Value)); // okay, now check whether the trivia is at the beginning of the line var firstNonWhitespacePosition = previousLine.GetFirstNonWhitespacePosition(); if (!firstNonWhitespacePosition.HasValue) { return(IndentFromStartOfLine(0)); } var trivia = Tree.GetRoot(CancellationToken).FindTrivia(firstNonWhitespacePosition.Value, findInsideTrivia: true); if (trivia.Kind() == SyntaxKind.None || this.LineToBeIndented.LineNumber > previousLine.LineNumber + 1) { // If the token belongs to the next statement and is also the first token of the statement, then it means the user wants // to start type a new statement. So get indentation from the start of the line but not based on the token. // Case: // static void Main(string[] args) // { // // A // // B // // $$ // return; // } var containingStatement = token.GetAncestor <StatementSyntax>(); if (containingStatement != null && containingStatement.GetFirstToken() == token) { var position = GetCurrentPositionNotBelongToEndOfFileToken(LineToBeIndented.Start); return(IndentFromStartOfLine(Finder.GetIndentationOfCurrentPosition(Tree, token, position, CancellationToken))); } // If the token previous of the base token happens to be a Comma from a separation list then we need to handle it different // Case: // var s = new List<string> // { // """", // """",/*sdfsdfsdfsdf*/ // // dfsdfsdfsdfsdf // // $$ // }; var previousToken = token.GetPreviousToken(); if (previousToken.IsKind(SyntaxKind.CommaToken)) { return(GetIndentationFromCommaSeparatedList(previousToken)); } else if (!previousToken.IsKind(SyntaxKind.None)) { // okay, beginning of the line is not trivia, use the last token on the line as base token return(GetIndentationBasedOnToken(token)); } } // this case we will keep the indentation of this trivia line // this trivia can't be preprocessor by the way. return(GetIndentationOfLine(previousLine)); } }
static void Main() { #region Initial boring stuff DynamitConfig.Init(enableEscapeStrings: true); foreach (var x in Db.SQL <DDictionary>($"SELECT t FROM {typeof(DDictionary).FullName} t")) { Db.TransactAsync(() => x.Delete()); } foreach (var x in Db.SQL <DList>($"SELECT t FROM {typeof(DList).FullName} t")) { Db.TransactAsync(() => x.Delete()); } #endregion // TEST BEGIN #region Inserting and removing values of various types MyDict myDict = null; Db.TransactAsync(() => { myDict = new MyDict(); dynamic d = myDict; d.Id = 1; d.Bool = true; d.Byte = (byte)125; d.DateTime = DateTime.Now; d.Decimal = 123.123123123123M; d.Double = 123.123321123321123321; d.Int = 124421; d.Long = 33219239321L; d.Sbyte = (sbyte)123; d.Short = (short)332; d.Single = (float)123.1; d.String = "\"ASddsddsa\""; d.Uint = (uint)123321; d.Ulong = (ulong)123321123; d.Ushort = (ushort)12331; d.Null = null; d.Thing = "SwooBoo"; d.EmptyString = ""; d.JustAQuote = "\""; new MyDict { ["Id"] = 2, ["Byte"] = (byte)12, ["String"] = "A", ["Bool"] = true, ["Goo"] = 123 }; new MyDict { Foo = "TheThird", ["Id"] = 3, ["Byte"] = (byte)122, ["String"] = "A", ["Bool"] = true }; }); Assert(!myDict.ContainsKey("Null")); Assert(myDict.ContainsKey("Thing")); Db.TransactAsync(() => myDict["Thing"] = null); Assert(!myDict.ContainsKey("Thing")); #endregion #region Checking that things exist Assert(Db.SQL <DDictionary>("SELECT t FROM Dynamit.DDictionary t").Any()); Assert(Db.SQL <DKeyValuePair>("SELECT t FROM Dynamit.DKeyValuePair t").Any()); Assert(Db.SQL <ValueObject>("SELECT t FROM Dynamit.ValueObjects.ValueObject t").Any()); #endregion #region Type consistency assertions dynamic dyn = myDict; Assert(dyn.Id is int); Assert(dyn.Bool is bool); Assert(dyn.Byte is byte); Assert(dyn.DateTime is DateTime); Assert(dyn.Decimal is Decimal); Assert(dyn.Double is double); Assert(dyn.Int is int); Assert(dyn.Long is long); Assert(dyn.Sbyte is sbyte); Assert(dyn.Short is short); Assert(dyn.Single is float); Assert(dyn.String is string); Assert(dyn.Uint is uint); Assert(dyn.Ulong is ulong); Assert(dyn.Ushort is ushort); Assert(dyn.Null is null); #endregion #region DDictionary instance member checks Assert(myDict.KvpTable == typeof(MyDictKVP).FullName); Db.TransactAsync(() => myDict.Add("Test1", "Swoo")); Assert(myDict.TryGetValue("Test1", out var t01) && t01.Equals("Swoo")); var test2kvp = new KeyValuePair <string, object>("Test2", "Goo"); Db.TransactAsync(() => myDict.Add(test2kvp)); Assert(myDict.TryGetValue("Test2", out var t02) && t02.Equals("Goo")); Assert(myDict.Contains(test2kvp)); Assert(myDict.Count == myDict.KeyValuePairs.Count()); Assert(myDict.ContainsKey("Test2")); Db.TransactAsync(() => myDict.Remove("Test1")); Assert(!myDict.TryGetValue("Test1", out t01)); Db.TransactAsync(() => myDict.Remove("Test1")); Assert(!myDict.TryGetValue("Test1", out t01)); Db.TransactAsync(() => myDict.Remove(test2kvp.Key)); Assert(!myDict.TryGetValue("Test2", out t01)); var arr = new KeyValuePair <string, object> [100]; myDict.CopyTo(arr, 0); Assert(arr[0].Key != null); Assert(arr.Count(a => a.Key != null) == myDict.KeyValuePairs.Count()); MyDict testThingy = null; Db.TransactAsync(() => testThingy = new MyDict { ["Test"] = true }); Assert(testThingy.Any()); Db.TransactAsync(() => testThingy.Clear()); Assert(!testThingy.Any()); Db.TransactAsync(() => testThingy.Delete()); object thing = myDict.SafeGet("Swoofooboasd"); Assert(thing == null); var otherThing = myDict.SafeGet("Bool"); Assert(otherThing is bool); #endregion #region Finder var all = Finder <MyDict> .All; var As = Finder <MyDict> .Where("String", EQUALS, "A"); var third = Finder <MyDict> .Where("Id", EQUALS, 3); var firstAndSecond = Finder <MyDict> .All.Where(dict => dict["Id"] < 3); var second = Finder <MyDict> .Where(("String", EQUALS, "A"), ("Byte", NOT_EQUALS, 122)); var alsoThird = Finder <MyDict> .Where(("String", EQUALS, "A")).Where(dict => dict["Byte"] == 122).FirstOrDefault(); var alsoThird3 = Finder <MyDict> .Where("$Foo", EQUALS, "TheThird").FirstOrDefault(); Assert(alsoThird.Equals(alsoThird3)); var objectNo = myDict.GetObjectNo(); var objectId = myDict.GetObjectID(); var _first = Finder <MyDict> .Where("$ObjectID", EQUALS, objectId).FirstOrDefault(); var _first2 = Finder <MyDict> .Where("$ObjectNo", EQUALS, objectNo).FirstOrDefault(); Assert(_first.Equals(_first2) && _first.Equals(myDict)); var firstAndThird = Finder <MyDict> .Where("Goo", EQUALS, null); var alsoSecond = Finder <MyDict> .Where("Goo", NOT_EQUALS, null); var json = JsonConvert.SerializeObject(all); var alsoAll1 = Finder <MyDict> .Where(); var alsoAll2 = Finder <MyDict> .Where(("Gooo", EQUALS, null)); var alsoAll3 = Finder <MyDict> .Where(("Gooo", EQUALS, null)); Assert(alsoAll1.Count() == 3); Assert(alsoAll2.Count() == 3); Assert(alsoAll3.Count() == 3); Assert(all.Count() == 3); Assert(As.Count() == 2); bool thirdOk = third.Count() == 1 && third.First()["Id"] == 3; Assert(thirdOk); var firstAndSecondOk = firstAndSecond.Count() == 2; Assert(firstAndSecondOk); bool secondOk = second.Count() == 1 && second.First()["Id"] == 2; Assert(secondOk); bool alsoThirdOk = third.Count() == 1 && third.First()["Id"] == 3; Assert(alsoThirdOk); Assert(firstAndThird.Count() == 2); bool alsoSecondOk = alsoSecond.Count() == 1 && alsoSecond.First()["Id"] == 2; Assert(alsoSecondOk); #endregion #region Handling errors in input Db.TransactAsync(() => { try { myDict["T"] = new { A = "ASD" }; } catch (Exception e) { Assert(e is InvalidValueTypeException); } try { myDict["V"] = new Stopwatch(); } catch (Exception e) { Assert(e is InvalidValueTypeException); } try { myDict["X"] = new JObject { ["A"] = 123 }; } catch (Exception e) { Assert(e is InvalidValueTypeException); } }); Assert(!myDict.ContainsKey("T")); Assert(!myDict.ContainsKey("V")); Assert(!myDict.ContainsKey("X")); #endregion #region JSON serialization var asJson = JsonConvert.SerializeObject(myDict); #endregion #region Deleting rows Db.TransactAsync(() => { myDict.Delete(); second.First().Delete(); third.First().Delete(); }); #endregion #region Checking that things don't exist anymore Assert(!Db.SQL <DDictionary>("SELECT t FROM Dynamit.DDictionary t").Any()); Assert(!Db.SQL <DKeyValuePair>("SELECT t FROM Dynamit.DKeyValuePair t").Any()); Assert(!Db.SQL <ValueObject>("SELECT t FROM Dynamit.ValueObjects.ValueObject t").Any()); #endregion // TEST END var s = 0; }
public RaceManager(Finder raceFinder) { RaceFinder = raceFinder; }
private IndentationResult?GetIndentationBasedOnToken(SyntaxToken token) { Contract.ThrowIfNull(Tree); Contract.ThrowIfTrue(token.Kind() == SyntaxKind.None); // special cases // case 1: token belongs to verbatim token literal // case 2: $@"$${0}" // case 3: $@"Comment$$ inbetween{0}" // case 4: $@"{0}$$" if (token.IsVerbatimStringLiteral() || token.IsKind(SyntaxKind.InterpolatedVerbatimStringStartToken) || token.IsKind(SyntaxKind.InterpolatedStringTextToken) || (token.IsKind(SyntaxKind.CloseBraceToken) && token.Parent.IsKind(SyntaxKind.Interpolation))) { return(IndentFromStartOfLine(0)); } // if previous statement belong to labeled statement, don't follow label's indentation // but its previous one. if (token.Parent is LabeledStatementSyntax || token.IsLastTokenInLabelStatement()) { token = token.GetAncestor <LabeledStatementSyntax>().GetFirstToken(includeZeroWidth: true).GetPreviousToken(includeZeroWidth: true); } var position = GetCurrentPositionNotBelongToEndOfFileToken(LineToBeIndented.Start); // first check operation service to see whether we can determine indentation from it var indentation = Finder.FromIndentBlockOperations(Tree, token, position, CancellationToken); if (indentation.HasValue) { return(IndentFromStartOfLine(indentation.Value)); } var alignmentTokenIndentation = Finder.FromAlignTokensOperations(Tree, token); if (alignmentTokenIndentation.HasValue) { return(IndentFromStartOfLine(alignmentTokenIndentation.Value)); } // if we couldn't determine indentation from the service, use heuristic to find indentation. var sourceText = LineToBeIndented.Text; // If this is the last token of an embedded statement, walk up to the top-most parenting embedded // statement owner and use its indentation. // // cases: // if (true) // if (false) // Foo(); // // if (true) // { } if (token.IsSemicolonOfEmbeddedStatement() || token.IsCloseBraceOfEmbeddedBlock()) { Contract.Requires( token.Parent != null && (token.Parent.Parent is StatementSyntax || token.Parent.Parent is ElseClauseSyntax)); var embeddedStatementOwner = token.Parent.Parent; while (embeddedStatementOwner.IsEmbeddedStatement()) { embeddedStatementOwner = embeddedStatementOwner.Parent; } return(GetIndentationOfLine(sourceText.Lines.GetLineFromPosition(embeddedStatementOwner.GetFirstToken(includeZeroWidth: true).SpanStart))); } switch (token.Kind()) { case SyntaxKind.SemicolonToken: { // special cases if (token.IsSemicolonInForStatement()) { return(GetDefaultIndentationFromToken(token)); } return(IndentFromStartOfLine(Finder.GetIndentationOfCurrentPosition(Tree, token, position, CancellationToken))); } case SyntaxKind.CloseBraceToken: { if (token.Parent.IsKind(SyntaxKind.AccessorList) && token.Parent.Parent.IsKind(SyntaxKind.PropertyDeclaration)) { if (token.GetNextToken().IsEqualsTokenInAutoPropertyInitializers()) { return(GetDefaultIndentationFromToken(token)); } } return(IndentFromStartOfLine(Finder.GetIndentationOfCurrentPosition(Tree, token, position, CancellationToken))); } case SyntaxKind.OpenBraceToken: { return(IndentFromStartOfLine(Finder.GetIndentationOfCurrentPosition(Tree, token, position, CancellationToken))); } case SyntaxKind.ColonToken: { var nonTerminalNode = token.Parent; Contract.ThrowIfNull(nonTerminalNode, @"Malformed code or bug in parser???"); if (nonTerminalNode is SwitchLabelSyntax) { return(GetIndentationOfLine(sourceText.Lines.GetLineFromPosition(nonTerminalNode.GetFirstToken(includeZeroWidth: true).SpanStart), OptionSet.GetOption(FormattingOptions.IndentationSize, token.Language))); } // default case return(GetDefaultIndentationFromToken(token)); } case SyntaxKind.CloseBracketToken: { var nonTerminalNode = token.Parent; Contract.ThrowIfNull(nonTerminalNode, @"Malformed code or bug in parser???"); // if this is closing an attribute, we shouldn't indent. if (nonTerminalNode is AttributeListSyntax) { return(GetIndentationOfLine(sourceText.Lines.GetLineFromPosition(nonTerminalNode.GetFirstToken(includeZeroWidth: true).SpanStart))); } // default case return(GetDefaultIndentationFromToken(token)); } case SyntaxKind.XmlTextLiteralToken: { return(GetIndentationOfLine(sourceText.Lines.GetLineFromPosition(token.SpanStart))); } case SyntaxKind.CommaToken: { return(GetIndentationFromCommaSeparatedList(token)); } default: { return(GetDefaultIndentationFromToken(token)); } } }
public void FindNextBiggerNumber_NumberLess0_ThrowsArgumentOutOfRangeException() { Assert.ThrowsException <ArgumentOutOfRangeException>(() => Finder.FindNextBiggerNumber(-1)); }
public void FindNextBiggerNumber_ReturnsRightNumber(int number, int expectedResult) { int result = Finder.FindNextBiggerNumber(number); Assert.AreEqual(expectedResult, result); }
public static int FindNextBiggerNumber(int number) { return(Finder.FindNextBiggerNumber(number)); }
public void Test1() { string c = Finder.FindFirstRecurring("acbbac"); Assert.Equal("b", c); }
/// <summary> /// <para> /// Queries the database for copies of the values of the tracked entity as they currently /// exist in the database. If the entity is not found in the database, then null is returned. /// </para> /// <para> /// Note that changing the values in the returned dictionary will not update the values /// in the database. /// </para> /// </summary> /// <returns> The store values, or null if the entity does not exist in the database. </returns> public virtual PropertyValues GetDatabaseValues() { var values = Finder.GetDatabaseValues(InternalEntry); return(values == null ? null : new ArrayPropertyValues(InternalEntry, values)); }