Esempio n. 1
0
 public static void ClearPairsValue(BaseScndCnpValue Destination)
 {
     if (Destination == null)
     {
         Destination = new PairableScndCnpValue();
     }
     ((PairableScndCnpValue)Destination).ClearPairs();
 }
Esempio n. 2
0
 public static void AppendPairsToScndCnpValue(BasePairableConceptValue <PermitPair> Source, BaseScndCnpValue Destination)
 {
     if (Destination == null)
     {
         Destination = new PairableScndCnpValue();
     }
     ((PairableScndCnpValue)Destination).AppendPairs(Source.Pairs);
 }
Esempio n. 3
0
 public static void AppendPairsToScndCnpValue(BaseScndCnpValue Source, BaseScndCnpValue Destination)
 {
     if (Destination == null)
     {
         Destination = new PairableScndCnpValue();
     }
     ((PairableScndCnpValue)Destination).AppendPairs(((PairableScndCnpValue)Source).Pairs);
 }
Esempio n. 4
0
 public static void AddPairToScndCnpValue(IPair Source, BaseScndCnpValue Destination)
 {
     if (Destination == null)
     {
         Destination = new PairableScndCnpValue();
     }
     ((PairableScndCnpValue)Destination).AddPair(Source);
 }
Esempio n. 5
0
 /// <summary>
 /// اضافه نمودن زوج مرتب های پارامتر ارسالی به خصوصیت زوج مرتب
 /// </summary>
 /// <param name="Source">لیستی از زوج مرتب ها که باید اضافه گردند</param>
 public virtual void AppendPairs(PairableScndCnpValue Source)
 {
     foreach (IPair pair in Source.Pairs)
     {
         this.Pairs.Add(new PairableScndCnpValuePair(pair.From, pair.To, this));
     }
     this.Value = this.PairValues;
 }
Esempio n. 6
0
        public static PairableScndCnpValue SortOrderPairs(this PairableScndCnpValue Source)
        {
            if (!Source.Pairs.Any())
            {
                return(Source);
            }

            var innerList = new List <IPair>();

            innerList.AddRange(Source.Pairs.OrderBy(x => x.From).ThenBy(x => x.To));

            Source.Pairs.Clear();
            foreach (IPair pair in innerList)
            {
                Source.Pairs.Add(pair);
            }

            return(Source);
        }
Esempio n. 7
0
        /// <summary>
        /// وظیفه این تابع کم کردن مقدار ورودی از آخرین زوج مرتب های "مفهوم زوج مرتبی" می باشد
        /// </summary>
        /// <returns>مقادیری که حذف شده اند</returns>
        /// <param name="value"></param>
        public virtual PairableScndCnpValue DecreasePairFromLast(int value)
        {
            PairableScndCnpValue pairList = new PairableScndCnpValue();

            if (value <= 0)
            {
                return(pairList);
            }
            foreach (IPair pair in this.Pairs.OrderByDescending(p => p.From))
            {
                if (pair.Value <= value)
                {
                    //مقداری که باید کم شود بزرگتر از اندازه زوج مرتب است بنابراین
                    //کل زوج مرتب را حذف می کنیم
                    value -= pair.Value;
                    pairList.Pairs.Add(pair);
                    this.RemovePair(pair);
                }
                else
                {
                    //مقداری که باید کم شود کوچکتر از اندازه زوج مرتب است بنابراین
                    //از مقدار "تا" زوج مرتب کم کرده و به عملیات خاتمه می دهیم
                    IPair p = new PairableScndCnpValuePair(pair.To - value, pair.To);
                    pairList.Pairs.Add(p);
                    pair.To -= value;
                    value    = 0;
                    break;
                }
            }
            this.Value = this.PairValues;
            if (value > 0) //اضافه کار میتواند منفی شود.فلوچار قانون 92
            {
                this.Value = -1 * value;
            }
            return(pairList);
        }