private static void VerifyAggregateListExitOperation <T>(AggregationFunc aggregation, IList <T> input, IList <T> expected, string description)
        {
            var listExitOperation = new ListExitOperation(null, 0, false, aggregation, null);
            var result            = listExitOperation.Execute(input);

            Assert.That(result, Is.EqualTo(expected), description);
        }
        /// <summary>
        /// Creates clone of another <see cref="ListExitOperationBuilder"/> instance.
        /// </summary>
        /// <param name="other">The builder to clone.</param>
        public ListExitOperationBuilder(ListExitOperationBuilder other)
        {
            Preconditions.CheckNotNull(other);

            this.orders.AddRange(other.orders);
            this.MaxResults  = other.MaxResults;
            this.FirstResult = other.FirstResult;
            this.Distinct    = other.Distinct;
            this.Aggregation = other.Aggregation;
        }
Exemple #3
0
        private static void VerifyAverageListExitOperation <T>(IList <T> input, IList <T> expected, string description)
        {
            AggregationFunc averageFunc = c => c.Average(
                arr => (double?)((object[])arr)[0],
                arr => (int?)((object[])arr)[1]);
            var listExitOperation = new ExitOperation(null, 0, false, averageFunc, null);
            var result            = listExitOperation.Execute(input);

            Assert.That(result, Is.EqualTo(expected), description);
        }
 /// <summary>
 ///     加载
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ctlMatchItem_Load(object sender, EventArgs e)
 {
     Common.UIAssistant.FillComberWithArray(cmbComparisonfunction, AggregationFunc.GetComparisonfunction(), true);
     if (RuntimeMongoDbContext.GetCurrentCollection() != null)
     {
         foreach (var item in MongoHelper.GetCollectionSchame(RuntimeMongoDbContext.GetCurrentCollection()))
         {
             cmbField.Items.Add(item);
         }
     }
 }
 /// <summary>
 /// Creates new <see cref="ExitOperation"/> instance.
 /// </summary>
 /// <param name="maxResults">Maximum number of results requested by the client.</param>
 /// <param name="firstResult">Index of the first result requested by the client.</param>
 /// <param name="distinct">Indication whether client requests removal of duplicate results.</param>
 /// <param name="aggregation">Optional aggregation function to be applied to the results. </param>
 /// <param name="order">Optional sort order to be applied to the results.</param>
 public ExitOperation(
     int?maxResults,
     int firstResult,
     bool distinct,
     AggregationFunc aggregation,
     IComparer <object> order)
 {
     this.MaxResults  = maxResults;
     this.FirstResult = firstResult;
     this.Distinct    = distinct;
     this.Aggregation = aggregation;
     this.Order       = order;
 }
Exemple #6
0
        public override int GetHashCode()
        {
            var hashCode = 1664113244;

            hashCode = hashCode * -1521134295 + Index.GetHashCode();
            hashCode = hashCode * -1521134295 + Name.GetHashCode();
            hashCode = hashCode * -1521134295 + NumberFmtId.GetHashCode();
            hashCode = hashCode * -1521134295 + AggregationFunc.GetHashCode();
            hashCode = hashCode * -1521134295 + AggregationFormula?.GetHashCode() ?? 0;
            hashCode = hashCode * -1521134295 + EqualityComparer <SharedItems> .Default.GetHashCode(Items);

            return(hashCode);
        }
Exemple #7
0
 private void GroupItem_Load(object sender, EventArgs e)
 {
     foreach (var item in AggregationFunc.GetGroupfunction())
     {
         cmbGroupFunction.Items.Add(item);
     }
     cmbGroupFunction.Items.Add("==========");
     if (RuntimeMongoDbContext.GetCurrentCollection() != null)
     {
         cmbGroupValue.Items.Add("1");
         foreach (var item in MongoHelper.GetCollectionSchame(RuntimeMongoDbContext.GetCurrentCollection()))
         {
             cmbGroupFunction.Items.Add("$" + item);
             cmbGroupValue.Items.Add("$" + item);
         }
     }
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new <see cref="MarkovChainMapBuilder{T}"/> instance with specified depth, and aggregation and
 /// partition functions.
 /// </summary>
 /// <param name="depth">Depth of the <see cref="MarkovChainMap{T}"/> to build.</param>
 /// <param name="partition"><see cref="PartitionFunc{T}"/> which will be used to build the
 /// <see cref="MarkovChainMap{T}"/>.</param>
 /// <param name="aggregate"><see cref="AggregationFunc{T}"/> which will be used to build the
 /// <see cref="MarkovChainMap{T}"/>.</param>
 /// <exception cref="ArgumentException"><paramref name="depth"/> is less than one.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="partition"/> is null, or <paramref name="aggregate"/>
 /// is null.</exception>
 public MarkovChainMapBuilder(int depth, PartitionFunc <T> partition, AggregationFunc <T> aggregate)
 {
     if (depth < 1)
     {
         throw new ArgumentException(nameof(depth));
     }
     if (partition == null)
     {
         throw new ArgumentNullException(nameof(partition));
     }
     if (aggregate == null)
     {
         throw new ArgumentNullException(nameof(aggregate));
     }
     _depth     = depth;
     _partition = partition;
     _aggregate = aggregate;
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new <see cref="MarkovChainStringMapBuilder"/> with specified depth and whitespace-skipping mode,
 /// as well as <see cref="PartitionFunc{T}"/> and <see cref="AggregationFunc{T}"/> functions for string type.
 /// </summary>
 /// <param name="depth">Depth of the <see cref="MarkovChainMap{T}"/> to build.</param>
 /// <param name="partition"><see cref="PartitionFunc{T}"/> which will be used to build the
 /// <see cref="MarkovChainMap{T}"/>.</param>
 /// <param name="aggregate"><see cref="AggregationFunc{T}"/> which will be used to build the
 /// <see cref="MarkovChainMap{T}"/>.</param>
 /// <param name="skipWhitespace">Whether or not white spaces should be considered while building maps. When set to
 /// true, individual samples will be split when containing white space(s). When set to false, white spaces will
 /// not be ignored, and thus will appear as valid states in the resulting map.</param>
 /// <exception cref="ArgumentException"><paramref name="depth"/> is less than one.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="partition"/> is null, or <paramref name="aggregate"/>
 /// is null.</exception>
 public MarkovChainStringMapBuilder(int depth, PartitionFunc <string> partition, AggregationFunc <string> aggregate,
                                    bool skipWhitespace = true)
     : base(depth, partition, aggregate)
 {
     _skipWhitespace = skipWhitespace;
 }