Esempio n. 1
0
        public override void Deserialize(IntermediateFormatReader reader)
        {
            reader.RegisterDeclaration(m_declaration);
            IScalabilityCache scalabilityCache = reader.PersistenceHelper as IScalabilityCache;

            while (reader.NextMember())
            {
                switch (reader.CurrentMember.MemberName)
                {
                case MemberName.ExpressionType:
                    m_expressionType = (Microsoft.ReportingServices.ReportProcessing.DataAggregate.DataTypeCode)reader.ReadEnum();
                    break;

                case MemberName.CurrentMin:
                    m_currentMin = reader.ReadVariant();
                    break;

                case MemberName.Comparer:
                {
                    int id = reader.ReadInt32();
                    m_comparer = (Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ProcessingComparer)scalabilityCache.FetchStaticReference(id);
                    break;
                }

                default:
                    Global.Tracer.Assert(condition: false);
                    break;
                }
            }
        }
        public static void BubbleDown <T>(this T[] source, int length, int index, IDataComparer <T> comparer)
        {
            int curIdx = index;

            while (curIdx < length)
            {
                int leftIndex = LeftIndex(curIdx);
                if (leftIndex >= length)
                {
                    return;
                }

                int rightIndex  = RightIndex(curIdx);
                int maxChildIdx = leftIndex;
                if (rightIndex < length && comparer.Compare(source[rightIndex], source[leftIndex]).IsFirstMore)
                {
                    maxChildIdx = rightIndex;
                }

                if (comparer.Compare(source[maxChildIdx], source[curIdx]).IsFirstMore)
                {
                    source.Swap(curIdx, maxChildIdx);
                    curIdx = maxChildIdx;
                    continue;
                }
                return;
            }
        }
Esempio n. 3
0
 public TeamRepository(
     IDbConnection connection,
     IDataComparer dataComparer,
     ITeamSqlGenerator sqlGenerator)
     : base(
         connection,
         dataComparer,
         sqlGenerator) => (_connection, _sqlGenerator) = (connection, sqlGenerator);
Esempio n. 4
0
 public ProjectRepository(
     IDbConnection connection,
     IDataComparer dataComparer,
     IProjectSqlGenerator sqlGenerator)
     : base(
         connection,
         dataComparer,
         sqlGenerator) => (_connection, _sqlGenerator) = (connection, sqlGenerator);
Esempio n. 5
0
 public DeliverableTypeRepository(
     IDbConnection connection,
     IDataComparer datacomparer,
     ISqlGenerator sqlGeneratorBase) :
     base(
         connection,
         datacomparer,
         sqlGeneratorBase)
 {
 }
Esempio n. 6
0
 public JurisdictionRepository(
     IDbConnection connection,
     IDataComparer datacomparer,
     ISqlGenerator sqlGeneratorBase) :
     base(
         connection,
         datacomparer,
         sqlGeneratorBase)
 {
 }
 public QuarterDueDateRepository(
     IDbConnection connection,
     IDataComparer datacomparer,
     ISqlGenerator sqlGeneratorBase) :
     base(
         connection,
         datacomparer,
         sqlGeneratorBase)
 {
 }
 public TaxPayerTypeRepository(
     IDbConnection connection,
     IDataComparer datacomparer,
     ISqlGenerator sqlGeneratorBase) :
     base(
         connection,
         datacomparer,
         sqlGeneratorBase)
 {
 }
Esempio n. 9
0
 public Repository(
     IDbConnection connection,
     IDataComparer datacomparer,
     ISqlGenerator sqlGeneratorBase)
 {
     Current           = new List <CleanEntity <TEntity> >();
     ActionCreated     = delegate { };
     _connection       = connection;
     _dataComparer     = datacomparer;
     _sqlGeneratorBase = sqlGeneratorBase;
 }
Esempio n. 10
0
 public FormRepository(
     IDbConnection connection,
     IDataComparer datacomparer,
     IFormSqlGenerator sqlGeneratorBase) :
     base(
         connection,
         datacomparer,
         sqlGeneratorBase)
 {
     _sqlGenerator = sqlGeneratorBase;
     _connection   = connection;
     _dataComparer = datacomparer;
 }
