// /// <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 // { // /// this should really use reflection to determine if the type supports serialization // BinaryFormatter formatter = new BinaryFormatter(); // MemoryStream stream = new MemoryStream(); // formatter.Serialize(stream, option.Value); // buffer = System.Text.Encoding.ASCII.GetString(stream.GetBuffer()); // stream.Close(); // } // catch(System.Exception systemException) // { // System.Diagnostics.Trace.WriteLine(systemException); // this.OnCannotWriteValue(this, new XmlConfigurationWriterEventArgs(systemException, option)); // } // return buffer; // } /// <summary> /// Raises the CannotWriteValue event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnCannotWriteValue(object sender, XmlConfigurationWriterEventArgs e) { try { if (this.CannotWriteValue != null) { this.CannotWriteValue(sender, e); } } catch (System.Exception systemException) { System.Diagnostics.Trace.WriteLine(systemException); } }
// /// <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 // { // /// this should really use reflection to determine if the type supports serialization // BinaryFormatter formatter = new BinaryFormatter(); // MemoryStream stream = new MemoryStream(); // formatter.Serialize(stream, option.Value); // buffer = System.Text.Encoding.ASCII.GetString(stream.GetBuffer()); // stream.Close(); // } // catch(System.Exception systemException) // { // System.Diagnostics.Trace.WriteLine(systemException); // this.OnCannotWriteValue(this, new XmlConfigurationWriterEventArgs(systemException, option)); // } // return buffer; // } /// <summary> /// Raises the CannotWriteValue event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnCannotWriteValue(object sender, XmlConfigurationWriterEventArgs e) { try { if (this.CannotWriteValue != null) this.CannotWriteValue(sender, e); } catch(System.Exception systemException) { System.Diagnostics.Trace.WriteLine(systemException); } }