Example #1
0
        public PassiveADPAgent(IMap <S, A> fixedPolicy, ISet <S> states,
                               S initialState, IActionsFunction <S, A> actionsFunction,
                               IPolicyEvaluation <S, A> policyEvaluation)
        {
            this.pi.AddAll(fixedPolicy);
            this.mdp = new MDP <S, A>(states, initialState, actionsFunction,
                                      new TransitionProbabilityFunctionImpl(P),
                                      new RewardFunctionImpl(R));

            this.policyEvaluation = policyEvaluation;
        }
Example #2
0
 public ExtendPolicyFailure(Violation violation, IPolicyEvaluation policy)
     : base(
         string.Format(
             "({0}) {1}:{2} {3}",
             violation.Rule.CheckId,
             Path.GetFileName(violation.SourceCode.Path),
             violation.Line,
             violation.Message),
         policy)
 {
     this._violation = violation;
 }
 public TsLintPolicyFailure(Violation violation, IPolicyEvaluation policy)
     : base(
         string.Format(
             "({0}) {1}{2}: {3}",
             violation.ruleName,
             Path.GetFileName(violation.name),
             violation.startPosition,
             violation.failure),
         policy)
 {
     this._violation = violation;
 }
        // [rgn] Public Methods (1)

        public static PolicyFailure[] Evaluate(IPendingCheckin pendingCheckin, IPolicyEvaluation policyEvaluation)
        {
            List <PolicyFailure> failures = new List <PolicyFailure>();

            // Iterate over all changes to files that end with ".csproj".
            foreach (PendingChange pendingChange in GetCheckedPendingProjects(pendingCheckin))
            {
                // Examine the csproj file and validate all constraints.
                // Start by reading the csproj into an XmlDocument.
                XmlDocument csprojDocument = new XmlDocument();
                csprojDocument.Load(pendingChange.LocalItem);

                // Iterate over all of this project's build configurations.
                foreach (XmlNode node in GetBuildConfigurationNodes(csprojDocument))
                {
                    // Get the build configuration's name.
                    string configurationName = node.Attributes["Condition"].InnerText;

                    // Get the build configuration's debug symbol type.
                    string debugType = node["DebugType"].InnerText;

                    // Check if any constraint is unsatisfied with this build configuration.
                    foreach (DebugSymbolConstraint unsatisfiedConstraint in GetUnsatisfiedConstraints(configurationName, debugType))
                    {
                        // A constraint is unsatisfied with this project's build configuration. Report a failure.
                        string message = string.Format("Project '{0}' does not satisfy the constraint '{1}'.",
                                                       pendingChange.FileName,
                                                       unsatisfiedConstraint);

                        PolicyFailure failure = new PolicyFailure(message, policyEvaluation);
                        failures.Add(failure);
                    }
                }
            }

            return(failures.ToArray());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RalphJansen.StyleCopCheckInPolicy.Policy.SourceAnalysisPolicyFailure"/> class.
 /// </summary>
 /// <param name="message">The message of the policy failure.</param>
 /// <param name="policy">The <see cref="IPolicyEvaluation"/> where the failure occurred.</param>
 /// <param name="violations">An array of <see cref="Microsoft.StyleCop.Violation"/> instances that occurred while analyzing the source file.</param>
 public SourceAnalysisPolicyFailure(string message, IPolicyEvaluation policy, Collection <Violation> violations)
     : base(message, policy)
 {
     this.Violations = violations;
 }
Example #6
0
 public CodeDocumentationPolicyFailure(Violation violation, PendingChange pendingChange, IPolicyEvaluation policyEvaluation) : base(GetMessage(violation), policyEvaluation)
 {
     Violation     = violation;
     PendingChange = pendingChange;
 }
Example #7
0
 /**
  * Constructor.
  *
  * @param policyEvaluation
  *            the policy evaluation function to use.
  */
 public PolicyIteration(IPolicyEvaluation <S, A> policyEvaluation)
 {
     this.policyEvaluation = policyEvaluation;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RalphJansen.StyleCopCheckInPolicy.Policy.EvaluationContext"/> class.
 /// </summary>
 /// <param name="policy">The policy instance.</param>
 /// <param name="settings">The policy settings.</param>
 /// <param name="pendingCheckin">The pending check-in whose files to analyze.</param>
 public EvaluationContext(IPolicyEvaluation policy, PolicySettings settings, IPendingCheckin pendingCheckin)
 {
     this.Policy         = policy;
     this.Settings       = settings;
     this.PendingCheckin = pendingCheckin;
 }
Example #9
0
 public ExtendPolicyFailure(string message, IPolicyEvaluation policy)
     : base(message, policy)
 {
 }
 public TsLintPolicyFailure(string message, IPolicyEvaluation policy)
     : base(message, policy)
 {
 }