Changeset 2369


Ignore:
Timestamp:
11/7/2011 11:56:39 AM (3 years ago)
Author:
lowjoel
Message:

Move the Settings class to Eraser.Plugins for plugins to store persistent state information. This will be passed to plugins as part of the Init function, where the PluginInfo? instance will be provided, including the Persistent Store for the plugin.

Location:
branches/eraser6/pluginsRewrite
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/pluginsRewrite/Eraser.Manager/Settings.cs

    r2366 r2369  
    6060    } 
    6161 
    62     /// <summary> 
    63     /// Settings class. Represents settings to a given client. 
    64     /// </summary> 
    65     public abstract class Settings 
    66     { 
    67         /// <summary> 
    68         /// Gets the setting for the given name, coercing the object stored in the backend 
    69         /// to the given type <typeparamref name="T"/>. 
    70         /// </summary> 
    71         /// <typeparam name="T">The type of the setting that is currently stored in the 
    72         /// backend.</typeparam> 
    73         /// <param name="name">The name of the setting that is used to uniquely refer 
    74         /// to the value.</param> 
    75         /// <param name="defaultValue">The default to return if the no data is assocated 
    76         /// with the given setting.</param> 
    77         /// <returns>The value stored in the backend, or null if none exists.</returns> 
    78         public abstract T GetValue<T>(string name, T defaultValue); 
    79  
    80         /// <summary> 
    81         /// Overload for <see cref="GetValue"/> which returns a default for the given type. 
    82         /// </summary> 
    83         /// <typeparam name="T">The type of the setting that is currently stored in the 
    84         /// backend.</typeparam> 
    85         /// <param name="name">The name of the setting that is used to uniquely refer 
    86         /// to the value.</param> 
    87         /// <param name="defaultValue">The default to return if the no data is assocated 
    88         /// with the given setting.</param> 
    89         /// <returns>The value stored in the backend, or null if none exists.</returns> 
    90         public T GetValue<T>(string name) 
    91         { 
    92             return GetValue<T>(name, default(T)); 
    93         } 
    94  
    95         /// <summary> 
    96         /// Sets the setting with the given name. 
    97         /// </summary> 
    98         /// <param name="name">The name of the setting.</param> 
    99         /// <param name="value">The value to store in the backend. This may be serialised.</param> 
    100         public abstract void SetValue(string name, object value); 
    101  
    102         /// <summary> 
    103         /// Gets or sets the given setting, without type hinting. This will not attempt to coerce 
    104         /// a type from an old version of the assembly to its current type. 
    105         /// </summary> 
    106         /// <param name="setting">The name of the setting.</param> 
    107         /// <returns>The object stored in the settings database, or null if undefined.</returns> 
    108         [Obsolete("Use the GetValue<T> and SetValue functions instead")] 
    109         public object this[string setting] 
    110         { 
    111             get 
    112             { 
    113                 return GetValue<object>(setting); 
    114             } 
    115             set 
    116             { 
    117                 SetValue(setting, value); 
    118             } 
    119         } 
    120     } 
    121  
    12262    #region Default attributes 
    12363    /// <summary> 
  • branches/eraser6/pluginsRewrite/Eraser.Plugins/Eraser.Plugins.csproj

    r2357 r2369  
    6363    <Compile Include="IRegistrar.cs" /> 
    6464    <Compile Include="LoadingPolicy.cs" /> 
     65    <Compile Include="PersistentStore.cs" /> 
    6566    <Compile Include="PluginInfo.cs" /> 
    6667    <Compile Include="PluginLoadedEventArgs.cs" /> 
  • branches/eraser6/pluginsRewrite/Eraser.Plugins/IPlugin.cs

    r2291 r2369  
    3737        /// Initializer. 
    3838        /// </summary> 
    39         /// <param name="host">The host object which can be used for two-way 
    40         /// communication with the program.</param> 
    41         void Initialize(Host host); 
     39        /// <param name="info">The Plugin Information structure describing the 
     40        /// current plugin.</param> 
     41        void Initialize(PluginInfo info); 
    4242 
    4343        /// <summary> 
  • branches/eraser6/pluginsRewrite/Eraser.Plugins/PluginInfo.cs

    r2298 r2369  
    6464        /// Executes the plugin's initialisation routine. 
    6565        /// </summary> 
    66         /// <param name="host">The host for the plugin</param> 
    6766        internal void Load(Host host) 
    6867        { 
     
    7877                //Initialize the plugin 
    7978                Plugin = (IPlugin)Activator.CreateInstance(typePlugin); 
    80                 Plugin.Initialize(host); 
     79                Plugin.Initialize(this); 
    8180            } 
    8281            catch (InvalidOperationException e) 
     
    143142 
    144143        /// <summary> 
     144        /// Gets the Persistent Data Store for this plugin. 
     145        /// </summary> 
     146        public PersistentStore PersistentStore { get; private set; } 
     147 
     148        /// <summary> 
    145149        /// Gets whether this particular plugin is currently loaded in memory. 
    146150        /// </summary> 
Note: See TracChangeset for help on using the changeset viewer.