コード例 #1
0
ファイル: Proyectos.aspx.cs プロジェクト: jramiloQV/Fonade
        public string CargarEvaluadores(int codproyecto)
        {
            string evaluador = string.Empty;

            if (codproyecto != 0)
            {
                var query = consultas.Db.Contacto.Join(consultas.Db.ProyectoContactos,
                                                       (c => c.Id_Contacto),
                                                       (p => p.CodContacto),
                                                       (c, p) => new
                {
                    Evaluador  = c.Nombres + " " + c.Apellidos,
                    PInactivo  = p.Inactivo,
                    CInactivo  = c.Inactivo,
                    Codproyect = p.CodProyecto,
                    Rols       = p.CodRol
                }).Where(
                    r =>
                    r.PInactivo == false &&
                    r.Rols == Constantes.CONST_RolEvaluador &&
                    r.Codproyect == codproyecto &&
                    r.CInactivo == false);


                if (query.Any())
                {
                    evaluador = Enumerable.Aggregate(query, evaluador, (valor, items) => valor + items.Evaluador);
                }
            }


            return(evaluador);
        }
        protected override List <ID> GetReference(PlayList entity, Item accountItem)
        {
            if (entity.PlayListSearch == null || entity.PlayListSearch.FilterTags == null || entity.PlayListSearch.FilterTags.Count == 0)
            {
                return(new List <ID>(0));
            }
            Expression <Func <TagSearchResult, bool> > ancestorFilter = ContentSearchUtil.GetAncestorFilter <TagSearchResult>(accountItem, TemplateIDs.Tag);
            Expression <Func <TagSearchResult, bool> > second         = Enumerable.Aggregate <string, Expression <Func <TagSearchResult, bool> > >((IEnumerable <string>)entity.PlayListSearch.FilterTags, PredicateBuilder.False <TagSearchResult>(), (Func <Expression <Func <TagSearchResult, bool> >, string, Expression <Func <TagSearchResult, bool> > >)((current, tmp) => PredicateBuilder.Or <TagSearchResult>(current, (Expression <Func <TagSearchResult, bool> >)(i => i.TagName == tmp))));
            List <TagSearchResult> all = ContentSearchUtil.FindAll <TagSearchResult>(Configuration.Settings.IndexName, PredicateBuilder.And <TagSearchResult>(ancestorFilter, second));

            if (all.Count < entity.PlayListSearch.FilterTags.Count)
            {
                IItemSynchronizer itemSynchronizer = MediaFrameworkContext.GetItemSynchronizer(typeof(Entities.Tag));
                if (itemSynchronizer != null)
                {
                    foreach (string str in entity.PlayListSearch.FilterTags)
                    {
                        string tagName = str;
                        if (!Enumerable.Any <TagSearchResult>((IEnumerable <TagSearchResult>)all, (Func <TagSearchResult, bool>)(i => i.Name == tagName)))
                        {
                            TagSearchResult tagSearchResult = itemSynchronizer.Fallback((object)new Entities.Tag()
                            {
                                Name = tagName
                            }, accountItem) as TagSearchResult;
                            if (tagSearchResult != null)
                            {
                                all.Add(tagSearchResult);
                            }
                        }
                    }
                }
            }
            return(Enumerable.ToList <ID>(Enumerable.Select <TagSearchResult, ID>((IEnumerable <TagSearchResult>)all, (Func <TagSearchResult, ID>)(i => i.ItemId))));
        }
