示例#1
0
        public void test_field_accessor_can_access_getter_over_class_parents()
        {
            var cls = new Child();

            var accessor = new FieldAccessor(cls, "childField", FieldAccessType.PUBLIC_METHOD);

            accessor.Exists().Should().BeTrue();
            var obj = accessor.Get <object>();

            (obj is String).Should().BeTrue();
            ((string)obj).Should().BeEquivalentTo("Hello child!");

            accessor = new FieldAccessor(cls, "parentField", FieldAccessType.PUBLIC_METHOD);

            accessor.Exists().Should().BeTrue();
            var obj2 = accessor.Get <object>();

            (obj2 is String).Should().BeTrue();
            ((string)obj2).Should().BeEquivalentTo("Hello parent!");

            accessor = new FieldAccessor(cls, "grandparentField", FieldAccessType.PUBLIC_METHOD);

            accessor.Exists().Should().BeTrue();
            var obj3 = accessor.Get <object>();

            (obj3 is String).Should().BeTrue();
            ((string)obj3).Should().BeEquivalentTo("Hello grandparent!");
        }
        private GridItem[] GetGridViewItems()
        {
            var items = allGridEntriesAccessor.Get();

            if (items == null)
            {
                return(null);
            }

            if (gridViewEntriesAccessor == null)
            {
                gridViewEntriesAccessor = new FieldAccessor(items, "entries");
            }

            return(gridViewEntriesAccessor.Get(items) as GridItem[]);
        }
示例#3
0
        public void test_field_accessor_access_getter_with_value_correctly_ensuring_that_field_exists()
        {
            var cls = new ClassWithGetters();

            var accessor = new FieldAccessor(cls, "getterWithoutProperty", FieldAccessType.PUBLIC_METHOD);

            accessor.Exists().Should().BeFalse();
            var obj = accessor.Get <object>();

            ((string)obj).Should().BeEquivalentTo(null);
        }
示例#4
0
        public void test_field_accessor_access_property_with_NULL_value_correctly()
        {
            var cls = new ClassWithGetters(null);

            var accessor = new FieldAccessor(cls, "id", FieldAccessType.PROPERTY);

            accessor.Exists().Should().BeTrue();
            var obj = accessor.Get <object>();

            obj.Should().BeNull();
        }
示例#5
0
        public void test_field_accessor_access_property_with_value_correctly()
        {
            var cls = new ClassWithGetters();

            var accessor = new FieldAccessor(cls, "id", FieldAccessType.PROPERTY);

            accessor.Exists().Should().BeTrue();
            var obj = accessor.Get <object>();

            (obj is Int32).Should().BeTrue();
            ((Int32)obj).Should().Be(500);
        }
示例#6
0
        test_field_accessor_access_property_with_value_correctly_using_a_custom_getter_as_field_has_no_effect()
        {
            var cls = new ClassWithGetters();

            var accessor = new FieldAccessor(cls, "barMethod3", FieldAccessType.PROPERTY);

            accessor.SetCustomGetterName("getBarMethod3Bis");

            accessor.Exists().Should().BeTrue();
            var obj = accessor.Get <object>();

            (obj is String).Should().BeTrue();
            ((string)obj).Should().BeEquivalentTo("Foo");
        }
