示例#1
0
文件: Folder.cs 项目: fr4gles/API
        public void AggregateState()
        {
            State = Items != null && Items.Any() ?
                    Items.Aggregate(ByPriority).State :
                    State.None;

            Count = (State == State.None || State == State.Disabled || State == State.Ok) ? 0 : CountItems(Items, State);
        }
        /// <summary>
        /// Для отладки
        /// </summary>
        /// <returns></returns>
        public override String ToString()
        {
            if (Items.Count == 0)
            {
                return("");
            }

            return(Items.Aggregate("", (current, item) => current + (item.LLPLifeLimit.ToString() + "; ")));
        }
 public override int GetHashCode()
 {
     unchecked
     {
         const int seed     = 487;
         const int modifier = 31;
         return(Items.Aggregate(seed, (current, item) =>
                                (current * modifier) + item.GetHashCode()));
     }
 }
    private void OnSaveCommand()
    {
        var message = Items.Aggregate(new StringBuilder(),
                                      (builder, item) => builder.AppendLine($"{item.Name} {item.Value}"));

        message.AppendLine("Will be save");


        MessageBox.Show(message.ToString());
    }
示例#5
0
        public override int GetHashCode()
        {
            var hc = 0;

            if (Items != null)
            {
                hc = Items.Aggregate(hc, (current, p) => current ^ p.GetHashCode());
            }

            return(new { Name, hc }.GetHashCode());
        }
示例#6
0
        public void Visit(AggregateNode node)
        {
            node.Inner[0].Accept(this);

            Items = Items.Aggregate(() => node.Aggregates.Select(a => a.Initialize()).ToArray(), Update, Join, Complete).AsParallel().AsOrdered();

            object[] Update(object[] state, LogItem item)
            {
                for (var n = 0; n < node.Aggregates.Length; n++)
                {
                    state[n] = node.Aggregates[n].Update(state[n], item);
                }

                return(state);
            }

            object[] Join(object[] a, object[] b)
            {
                for (var n = 0; n < node.Aggregates.Length; n++)
                {
                    a[n] = node.Aggregates[n].Join(a[n], b[n]);
                }

                return(a);
            }

            IEnumerable <LogItem> Complete(object[] state)
            {
                var aggregates = node.Aggregates.Select((a, i) => a.Complete(state[i]).GetEnumerator()).ToArray();
                var hasNext    = aggregates.Select(a => a.MoveNext()).ToArray();

                while (hasNext.Any(a => a))
                {
                    var item = new LogItem(string.Empty, string.Empty, string.Empty, 0, 0);
                    for (var n = 0; n < aggregates.Length; n++)
                    {
                        if (hasNext[n])
                        {
                            item.Fields[node.Names[n]] = aggregates[n].Current;
                        }
                        else
                        {
                            item.Fields[node.Names[n]] = null;
                        }

                        hasNext[n] = aggregates[n].MoveNext();
                    }

                    yield return(item);
                }
            }
        }
示例#7
0
        public int GetMerchantTax()
        {
            var resultTax = Items.Aggregate <KeyValuePair <int, MerchantItem>, double>(0, (current, item) => current + Math.Round((double)item.Value.Price * item.Value.Stack));

            resultTax = (resultTax * 0.0001);

            if (resultTax > int.MaxValue)
            {
                return(int.MaxValue);
            }

            return((int)resultTax);
        }
示例#8
0
        /// <summary>
        /// Initializes the mastery.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">character</exception>
        internal void Initialize()
        {
            while (true)
            {
                bool updatedAnything = Items
                                       .Aggregate(false, (current, mastery) => current | mastery.TryUpdateMasteryStatus());

                if (!updatedAnything)
                {
                    break;
                }
            }
        }