コード例 #3
0
        public LambdaExpression CreateLambda(Type from, Type to)
        {
            var fromParameters = from.GetTypeInfo().GenericTypeArguments;
            var toParameters   = to.GetTypeInfo().GenericTypeArguments;

            var converters = fromParameters
                             .Zip(toParameters, (f, t) => Ref.GetLambda(f, t))
                             .ToArray();
            var input = Ex.Parameter(from, "input");

            var res = toParameters.Select(t => Ex.Parameter(typeof(ConversionResult <>).MakeGenericType(t))).ToArray();

            var conversion = res.Select((r, i) =>
                                        Ex.Assign(res[i], converters[i].ApplyTo(Ex.PropertyOrField(input, $"Item{i + 1}")))).ToArray();
            var conversionSuccesful = Enumerable.Aggregate(res, (Ex)Ex.Constant(true),
                                                           (c, p) => Ex.MakeBinary(Et.AndAlso, c, Ex.Property(p, nameof(IConversionResult.IsSuccessful))));

            var block = Ex.Block(res,
                                 Ex.Block(conversion),
                                 Ex.Condition(conversionSuccesful,
                                              Result(to,
                                                     Ex.Call(Creator(to), Enumerable.Select(res, p => Ex.Property(p, nameof(IConversionResult.Result))))),
                                              NoResult(to)));
            var lambda = Ex.Lambda(block, input);

            return(lambda);
        }
コード例 #4
0
        public LongRunningAction SpiralAround(bool withCamera, bool hideDot)
        {
            this.Dot.PreventPoI = true;
            Vector3 center  = Enumerable.Aggregate <TrileInstance, Vector3>((IEnumerable <TrileInstance>) this.LevelManager.Triles.Values, Vector3.Zero, (Func <Vector3, TrileInstance, Vector3>)((a, b) => a + b.Position)) / (float)this.LevelManager.Triles.Values.Count;
            Vector3 vector3 = this.LevelManager.Size + 4f * Vector3.UnitY;

            if (this.LevelManager.Name == "SEWER_HUB")
            {
                vector3 -= Vector3.UnitY * 20f;
            }
            if (this.LevelManager.Name.EndsWith("BIG_TOWER"))
            {
                vector3 -= Vector3.UnitY * 13.5f;
            }
            this.Dot.SpiralAround(new Volume()
            {
                From = Vector3.Zero,
                To   = vector3
            }, center, (hideDot ? 1 : 0) != 0);
            return(new LongRunningAction((Func <float, float, bool>)((_, __) => this.Dot.Behaviour == DotHost.BehaviourType.ReadyToTalk), (Action)(() =>
            {
                this.CameraManager.Constrained = false;
                this.Dot.PreventPoI = false;
            })));
        }
コード例 #5
0
 public static Task <V> Aggregate <T, U, V>(this IEnumerable <Task <T> > tasks, U seed, Func <U, T, Task <U> > accumulator, Func <U, Task <V> > mapper) =>
 Enumerable.Aggregate(tasks, Utilities.FromResult(seed), async(tv, t) =>
 {
     var v = await tv.ConfigureAwait(false);
     var r = await t.ConfigureAwait(false);
     return(await accumulator(v, r).ConfigureAwait(false));
 }, async tv => await mapper(await tv.ConfigureAwait(false)).ConfigureAwait(false));
コード例 #6
0
ファイル: LambdaSubstituter.cs プロジェクト: fafnir901/fwd
        public static Expression ReplaceParameters(LambdaExpression @in, IEnumerable <Expression> with)
        {
            Expression        expression = @in.Body;
            List <Expression> list       = Enumerable.ToList <Expression>(with);

            if (Enumerable.Count <Expression>((IEnumerable <Expression>)list) == @in.Parameters.Count)
            {
                expression = Enumerable.Aggregate(Enumerable.Zip((IEnumerable <ParameterExpression>)@in.Parameters, (IEnumerable <Expression>)list, (parameter, replace) =>
                {
                    var local_0 = new
                    {
                        parameter = parameter,
                        replace   = replace
                    };
                    return(local_0);
                }), expression, (current, exp) => LambdaSubstituter.Rewrite(current, exp.parameter, exp.replace));
            }
            else
            {
                foreach (ParameterExpression what in @in.Parameters)
                {
                    ParameterExpression parameter1 = what;
                    using (IEnumerator <Expression> enumerator = Enumerable.Where <Expression>((IEnumerable <Expression>)list, (Func <Expression, bool>)(withParameter => parameter1.Type == withParameter.Type)).GetEnumerator())
                    {
                        if (enumerator.MoveNext())
                        {
                            Expression current = enumerator.Current;
                            expression = LambdaSubstituter.Rewrite(expression, what, current);
                        }
                    }
                }
            }
            return(expression);
        }
