private static void Update()
    {
        if (!active)
        {
            return;
        }

        activeTime += Time.deltaTime;

        // make sure we are not autosimulating
        Physics.autoSimulation = false;

        // see if all our
        bool allSleeping = Enumerable.Aggregate(Enumerable.Where(workList, body => body != null), true, (current, body) => current & body.IsSleeping());

        if (allSleeping || activeTime >= timeToSettle)
        {
            Physics.autoSimulation = cachedAutoSimulation;
            active = false;
        }
        else
        {
            Physics.Simulate(Time.deltaTime);
        }
    }
Example #2
0
    public void BlinqShouldEqualLinqNativeArrayAggregate([ArrayValues] int[] sourceArr)
    {
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.Aggregate(
                                             source,
                                             Sum.Invoke
                                             ));
        var actual = ExceptionAndValue(() => Blinq.Aggregate(source, Sum));

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
Example #3
0
    public void BlinqShouldEqualLinqNativeArrayAggregateWithAccumulateAndResult([ArrayValues] int[] sourceArr)
    {
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.Aggregate <int, long, double>(
                                             source,
                                             0,
                                             LongSum.Invoke,
                                             LongToDouble.Invoke
                                             ));
        var actual = ExceptionAndValue(() => Blinq.Aggregate(source, 0, LongSum, LongToDouble));

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
Example #4
0
 public static TResult Aggregate <TSource, TAccumulate, TResult>(this IEnumerable <TSource> source, TAccumulate seed, Func <TAccumulate, TSource, TAccumulate> func, Func <TAccumulate, TResult> resultSelector) =>
 LinqEnumerable.Aggregate(source, seed, func, resultSelector);
Example #5
0
 public static TAccumulate Aggregate <TSource, TAccumulate>(this IEnumerable <TSource> source, TAccumulate seed, Func <TAccumulate, TSource, TAccumulate> func) =>
 LinqEnumerable.Aggregate(source, seed, func);
Example #6
0
 public static TSource Aggregate <TSource>(this IEnumerable <TSource> source, Func <TSource, TSource, TSource> func) =>
 LinqEnumerable.Aggregate(source, func);
Example #7
0
 public void LinqNativeSequence()
 {
     MeasureLinq(() => Linq.Aggregate(source, 0, Sum.Invoke, IntToLong.Invoke)).Run();
 }
    /// <summary>
    /// Formats the email body.
    /// </summary>
    /// <param name="opportunity">The opportunity.</param>
    /// <returns></returns>
    private string FormatEmailBody(IOpportunity opportunity)
    {
        IContextService context     = ApplicationContext.Current.Services.Get <IContextService>(true);
        TimeZone        timeZone    = (TimeZone)context.GetContext("TimeZone");
        string          datePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;

        string oppProducts = String.Empty;
        bool   oppWon      = GetOpportunityStatusMatch(opportunity, "ClosedWon");
        bool   oppLost     = GetOpportunityStatusMatch(opportunity, "ClosedLost");
        string emailBody   = String.Format("{0} \r\n", GetLocalResourceObject("lblEmailInfo.Caption"));

        emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailOppDesc.Caption"),
                                   CheckForNullValue(opportunity.Description));
        emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("lblEmailOppAccount.Caption"),
                                   CheckForNullValue(opportunity.Account != null
                                                         ? opportunity.Account.AccountName
                                                         : String.Empty));
        emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppAcctMgr.Caption"),
                                   CheckForNullValue(opportunity.AccountManager));
        emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppReseller.Caption"),
                                   CheckForNullValue(opportunity.Reseller));
        emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppEstClose.Caption"),
                                   opportunity.EstimatedClose.HasValue
                                       ? timeZone.UTCDateTimeToLocalTime((DateTime)opportunity.EstimatedClose).ToString
                                       (datePattern)
                                       : String.Empty);
        emailBody += String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppCloseProb.Caption"),
                                   CheckForNullValue(opportunity.CloseProbability));
        emailBody += String.Format("{0} {1} \r\n\r\n", GetLocalResourceObject("EmailOppComments.Caption"),
                                   CheckForNullValue(opportunity.Notes));
        emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppValue.Caption"));
        //emailBody += BusinessRuleHelper.AccountingSystemHandlesSO()
        //                 ? String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppPotential.Caption"),
        //                                 curERPOpenBaseSalesPotential.FormattedText)
        //                 : String.Format("{0} {1} \r\n", GetLocalResourceObject("EmailOppPotential.Caption"),
        //                                 curOpenBaseSalesPotential.FormattedText);
        emailBody += String.Format("{0} {1} \r\n\r\n", GetLocalResourceObject("EmailOppWeighted.Caption"),
                                   curBaseWeighted.FormattedText);
        emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppSummary.Caption"));
        if (oppWon || oppLost)
        {
            emailBody += String.Format("{0} \r\n",
                                       String.Format(
                                           GetLocalResourceObject("EmailOppWonLostSummary.Caption").ToString(),
                                           dtpClosedWonSummary.Text,
                                           Convert.ToString(opportunity.DaysOpen)));
            emailBody += oppWon
                             ? String.Format("{0} \r\n",
                                             String.Format(
                                                 GetLocalResourceObject("EmailOppReasonWon.Caption").ToString(),
                                                 CheckForNullValue(opportunity.Reason)))
                             : String.Format("{0} \r\n",
                                             String.Format(
                                                 GetLocalResourceObject("EmailOppReasonLost.Caption").ToString(),
                                                 CheckForNullValue(opportunity.Reason)));
        }
        else
        {
            emailBody += String.Format("{0} \r\n",
                                       String.Format(GetLocalResourceObject("EmailOppStageSummary.Caption").ToString(),
                                                     CheckForNullValue(opportunity.Stage)));
        }
        emailBody += String.Format("{0} \r\n\r\n",
                                   String.Format(GetLocalResourceObject("lblEmailOppType.Caption").ToString(),
                                                 CheckForNullValue(opportunity.Type)));

        emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppProducts.Caption"));

        oppProducts = Enumerable.Aggregate(opportunity.Products, oppProducts,
                                           (current, oppProduct) =>
                                           current +
                                           String.Format("{0} ({1}); ", oppProduct.Product, oppProduct.Quantity));

        if (!string.IsNullOrEmpty(oppProducts))
        {
            emailBody += String.Format("{0} \r\n\r\n", CheckForNullValue(oppProducts.Substring(0, oppProducts.Length - 2)));
        }

        if (oppWon || oppLost)
        {
            emailBody += String.Format("{0} \r\n{1} \r\n\r\n", GetLocalResourceObject("EmailOppCompetitors.Caption"),
                                       GetOpportunityCompetitors());
        }

        emailBody += String.Format("{0} \r\n", GetLocalResourceObject("EmailOppContacts.Caption"));
        emailBody  = Enumerable.Aggregate(opportunity.Contacts, emailBody,
                                          (current, oppContact) =>
                                          current +
                                          String.Format("{0} \r\n",
                                                        String.Format("{0}, {1}; {2}", oppContact.Contact.Name,
                                                                      oppContact.Contact.Title, oppContact.SalesRole)));
        return(HttpUtility.JavaScriptStringEncode(emailBody));
    }