示例#7
0
        public void test_field_accessor_access_property_with_value_correctly_using_a_custom_getter()
        {
            var cls = new ClassWithGetters();

            var accessor = new FieldAccessor(cls, "barMethod2", FieldAccessType.PUBLIC_METHOD);

            accessor.SetCustomGetterName("getBarMethodBis");

            accessor.Exists().Should().BeTrue();
            var obj = accessor.Get <object>();

            (obj is String).Should().BeTrue();
            ((string)obj).Should().BeEquivalentTo("Foo Bar Foo Bar");
        }
        // Serialization
        public void Serialize(PerfTests.Classes.AzureEntityFramework.Address serializedObject)
        {
            // Do we have to store full data (when it's not null or cached object)?
            if (!ShouldStoreFullData(serializedObject))
            {
                return;
            }

            // <StreetName>k__BackingField - WellKnownType object
            System.String _StreetName_k__BackingFieldValue = s_Accessor4_StreetName_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_StreetName_k__BackingFieldValue);

            // <Building>k__BackingField - WellKnownType object
            System.String _Building_k__BackingFieldValue = s_Accessor4_Building_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_Building_k__BackingFieldValue);

            // <City>k__BackingField - WellKnownType object
            System.String _City_k__BackingFieldValue = s_Accessor4_City_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_City_k__BackingFieldValue);

            // <PostCode>k__BackingField - WellKnownType object
            System.String _PostCode_k__BackingFieldValue = s_Accessor4_PostCode_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_PostCode_k__BackingFieldValue);

            // <Country>k__BackingField - WellKnownType object
            System.String _Country_k__BackingFieldValue = s_Accessor4_Country_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_Country_k__BackingFieldValue);

            // <ExternalId1>k__BackingField - WellKnownType object
            System.Guid _ExternalId1_k__BackingFieldValue = s_Accessor4_ExternalId1_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_ExternalId1_k__BackingFieldValue);

            // <ExternalId2>k__BackingField - WellKnownType object
            System.Guid _ExternalId2_k__BackingFieldValue = s_Accessor4_ExternalId2_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_ExternalId2_k__BackingFieldValue);

            // <ExternalId3>k__BackingField - WellKnownType object
            System.Guid _ExternalId3_k__BackingFieldValue = s_Accessor4_ExternalId3_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_ExternalId3_k__BackingFieldValue);

            // <ExternalId4>k__BackingField - WellKnownType object
            System.Guid _ExternalId4_k__BackingFieldValue = s_Accessor4_ExternalId4_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_ExternalId4_k__BackingFieldValue);

            // <ExternalId5>k__BackingField - WellKnownType object
            System.Guid _ExternalId5_k__BackingFieldValue = s_Accessor4_ExternalId5_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_ExternalId5_k__BackingFieldValue);
        }
        private void InitializeAccessors()
        {
            var gridViewAccessor = new FieldAccessor(this, "gridView");

            reflectedGridView = gridViewAccessor.Get();
            var gridViewType = reflectedGridView.GetType();

            allGridEntriesAccessor      = new FieldAccessor(reflectedGridView, "allGridEntries");
            topLevelGridEntriesAccessor = new FieldAccessor(reflectedGridView, "topLevelGridEntries");
            totalPropsAccessor          = new FieldAccessor(reflectedGridView, "totalProps");
            selectedRowAccessor         = new FieldAccessor(reflectedGridView, "selectedRow");

            setScrollOffsetAccessor = new MethodAccessor(gridViewType, "SetScrollOffset");
            refreshAccessor         = new MethodAccessor(gridViewType, "Refresh");

            selectedGridEntryAccessor = new PropertyAccessor(reflectedGridView, "SelectedGridEntry");
        }
示例#10
0
        public void test_field_accessor_access_getter_with_value_correctly()
        {
            var cls = new ClassWithGetters();

            var accessor = new FieldAccessor(cls, "foo", FieldAccessType.PUBLIC_METHOD);

            accessor.Exists().Should().BeTrue();
            var obj = accessor.Get <object>();

            (obj is String).Should().BeTrue();
            ((string)obj).Should().BeEquivalentTo("Hello world!");

            var accessor2 = new FieldAccessor(cls, "bar", FieldAccessType.PUBLIC_METHOD);

            accessor2.Exists().Should().BeTrue();
            var obj2 = accessor2.Get <object>();

            (obj2 is Boolean).Should().BeTrue();
            ((bool)obj2).Should().BeTrue();
        }
        private void SetGridViewItems(GridItem[] newItems)
        {
            var items = allGridEntriesAccessor.Get();

            if (items == null)
            {
                return;
            }

            if (newItems == null)
            {
                newItems = new GridItem[0];
            }

            var wasFocused = searchBox.Focused;

            if (gridViewEntriesAccessor == null)
            {
                gridViewEntriesAccessor = new FieldAccessor(items, "entries");
            }

            setScrollOffsetAccessor.Invoke(reflectedGridView, 0);

            gridViewEntriesAccessor.Set(newItems, items);
            gridViewEntriesAccessor.Set(newItems, topLevelGridEntriesAccessor.Get());

            totalPropsAccessor.Set(newItems.Length);
            selectedRowAccessor.Set(0);

            if (newItems.Length > 0)
            {
                selectedGridEntryAccessor.Set(newItems[0]);
            }

            ((Control)reflectedGridView).Invalidate();

            if (wasFocused)
            {
                searchBox.Focus();
            }
        }
