Example #1
0
        /// <summary>
        /// Saves the specified instance the the options file(s).
        /// </summary>
        public void SaveInstance(IPersistable persistableObject)
        {
            Type t = persistableObject.GetType();

            if (!typeCache.ContainsKey(t))
            {
                RegisterInstance(persistableObject);
            }

            TypeReflectionCache cache = typeCache[t];

            foreach (TypeReflectionCacheItem item in cache.Properties)
            {
                bool    created;
                XmlNode valueNode = OptionsMerger.LocateOrCreateNode(item, persistableObject, out created);
                object  newValue  = item.PropertyInfo.GetValue(persistableObject, null);
                OptionsMerger.SetNodeValue(valueNode, newValue.ToString(), item.PersistanceInformation.Encrypted);
            }

            // Don't save the files to disk if we are currently in batch update mode.
            if (!batchInProgress)
            {
                SaveFiles();
            }
        }
Example #2
0
 /// <summary>
 /// Locates the XML node that contains persistance information for the specified item.
 /// If the node is not found, it will be created.
 /// </summary>
 private static XmlNode LocateOrCreateNode(TypeReflectionCacheItem item, IPersistable instance, out bool created)
 {
     return(OptionsMerger.LocateOrCreateNode(item, instance, out created));
 }