コード例 #7
0
 static Utility()
 {
     directoryChars = new Lazy <string>(() => "abcdefghijklmnopqrstuvwxyz" + Enumerable.Aggregate <int, StringBuilder>(Enumerable.Range(0x3b0, 0x4f).Concat <int>(Enumerable.Range(0x400, 0xff)), new StringBuilder(), delegate(StringBuilder acc, int x) {
         acc.Append(char.ConvertFromUtf32(x));
         return(acc);
     }).ToString());
 }
コード例 #8
0
 public static Task <T> Aggregate <T>(this IEnumerable <Task <T> > tasks, Func <T, T, Task <T> > accumulator) =>
 Enumerable.Aggregate(tasks, async(ta, tb) =>
 {
     var ra = await ta.ConfigureAwait(false);
     var rb = await tb.ConfigureAwait(false);
     return(await accumulator(ra, rb).ConfigureAwait(false));
 });
コード例 #9
0
 public override int GetHashCode()
 {
     return(17 * Name.GetHashCode()
            + 23 * Label.GetHashCode()
            + 31 * Documentation.GetHashCode()
            + Enumerable.Aggregate(Parameters, 37, (current, element) => current + element.GetHashCode()));
 }
コード例 #10
0
 public static Task <U> Aggregate <T, U>(this IEnumerable <Task <T> > tasks, U seed, Func <U, T, U> accumulator) =>
 Enumerable.Aggregate(tasks, Utilities.FromResult(seed), async(tv, t) =>
 {
     var v = await tv.ConfigureAwait(false);
     var r = await t.ConfigureAwait(false);
     return(accumulator(v, r));
 });
コード例 #11
0
        public HttpParser HexadecimalNumber(out uint?number)
        {
            if (!this.Success)
            {
                number = new uint?();
                return(this);
            }
            IEnumerable <byte> source = Enumerable.TakeWhile <byte>(this.Range, (Func <byte, bool>)(value => ByteExtensions.IsHexadecimalDigit(value)));

            if (!Enumerable.Any <byte>(source))
            {
                number = new uint?();
                return(this.Fail());
            }
            int num1 = Enumerable.Count <byte>(source);
            int num2 = Enumerable.Count <byte>(Enumerable.TakeWhile <byte>(source, (Func <byte, bool>)(value => (int)value == 48)));

            if (num1 - num2 > 8)
            {
                number = new uint?();
                return(this.Fail());
            }
            uint num3 = Enumerable.Aggregate <uint, uint>(Enumerable.Select <byte, uint>(source, (Func <byte, uint>)(value => (uint)ByteExtensions.ToHexadecimalValue(value))), 0U, (Func <uint, uint, uint>)((accumulated, value) => 16U * accumulated + value));

            number        = new uint?(num3);
            this._offset += num1;
            return(this);
        }
        public async Task CatchUp()
        {
            var ids = await _context.Events
                      .Select(x => x.EntityId).Distinct().ToArrayAsync();

            foreach (var target in _targets)
            {
                var anyChanges = false;
                foreach (var id in ids)
                {
                    var databaseEntity = await target.GetById(id);

                    if (databaseEntity == null)
                    {
                        var events = _context.Events
                                     .Where(x => x.EntityId == id)
                                     .OrderBy(x => x.EntityVersion);
                        var entity = new T();
                        entity = Enumerable.Aggregate(events, entity,
                                                      (current, @event) => GetEvent(@event).Apply(current));
                        if (!entity.Metadata.Removed)
                        {
                            anyChanges = true;
                            await target.Add(entity);
                        }
                    }
                    else
                    {
                        var maxVersion = await _context.Events
                                         .Where(x => x.EntityId == id)
                                         .Select(x => x.EntityVersion)
                                         .MaxAsync();

                        if (databaseEntity.Metadata.Version < maxVersion)
                        {
                            var events = _context.Events
                                         .Where(x => x.EntityId == id)
                                         .Where(x => x.EntityVersion > databaseEntity.Metadata.Version)
                                         .OrderBy(x => x.EntityVersion);
                            var entity = Enumerable.Aggregate(events, databaseEntity,
                                                              (current, @event) => GetEvent(@event).Apply(current));
                            if (entity.Metadata.Removed)
                            {
                                await target.Delete(databaseEntity);
                            }
                            else
                            {
                                await target.Update(entity);
                            }
                            anyChanges = true;
                        }
                    }
                }

                if (anyChanges)
                {
                    await target.SaveChanges();
                }
            }
        }
