Exemple #1
0
        /// <summary>
        /// prepare struct for serialization and store settings
        /// </summary>
        /// <returns></returns>
        public TileWrapperSettings SerializeSettings()
        {
            var settings = new TileWrapperSettings
                               {
                                   Size = GridSize,
                                   Location = GridPosition,
                                   TileClassName = TileClass,
                                   Parameters = new List<StoredParameter>()
                               };

            foreach (var prop in _propertyInfos)
                settings.Parameters.Add(new StoredParameter(prop.Name, prop.GetValue(Tile, null).ToString()));

            return settings;
        }
Exemple #2
0
        /// <summary>
        /// parse settings struct read from settings file and apply these settings to widget
        /// </summary>
        /// <param name="settings"></param>
        public void DeserializeSettings(TileWrapperSettings settings)
        {
            try
            {
                TileClass = settings.TileClassName;
                GridSize = settings.Size;
                GridPosition = settings.Location;

                foreach (var param in settings.Parameters)
                    SetParameter(param.Name, param.Value);
            }
            catch (Exception e)
            {
                Logger.WriteLog(e.StackTrace, "DeserializeSettings error");
            }
        }