public override void FromXml(XElement config, ObjectsMap map, bool invert) { base.FromXml(config, map, invert); SquareSide.FromXml(config, DefaultCrosswalkSquareSide); LineCount.FromXml(config, DefaultCrosswalkLineCount); Invert.FromXml(config, false); Invert.Value ^= map.IsMirror ^ invert; }
public override XElement ToXml() { var config = base.ToXml(); SquareSide.ToXml(config); LineCount.ToXml(config); Invert.ToXml(config); return(config); }
public int GetTotalLineCount() { if (count == null) { var theCount = new LineCount { Count = ReadAllLines().Count() }; Interlocked.CompareExchange(ref count, theCount, null); } return count.Count; }
public int GetTotalLineCount() { if (count == null) { var theCount = new LineCount { Count = ReadAllLines().Count() }; Interlocked.CompareExchange(ref count, theCount, null); } return(count.Count); }
public TextTabItem(string header, string contents, ControlType Type) : base(header, Type) { this.TextBoxInstance = new TextBox(); this.Header = header; this.Contents = contents; this.TabType = Type; this.TabID = System.Guid.NewGuid().ToString(); for (int i = 1; i <= Int16.MaxValue; i++) { LineCount.Add(i); } }
public override void Write(string message) { LineCount++; TraceOutput traceOutput = new TraceOutput(); traceOutput.ID = LineCount.ToString(); traceOutput.Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); traceOutput.Line = message; Lines.Add(traceOutput); if (Lines.Count > MAX_LINES) { Lines.RemoveAt(0); } }
private (LineCount current, LineCount previous) AddOrUpdateLineCount(string filePath, int count) { var current = new LineCount(count); LineCount previous; lock (PathLineCounts) { if (PathLineCounts.TryGetValue(filePath, out previous)) { PathLineCounts.Remove(filePath); } PathLineCounts.Add(filePath, current); } return(current, previous); }
/// <summary> /// Compares this counter with another counter. A cookie can specify /// a specific counter type. /// </summary> /// <param name="other">The other.</param> /// <param name="cookie">The cookie.</param> /// <returns></returns> public double Compare(DistanceLineCounter other, int cookie) { if (other == null) { return(0); } int cmp = 0; if ((cookie & DistanceLineCounterKind.Distance) != 0) { cmp = Distance.CompareTo(other.Distance); } if (cmp == 0 && (cookie & DistanceLineCounterKind.Lines) != 0) { cmp = LineCount.CompareTo(other.LineCount); } return(cmp); }
private static async Task <LineCount> GetAllOut(BatchBlock <LineCount> batcher) { var totalSum = new LineCount(); while (await batcher.OutputAvailableAsync()) { LineCount[] batchedDicList; if (!batcher.TryReceive(out batchedDicList)) { continue; } foreach (var lc in batchedDicList) { foreach (var kvp in lc.ByAuthor) { int currentCount; if (!totalSum.ByAuthor.TryGetValue(kvp.Key, out currentCount)) { currentCount = 0; } currentCount += kvp.Value; totalSum.ByAuthor[kvp.Key] = currentCount; } foreach (var kvp in lc.ByUnixTimeStamp) { int currentCount; if (!totalSum.ByUnixTimeStamp.TryGetValue(kvp.Key, out currentCount)) { currentCount = 0; } currentCount += kvp.Value; totalSum.ByUnixTimeStamp[kvp.Key] = currentCount; } } } return(totalSum); }
static void Main(string[] args) { string text = File.ReadAllText(args[0]); SyntaxTree tree = CSharpSyntaxTree.ParseText(text); SingleReturnMethodAnalyzer analyzer = new SingleReturnMethodAnalyzer(tree); AnalyzeResult result = analyzer.analyze(); // BooleanParameterAnalyzer booleanParameterAnalyzer = new BooleanParameterAnalyzer(tree); // AnalyzeResult result2 = booleanParameterAnalyzer.analyze(); OneLineBranchStatement oneLineBranchStatement = new OneLineBranchStatement(tree); AnalyzeResult resultOneLineBranchStatement = oneLineBranchStatement.analyze(); FunctionArgCounter functionArgCounter = new FunctionArgCounter(tree); AnalyzeResult resultfunctionArgCounter = functionArgCounter.analyze(); NestedLoops nestedLoops = new NestedLoops(tree); AnalyzeResult nestedLoopResult = nestedLoops.analyze(); CommentPercentage comment = new CommentPercentage(tree); AnalyzeResult resultcomment = comment.analyze(); StaticNotVoid staticNotVoid = new StaticNotVoid(tree); AnalyzeResult resultstaticNotVoid = staticNotVoid.analyze(); TryCatchFucntionCall tryCatchFucntionCall = new TryCatchFucntionCall(tree); AnalyzeResult resulttryCatchFucntionCall = tryCatchFucntionCall.analyze(); SingleAssertPerTest singleAssertPerTest = new SingleAssertPerTest(tree); AnalyzeResult singleAssertAnalyzeResult = singleAssertPerTest.analyze(); MagicNumbers magicNumbersAnalyzer = new MagicNumbers(tree); AnalyzeResult magicAnalyzeResult = magicNumbersAnalyzer.analyze(); LongClasses longClasses = new LongClasses(tree); AnalyzeResult longClassesResult = longClasses.analyze(); var analyzers = new List <BaseAnalyzer>() { new SingleReturnMethodAnalyzer(tree), // new BooleanParameterAnalyzer(tree), new OneLineBranchStatement(tree), new FunctionArgCounter(tree), new NestedLoops(tree), new CommentPercentage(tree), new StaticNotVoid(tree), new TryCatchFucntionCall(tree), new SingleAssertPerTest(tree), new MagicNumbers(tree), new LongClasses(tree), new EmptyCatch(tree), new NestedConditions(tree), new LongLine(tree), new LongMethods(tree), new LineCount(tree), new StaticOneParameter(tree), new StaticState(tree), new RefOutParameters(tree), new FuncContainAnd(tree) }; var diagnoseResponse = CodeDiagnosticResponse.fromAnalyzers( analyzers ); Console.WriteLine(diagnoseResponse); EmptyCatch emptyCatch = new EmptyCatch(tree); AnalyzeResult resultemptyCatch = emptyCatch.analyze(); NestedConditions nestedConditions = new NestedConditions(tree); AnalyzeResult resultNested = nestedConditions.analyze(); LongLine longLine = new LongLine(tree); AnalyzeResult resultlongLine = longLine.analyze(); LongMethods longMethods = new LongMethods(tree); AnalyzeResult resultLongMethods = longMethods.analyze(); LineCount lineCount = new LineCount(tree); AnalyzeResult lineCountResult = lineCount.analyze(); StaticOneParameter staticOneParameter = new StaticOneParameter(tree); AnalyzeResult staticOneParatemerResult = staticOneParameter.analyze(); StaticState staticState = new StaticState(tree); AnalyzeResult staticStateStaticResult = staticState.analyze(); RefOutParameters refOutParameters = new RefOutParameters(tree); AnalyzeResult refOutParametersResult = refOutParameters.analyze(); FuncContainAnd funcContainAnd = new FuncContainAnd(tree); AnalyzeResult funcContainAndResult = funcContainAnd.analyze(); }
private void ComputeLineCount() { LineCount.ComputedAs(SalesOrderDetails.SalesOrderDetailID.CountRows()); }
public static List <ColorMethods.ColorName> GetLines(Color[,] data, LineCount lineCount) { List <ColorMethods.ColorName> result = new List <ColorMethods.ColorName>(); if (lineCount == LineCount.four) { //Add most left line ColorMethods.ColorName color = GetColor(data, 1); //if (color != ColorMethods.ColorName.Unknown) result.Add(color); //else // return null; //Add second line int linePosition = data.GetLength(1) / 3; color = GetColor(data, linePosition); //if (color != ColorMethods.ColorName.Unknown) result.Add(color); //else // return null; //Add third line linePosition = data.GetLength(1) / 3 * 2; color = GetColor(data, linePosition); //if (color != ColorMethods.ColorName.Unknown) result.Add(color); //else // return null; //Add fourth line linePosition = data.GetLength(1) - 2; color = GetColor(data, linePosition); //if (color != ColorMethods.ColorName.Unknown) result.Add(color); //else // return null; } else { //Add most left line ColorMethods.ColorName color = GetColor(data, 1); //if (color != ColorMethods.ColorName.Unknown) result.Add(color); //else // return null; //Add second line int linePosition = (int)(data.GetLength(1) * 0.27f); color = GetColor(data, linePosition); //if (color != ColorMethods.ColorName.Unknown) result.Add(color); //else // return null; //Add third line linePosition = (int)(data.GetLength(1) * 0.5f); color = GetColor(data, linePosition); //if (color != ColorMethods.ColorName.Unknown) result.Add(color); //else // return null; //Add fourth line linePosition = (int)(data.GetLength(1) * 0.73f); color = GetColor(data, linePosition); //if (color != ColorMethods.ColorName.Unknown) result.Add(color); //else // return null; //Add fourth line linePosition = data.GetLength(1) - 2; color = GetColor(data, linePosition); //if (color != ColorMethods.ColorName.Unknown) result.Add(color); //else // return null; } //Debug.Log("LINES FOUND!"); return(result); }
private void RunParse_Click(object sender, EventArgs e) { Results.Text = ""; int count = 3; // The first line containing attributes starts at array position 3 (4th line in the xml) char startChar = '>'; char interChar = '/'; char endChar = '<'; int preCheck = 0; int start = 0; int end = 0; string[] fileLines = File.ReadAllLines(FileName.Text); // Line 1 in the file corresponds to fileLines[0]. count++ gives the current line List <int> linesOfFail = new List <int>(); // Contains falied line number List <string> errorType = new List <string>(); // Contains error type respective to the linesOfFail Verify_Req req = new Verify_Req(); // Class contains the logic while (count <= fileLines.Length - 3) // The last 3 lines are ending tags for xmls { LineCount.Text = count.ToString(); LineCount.Update(); string currentLine = fileLines[count]; preCheck = currentLine.IndexOf(endChar); // Find the index of the first '<' if (currentLine[preCheck + 1] != interChar) // Is the charater proceeding '<' a '/'? If it is, this is a tag with nothing to check { start = currentLine.IndexOf(startChar) + 1; // Add 1 to start so '>' is not collected as part of the substring to check end = req.CheckEndTags(currentLine, startChar, interChar, endChar, start, end); if (end > 0) // If end is -1 an end tag was never found and this could be an error { if (req.IsValidLength(count, start, end, currentLine)) { if (req.ContainsValidChars(currentLine, start, end)) { if (req.ContainsNaN(currentLine, start, end)) { linesOfFail.Add(++count); errorType.Add(" NaN found"); } } else { linesOfFail.Add(++count); errorType.Add(" Invalid character found"); } } else { linesOfFail.Add(++count); errorType.Add(" Over 2k characters"); } } else if (end == -2) { linesOfFail.Add(++count); errorType.Add(" Invaild carrot found"); } } count++; } if (linesOfFail.Count > 0) { for (int i = 0; i < linesOfFail.Count; i++) { Results.Text += linesOfFail[i].ToString() + errorType[i] + "\n\n"; } } else { Results.Text = "No errored lines detected"; } }
private void CalculateWidth() { var digits = LineCount > 99 ? LineCount.ToString() : "99"; _width = LineNumberStyle.CalcSize(MissingEngineAPI.GUIContent_Temp(digits)).x; }
static async Task <LineCount> ProcessBlame(string filePath) { var ret = new LineCount(); if (string.IsNullOrEmpty(filePath)) { return(ret); } if (filePath.EndsWith(".designer.cs", StringComparison.OrdinalIgnoreCase)) { return(ret); } var p = StartWithOutputRedirect($"blame -p -w HEAD -- \"{filePath}\""); var stdout = p.StandardOutput; var commitToAuthorMap = new Dictionary <string, string>(); var commitToTimestampMap = new Dictionary <string, long>(); #if DEBUG var sb = new StringBuilder(); #endif string line; while (null != (line = await stdout.ReadLineAsync())) { #if DEBUG sb.AppendLine(line); #endif var splits = line.Split(Space); Debug.Assert(splits.Length == 4); Debug.Assert(splits[0].Length == 40); if (splits.Length != 4 || splits[0].Length != 40) { Console.WriteLine("bad: " + filePath); return(new LineCount()); } string hash = splits[0]; int lineCount = int.Parse(splits[3], NumberStyles.None, CultureInfo.InvariantCulture); int linesToEat = lineCount * 2; if (sInitalInportCommits.Contains(hash)) { lineCount = 0; } if (commitToAuthorMap.ContainsKey(hash)) { ret.ByAuthor[commitToAuthorMap[hash]] += lineCount; ret.ByUnixTimeStamp[commitToTimestampMap[hash]] += lineCount; linesToEat -= 1; } else { linesToEat -= 2; string author = null; long? authorTime = null; while (null != (line = await stdout.ReadLineAsync())) { #if DEBUG sb.AppendLine(line); #endif if (line[0] == '\t') { break; } const string AUTHOR = "author "; const string AUTHOR_TIME = "author-time "; if (line.StartsWith(AUTHOR)) { author = line.Substring(AUTHOR.Length); } else if (line.StartsWith(AUTHOR_TIME)) { authorTime = long.Parse(line.Substring(AUTHOR_TIME.Length)); } } if (author == null || authorTime == null) { throw new Exception(); } commitToAuthorMap[hash] = author; int countForAuthor; if (!ret.ByAuthor.TryGetValue(author, out countForAuthor)) { countForAuthor = 0; } countForAuthor += lineCount; ret.ByAuthor[author] = countForAuthor; commitToTimestampMap[hash] = authorTime.Value; int countForTimeStamp; if (!ret.ByUnixTimeStamp.TryGetValue(authorTime.Value, out countForTimeStamp)) { countForTimeStamp = 0; } countForTimeStamp += lineCount; ret.ByUnixTimeStamp[authorTime.Value] = countForTimeStamp; } for (int i = 0; i < linesToEat; i++) { line = await stdout.ReadLineAsync(); #if DEBUG sb.AppendLine(line); #endif if (line == null) { throw new Exception(); } } } p.WaitForExit(); if (p.ExitCode != 0) { throw new Exception(); } return(ret); }