示例#9
0
 public ItemGroupWithQualities(string name, IEnumerable <ItemWithQualities> items)
 {
     Name             = name;
     Items            = items.ToList();
     LowQuality       = Items.Aggregate(new BoolNotifyCollection(), (seed, i) => { seed.Add(i.LowQuality); return(seed); });
     NormalQuality    = Items.Aggregate(new BoolNotifyCollection(), (seed, i) => { seed.Add(i.NormalQuality); return(seed); });
     SuperiorQuality  = Items.Aggregate(new BoolNotifyCollection(), (seed, i) => { seed.Add(i.SuperiorQuality); return(seed); });
     MagicQuality     = Items.Aggregate(new BoolNotifyCollection(), (seed, i) => { seed.Add(i.MagicQuality); return(seed); });
     RareQuality      = Items.Aggregate(new BoolNotifyCollection(), (seed, i) => { seed.Add(i.RareQuality); return(seed); });
     SetQuality       = Items.Aggregate(new BoolNotifyCollection(), (seed, i) => { seed.Add(i.SetQuality); return(seed); });
     UniqueQuality    = Items.Aggregate(new BoolNotifyCollection(), (seed, i) => { seed.Add(i.UniqueQuality); return(seed); });
     CraftedQuality   = Items.Aggregate(new BoolNotifyCollection(), (seed, i) => { seed.Add(i.CraftedQuality); return(seed); });
     HonorificQuality = Items.Aggregate(new BoolNotifyCollection(), (seed, i) => { seed.Add(i.HonorificQuality); return(seed); });
 }
        public override bool CalculateResult(object entity)
        {
            if (!Items.Any())
            {
                return(true);
            }

            if (Type == ConditionGroupType.And)
            {
                return(Items.Aggregate(true, (current, item) => current && item.CalculateResult(entity)));
            }
            else
            {
                return(Items.Aggregate(false, (current, item) => current || item.CalculateResult(entity)));
            }
        }
示例#11
0
        public PipelineResult Execute(PipelineResult result)
        {
            var tempValue = result.Result;
            var value     = result.Result;

            if (value == null)
            {
                return(result);
            }

            result = Items.Aggregate(result, (current, item) => item.Execute(value.GetType(), current));

            if (value == null)
            {
                throw new RegistrationNotFoundException(tempValue.GetType());
            }

            return(result);
        }
        /// <inheritdoc cref="GLOFC.GL4.Controls.GLBaseControl.SizeControl(Size)"/>
        protected override void SizeControl(Size parentsize)
        {
            base.SizeControl(parentsize);
            if (AutoSize)
            {
                SizeF size = new Size(80, 24);

                if (Items != null)
                {
                    string longest = Items.Aggregate("", (max, cur) => max.Length > cur.Length ? max : cur);
                    if (longest.HasChars())
                    {
                        size = GLOFC.Utils.BitMapHelpers.MeasureStringInBitmap(longest, Font, ControlHelpersStaticFunc.StringFormatFromContentAlignment(ContentAlignment.MiddleLeft));
                        int arrowwidth = Font.ScalePixels(20);
                        size.Width  += arrowwidth + textspacing * 2;
                        size.Height += textspacing * 2;
                    }
                }
                SetNI(clientsize: new Size((int)size.Width, (int)size.Height));
            }
        }
示例#13
0
        public string GetLog()
        {
            StringBuilder sb = new StringBuilder();

            if (Items.Count > 0)
            {
                sb.AppendLine(__breakline);
                var maxKeyLength = Items.Aggregate((l, r) => l.Key.ToString().Length > r.Key.ToString().Length ? l : r).Key;
                //var totalTime = Items.Sum(i => i.Value.ElapsedMilliseconds);

                foreach (KeyValuePair <ExecutionTimeTrackers, Stopwatch> item in Items)
                {
                    sb.AppendLine(string.Format("{0}:{1}", item.Key.ToString().PadRight(maxKeyLength.ToString().Length, ' '),
                                                FormatMiliseconds(item.Value.ElapsedMilliseconds)));
                }
                sb.AppendLine(__breakline);
                sb.AppendLine(string.Format("{0}:{1}", "Total Time".PadRight(maxKeyLength.ToString().Length, ' '),
                                            TotalTimeFormatted));
                sb.AppendLine(__breakline);
            }
            return(sb.ToString());
        }