Esempio n. 11
0
 public static T[] ApplyInsertionSort <T>(this T[] source, IDataComparer <T> comparer)
 {
     for (int idx = 1; idx < source.Length; idx++)
     {
         T   currentItem = source[idx];
         int prev        = idx - 1;
         while (prev >= 0 && comparer.Compare(source[prev], currentItem).IsFirstMore)
         {
             source[prev + 1] = source[prev];
             prev--;
         }
         source[prev + 1] = currentItem;
     }
     return(source);
 }
        public static T[] ApplySelectionSort <T>(this T[] source, IDataComparer <T> comparer)
        {
            for (int swapIdx = 0; swapIdx < source.Length - 1; swapIdx++)
            {
                int minIdx = swapIdx;
                for (int idx = swapIdx + 1; idx < source.Length; idx++)
                {
                    var item1 = source[minIdx];
                    var item2 = source[idx];
                    if (comparer.Compare(item1, item2).IsFirstMore)
                    {
                        minIdx = idx;
                    }
                }

                source.Swap(swapIdx, minIdx);
            }
            return(source);
        }
Esempio n. 13
0
        public UnitOfWork(
            IDbConnection connection,
            ITeamRepository teams,
            IProjectRepository projects,
            IDueDateRepository duedates,
            ITaxPayerTypeRepository taxPayerTypes,
            IDeliverableTypeRepository deliverableTypes,
            IJurisdictionRepository jurisdictions,
            IFormRepository forms,
            ITaxYearRepository taxYears,
            IQuarterRepository quarters,
            IQuarterDueDateRepository quarterDueDates,
            ISqlGenerator sqlGeneratorBase,
            IDataComparer datacomparer)
        {
            _connection = connection;

            Teams            = teams;
            DueDates         = duedates;
            Projects         = projects;
            TaxPayerTypes    = taxPayerTypes;
            DeliverableTypes = deliverableTypes;
            Jurisdictions    = jurisdictions;
            Forms            = forms;
            TaxYears         = taxYears;
            Quarters         = quarters;
            QuarterDueDates  = quarterDueDates;

            Teams.ActionCreated            += ActionCreated;
            DueDates.ActionCreated         += ActionCreated;
            Projects.ActionCreated         += ActionCreated;
            TaxPayerTypes.ActionCreated    += ActionCreated;
            DeliverableTypes.ActionCreated += ActionCreated;
            Jurisdictions.ActionCreated    += ActionCreated;
            Forms.ActionCreated            += ActionCreated;
            TaxYears.ActionCreated         += ActionCreated;
            Quarters.ActionCreated         += ActionCreated;
            QuarterDueDates.ActionCreated  += ActionCreated;

            _sqlGeneratorBase = sqlGeneratorBase;
            _dataComparer     = datacomparer;
            ActionsQueue      = new Queue <EntityAction>();
        }
Esempio n. 14
0
        public static T[] ApplyMergeSort <T>(this T[] source, IDataComparer <T> comparer)
        {
            int size         = source.Length;
            int maxLength    = size - 1;
            int divideLength = 1;

            while (divideLength < size)
            {
                int  startIdx  = 0;
                bool isStopped = false;
                var  newLength = divideLength * 2;

                while (!isStopped)
                {
                    var start = startIdx;
                    var end   = startIdx + newLength - 1;
                    var split = (end - start) / 2 + start;

                    if (!source.IndexExists(split))
                    {
                        split = maxLength;
                    }
                    if (!source.IndexExists(end))
                    {
                        end = maxLength;
                    }

                    isStopped = end == maxLength;
                    source.MergeByMinElements(
                        start,
                        split,
                        end,
                        comparer
                        );
                    startIdx += newLength;
                }

                divideLength = newLength;
            }
            return(source);
        }
