Exemple #1
0
 public IEnumerator <TResult> GetEnumerator()
 {
     if (notifyEnumerable != null)
     {
         return(notifyEnumerable.GetEnumerator());
     }
     return(SL.Select(Source, SelectorCompiled).GetEnumerator());
 }
Exemple #2
0
    public void BlinqShouldEqualLinqNativeArraySelect([ArrayValues] int[] sourceArr)
    {
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.ToArray(Linq.Select(source, IntToLong.Invoke)));
        var actual   = ExceptionAndValue(() => Linq.ToArray(Blinq.Select(source, IntToLong)));

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
Exemple #3
0
    public void BlinqShouldEqualLinqNativeArrayMinComparableSelector([ArrayValues] int[] sourceArr)
    {
        var arr            = Linq.ToArray(Linq.Select(sourceArr, (i) => (Comparable)i));
        var srcNativeArray = new NativeArray <Comparable>(arr, Allocator.Persistent);
        var expected       = ExceptionAndValue(() => Linq.Min(srcNativeArray, SelectSelf <Comparable>().Invoke));
        var actual         = ExceptionAndValue(() => Blinq.Min(srcNativeArray, SelectSelf <Comparable>()));

        srcNativeArray.Dispose();
    }
Exemple #4
0
            //public List<List<double>> SumResProbs = new List<List<double>>();
            //public List<double> MaxResProb = new List<double>();

            public BCMBiomeLayer(BiomeLayer layer)
            {
                Block  = new BCMBiomeBlockDecoration(layer.m_Block);
                Depth  = layer.m_Depth;
                FillTo = layer.m_FillUpTo;
                foreach (var p in layer.m_Resources)
                {
                    Resources.Add(Enumerable.ToList(Enumerable.Select(p, deco => new BCMBiomeBlockDecoration(deco))));
                }
            }
Exemple #5
0
        protected override long GetCalculationResult()
        {
            var t1 = new Triangle("-340,495,-153,-910,835,-947");
            var t2 = new Triangle("-175,41,-421,-714,574,-645");

            Print("Contains origo: {0} (should be true)", t1.ContainsOrigo);
            Print("Contains origo: {0} (should be false)", t2.ContainsOrigo);

            var triangles = Enumerable.Select <string, Triangle>(File.ReadAllLines("p102_triangles.txt"), s => new Triangle(s));

            return(triangles.Count(t => t.ContainsOrigo));
        }
 private void QueryApplyForm(Pagination pagination)
 {
     try
     {
         IEnumerable <OrderListView> orderInfos = OrderQueryService.QueryOrders(getCondition(), pagination);
         dataList.DataSource = Enumerable.Select(orderInfos, order =>
         {
             return(new
             {
                 order.OrderId,
                 PNR = order.ETDZPNR == null ? string.Empty : order.ETDZPNR.ToListString(),
                 AirportPair = order.Flights.Join("<br />",
                                                  f =>
                                                  string.Format(
                                                      "{0}-{1}",
                                                      f.DepartureCity,
                                                      f.ArrivalCity)),
                 FlightInfo = order.Flights.Join("<br />",
                                                 f => string.Format(
                                                     "{0}{1}<br />{2} / {3}",
                                                     f.Carrier,
                                                     f.FlightNo,
                                                     string.IsNullOrEmpty(f.Bunk) ? "-" : f.Bunk, getDiscountText(f.Discount))),
                 TakeoffTime = order.Flights.Join("<br />",
                                                  f => f.TakeoffTime.ToString("yyyy-MM-dd<br />HH:mm")),
                 Passengers = string.Join("<br />", order.Passengers),
                 ProducedTime =
                     order.ProducedTime.ToString("yyyy-MM-dd HH:mm"),
                 order.ProducedAccount,
                 order.PurchaserName,
                 allTakeOff = order.Flights.All(item => item.TakeoffTime < DateTime.Now)
             });
         });
         dataList.DataBind();
         if (orderInfos.Any())
         {
             pager.Visible = true;
             if (pagination.GetRowCount)
             {
                 pager.RowCount = pagination.RowCount;
             }
         }
         else
         {
             pager.Visible = false;
         }
     }
     catch (Exception ex)
     {
         ShowExceptionMessage(ex, "查询");
     }
 }
Exemple #7
0
        public SubscriberWithSettingsModel[] Subscribers(long accountId)
        {
            //var query = from subscriber in db.signal_subscribers
            //			join subscription in db.signal_subscriptions on subscriber.id equals subscription.account_slave_id
            //			where subscription.account_master_id == accountId && (subscription.status == (short)SubscriptionStatus.On || subscription.status == (short)SubscriptionStatus.CloseOnly)
            //			select new { subscription, subscriber };

            //var res = query.Select(
            //		subscription =>
            //			new Tuple<signal_subscribers, ISubscribeSettings>(subscription.subscriber,
            //				new SubscriptionSettings(subscription.subscription))).ToArray();

            return(Enumerable.ToArray(Enumerable.Select(subscriptionCache.Filter(x => x.account_master_id == accountId), subscription => new SubscriberWithSettingsModel
            {
                Subscriber = subscriberCache.Get(subscription.account_slave_id),
                Subscription = subscription
            })));
        }
