Esempio n. 1
0
        internal static NrpnSysExMessage CreateReadMessage(Module mod, PropertyInfo prop)
        {
            var attr = prop.GetCustomAttribute <NrpnParameterAttribute>();
            var addr = new NrpnAddress(mod.NrpnPageNo, attr.NrpnAddress);

            return
                (attr.IsStringParameter ?
                 (NrpnSysExMessage) new ReadStringValueMessage(addr.Page, addr.Address) :
                 new ReadValueMessage(addr.Page, addr.Address));
        }
Esempio n. 2
0
        internal static SysExMessage CreateWriteMessage(Module mod, PropertyInfo prop, object value)
        {
            var attr = prop.GetCustomAttribute <NrpnParameterAttribute>();
            var addr = new NrpnAddress(mod.NrpnPageNo, attr.NrpnAddress);

            var newValue = ConverterCache.Instance.ConvertToMidi(prop, value);

            return
                (attr.IsStringParameter ?
                 (NrpnSysExMessage) new WriteStringValueMessage(addr.Page, addr.Address, (string)newValue) :
                 new WriteValueMessage(addr.Page, addr.Address, (int)newValue));
        }
Esempio n. 3
0
        public PropertyInfo GetPropertyByAddress(NrpnAddress addr, bool isStringValue)
        {
            var properties = GetParameterProperties(isStringValue);

            return(properties.FirstOrDefault(p =>
            {
                var attr = p.GetCustomAttribute <NrpnParameterAttribute>();
                if (attr == null)
                {
                    return false;
                }
                return NrpnPageNo == addr.Page && attr.NrpnAddress == addr.Address;
            }));
        }