Esempio n. 15
0
        public static T[] ApplyBubbleSort <T>(this T[] source, IDataComparer <T> comparer)
        {
            bool isSorted     = false;
            int  lastUnsorted = source.Length - 1;

            while (!isSorted)
            {
                isSorted = true;
                for (int idx = 0; idx < lastUnsorted; idx++)
                {
                    var item1 = source[idx];
                    var item2 = source[idx + 1];
                    if (comparer.Compare(item1, item2).IsFirstMore)
                    {
                        source.Swap(idx, idx + 1);
                        isSorted = false;
                    }
                }
                lastUnsorted--;
            }
            return(source);
        }
        public static T[] ApplyHeapSort <T>(this T[] source, IDataComparer <T> comparer)
        {
            int length = source.Length;

            var index = length / 2 - 1;

            while (index >= 0)
            {
                source.BubbleDown(length, index, comparer);
                index--;
            }

            var end = length - 1;

            while (end >= 0)
            {
                source.Swap(0, end);
                source.BubbleDown(end, 0, comparer);
                end--;
            }

            return(source);
        }
Esempio n. 17
0
        public static bool BinarySearch <T>(this T[] arr, T item, IDataComparer <T> comparer)
        {
            int left  = 0;
            int right = arr.Length - 1;

            while (left <= right)
            {
                int middle        = (right - left) / 2 + left;
                var compareResult = comparer.Compare(item, arr[middle]);
                if (compareResult.IsEqual)
                {
                    return(true);
                }
                if (compareResult.IsFirstLess)
                {
                    right = middle - 1;
                }
                if (compareResult.IsFirstMore)
                {
                    left = middle + 1;
                }
            }
            return(false);
        }
Esempio n. 18
0
 internal MyBottomComparer(IDataComparer comparer)
 {
     m_comparer = comparer;
 }
Esempio n. 19
0
 internal MyTopComparer(IDataComparer comparer)
 {
     m_comparer = comparer;
 }
Esempio n. 20
0
 public DueDateSqlGenerator(IDataComparer dataComparer) : base(dataComparer)
 {
 }
Esempio n. 21
0
 public MyTopComparer(IDataComparer comparer)
 {
     this.m_comparer = comparer;
 }
Esempio n. 22
0
 public TeamSqlGenerator(IDataComparer dataComparer) : base(dataComparer)
 {
 }
Esempio n. 23
0
 public MyBottomComparer(IDataComparer comparer)
 {
     this.m_comparer = comparer;
 }
Esempio n. 24
0
 public TaxYearSqlGenerator(IDataComparer dataComparer) : base(dataComparer)
 {
 }
Esempio n. 25
0
        public static void MergeByMinElements <T>(this T[] arr, int start, int split, int end, IDataComparer <T> comparer)
        {
            var buffer    = new T[end - start + 1];
            var firstIdx  = start;
            var secondIdx = split + 1;
            int resIdx    = 0;

            while (firstIdx <= split && secondIdx <= end)
            {
                if (comparer.Compare(arr[firstIdx], arr[secondIdx]).IsFirstMore)
                {
                    buffer[resIdx] = arr[secondIdx];
                    secondIdx++;
                }
                else
                {
                    buffer[resIdx] = arr[firstIdx];
                    firstIdx++;
                }
                resIdx++;
            }

            while (firstIdx <= split)
            {
                buffer[resIdx] = arr[firstIdx];
                firstIdx++;
                resIdx++;
            }

            while (secondIdx <= end)
            {
                buffer[resIdx] = arr[secondIdx];
                secondIdx++;
                resIdx++;
            }

            buffer.CopyTo(arr, start);
        }
Esempio n. 26
0
 public static IEnumerable <T> ApplyMergeSort <T>(this IEnumerable <T> source, IDataComparer <T> comparer)
 {
     return(ApplyMergeSort(source.ToArray(), comparer));
 }
Esempio n. 27
0
 public BaseSqlGenerator(IDataComparer dataComparer) => _dataComparer = dataComparer;
Esempio n. 28
0
 public static bool BinarySearch <T>(this IEnumerable <T> arr, T item, IDataComparer <T> comparer)
 {
     return(arr.ToArray().BinarySearch(item, comparer));
 }
Esempio n. 29
0
 internal Min(IDataComparer comparer)
 {
     m_currentMin = null;
     m_comparer   = comparer;
 }
Esempio n. 30
0
 public Max(IDataComparer comparer)
 {
     this.m_currentMax = null;
     this.m_comparer   = comparer;
 }