using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using TradeIdeas.Extensions; using TradeIdeas.TIProData; namespace TIProDevExtension.ValueEditor { /// /// This is only aimed at a developer. /// /// We have rules for serializing objects to XML and restoring them. These should /// persisit for a long time; even if this code changes, some XML will be left in /// the wild and we need to be able to read it. These rules should be consistent /// across multiple platforms. /// public partial class DataNodeEditorDebug : Form { public DataNodeEditorDebug() { InitializeComponent(); // If we see an object with EXACTLY this type, we will use the corresponding // rule to serialize it. We will add TYPE= and the name shown here to the // XML file. The rule can add more. // // This list is shorter than the result rules, for a few reasons: // o Null is handled as a special case. // o Some types implement XmlSerializer.Self // o DataNode.FactoryWithHash takes one type of input and creates a lot of // different restore rules. typesTextBox.Text = XmlSerializer.DebugGetKnownTypes(); // If we see TYPE= and one of these values in the XML file, we have a rule // to restore the object. restoreRulesTextBox.Text = XmlSerializer.DebugGetKnownTypeStrings(); // Some specific objects are handled directly. We don't look at the type. // In XML these will say TYPE="object" and VALUE= the name shown here. // We use the same list for serializing or deserializing. objectsTextBox.Text = XmlSerializer.DebugGetKnownObjects(); } } public class DataNodeEditorDebugExtension : IMainInit { public static IList GetExtensions(Object mainProgram) { List result = new List(1); result.Add(new DataNodeEditorDebugExtension((IMainProgram)mainProgram)); return result; } private readonly IMainProgram _mainProgram; private DataNodeEditorDebugExtension(IMainProgram mainProgram) { _mainProgram = mainProgram; } public void MainInit() { _mainProgram.AddToToolsMenu("DataNode XML Debug", delegate { new DataNodeEditorDebug().Show(); }); } } }