コード例 #1
0
    public void LinqNativeSequence()
    {
        var second = new NativeArray <int>(source, Allocator.Persistent);

        MeasureLinq(() => Linq.ToList(Linq.Concat(source, second))).Run();
        second.Dispose();
    }
コード例 #2
0
    /// <summary>
    /// Sets the client select context.
    /// </summary>
    /// <param name="selectState">State of the select.</param>
    private void LoadClientSelects(IDictionary <string, bool> selectState)
    {
        ClientContextService clientContextService = PageWorkItem.Services.Get <ClientContextService>();

        if (clientContextService != null)
        {
            if (clientContextService.CurrentContext.ContainsKey("ct_selectedTargetsCtrlId"))
            {
                foreach (var value in Enumerable.Where(clientContextService.CurrentContext, value => value.Key == "ct_selectedTargetsCtrlId"))
                {
                    txtSelectedTargets.Value = value.Value;
                }
            }
            string clientContext = txtSelectedTargets.Value;
            if (!string.IsNullOrEmpty(clientContext))
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(clientContext);
                XmlNodeList targetNodes = xmlDoc.DocumentElement.SelectNodes("//Targets/Target");
                foreach (XmlNode tn in targetNodes)
                {
                    string id       = tn.Attributes["Id"].Value;
                    string selected = tn.Attributes["Selected"].Value;
                    if (selectState.ContainsKey(id))
                    {
                        selectState.Remove(id);
                    }
                    selectState.Add(id, Convert.ToBoolean(selected));
                }
                txtSelectedTargets.Value = string.Empty;
            }
        }
    }
コード例 #3
0
    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);
        }
    }
コード例 #4
0
    public void Linq_int(
        [ValueSource(typeof(Values_int), nameof(Values_int.Values))] int[] sourceArr
        )
    {
        var src = new NativeArray <int>(sourceArr, Allocator.Persistent);

        MakeMeasurement("Linq_int", () => Linq.Average(src)).Run();
        src.Dispose();
    }
コード例 #5
0
    public void LinqSelect_double(
        [ValueSource(typeof(SelectValues), nameof(SelectValues.Values))] int[] sourceArr
        )
    {
        var src = new NativeArray <int>(sourceArr, Allocator.Persistent);

        MakeMeasurement("Linq_double", () => Linq.Average(src, IntTo_double.Invoke)).Run();
        src.Dispose();
    }
コード例 #6
0
    public void Linq_double(
        [ValueSource(typeof(Values_double), nameof(Values_double.Values))] double[] sourceArr
        )
    {
        var src = new NativeArray <double>(sourceArr, Allocator.Persistent);

        MakeMeasurement("Linq_double", () => Linq.Average(src)).Run();
        src.Dispose();
    }
コード例 #7
0
    public void BlinqShouldEqualLinqNativeArrayFirstOrDefault([ArrayValues] int[] sourceArr)
    {
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.FirstOrDefault(source));
        var actual   = ExceptionAndValue(() => source.FirstOrDefault());

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
コード例 #8
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();
    }
コード例 #9
0
    public void BlinqShouldEqualLinqNativeArrayWhereWithIndex([ArrayValues] int[] sourceArr)
    {
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.ToArray(Linq.Where(source, EqualToIndex.Invoke)));
        var actual   = ExceptionAndValue(() => Linq.ToArray(Blinq.Where(source, EqualToIndex)));

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
コード例 #10
0
    public void BlinqShouldEqualLinqNativeArraySelectManyIndexResultSelector([ArrayValues] int[] sourceArr)
    {
        var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected        = ExceptionAndValue(() => Linq.ToArray(Linq.SelectMany(sourceNativeArr, (x, i) => RepeatAmountPlusIndex.Invoke(x, i), AddToIndex.Invoke)));
        var actual          = ExceptionAndValue(() => Linq.ToArray(Blinq.SelectMany(sourceNativeArr, RepeatAmountPlusIndex, AddToIndex)));

        AssertAreEqual(expected, actual);
        sourceNativeArr.Dispose();
    }
コード例 #11
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();
    }
