summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Tweening/TweenMember.cs
blob: adcee5982c7253d507946c3288e4f674b4114212 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Linq.Expressions;

namespace MonoGame.Extended.Tweening
{
    public abstract class TweenMember
    {
        protected TweenMember(object target)
        {
            Target = target;
        }

        public object Target { get; }
        public abstract Type Type { get; }
        public abstract string Name { get; }
    }

    public abstract class TweenMember<T> : TweenMember
        where T : struct
    {
        protected TweenMember(object target, Func<object, object> getMethod, Action<object, object> setMethod)
            : base(target)
        {
            _getMethod = getMethod;
            _setMethod = setMethod;
        }

        private readonly Func<object, object> _getMethod;
        private readonly Action<object, object> _setMethod;

        public T Value
        {
            get { return (T) _getMethod(Target); }
            set { _setMethod(Target, value); }
        }
    }
}