Exemple #8
0
        public void CanProvideAllColumnsFromTable()
        {
            var table           = new Table("users", null, TableType.Table);
            var expectedColumns = new List <Column>
            {
                new Column("Id", table, true, DbType.Int32, 11),
                new Column("Name", table, false, DbType.String, 255),
                new Column("Password", table, false, DbType.String, 255),
                new Column("Age", table, false, DbType.Int32, 11)
            };
            var connectionProvider = new Mysql40.Mysql40ConnectionProvider();

            connectionProvider.SetConnectionString(ConnectionString);

            var schemaDataProvider = new MysqlScemaDataProvider40(connectionProvider);
            var columns            = Enumerable.Select <MysqlColumnInfo, Column>(schemaDataProvider.GetColumnsFor(table), c => new Column(c.Name, table, c.IsAutoincrement, c.DbType, c.Capacity));

            Assert.AreEqual(expectedColumns.Count, columns.Count());
            columns.Should().Contain(expectedColumns);
        }
    /// <summary>
    /// Gets the smart part info.
    /// </summary>
    /// <param name="smartPartInfoType">Type of the smart part info.</param>
    /// <returns></returns>
    public override ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
    {
        ToolsSmartPartInfo tinfo = new ToolsSmartPartInfo();

        if (BindingSource != null)
        {
            if (BindingSource.Current != null)
            {
                tinfo.Description = BindingSource.Current.ToString();
                tinfo.Title       = BindingSource.Current.ToString();
            }
        }

        foreach (SmartPartToolsContainer cont in Enumerable.Select(Enumerable.OfType <SmartPartToolsContainer>(Controls), c => c as SmartPartToolsContainer))
        {
            switch (cont.ToolbarLocation)
            {
            case SmartPartToolsLocation.Right:
                foreach (Control tool in cont.Controls)
                {
                    tinfo.RightTools.Add(tool);
                }
                break;

            case SmartPartToolsLocation.Center:
                foreach (Control tool in cont.Controls)
                {
                    tinfo.CenterTools.Add(tool);
                }
                break;

            case SmartPartToolsLocation.Left:
                foreach (Control tool in cont.Controls)
                {
                    tinfo.LeftTools.Add(tool);
                }
                break;
            }
        }
        return(tinfo);
    }
Exemple #10
0
 public IEnumerator <TResult> GetEnumerator()
 {
     return(SL.Select(Source, SelectorCompiled).GetEnumerator());
 }
Exemple #11
0
 public static IEnumerable <TResult> Select <TSource, TResult>(this IEnumerable <TSource> source, Func <TSource, int, TResult> selector) =>
 LinqEnumerable.Select(source, selector);
Exemple #12
0
 public void LinqSequence()
 {
     MeasureLinq(() => Linq.ToList(Linq.Select(source, IntToLong.Invoke))).Run();
 }
Exemple #13
0
        private static void PlayAroundOption()
        {
            Console.WriteLine("==================== Option ====================");

            var thai       = Create.Option(Nationality.Thai);
            var japanese   = Create.Option(Nationality.Japanese);
            var nullOption = Create.Option <Nationality>(null);

            Console.WriteLine("{0} is {1}", thai, thai.IsSome ? "Some" : "None");
            Console.WriteLine("{0} is {1}", japanese, japanese.IsSome ? "Some" : "None");
            Console.WriteLine("{0} is None = {1}", nullOption, nullOption.IsNone);
            Console.WriteLine("{0} if Thai", Nationality.Thai.ToString().NoneIf("Thai"));
            string nullStr = null;

            Console.WriteLine("{0} if null", nullStr.NoneIfNull());

            Func <string, Nationality> func = a =>
            {
                switch (a.ToLower())
                {
                case "thai":
                    return(Nationality.Thai);

                case "japanese":
                    return(Nationality.Japanese);

                default:
                    throw new Exception();
                }
            };

            Console.WriteLine(Option.FromFunc(() => func("Thai")));
            Console.WriteLine(Option.FromFunc(() => func("THAI")));
            Console.WriteLine(Option.FromFunc(() => func("japanese")));
            Console.WriteLine(Option.FromFunc(() => func("Chinese")));

            var emptyOption = new Option <int>();

            Console.WriteLine("{0} is None : {1}", emptyOption.GetType(), emptyOption.IsNone);

            var sizes = new[] { "S", "M", "L", "XL", "", null };

            foreach (var option in Enumerable.Select(sizes, Create.Option))
            {
                Console.WriteLine(option.GetOr("F"));
                Console.WriteLine(option.GetOrElse(() => "No option ==> Do this instead"));
                Console.WriteLine("{0} is Some {1}", option, option.Match(
                                      Some: v => true,
                                      None: () => false));
                option.Match(
                    Some: v => Console.WriteLine("{0} do something", v),
                    None: () => Console.WriteLine("None do nothing"));

                if (option == Option.Some("XL"))
                {
                    Console.WriteLine("You're overweight, do more exercise!!!");
                }
                else
                {
                    Console.WriteLine("Skinny!!");
                }

                Console.WriteLine(option.Maybe("F", v => string.Format("{0} is a Valid Size", v)));
            }

            //Fold?
            var opt = Option.Some("abcd");

            Console.WriteLine("Fold : {0}", opt.Fold("efgh", (a, b) => string.Concat(a, b)));


            Console.WriteLine();
        }