/// <summary> /// Calculate metrics for Method /// </summary> /// <param name="node"></param> /// <param name="mi"></param> /// <returns></returns> public static MethodInfo FillMethodMetrics(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode node, MethodInfo mi) { mi.NL = NL.Calculate(node); mi.NLE = NLE.Calculate(node); mi.NOB = NOB.Calculate(node); mi.NOS = NOS.Calculate(node); return(mi); }
/// <summary> /// Called at every iteration; the arguments are /// - iteration index /// - current solution /// - current residual /// - current multigrid operator /// </summary> //public event Action<int, double[], double[], MultigridOperator> IterationCallback; public override void SolverDriver <S>(CoordinateVector SolutionVec, S RHS) { if (m_NLSequence == null) { throw new FormatException("m_NLSequence is empty. You fool!"); } foreach (NonlinearSolver NL in m_NLSequence) { //NL.IterationCallback += IterationCallback; NL.SolverDriver(SolutionVec, RHS); } }
private PtExpression?TryInfix(NL nl = NL.Both) { var term = TryTerm(nl); if (term == null) { return(null); } var parts = Collect(TryInfixPart); if (parts.Count >= 1) { var operators = parts.Select(p => p.Kind).Distinct().ToList(); if (operators.Count >= 2) { var part = parts.Where(p => p.Kind != operators[0]).First(); var token = Tokens[part.Span.Start]; Errors.Help.Add( token, ErrNo.Err002, "binary operators have no precedence, use ( ) to group binary expressions"); } var @operator = operators[0]; switch (@operator) { case PtBinaryKind.As: if (parts.Count > 1) { throw NoParse("binary operator <as> doesn't associate"); } return(new PtAs(Mark(term), term, ((Parts.AsPart)parts[0]).Type)); case PtBinaryKind.Is: case PtBinaryKind.Isnt: if (parts.Count > 1) { throw NoParse("binary operator <is>/<isnt> doesn't associate"); } return(new PtBinary(Mark(term), @operator, term, ((Parts.IsPart)parts[0]).Expression)); default: var operands = new List <PtExpression> { term }; operands.AddRange(parts.Cast <Parts.BinaryPart>().Select(b => b.Right)); return(new PtBinary(Mark(term), @operator, operands)); } } return(term); }
public override string ToString() { return(NV.ToString() + NR.ToString() + NC.ToString() + NL.ToString() + N_BPT.ToString() + N_UPT.ToString() + NOA.ToString() + NT.ToString() + NIOA.ToString() + NTR.ToString()); }
protected static void LoadMessages(string localizationId) { Type nlsAccessType = typeof(TObject); localizationId = string.IsNullOrEmpty(localizationId) ? GetLocalizationId(nlsAccessType) : localizationId; try { // Grab fields to set up FieldInfo[] fields = nlsAccessType.GetFields(FieldBindingFlags); // Loads messages according to the NL specialization string[] nlSpecs = NL.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries); string majorNlSpec = nlSpecs[0]; string minorNlSpec = nlSpecs.Length > 1 ? nlSpecs[1] : null; Dictionary <string, string> messageSet = new Dictionary <string, string>(fields.Length); // Load default messages string defaultNlFileContent = NLSRegistry.Instance.GetResourceFile(localizationId, null); PutMessages(defaultNlFileContent, messageSet); // Add major NL specialization if (!string.IsNullOrEmpty(majorNlSpec)) { string majorNlFileContent = NLSRegistry.Instance.GetResourceFile(localizationId, majorNlSpec); if (!string.IsNullOrEmpty(majorNlFileContent)) { PutMessages(majorNlFileContent, messageSet); } } // Add minor NL specialization if (!string.IsNullOrEmpty(minorNlSpec)) { string minorNlFileContent = NLSRegistry.Instance.GetResourceFile(localizationId, NL); if (!string.IsNullOrEmpty(minorNlFileContent)) { PutMessages(minorNlFileContent, messageSet); } } // Apply all messages to the fields for (int i = -1; ++i != fields.Length;) { FieldInfo field = fields[i]; string fieldName = field.Name; if (!messageSet.TryGetValue(fieldName, out string fieldValue)) { _log.Warning($"{nlsAccessType} declares a message that has not been set by a NLS resource file"); continue; } messageSet.Remove(fieldName); try { field.SetValue(null, fieldValue); } catch (Exception ex) { _log.Error("Error on applying localized text", ex); } } // Log unused messages using (Dictionary <string, string> .Enumerator itr = messageSet.GetEnumerator()) { while (itr.MoveNext()) { KeyValuePair <string, string> entry = itr.Current; string key = entry.Key; _log.Warning($"Unused message found for key '{key}'"); } } } catch (Exception ex) { _log.Error($"Error on applying localized messages to '{nlsAccessType}'", ex); } }
private PtExpression Infix(NL nl = NL.Both) => TryInfix(nl) ?? throw NoParse("infix");
/// <summary> /// Validates VAT number /// </summary> /// <returns>Corrected VAT number in VatNumber object</returns> public static VatNumber Validate(string vat, EUCountry euCountry) { string countryCode = euCountry.ToString().ToUpper(); vat = vat.ToUpper(); CountryBase countryBase; switch (euCountry) { case EUCountry.AT: countryBase = new AT(); break; case EUCountry.BE: countryBase = new BE(); break; case EUCountry.BG: countryBase = new BG(); break; case EUCountry.CY: countryBase = new CY(); break; case EUCountry.CZ: countryBase = new CZ(); break; case EUCountry.DE: countryBase = new DE(); break; case EUCountry.DK: countryBase = new DK(); break; case EUCountry.EE: countryBase = new EE(); break; case EUCountry.EL: countryBase = new EL(); break; case EUCountry.ES: countryBase = new ES(); break; case EUCountry.FI: countryBase = new FI(); break; case EUCountry.FR: countryBase = new FR(); break; case EUCountry.GB: countryBase = new GB(); break; case EUCountry.HR: countryBase = new HR(); break; case EUCountry.HU: countryBase = new HU(); break; case EUCountry.IE: countryBase = new IE(); break; case EUCountry.IT: countryBase = new IT(); break; case EUCountry.LT: countryBase = new LT(); break; case EUCountry.LU: countryBase = new LU(); break; case EUCountry.LV: countryBase = new LV(); break; case EUCountry.MT: countryBase = new MT(); break; case EUCountry.NL: countryBase = new NL(); break; case EUCountry.PL: countryBase = new PL(); break; case EUCountry.PT: countryBase = new PT(); break; case EUCountry.RO: countryBase = new RO(); break; case EUCountry.SE: countryBase = new SE(); break; case EUCountry.SI: countryBase = new SI(); break; case EUCountry.SK: countryBase = new SK(); break; default: throw new InvalidCountryException(); } if (countryBase.StripLetters) { return(new VatNumber(euCountry, countryBase.Validate(Strip(vat)))); } return(new VatNumber(euCountry, countryBase.Validate(StripNoLetters(vat, countryCode)))); }