Example #1
0
        private void TestProperty(IInvoker <TestClass, int> invoker, [CallerMemberName] string name = null)
        {
            var x = invoker.GetValue(testReference);

            Assert.AreEqual(value, x, $"{name} Fail Get Operation");
            invoker.SetValue(testReference, x + 1);
            Assert.AreEqual(value + 1, invoker.GetValue(testReference), $"{name} Fail Set Operation");
        }
Example #2
0
        private void TestInlineProperty(IInvoker <TestClass, int> invoker, [CallerMemberName] string name = null)
        {
            var width = invoker.GetValue(testReference);

            Assert.AreEqual(value, width, $"{name} Fail Get Operation");
            invoker.SetValue(testReference, width + 1);
            Assert.AreEqual(value + 1, testReference.Group.Struct.Width, $"{name} Fail Set Operation");
        }
Example #3
0
        private void TestInlineField(IInvoker <TestClass, int> invoker, [CallerMemberName] string name = null)
        {
            var x = invoker.GetValue(testReference);

            Assert.AreEqual(value, x, $"{name} Fail Get Operation");
            x++;
            invoker.SetValue(testReference, x);
            Assert.AreEqual(value + 1, testReference.Struct.Field, $"{name} Fail Set Operation");
        }
Example #4
0
 public static IEnumerable Search(IEnumerable items, IInvoker invoker, object value, CompareType compare, IComparer comparer)
 {
     foreach (var item in items)
     {
         if (CheckItem(invoker.GetValue(item), value, compare, comparer))
         {
             yield return(item);
         }
     }
 }
Example #5
0
        public override void InitializeEditor(LayoutEditor editor, object value, object dataSource)
        {
            base.InitializeEditor(editor, value, dataSource);

            if (!ReadOnly)
            {
                editor.DropDownClick += OnDropDownClick;
            }
            editor.DropDownExClick += OnDropDownExClick;
            invoker = null;

            if (dataSource != null)
            {
                invoker = GetFileNameInvoker(dataSource);
            }

            if (invoker != null)
            {
                fdOpen.InitialFileName = invoker.GetValue(dataSource) as string;
            }
        }
Example #6
0
        public void BenchmarkBoxing(string category, string name, IInvoker invoker)
        {
            Stopwatch watch = new Stopwatch();

            watch.Reset();
            watch.Start();
            for (int i = 0; i < count; i++)
            {
                var width = invoker.GetValue(testReference);
                width = 0;
                invoker.SetValue(testReference, width);
            }
            watch.Stop();
            BenchmarkResult.Add($"{category}(Boxing)", name, watch.Elapsed);
        }
Example #7
0
        public void Benchmark <T, V>(string category, string name, IInvoker <T, V> invoker)
        {
            Stopwatch watch = new Stopwatch();

            watch.Reset();
            watch.Start();
            for (int i = 0; i < count; i++)
            {
                var width = invoker.GetValue(testReference);
                width = default(V);
                invoker.SetValue(testReference, width);
            }
            watch.Stop();
            BenchmarkResult.Add(category, name, watch.Elapsed);
        }
Example #8
0
        public static IEnumerable <object> SearchByValue(this IEnumerable itemsSource, IInvoker valueInvoker, object value)
        {
            if (itemsSource == null)
            {
                yield break;
            }

            foreach (var item in itemsSource)
            {
                if (Equal(valueInvoker.GetValue(item), value))
                {
                    yield return(item);
                }
            }
        }
Example #9
0
        public IEnumerable <T> Select(IInvoker invoker, CompareType comparer, object value, IEnumerable <T> list = null)
        {
            list = list ?? this;
            if (invoker == null)
            {
                yield break;
            }

            value = Optimisation(null, comparer, value);

            foreach (T row in list)
            {
                if (CheckItem(row, invoker.GetValue(row), value, comparer))
                {
                    yield return(row);
                }
            }
        }
Example #10
0
        public static IEnumerable Distinct(IEnumerable items, IInvoker param, IComparer comparer = null)
        {
            var oldValue = (object)null;
            var list     = items.Cast <object>().ToList();

            ListHelper.QuickSort(list, comparer ?? ((IInvokerExtension)param).CreateComparer(param.TargetType, ListSortDirection.Descending));
            foreach (var item in list)
            {
                var newValue = param.GetValue(item);
                if (!Equal(newValue, oldValue))
                {
                    oldValue = newValue;
                    if (newValue != null)
                    {
                        yield return(item);
                    }
                }
            }
        }
Example #11
0
 public static int CompareKey(IInvoker accesor, object x, object key, IComparer comparer)
 {
     return(ListHelper.Compare(accesor.GetValue(x), key, comparer, false));
 }
Example #12
0
 public virtual object ReadValue(object listItem)
 {
     return(invoker?.GetValue(listItem));
 }