コード例 #13
0
        protected override string GetPredefinedValues(IModelMember wrapper)
        {
            IQueryable <string> queryable = new XPQuery <ModelDifferenceObject>(((XPObjectSpace)ObjectSpace).Session).Select(o => o.Name);
            string ret = Enumerable.Aggregate(queryable, "", (current, s) => current + (s + ";"));

            return(ret.TrimEnd(';'));
        }
コード例 #14
0
        public async Task <IActionResult> CartAsync()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }
            ViewBag.UserFirstName   = user.UserFirstName;
            ViewBag.UserLastName    = user.UserLastName;
            ViewBag.UserName        = user.NormalizedUserName;
            ViewBag.Email           = user.Email;
            ViewBag.PhoneNumber     = user.PhoneNumber;
            ViewBag.BillingAddress  = user.UserAddress;
            ViewBag.ShippingAddress = user.UserAddress2;
            ViewBag.Country         = user.UserCountry;
            ViewBag.City            = user.UserCity;
            ViewBag.State           = user.UserState;
            ViewBag.ZipCode         = user.UserZip;

            var tempCarts = _db.TempCarts.Where(o => o.CustomerID == user.Id).Include(o => o.Product);
            var total     = Enumerable.Aggregate(tempCarts, 0.00, (current, obj) => current + obj.Product.ProductPrice * obj.Quantity);

            ViewBag.Counter = tempCarts.Count();
            ViewBag.UserId  = user.Id;
            ViewBag.Total   = Math.Round(total, 2);
            return(View(tempCarts));
        }
コード例 #15
0
        public void Process(AggregateResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree)
        {
            var inputExpr       = ((StreamedSequenceInfo)queryModelVisitor.PreviousEvaluationType).ItemExpression;
            var inputType       = inputExpr.Type;
            var paramExpr       = Expression.Parameter(inputType, "item");
            var accumulatorFunc = Expression.Lambda(
                ReplacingExpressionTreeVisitor.Replace(inputExpr, paramExpr, resultOperator.Func.Body),
                resultOperator.Func.Parameters[0],
                paramExpr);

            var inputList = Expression.Parameter(typeof(IEnumerable <>).MakeGenericType(typeof(object)), "inputList");

            var castToItem     = EnumerableHelper.GetMethod("Cast", new[] { typeof(IEnumerable) }, new[] { inputType });
            var castToItemExpr = Expression.Call(castToItem, inputList);

            var aggregate = ReflectionHelper.GetMethodDefinition(() => Enumerable.Aggregate <object>(null, null));

            aggregate = aggregate.GetGenericMethodDefinition().MakeGenericMethod(inputType);

            MethodCallExpression call = Expression.Call(
                aggregate,
                castToItemExpr,
                accumulatorFunc
                );

            tree.AddListTransformer(Expression.Lambda(call, inputList));
        }
コード例 #16
0
 private string GetSelectedBasesDescription()
 {
     if (lbBase.GetSelectedIndices().Length == 0)
     {
         lbBase.ToogleItems();
     }
     return(Enumerable.Aggregate <int, string>(lbBase.GetSelectedIndices(), string.Empty, (current, i) => String.Concat(current, lbBase.Items[i].Text, ",")).TrimEnd(','));
 }
