コード例 #1
0
 public ChooseOneAnswer(string head, string body, int mark, ICorrector correctAnswer)
 {
     base.head          = head;
     base.body          = body;
     base.correctAnswer = correctAnswer;
     base.mark          = mark;
 }
コード例 #2
0
 public TrueOrFalse(string head, string body, int mark, ICorrector correctAnswer)
 {
     base.head          = head;
     base.body          = body;
     base.correctAnswer = correctAnswer;
     base.mark          = mark;
 }
コード例 #3
0
        public BrightnessAdapter(Config portconfig)
        {
            for (int _ = 0; _ < 10; _++)
            {
                if (Connect())
                {
                    break;
                }
                else
                {
                    Thread.Sleep(500);
                }
            }

            if (!socket.Connected)
            {
                throw new TimeoutException();
            }

            GetBrightness();

            config             = portconfig;
            port               = new SerialPort(config.Port, config.Bauderate);
            port.DataReceived += Port_DataReceived;
            port.Open();

            corrector            = AbstractCorrector.CreateCorrector(config.CorrectorType);
            corrector.Corrected += Corrector_Corrected;
            corrector.Start(CurrentBrightness);
        }
コード例 #4
0
        private static string Correct(string query, ICorrector correctors)
        {
            IExpression expression = QueryParser.Parse(query);
            IExpression corrected  = correctors.Correct(expression);

            return(corrected.ToString());
        }
コード例 #5
0
 public void Correct(ICorrector corrector)
 {
     if (corrector == null)
     {
         throw new ArgumentNullException("corrector");
     }
     this.Where = corrector.Correct(this.Where);
 }
コード例 #6
0
ファイル: JoinQuery.cs プロジェクト: sharwell/elfie-arriba
        public void Correct(ICorrector corrector)
        {
            // Correct with the existing correctors
            this.PrimaryQuery.Correct(corrector);

            // Correct and evaluate any referenced join queries
            JoinCorrector j = new JoinCorrector(this.DB, corrector, this.JoinQueries);

            this.PrimaryQuery.Correct(j);
        }
コード例 #7
0
ファイル: SelectQuery.cs プロジェクト: sharwell/elfie-arriba
        public void Correct(ICorrector corrector)
        {
            // Null corrector means no corrections to make
            if (corrector == null)
            {
                return;
            }

            this.Where = corrector.Correct(this.Where);
        }
コード例 #8
0
        private async Task<IResponse> Select(IRequestContext ctx, Route route)
        {
            string tableName = GetAndValidateTableName(route);
            if (!this.Database.TableExists(tableName))
            {
                return ArribaResponse.NotFound("Table not found to select from.");
            }

            string outputFormat = ctx.Request.ResourceParameters["fmt"];

            SelectQuery query = await SelectQueryFromRequest(this.Database, ctx);
            query.TableName = tableName;

            Table table = this.Database[tableName];
            SelectResult result = null;

            // If no columns were requested or this is RSS, get only the ID column
            if(query.Columns == null || query.Columns.Count == 0 || String.Equals(outputFormat, "rss", StringComparison.OrdinalIgnoreCase))
            {
                query.Columns = new string[] { table.IDColumn.Name };
            }

            // Read Joins, if passed
            IQuery<SelectResult> wrappedQuery = WrapInJoinQueryIfFound(query, this.Database, ctx);

            ICorrector correctors = this.CurrentCorrectors(ctx);
            using (ctx.Monitor(MonitorEventLevel.Verbose, "Correct", type: "Table", identity: tableName, detail: query.Where.ToString()))
            {
                // Run server correctors
                wrappedQuery.Correct(correctors);
            }

            using (ctx.Monitor(MonitorEventLevel.Information, "Select", type: "Table", identity: tableName, detail: query.Where.ToString()))
            {
                // Run the query
                result = this.Database.Query(wrappedQuery, (si) => this.IsInIdentity(ctx.Request.User, si));
            }

            // Format the result in the return format
            switch((outputFormat ?? "").ToLowerInvariant())
            {
                case "":
                case "json":
                    return ArribaResponse.Ok(result);
                case "csv":
                    return ToCsvResponse(result, $"{tableName}-{DateTime.Now:yyyyMMdd}.csv");
                case "rss":
                    return ToRssResponse(result, "", query.TableName + ": " + query.Where, ctx.Request.ResourceParameters["iURL"]);
                default:
                    throw new ArgumentException($"OutputFormat [fmt] passed, '{outputFormat}', was invalid.");
            }
        }