コード例 #12
0
    public void BlinqShouldEqualLinqNativeArrayLastPredicate([ArrayValues] int[] sourceArr)
    {
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.Last(source, EqualsZero.Invoke));
        var actual   = ExceptionAndValue(() => source.Last(EqualsZero));

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
コード例 #13
0
    public void BlinqShouldEqualLinqNativeArrayOrderByDescending([OrderValues] Order[] sourceArr)
    {
        var source   = new NativeArray <Order>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.ToArray(Linq.OrderByDescending(source, SelectFirst.Invoke)));
        var actual   = ExceptionAndValue(() => Linq.ToArray(Blinq.OrderByDescending(source, SelectFirst)));

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
コード例 #14
0
    public void BlinqShouldEqualLinqNativeArraySequenceCountPredicate([ArrayValues] int[] sourceArr)
    {
        var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected        = ExceptionAndValue(() => Linq.Count(sourceNativeArr, EqualsOne.Invoke));
        var actual          = ExceptionAndValue(() => Blinq.Count(sourceNativeArr, EqualsOne));

        AssertAreEqual(expected, actual);
        sourceNativeArr.Dispose();
    }
コード例 #15
0
    public void BlinqShouldEqualLinqNativeArrayDefaultIfEmpty([ArrayValues] int[] sourceArr)
    {
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.ToArray(Linq.DefaultIfEmpty(source, 1)));
        var actual   = ExceptionAndValue(() => Linq.ToArray(source.DefaultIfEmpty(1)));

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
コード例 #16
0
    public void BlinqShouldEqualLinqValueSequenceThenBy([OrderValues] Order[] sourceArr)
    {
        var sourceNativeArr = new NativeArray <Order>(sourceArr, Allocator.Persistent);
        var source          = sourceNativeArr.ToValueSequence();
        var expected        = ExceptionAndValue(() => Linq.ToArray(Linq.ThenBy(Linq.OrderBy(source, SelectSecond.Invoke), SelectFirst.Invoke)));
        var actual          = ExceptionAndValue(() => Linq.ToArray(Blinq.ThenBy(Blinq.OrderBy(source, SelectSecond), SelectFirst)));

        AssertAreEqual(expected, actual);
        sourceNativeArr.Dispose();
    }
コード例 #17
0
    public void BlinqShouldEqualLinqNativeArraySumSelector_float(
        [ValueSource(typeof(Values_float), nameof(Values_float.Values))] float[] sourceArr
        )
    {
        var srcNativeArray = new NativeArray <float>(sourceArr, Allocator.Persistent);
        var expected       = ExceptionAndValue(() => Linq.Sum(srcNativeArray, SelectSelf <float>().Invoke));
        var actual         = ExceptionAndValue(() => Blinq.Sum(srcNativeArray, SelectSelf <float>()));

        srcNativeArray.Dispose();
    }
コード例 #18
0
    public void BlinqShouldEqualLinqNativeArraySum_int(
        [ValueSource(typeof(Values_int), nameof(Values_int.Values))] int[] sourceArr
        )
    {
        var srcNativeArray = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected       = ExceptionAndValue(() => Linq.Sum(srcNativeArray));
        var actual         = ExceptionAndValue(() => Blinq.Sum(srcNativeArray));

        srcNativeArray.Dispose();
    }
コード例 #19
0
    public void BlinqShouldEqualLinqValueSequenceTakeWhile([ArrayValues] int[] sourceArr)
    {
        var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var source          = sourceNativeArr.ToValueSequence();
        var expected        = ExceptionAndValue(() => Linq.ToArray(Linq.TakeWhile(source, EqualToIndex.Invoke)));
        var actual          = ExceptionAndValue(() => Linq.ToArray(Blinq.TakeWhile(source, EqualToIndex)));

        AssertAreEqual(expected, actual);
        sourceNativeArr.Dispose();
    }
コード例 #20
0
    public static NativeArray <T> ToNativeArray <T>(this IEnumerable <T> source, Allocator allocator)
        where T : struct
    {
        if (source == null)
        {
            throw new ArgumentNullException(nameof(source));
        }

        return(new NativeArray <T>(LinqEnumerable.ToArray(source), allocator));
    }
コード例 #21
0
    public void BlinqShouldEqualLinqNativeArrayElementAt([ArrayValues] int[] sourceArr)
    {
        var index    = 10;
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.ElementAt(source, index));
        var actual   = ExceptionAndValue(() => Blinq.ElementAt(source, index));

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
コード例 #22
0
    public void BlinqShouldEqualLinqNativeSequenceFirstOrDefaultPredicate([ArrayValues] int[] sourceArr)
    {
        var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var source          = sourceNativeArr.ToValueSequence();
        var expected        = ExceptionAndValue(() => Linq.FirstOrDefault(source, EqualsZero.Invoke));
        var actual          = ExceptionAndValue(() => source.FirstOrDefault(EqualsZero));

        AssertAreEqual(expected, actual);
        sourceNativeArr.Dispose();
    }