コード例 #17
0
        public IActionResult Invoice(int?id)
        {
            var order = _db.Orderdetails.Where(o => o.DetailOrder.OrderId == id).Include(o => o.DetailOrder).Include(o => o.DetailOrder.OrderUser).Include(o => o.DetailProduct);
            var total = Enumerable.Aggregate(order, 0.00, (current, obj) => current + obj.DetailPrice);

            ViewBag.Total = Math.Round(total, 2);
            return(View(order));
        }
コード例 #18
0
        public override string DebugToString()
        {
            var builder = new StringBuilder();

            Enumerable.Aggregate(Children, builder, (sb, node) => sb.Append(node.DebugToString()));

            return(builder.ToString());
        }
コード例 #19
0
ファイル: ExpressionExtensions.cs プロジェクト: fafnir901/fwd
 private static Expression <Func <T, bool> > Combine <T>(Expression <Func <T, bool> > head, IEnumerable <Expression <Func <T, bool> > > tail, Func <Expression, Expression, BinaryExpression> combiner)
 {
     return(Enumerable.Aggregate <Expression <Func <T, bool> >, Expression <Func <T, bool> > >(tail, head, (Func <Expression <Func <T, bool> >, Expression <Func <T, bool> >, Expression <Func <T, bool> > >)((soFar, element) =>
     {
         Expression local_0 = LambdaSubstituter.ReplaceParameters((LambdaExpression)element, (IEnumerable <Expression>)soFar.Parameters);
         return (Expression <Func <T, bool> >)Expression.Lambda((Expression)combiner(soFar.Body, local_0), (IEnumerable <ParameterExpression>)soFar.Parameters);
     })));
 }
コード例 #20
0
 /// <summary>
 /// Get a string that represents the ids of all selected mobiles.
 /// </summary>
 /// <returns></returns>
 private string GetSelectedClientsDescriptions()
 {
     if (Enumerable.Count <int>(lbClientes.GetSelectedIndices()) == 0)
     {
         lbClientes.ToogleItems();
     }
     return(Enumerable.Aggregate <int, string>(lbClientes.GetSelectedIndices(), string.Empty, (current, index) => string.Concat(current, string.Format("{0},", (object)lbClientes.Items[index].Text))).TrimEnd(','));
 }
コード例 #21
0
 public static Range <T> Sum <T>(this IEnumerable <Range <T> > that) where T : IComparable
 {
     if (!Enumerable.Any <Range <T> >(that))
     {
         return(new Range <T>());
     }
     return(Enumerable.Aggregate <Range <T> >(that, (Func <Range <T>, Range <T>, Range <T> >)((x, y) => x.Add(y))));
 }
コード例 #22
0
        //template<class DeviceClass> inline DeviceClass *device(const char *tag) const { return downcast<DeviceClass *>(device(tag)); }


        public attotime maximum_quantum(attotime default_quantum)
        {
            //return std::accumulate(
            //        m_maximum_quantums.begin(),
            //        m_maximum_quantums.end(),
            //        default_quantum,
            //        [] (attotime const &lhs, maximum_quantum_map::value_type const &rhs) { return (std::min)(lhs, rhs.second); });
            return(Enumerable.Aggregate(m_maximum_quantums, default_quantum, (current, next) => { return std.min(current, next.second()); }));
        }
コード例 #23
0
        private static Expression <Func <T, bool> > BuildSearchExpression <T>(IEnumerable <string> propertiesToSearch, IEnumerable <string> searchTerms) where T : IPackage
        {
            ParameterExpression parameterExpression = Expression.Parameter(typeof(IPackageMetadata));

            ParameterExpression[] parameters = new ParameterExpression[] { parameterExpression };
            return(Expression.Lambda <Func <T, bool> >(Enumerable.Aggregate <Expression>(from term in searchTerms
                                                                                         from property in propertiesToSearch
                                                                                         select BuildExpressionForTerm(parameterExpression, term, property), new Func <Expression, Expression, Expression>(Expression.OrElse)), parameters));
        }