示例#14
0
 public override string ToString()
 {
     return
         (string.Format(
              "{{ ID: {0}, Index: {1}, Name: {2}, Gender: {3}, Ass: {4}, Position: {5}, Rect: {6} Items: [{7}], Bytes: [{8}]}}, List: [{9}]}}",
              ID,
              Index,
              Name,
              Gender,
              Ass,
              Position,
              Rect,
              Items == null
                 ? null
                 : Items.Aggregate(string.Empty, (s, n) => string.IsNullOrEmpty(s) ? n.ToString() : s + ", " + n),
              Bytes == null
                 ? null
                 : Bytes.Aggregate(string.Empty, (s, n) => string.IsNullOrEmpty(s) ? n.ToString() : s + ", " + n),
              List == null
                 ? null
                 : List.Aggregate(string.Empty, (s, n) => string.IsNullOrEmpty(s) ? n.ToString() : s + ", " + n)
              ));
 }
 public override int GetHashCode()
 {
     return(Key.SelectOrDefault(k => k.GetHashCode(), 0)
            ^ Items.Aggregate(0, (hash, i) => hash ^ i.GetHashCode()));
 }
 protected override ISpecification <T> BuildImpl()
 {
     return(Items.Aggregate(Specification.True <T>(), (current, item) => current.And(item.Build())));
 }
示例#17
0
 /// <summary>
 ///     Returns items in a query string format.
 /// </summary>
 /// <param name="paramName"></param>
 /// <returns></returns>
 internal string GetItemQuery(string paramName)
 {
     return(Items.Count == 0
         ? ""
         : Items.Aggregate("", (current, type) => current + (paramName + "=" + type + "&")));
 }
示例#18
0
 /// <summary>
 /// Computes the hash code for the current <see cref="ResourceName"/>.
 /// </summary>
 /// <returns>
 /// The hash code for the current <see cref="ResourceName"/>.
 /// </returns>
 /// <seealso cref="M:System.Object.GetHashCode()"/>
 public override int GetHashCode()
 {
     return(Items.Aggregate(seed: 17, func: (value, part) => (value * 23) + part.GetHashCode()));
 }
示例#19
0
 public string GetAllPassiveInv()
 {
     return(Items.Aggregate("", (current, item) => current + $"{item}\n"));
 }
示例#20
0
 public override string ToString()
 {
     return(Items.Aggregate("{", (currentString, el) => currentString + (el.ToString() + ", ")) + "}");
 }
示例#21
0
 public double TotalItemsCost()
 {
     return(Items.Aggregate <IItem, double>(0, (current, item) => current + item.Total()));
 }
示例#22
0
 public void AggregateState()
 {
     State = Items != null && Items.Any() ?
             Items.Aggregate(ByPriority).State :
             State.None;
 }
示例#23
0
        public string Get(string propertyName)
        {
            switch (propertyName)
            {
            //ELEMENT
            case nameof(ClassId):
                return(ClassId.ToString());

            case nameof(AutomationId):
                return(AutomationId.ToString());

            case nameof(Id):
                return(Id.ToString());

            case nameof(StyleId):
                return(StyleId.ToString());

            //VISUAL ELEMENT
            case nameof(AnchorX):
                return(AnchorX.ToString());

            case nameof(AnchorY):
                return(AnchorY.ToString());

            case nameof(BackgroundColor):
                return(BackgroundColor.ToHex());

            case nameof(Width):
                return(this.Width.ToString());

            case nameof(Height):
                return(this.Height.ToString());

            case nameof(IsEnabled):
                return(IsEnabled.ToString());

            case nameof(WidthRequest):
                return(this.WidthRequest.ToString());

            case nameof(HeightRequest):
                return(this.HeightRequest.ToString());

            case nameof(IsFocused):
                return(IsFocused.ToString());

            case nameof(IsVisible):
                return(IsVisible.ToString());

            case nameof(InputTransparent):
                return(InputTransparent.ToString());

            case nameof(X):
                return(this.X.ToString());

            case nameof(Y):
                return(this.Y.ToString());

            case nameof(Opacity):
                return(this.Opacity.ToString());

            case nameof(TranslationX):
                return(this.TranslationX.ToString());

            case nameof(TranslationY):
                return(this.TranslationY.ToString());

            case nameof(Rotation):
                return(this.Rotation.ToString());

            case nameof(RotationX):
                return(this.RotationX.ToString());

            case nameof(RotationY):
                return(this.RotationY.ToString());

            case nameof(Scale):
                return(this.Scale.ToString());

            //VIEW
            case nameof(Margin):
                return(this.Margin.ToString());

            case nameof(VerticalOptions):
                return(this.VerticalOptions.ToString());

            case nameof(HorizontalOptions):
                return(this.HorizontalOptions.ToString());

            //PICKER
            case nameof(ItemsSource):
                return(ItemsSource.OfType <object>().Select(x => x.ToString()).Aggregate((x, y) => x + "," + y));

            case nameof(SelectedItem):
                return(SelectedItem.ToString());

            case nameof(SelectedIndex):
                return(SelectedIndex.ToString());

            case nameof(Items):
                return(Items.Aggregate((x, y) => x + "," + y));

            case nameof(Title):
                return(Title);

            default:
                return(string.Empty);
            }
        }
