Exemplo n.º 1
0
        protected override void ValueToOSCValues(List <OSCValue> values, object value)
        {
            var members = GetMembers(value.GetType());

            foreach (var memberInfo in members)
            {
                var property = OSCReflectionProperty.Create(value, memberInfo);
                if (property != null)
                {
                    var propertyValue = property.GetValue();
                    if (propertyValue == null)
                    {
                        values.Add(OSCValue.Null());

                        continue;
                    }

                    OSCSerializer.Pack(values, propertyValue);
                }
                else
                {
                    throw new NullReferenceException("Property not found!");
                }
            }
        }
Exemplo n.º 2
0
        protected override object OSCValuesToValue(List <OSCValue> values, ref int start, Type type)
        {
            var members = GetMembers(type);
            var value   = Activator.CreateInstance(type);

            foreach (var memberInfo in members)
            {
                var oscValue = values[start];

                var property = OSCReflectionProperty.Create(value, memberInfo);
                if (property != null && !oscValue.IsNull)
                {
                    property.SetValue(OSCSerializer.Unpack(values, ref start, property.PropertyType));
                }
                else
                {
                    start++;
                }
            }

            return(value);
        }