示例#12
0
        private void SetGridViewItems(GridItem[] newItems)
        {
            object items = _allGridEntriesAccessor.Get();

            if (items == null)
            {
                return;
            }

            if (newItems == null)
            {
                newItems = new GridItem[0];
            }

            bool wasFocused = _searchBox.Focused;

            if (_gridViewEntriesAccessor == null)
            {
                _gridViewEntriesAccessor = new FieldAccessor(items, "entries");
            }

            _setScrollOffsetAccessor.Invoke(_reflectedGridView, 0);

            _gridViewEntriesAccessor.Set(newItems, items);
            _gridViewEntriesAccessor.Set(newItems, _topLevelGridEntriesAccessor.Get());

            _totalPropsAccessor.Set(newItems.Length);
            _selectedRowAccessor.Set(0);

            if (newItems.Length > 0)
            {
                _selectedGridEntryAccessor.Set(newItems[0]);
            }

            ((Control)_reflectedGridView).Invalidate();

            if (wasFocused)
            {
                _searchBox.Focus();
            }
        }
示例#13
0
        public static void SetNoteColour(ColorNoteVisuals noteVis, Color c)
        {
            FieldAccessor <ColorNoteVisuals, Color> .Set(ref noteVis, "_noteColor", c);

            SpriteRenderer ____arrowGlowSpriteRenderer = FieldAccessor <ColorNoteVisuals, SpriteRenderer> .Get(ref noteVis, "_arrowGlowSpriteRenderer");

            SpriteRenderer ____circleGlowSpriteRenderer = FieldAccessor <ColorNoteVisuals, SpriteRenderer> .Get(ref noteVis, "_circleGlowSpriteRenderer");

            MaterialPropertyBlockController[] ____materialPropertyBlockController = FieldAccessor <ColorNoteVisuals, MaterialPropertyBlockController[]> .Get(ref noteVis, "_materialPropertyBlockControllers");

            if (____arrowGlowSpriteRenderer != null)
            {
                ____arrowGlowSpriteRenderer.color = c;
            }
            if (____circleGlowSpriteRenderer != null)
            {
                ____circleGlowSpriteRenderer.color = c;
            }
            foreach (var block in ____materialPropertyBlockController)
            {
                block.materialPropertyBlock.SetColor(colorID, c);
                block.ApplyChanges();
            }
        }
