private string TryGetGeneratedClassNameFromFile() { var projectFile = File.GetSourceFile()?.ToProjectFile(); if (projectFile == null) { return(null); } var dataManager = File.GetSolution().GetComponent <IT4TemplateKindProvider>(); if (!dataManager.IsPreprocessedTemplate(projectFile)) { return(null); } string fileName = File.GetSourceFile()?.Name.WithoutExtension(); if (fileName == null) { return(null); } if (!ValidityChecker.IsValidIdentifier(fileName)) { return(null); } return(fileName); }
public override void Initialize() { ValidityChecker temporaryValidator = new ValidityChecker(new DummyChecker(new FirstRunActivationCodeAction(_hardwareId)), new DummyAction(), InstallationManager.Instance.InstallationInfo.Licence); TemporaryChecker temporary = new TemporaryChecker(new DummyChecker(new DummyAction()), temporaryValidator, InstallationManager.Instance.InstallationInfo.Licence); ValidityChecker trialValidator = new ValidityChecker(new DummyChecker(new FirstRunActivationCodeAction(_hardwareId)), new DummyAction(), InstallationManager.Instance.InstallationInfo.Licence); TrialChecker trial = new TrialChecker(temporary, trialValidator, InstallationManager.Instance.InstallationInfo.Licence); _decisionTree = trial; }
public static string CreateGeneratedClassName([NotNull] this IPsiSourceFile thіs) { string fileName = thіs.Name.WithoutExtension(); if (ValidityChecker.IsValidIdentifier(fileName)) { return(fileName); } return(T4CSharpIntermediateConverterBase.GeneratedClassNameString); }
public void ValidityChecker_ValidRow_ReturnTrue() { var row = new List <int> { 1, 2, 3, 4 }; ValidityChecker validityChecker = new ValidityChecker(game, row); var result = validityChecker.ListValid(); Assert.IsTrue(result); }
public void ValidityChecker_InvalidRowWithInvalidRange_ReturnFalse() { var row = new List <int> { 5, 2, 3, 4 }; ValidityChecker validityChecker = new ValidityChecker(game, row); var result = validityChecker.ListValid(); Assert.IsFalse(result); }
public PreferAddressByIdToGraphicsParamsQuickFix(PreferAddressByIdToGraphicsParamsWarning warning) { myInvocationExpression = warning.InvocationMethod; myArgument = warning.Argument; myFieldName = myGraphicsPropertyName = warning.Literal; if (!ValidityChecker.IsValidIdentifier(myFieldName)) { myFieldName = "Property"; } myArgumentExpression = warning.ArgumentExpression; myMapFunction = warning.MapFunction; myTypeName = warning.TypeName; }
public void TestCheckLower_int() { List <int> beau = new List <int> { 1, 0, -1, 1, 0, -1 }; List <int> lower = new List <int> { 0, 0, 0, 0, 0, 0 }; List <bool> canEquals = new List <bool> { false, false, false, true, true, true }; List <bool> willThrowError = new List <bool> { false, true, true, false, false, true }; List <string> error = new List <string>(); string pd = "测试数据"; for (int i = 0; i < beau.Count; i++) { bool hadThrowError = false; try { ValidityChecker.CheckLower(beau[i], lower[i], pd, canEquals[i]); } catch (Exception) { hadThrowError = true; } string message = string.Format("\r\n输入数据:{0} 输入边际:{1} 允许相等:{2} 预期结果:{3} 实际结果:{4}" , beau[i] , lower[i] , canEquals[i] ? "允许" : "不允许" , willThrowError[i] ? "抛出异常" : "不抛出异常" , hadThrowError ? "抛出异常" : "未抛出异常"); if (hadThrowError != willThrowError[i]) { error.Add(message); } } Assert.IsTrue(error.Count == 0, string.Join("", error)); }
/// <summary> /// Calculates for each agent and each direction it can go, the effect of that move on F. Illegal moves get byte.MaxValue. /// Also calcs maxDeltaF. /// Implicitly uses the SIC heuristic. /// </summary> /// <param name="problem">For GetSingleAgentOptimalCost</param> /// <param name="isValid"></param> /// <returns></returns> public void calcSingleAgentDeltaFs(ProblemInstance problem, ValidityChecker isValid) { // Init this.singleAgentDeltaFs = new byte[allAgentsState.Length][]; for (int i = 0; i < singleAgentDeltaFs.Length; i++) { this.singleAgentDeltaFs[i] = new byte[Constants.NUM_ALLOWED_DIRECTIONS]; } int hBefore, hAfter; this.maxDeltaF = 0; // Set values for (int i = 0; i < allAgentsState.Length; i++) { hBefore = problem.GetSingleAgentOptimalCost(allAgentsState[i]); int singleAgentMaxLegalDeltaF = -1; foreach (TimedMove check in allAgentsState[i].lastMove.GetNextMoves()) { if (isValid(check, noMoves, this.makespan + 1, i, this, this) == false) // Is this move by itself invalid because of constraints or obstacles { singleAgentDeltaFs[i][(int)check.direction] = byte.MaxValue; } else { hAfter = problem.GetSingleAgentOptimalCost(allAgentsState[i].agent.agentNum, check); if (Constants.sumOfCostsVariant == Constants.SumOfCostsVariant.ORIG) { if (hBefore != 0) { singleAgentDeltaFs[i][(int)check.direction] = (byte)(hAfter - hBefore + 1); // h difference + g difference in this specific domain } else if (hAfter != 0) // If agent moved from its goal we must count and add all the steps it was stationed at the goal, since they're now part of its g difference { singleAgentDeltaFs[i][(int)check.direction] = (byte)(hAfter - hBefore + makespan - allAgentsState[i].arrivalTime + 1); } else { singleAgentDeltaFs[i][(int)check.direction] = 0; // This is a WAIT move at the goal. } } else if (Constants.sumOfCostsVariant == Constants.SumOfCostsVariant.WAITING_AT_GOAL_ALWAYS_FREE) { if (hBefore == 0 && hAfter == 0) { singleAgentDeltaFs[i][(int)check.direction] = 0; // This is a WAIT move at the goal. } else { singleAgentDeltaFs[i][(int)check.direction] = (byte)(hAfter - hBefore + 1); // h difference + g difference in this specific domain } } singleAgentMaxLegalDeltaF = Math.Max(singleAgentMaxLegalDeltaF, singleAgentDeltaFs[i][(int)check.direction]); } } if (singleAgentMaxLegalDeltaF == -1) // No legal action for this agent, so no legal children exist for this node { this.maxDeltaF = 0; // Can't make it negative without widening the field. break; } this.maxDeltaF += (byte)singleAgentMaxLegalDeltaF; } fLookup = new DeltaFAchievable[allAgentsState.Length][]; for (int i = 0; i < fLookup.Length; i++) { fLookup[i] = new DeltaFAchievable[this.maxDeltaF + 1]; // Towards the last agents most of the row will be wasted (the last one can do delta F of 0 or 1), // but it's easier than fiddling with array sizes } }