Пример #1
0
        public void StructValueField()
        {
            var s = new TestStructField()
            {
                Value = 123
            };
            var    getter = AccessorsCache.GetAccessors(typeof(TestStructField).GetField("Value")).Get;
            object v      = getter(s);

            Assert.That(v, Is.EqualTo(s.Value));
        }
Пример #2
0
        public void StructRefField()
        {
            var s = new TestStructField()
            {
                Ref = new object()
            };
            var    getter = AccessorsCache.GetAccessors(typeof(TestStructField).GetField("Ref")).Get;
            object v      = getter(s);

            Assert.That(v, Is.SameAs(s.Ref));
        }
Пример #3
0
        public void PocoStruct()
        {
            var s = new PocoStruct.Company();

            s.Employees.Add(new PocoStruct.Employee());
            PropertyInfo prop   = s.GetType().GetProperty("Employees");
            var          getter = AccessorsCache.GetAccessors(prop).Get;
            object       v      = getter(s);

            s.Employees.Add(new PocoStruct.Employee());
            Assert.That(((IList)v).Count, Is.EqualTo(s.Employees.Count));
        }
Пример #4
0
        public FieldDecorator(Type forType, FieldInfo field, IProtoSerializerWithWireType tail)
            : base(tail)
        {
            Helpers.DebugAssert(forType != null);
            Helpers.DebugAssert(field != null);
            this._forType = forType;
            this._field   = field;
            _tail         = tail;
#if FEAT_COMPILER && !FEAT_IKVM
            _accessors = AccessorsCache.GetAccessors(field);
#endif
        }
Пример #5
0
        public PropertyDecorator(TypeModel model, Type forType, PropertyInfo property, IProtoSerializerWithWireType tail)
            : base(tail)
        {
            Helpers.DebugAssert(forType != null);
            Helpers.DebugAssert(property != null);
            this._forType  = forType;
            this._property = property;
            _tail          = tail;
            SanityCheck(model, property, tail, out _canSetInRuntime, true, true, false);
            _shadowSetter = Helpers.GetShadowSetter(model, property);
#if FEAT_COMPILER && !FEAT_IKVM
            _accessors = AccessorsCache.GetAccessors(property);
            if (_shadowSetter != null)
            {
                _accessors.Set = AccessorsCache.GetShadowSetter(_shadowSetter);
            }
#endif
        }