コード例 #9
0
        public void Correct(ICorrector corrector)
        {
            if (corrector == null)
            {
                throw new ArgumentNullException("corrector");
            }

            this.Where = corrector.Correct(this.Where);

            foreach (AggregationDimension dimension in this.Dimensions)
            {
                for (int i = 0; i < dimension.GroupByWhere.Count; ++i)
                {
                    dimension.GroupByWhere[i] = corrector.Correct(dimension.GroupByWhere[i]);
                }
            }
        }
コード例 #10
0
ファイル: ICorrector.cs プロジェクト: sharwell/elfie-arriba
        /// <summary>
        ///  Traverse the Expression, considering correcting each term
        ///  with the provided Corrector. This should be the default
        ///  implementation of Correct() for Correctors which only care
        ///  about correcting individual terms.
        ///
        ///  Callers which are not correctors should call corrector.Correct,
        ///  not this method, so that correctors which correct more broadly
        ///  than terms will work.
        /// </summary>
        /// <param name="expression">IExpression to correct</param>
        /// <param name="corrector">ICorrector to use</param>
        /// <returns>IExpression with any corrections</returns>
        public static IExpression CorrectTerms(IExpression expression, ICorrector corrector)
        {
            // Correct the root term, if it's a term
            if (expression is TermExpression)
            {
                IExpression correction = corrector.CorrectTerm((TermExpression)expression);
                if (correction != null)
                {
                    return(correction);
                }
            }
            else
            {
                // Otherwise, consider correcting each child and recurse
                IList <IExpression> children = expression.Children();

                for (int i = 0; i < children.Count; ++i)
                {
                    IExpression child = children[i];

                    // Correct this child, if it's a Term
                    if (child is TermExpression)
                    {
                        IExpression correction = corrector.CorrectTerm((TermExpression)child);
                        if (correction != null)
                        {
                            children[i] = correction;
                        }
                    }
                    else
                    {
                        // Otherwise, recurse
                        CorrectTerms(child, corrector);
                    }
                }
            }

            return(expression);
        }
コード例 #11
0
 public JoinCorrector(Database db, ICorrector nestedCorrector, IList <SelectQuery> querySet)
 {
     this.DB = db;
     this.NestedCorrector = nestedCorrector;
     this.Queries         = querySet;
 }
コード例 #12
0
ファイル: CorrectorChain.cs プロジェクト: yxw027/GNSSer
 /// <summary>
 /// 通过这种方法添加责任链的后继者。
 /// </summary>
 /// <param name="node">改正器</param>
 /// <returns></returns>
 public CorrectorChain <TCorrection, TInput> Add(ICorrector <TCorrection, TInput> node)
 {
     this.Correctors.Add(node);
     return(this);
 }
コード例 #13
0
 public Streams([NotNull] ICamera camera, [NotNull] IDenoiser denoiser, [NotNull] IBackgroundSubtractor subtractor, [NotNull] ICorrector corrector, [NotNull] IPeopleDetector detector)
 {
     Camera     = camera ?? throw new ArgumentNullException(nameof(camera));
     Denoiser   = denoiser ?? throw new ArgumentNullException(nameof(denoiser));
     Subtractor = subtractor ?? throw new ArgumentNullException(nameof(subtractor));
     Corrector  = corrector ?? throw new ArgumentNullException(nameof(corrector));
     Detector   = detector ?? throw new ArgumentNullException(nameof(detector));
 }
コード例 #14
0
ファイル: ObsCorrectionSetter.cs プロジェクト: yxw027/GNSSer
 /// <summary>
 /// 添加一个改正链表。
 /// 注意:添加的类型必须在 Process 中判断并处理,否则添加进来不会起作用的。
 /// </summary>
 /// <param name="chain">改正链表</param>
 public void AddCorrectorChain(ICorrector chain)
 {
     CorrectorChains.Add(chain);
 }
コード例 #15
0
 public void Add(ICorrector corrector)
 {
     this.InnerCorrectors.Add(corrector);
 }