コード例 #1
0
 private object GetPayloadSettingsValue(StreamDeckEventPayload obj, string propertyName)
 {
     if (obj.PayloadSettingsHasProperty(propertyName))
     {
         if (obj.payload.settings.settingsModel[propertyName].Type != JTokenType.Array)
         {
             return(obj.payload.settings.settingsModel[propertyName].Value);
         }
         else
         {
             return(((JArray)obj.payload.settings.settingsModel[propertyName]).ToObject(typeof(string[])));
         }
     }
     return(null);
 }
コード例 #2
0
        protected void SetModelProperties(StreamDeckEventPayload args)
        {
            var properties = typeof(T).GetProperties();

            foreach (var prop in properties)
            {
                if (args.payload != null && args.payload.settings != null && args.payload.settings.settingsModel != null)
                {
                    if (args.PayloadSettingsHasProperty(prop.Name))
                    {
                        var value  = args.GetPayloadSettingsValue(prop.Name);
                        var value2 = Convert.ChangeType(value, prop.PropertyType);
                        prop.SetValue(SettingsModel, value2);
                    }
                }
            }
        }
コード例 #3
0
 // These methods are overriding the default methods because arrays are not supported
 // in model yet.
 private new void SetModelProperties(StreamDeckEventPayload args)
 {
     PropertyInfo[] properties = typeof(T).GetProperties();
     PropertyInfo[] array      = properties;
     foreach (PropertyInfo propertyInfo in array)
     {
         if ((args.payload != null && args.payload.settings != null && args.payload.settings.settingsModel != null) && args.PayloadSettingsHasProperty(propertyInfo.Name))
         {
             object payloadSettingsValue = this.GetPayloadSettingsValue(args, propertyInfo.Name);
             object value = Convert.ChangeType(payloadSettingsValue, propertyInfo.PropertyType);
             propertyInfo.SetValue(this.SettingsModel, value);
         }
     }
 }