コード例 #24
0
ファイル: Crc.cs プロジェクト: chandan-97-source/new-world
 // broke: see https://code.google.com/p/zero-k/issues/detail?id=2129
 public static uint Crc32Old(byte[] data)
 {
     return
         (Enumerable.Aggregate <byte, uint>((IEnumerable <byte>)data,
                                            uint.MaxValue,
                                            (Func <uint, byte, uint>)
                                                ((current, b) => Crc.Crc32Table[(long)(current >> 24 ^ (uint)b) & (long)byte.MaxValue] ^ current << 8)) ^
          uint.MaxValue);
 }
コード例 #25
0
 private static string FixMeFormat(string formatString, object[] args)
 {
     if (args == null || args.Length == 0)
     {
         // not really any args, and not really expectng any
         return(formatString.Replace('{', '\u00ab').Replace('}', '\u00bb'));
     }
     return(Enumerable.Aggregate(args, formatString.Replace('{', '\u00ab').Replace('}', '\u00bb'), (current, arg) => current + string.Format(CultureInfo.CurrentCulture, " \u00ab{0}\u00bb", arg)));
 }
コード例 #26
0
        public long Factorial(int num)
        {
            if (num < 0)
            {
                throw new ArgumentException(Resources.Err_FactorialForNegativeIntegersNotDefined, nameof(num));
            }

            return(num > 0 ? Enumerable.Aggregate(Enumerable.Range(1, num), 1L, (a, b) => a * b) : 1);
        }
コード例 #27
0
        public static void Test1()
        {
            var koss = people.Aggregate(string.Empty,
                                        (result, person) =>
                                        result += person.GetName());

            var moss = Enumerable.Aggregate <Person, string>(people, null, (result, person) => result += person.GetName());

            var finalResult = koss == moss;
        }
コード例 #28
0
        public void CheckAggregate()
        {
            string[] fruits = { "apple", "mango", "orange", "passionfruit", "grape" };
#if NET20
            var longestName = BackportedExtensions.Aggregate(fruits, "banana", Select, fruit => fruit.ToUpper());
#else
            var longestName = Enumerable.Aggregate(fruits, "banana", Select, fruit => fruit.ToUpper());
#endif
            Assert.AreEqual(longestName, "PASSIONFRUIT");
        }
コード例 #29
0
ファイル: MemorySet.cs プロジェクト: sokogfb/LMS-1
        private void Validate(TEntity entity)
        {
            List <ValidationResult> list = new List <ValidationResult>();
            ValidationContext       validationContext = new ValidationContext((object)entity, (IServiceProvider)null, (IDictionary <object, object>)null);

            if (!Validator.TryValidateObject((object)entity, validationContext, (ICollection <ValidationResult>)list))
            {
                throw new Exception(Enumerable.Aggregate <ValidationResult, string>((IEnumerable <ValidationResult>)list, "", (Func <string, ValidationResult, string>)((x, c) => x + "  " + c.ErrorMessage)));
            }
        }
コード例 #30
0
        public void Aggregate()
        {
            Assert.Throws <ArgumentNullException>(() => ImmutableArrayExtensions.Aggregate(oneElement, null));
            Assert.Throws <ArgumentNullException>(() => ImmutableArrayExtensions.Aggregate(oneElement, 1, null));
            Assert.Throws <ArgumentNullException>(() => ImmutableArrayExtensions.Aggregate <int, int, int>(oneElement, 1, null, null));
            Assert.Throws <ArgumentNullException>(() => ImmutableArrayExtensions.Aggregate <int, int, int>(oneElement, 1, (a, b) => a + b, null));

            Assert.Equal(Enumerable.Aggregate(manyElements, (a, b) => a * b), ImmutableArrayExtensions.Aggregate(manyElements, (a, b) => a * b));
            Assert.Equal(Enumerable.Aggregate(manyElements, 5, (a, b) => a * b), ImmutableArrayExtensions.Aggregate(manyElements, 5, (a, b) => a * b));
            Assert.Equal(Enumerable.Aggregate(manyElements, 5, (a, b) => a * b, a => - a), ImmutableArrayExtensions.Aggregate(manyElements, 5, (a, b) => a * b, a => - a));
        }