Beispiel #1
0
        /// <summary>
        /// Gets or sets a value indicating whether [trim input].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [trim input]; otherwise, <c>false</c>.
        /// </value>

        /*
         * public List<String> NoDataWillCards
         * {
         *  get
         *  {
         *      if (!_noDataWillCards.Any())
         *      {
         *          return DefaultNoDataWillcads;
         *      }
         *      return _noDataWillCards;
         *  }
         *  set
         *  {
         *      if (value.SequenceEqual(DefaultNoDataWillcads))
         *      {
         *          return;
         *      }
         *      _noDataWillCards = value;
         *  }
         * }*/

        /// <summary>
        /// Performs a test on
        /// </summary>
        /// <param name="sourceTable">The source table.</param>
        /// <param name="type">The type.</param>
        /// <param name="i">The i.</param>
        /// <returns></returns>
        public SourceTableSliceTest MakeSliceTest(SourceTable sourceTable, SourceTableSliceType type, Int32 i = 0)
        {
            SourceTableSliceTest output = new SourceTableSliceTest()
            {
                format = type
            };

            switch (type)
            {
            case SourceTableSliceType.row:
                output.Values = sourceTable.GetRow(i);
                break;

            default:
            case SourceTableSliceType.column:
                output.Values = sourceTable.GetColumn(i);
                break;
            }

            //  CellContentType contentType = CellContentType.unknown;

            foreach (var v in output.Values)
            {
                output.ValueStats.Assign(DetermineContentType(v));

                //if (contentType == CellContentType.unknown)
                //{
                //    contentType = t.type;
                //} else if (contentType != t.type)
                //{
                //    if (!t.type.HasFlag(contentType))
                //    {
                //        output.IsUniformFormat = false;
                //    }
                //}

                if (v.IsNullOrEmpty())
                {
                    output.IsNoEmptyValue = false;
                }
                if (!output.DistinctValues.Contains(v))
                {
                    output.DistinctValues.Add(v);
                }
            }
            output.ValueStats.Compute();

            output.IsUniformFormat = output.ValueStats.IsUniformFormat();

            if (output.DistinctValues.Count < output.Values.Count)
            {
                output.IsDistinctValue = false;
            }
            return(output);
        }
        /// <summary>
        /// Performs a test on
        /// </summary>
        /// <param name="sourceTable">The source table.</param>
        /// <param name="type">The type.</param>
        /// <param name="i">The i.</param>
        /// <returns></returns>
        public SourceTableSliceTest MakeSliceTest(SourceTable sourceTable, SourceTableSliceType type, Int32 i = 0)
        {
            SourceTableSliceTest output = new SourceTableSliceTest()
            {
                format = type
            };

            switch (type)
            {
            case SourceTableSliceType.row:
                output.Values = sourceTable.GetRow(i);
                break;

            default:
            case SourceTableSliceType.column:
                output.Values = sourceTable.GetColumn(i);
                break;
            }

            CellContentType contentType    = CellContentType.unknown;
            List <String>   DistinctValues = new List <string>();

            foreach (var v in output.Values)
            {
                CellContentInfo t = sourceContentAnalysis.DetermineContentType(v);
                if (contentType == CellContentType.unknown)
                {
                    contentType = t.type;
                }
                else if (contentType != t.type)
                {
                    if (!t.type.HasFlag(contentType))
                    {
                        output.IsUniformFormat = false;
                    }
                }

                if (v.IsNullOrEmpty())
                {
                    output.IsNoEmptyValue = false;
                }
                if (!DistinctValues.Contains(v))
                {
                    DistinctValues.Add(v);
                }
            }
            if (DistinctValues.Count < output.Values.Count)
            {
                output.IsDistinctValue = false;
            }
            return(output);
        }