示例#14
0
 public static TDel GetEventHandlers <TTarget, TDel>(this TTarget target, string name)
 {
     return(FieldAccessor <TTarget, TDel> .Get(target, name));
 }
        // Serialization
        public void Serialize(PerfTests.Classes.AzureEntityFramework.Person serializedObject)
        {
            // Do we have to store full data (when it's not null or cached object)?
            if (!ShouldStoreFullData(serializedObject))
            {
                return;
            }

            // <PersonID>k__BackingField - WellKnownType object
            System.Guid _PersonID_k__BackingFieldValue = s_Accessor4_PersonID_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_PersonID_k__BackingFieldValue);

            // <FirstName>k__BackingField - WellKnownType object
            System.String _FirstName_k__BackingFieldValue = s_Accessor4_FirstName_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_FirstName_k__BackingFieldValue);

            // <LastName>k__BackingField - WellKnownType object
            System.String _LastName_k__BackingFieldValue = s_Accessor4_LastName_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_LastName_k__BackingFieldValue);

            // <BirthDate>k__BackingField - WellKnownType object
            System.DateTime _BirthDate_k__BackingFieldValue = s_Accessor4_BirthDate_k__BackingField.Get(serializedObject);
            WKTSerializers.DateTime.Serialize(_BirthDate_k__BackingFieldValue);

            // <ExternalId1>k__BackingField - WellKnownType object
            System.Guid _ExternalId1_k__BackingFieldValue = s_Accessor4_ExternalId1_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_ExternalId1_k__BackingFieldValue);

            // <ExternalId2>k__BackingField - WellKnownType object
            System.Guid _ExternalId2_k__BackingFieldValue = s_Accessor4_ExternalId2_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_ExternalId2_k__BackingFieldValue);

            // <ExternalId3>k__BackingField - WellKnownType object
            System.Guid _ExternalId3_k__BackingFieldValue = s_Accessor4_ExternalId3_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_ExternalId3_k__BackingFieldValue);

            // <ExternalId4>k__BackingField - WellKnownType object
            System.Guid _ExternalId4_k__BackingFieldValue = s_Accessor4_ExternalId4_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_ExternalId4_k__BackingFieldValue);

            // <ExternalId5>k__BackingField - WellKnownType object
            System.Guid _ExternalId5_k__BackingFieldValue = s_Accessor4_ExternalId5_k__BackingField.Get(serializedObject);
            WKTSerializers.Guid.Serialize(_ExternalId5_k__BackingFieldValue);

            // <Sallary1>k__BackingField - WellKnownType object
            System.Decimal _Sallary1_k__BackingFieldValue = s_Accessor4_Sallary1_k__BackingField.Get(serializedObject);
            WKTSerializers.Decimal.Serialize(_Sallary1_k__BackingFieldValue);

            // <Sallary2>k__BackingField - WellKnownType object
            System.Decimal _Sallary2_k__BackingFieldValue = s_Accessor4_Sallary2_k__BackingField.Get(serializedObject);
            WKTSerializers.Decimal.Serialize(_Sallary2_k__BackingFieldValue);

            // <Sallary3>k__BackingField - WellKnownType object
            System.Decimal _Sallary3_k__BackingFieldValue = s_Accessor4_Sallary3_k__BackingField.Get(serializedObject);
            WKTSerializers.Decimal.Serialize(_Sallary3_k__BackingFieldValue);

            // <Sallary4>k__BackingField - WellKnownType object
            System.Decimal _Sallary4_k__BackingFieldValue = s_Accessor4_Sallary4_k__BackingField.Get(serializedObject);
            WKTSerializers.Decimal.Serialize(_Sallary4_k__BackingFieldValue);

            // <Sallary5>k__BackingField - WellKnownType object
            System.Decimal _Sallary5_k__BackingFieldValue = s_Accessor4_Sallary5_k__BackingField.Get(serializedObject);
            WKTSerializers.Decimal.Serialize(_Sallary5_k__BackingFieldValue);

            // <Result1>k__BackingField - WellKnownType object
            System.Double _Result1_k__BackingFieldValue = s_Accessor4_Result1_k__BackingField.Get(serializedObject);
            WKTSerializers.Double.Serialize(_Result1_k__BackingFieldValue);

            // <Result2>k__BackingField - WellKnownType object
            System.Double _Result2_k__BackingFieldValue = s_Accessor4_Result2_k__BackingField.Get(serializedObject);
            WKTSerializers.Double.Serialize(_Result2_k__BackingFieldValue);

            // <Result3>k__BackingField - WellKnownType object
            System.Double _Result3_k__BackingFieldValue = s_Accessor4_Result3_k__BackingField.Get(serializedObject);
            WKTSerializers.Double.Serialize(_Result3_k__BackingFieldValue);

            // <Result4>k__BackingField - WellKnownType object
            System.Double _Result4_k__BackingFieldValue = s_Accessor4_Result4_k__BackingField.Get(serializedObject);
            WKTSerializers.Double.Serialize(_Result4_k__BackingFieldValue);

            // <Result5>k__BackingField - WellKnownType object
            System.Double _Result5_k__BackingFieldValue = s_Accessor4_Result5_k__BackingField.Get(serializedObject);
            WKTSerializers.Double.Serialize(_Result5_k__BackingFieldValue);

            // <Skill1>k__BackingField - WellKnownType object
            System.String _Skill1_k__BackingFieldValue = s_Accessor4_Skill1_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_Skill1_k__BackingFieldValue);

            // <Skill2>k__BackingField - WellKnownType object
            System.String _Skill2_k__BackingFieldValue = s_Accessor4_Skill2_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_Skill2_k__BackingFieldValue);

            // <Skill3>k__BackingField - WellKnownType object
            System.String _Skill3_k__BackingFieldValue = s_Accessor4_Skill3_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_Skill3_k__BackingFieldValue);

            // <Skill4>k__BackingField - WellKnownType object
            System.String _Skill4_k__BackingFieldValue = s_Accessor4_Skill4_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_Skill4_k__BackingFieldValue);

            // <Skill5>k__BackingField - WellKnownType object
            System.String _Skill5_k__BackingFieldValue = s_Accessor4_Skill5_k__BackingField.Get(serializedObject);
            WKTSerializers.String.Serialize(_Skill5_k__BackingFieldValue);

            // <KnownAddresses>k__BackingField - normal array of PerfTests.Classes.AzureEntityFramework.Address elements
            PerfTests.Classes.AzureEntityFramework.Address[] _KnownAddresses_k__BackingFieldValue = s_Accessor4_KnownAddresses_k__BackingField.Get(serializedObject);
            new SZRefArraySerializer <PerfTests.Classes.AzureEntityFramework.Address>(SerializerStorage,
                                                                                      elem => { new PerfTests_Classes_AzureEntityFramework_AddressSerializer(SerializerStorage, ObjectCache, ValObjectsCache).Serialize(elem); },
                                                                                      () => new PerfTests_Classes_AzureEntityFramework_AddressSerializer(SerializerStorage, ObjectCache, ValObjectsCache).Deserialize()
                                                                                      ).Serialize(_KnownAddresses_k__BackingFieldValue);
        }