Ejemplo n.º 1
0
        /// <summary>
        /// Gets the value to write using a BinaryFormatter to serialize the Object.Value property.
        /// </summary>
        /// <param name="option"></param>
        /// <returns></returns>
        private string GetSerializedValue(XmlConfigurationOption option)
        {
            string buffer = null;

            try
            {
                Type t = Type.GetType(option.ValueAssemblyQualifiedName);
                if (t != null)
                {
                    if (Base64SerializationUtilities.Serialize(option.Value, t, out buffer))
                    {
                        return(buffer);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                this.OnCannotWriteValue(this, new XmlConfigurationWriterEventArgs(ex, option));
            }
            return(buffer);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deserializes an object assuming that the string contains the base64 encoded data for the object
        /// </summary>
        /// <param name="option"></param>
        /// <param name="buffer"></param>
        /// <returns></returns>
        private object GetSerializedValue(XmlConfigurationOption option, string buffer)
        {
            object instance = null;

            try
            {
                // try and base 64 decode the string
                if (buffer != null && buffer != string.Empty)
                {
                    if (Base64SerializationUtilities.Deserialize(buffer, out instance))
                    {
                        return(instance);
                    }
                }
            }
            catch (Exception ex)
            {
                this.OnCannotReadValue(this, new XmlConfigurationReaderEventArgs(ex, option, buffer));
//				Debug.WriteLine(ex);
            }
            return(instance);
        }