示例#24
0
        public void Visit(GroupByNode node)
        {
            node.Inner[0].Accept(this);

            Items = Items.Aggregate(() => new Dictionary <GroupKey, object[]>(), Update, Join, Complete).AsParallel().AsOrdered();

            Dictionary <GroupKey, object[]> Update(Dictionary <GroupKey, object[]> state, LogItem item)
            {
                // calculate the key for the item
                var key = new GroupKey(item, node.GroupFunctions.Select(k => k(item)).ToArray());

                // find the group for the item
                object[] group;
                if (!state.TryGetValue(key, out group))
                {
                    group      = node.Aggregates.Select(a => a.Initialize()).ToArray();
                    state[key] = group;
                }

                // update the group with the item
                for (var n = 0; n < node.Aggregates.Length; n++)
                {
                    group[n] = node.Aggregates[n].Update(group[n], item);
                }

                return(state);
            }

            Dictionary <GroupKey, object[]> Join(Dictionary <GroupKey, object[]> a, Dictionary <GroupKey, object[]> b)
            {
                foreach (var group in b)
                {
                    if (a.ContainsKey(group.Key))
                    {
                        a[group.Key] = node.Aggregates.Select((x, i) => x.Join(a[group.Key][i], group.Value[i])).ToArray();
                    }
                    else
                    {
                        a[group.Key] = group.Value;
                    }
                }

                return(a);
            }

            IEnumerable <LogItem> Complete(Dictionary <GroupKey, object[]> state)
            {
                foreach (var key in state.Keys)
                {
                    // create a new item and populate it using the group key
                    var item = new LogItem(string.Empty, key.Anchor.File, key.Anchor.Member, key.Anchor.Position, key.Anchor.Line);
                    for (var n = 0; n < node.GroupNames.Length; n++)
                    {
                        item.Fields[node.GroupNames[n]] = key.Values[n];
                    }

                    // complete all aggregates for the group and add them to the group
                    var aggregates = node.Aggregates.Select((a, i) => a.Complete(state[key][i]).ToList()).ToList();
                    for (var n = 0; n < node.Aggregates.Length; n++)
                    {
                        if (aggregates[n].Count > 1)
                        {
                            item.Fields[node.AggregateNames[n]] = string.Join("\n", aggregates[n]);
                        }
                        else
                        {
                            item.Fields[node.AggregateNames[n]] = aggregates[n].FirstOrDefault();
                        }
                    }

                    yield return(item);
                }
            }
        }
示例#25
0
 /// <summary>
 /// 获得 所有选中节点集合
 /// </summary>
 /// <returns></returns>
 public IEnumerable <TreeItem> GetCheckedItems() => Items.Aggregate(new List <TreeItem>(), (t, item) =>
 {
     t.Add(item);
     t.AddRange(item.GetAllSubItems());
     return(t);
 }).Where(i => i.Checked);
示例#26
0
 public int GetPriceOfAllItems()
 {
     return(Items.Aggregate(0, (acc, i) => i.Price + acc));
 }
示例#27
0
 private Money CalculateTotalPrice()
 {
     return(Items.Aggregate(Money.Zero(), (m, i) => m + i.TotalPrice));
 }
示例#28
0
 public ItemGroupWithoutQualities(string name, IEnumerable <ItemWithoutQualities> items)
 {
     Name            = name;
     Items           = items.ToList();
     AllItemsEnabled = Items.Aggregate(new BoolNotifyCollection(), (seed, i) => { seed.Add(i.Selected); return(seed); });
 }
        public override string ToString()
        {
            string result = Items.Aggregate(string.Empty, (current, item) => string.Concat(current, Splitter, item.Name));

            return(string.Concat(base.ToString(), result, Splitter));
        }
示例#30
0
文件: Array.cs 项目: Astn/ekati
 public override int GetHashCode()
 {
     return(Items != null ? Items.Aggregate(0, ((i, primitive) => HashCode.Combine(i, primitive.GetHashCode()))) : 0);
 }