IConfigurablePlugin.Settings Property

Gets or sets an object containing the plug-in's settings.

object Settings { get; set; }

Example

  CoolPluginSettings settings;

  // IConfigurablePlugin.Settings implementation
  public object Settings
  {
      get
      {
          if (settings == null)
              settings = new CoolPluginSettings();
          return settings;
      }
      set { settings = value as CoolPluginSettings; }
  }

  public class CoolPluginSettings
  {
      private int imageQuality = 80;
      private string extension;

      public int ImageQuality
      {
          get { return imageQuality; }
          set { imageQuality = value; }
      }

      public string Extension
      {
          get { return format; }
          set { format = value; }
      }
  }

Remarks

This property is set during startup with the settings contained in the applications configuration file.

The object returned by this property is serialized into Cropper's configuration file on shutdown.

Last edited Feb 24, 2007 at 2:38 PM by BrhineScot, version 4

Comments

runebjerke Sep 10, 2007 at 4:23 PM 
It would be worth noting here that the serialization is done using SoapFormatter or something - definitely not BinaryFormatter.. And even more; that if an error occurs during serialization of user data (e.g. if the object returned in the getter contains a generic type like List<>, which will throw an exception) it will end up with NO user data being stored. (The entire "PluginSettings" branch is gone). It would be nice if an error message would be shown, at least, or if the documentation here would indicate some more detail on the limitations of what the object returned here can contain. Would have saved me some head scratching also =)