コード例 #23
0
    public void BlinqShouldEqualLinqNativeArrayPrepend([ArrayValues] int[] sourceArr)
    {
        int item     = 1;
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.ToArray(Linq.Prepend(source, item)));
        var actual   = ExceptionAndValue(() => Linq.ToArray(Blinq.Prepend(source, item)));

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
コード例 #24
0
    public void BlinqShouldEqualLinqNativeArrayContainsComparer([ArrayValues] int[] sourceArr)
    {
        var source = new NativeArray <int>(sourceArr, Allocator.Persistent);

        var(expectedException, expectedValue) = ExceptionAndValue(() => Linq.Contains(source, 7, default(RemainderTwoComparer)));
        var(actualException, actualValue)     = ExceptionAndValue(() => source.Contains(7, default(RemainderTwoComparer)));
        Assert.AreEqual(expectedException, actualException);
        Assert.AreEqual(expectedValue, actualValue);
        source.Dispose();
    }
コード例 #25
0
 public void BlinqShouldEqualLinqNativeSequenceLast([ArrayValues] int[] sourceArr)
 {
     using (var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent))
     {
         var source   = sourceNativeArr.ToValueSequence();
         var expected = ExceptionAndValue(() => Linq.Last(source));
         var actual   = ExceptionAndValue(() => source.Last());
         AssertAreEqual(expected, actual);
     }
 }
コード例 #26
0
    public void BlinqShouldEqualLinqValueSequenceLongCount([ArrayValues] int[] sourceArr)
    {
        var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var source          = sourceNativeArr.ToValueSequence();
        var expected        = ExceptionAndValue(() => Linq.LongCount(source));
        var actual          = ExceptionAndValue(() => Blinq.LongCount(source));

        AssertAreEqual(expected, actual);
        sourceNativeArr.Dispose();
    }
コード例 #27
0
    public void BlinqShouldEqualLinqValueSequenceSelectMany([ArrayValues] int[] sourceArr)
    {
        var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var source          = sourceNativeArr.ToValueSequence();
        var expected        = ExceptionAndValue(() => Linq.ToArray(Linq.SelectMany(source, (x) => RepeatAmount.Invoke(x))));
        var actual          = ExceptionAndValue(() => Linq.ToArray(Blinq.SelectMany(source, RepeatAmount)));

        AssertAreEqual(expected, actual);
        sourceNativeArr.Dispose();
    }
コード例 #28
0
    public void BlinqShouldEqualLinqNativeArrayMinSelector_double(
        [ValueSource(typeof(Values_double), nameof(Values_double.Values))] double[] sourceArr
        )
    {
        var srcNativeArray = new NativeArray <double>(sourceArr, Allocator.Persistent);
        var expected       = ExceptionAndValue(() => Linq.Min(srcNativeArray, SelectSelf <double>().Invoke));
        var actual         = ExceptionAndValue(() => Blinq.Min(srcNativeArray, SelectSelf <double>()));

        srcNativeArray.Dispose();
    }
コード例 #29
0
    public void BlinqShouldEqualLinqNativeArraySequenceEqualArray([ArrayValues] int[] sourceArr, [ArrayValues] int[] secondArr)
    {
        var sourceNativeArr = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var secondNativeArr = new NativeArray <int>(secondArr, Allocator.Persistent);
        var expected        = ExceptionAndValue(() => Linq.SequenceEqual(sourceNativeArr, secondNativeArr));
        var actual          = ExceptionAndValue(() => Blinq.SequenceEqual(sourceNativeArr, secondNativeArr));

        AssertAreEqual(expected, actual);
        sourceNativeArr.Dispose();
        secondNativeArr.Dispose();
    }
コード例 #30
0
    public void BlinqShouldEqualLinqNativeArrayUnion([ArrayValues] int[] sourceArr, [ArrayValues] int[] secondArr)
    {
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var second   = new NativeArray <int>(secondArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() => Linq.ToArray(Linq.Union(source, second)));
        var actual   = ExceptionAndValue(() => Linq.ToArray(Blinq.Union(source, second)));

        AssertAreEqual(expected, actual);
        source.Dispose();
        second.Dispose();
    }