public MainWindow() { InitializeComponent(); Instance = this; Title = Title.Put(LocalizedStrings.Str1355); _ordersWindow.MakeHideable(); _myTradesWindow.MakeHideable(); _strategiesWindow.MakeHideable(); _securitiesWindow.MakeHideable(); _portfoliosWindow.MakeHideable(); LogManager = new LogManager(); LogManager.Listeners.Add(new FileLogListener("Data\\sample.log")); LogManager.Listeners.Add(new GuiLogListener(Monitor)); var entityRegistry = new CsvEntityRegistry("Data"); ConfigManager.RegisterService(entityRegistry.ProcessorProvider); ConfigManager.RegisterService <IEntityRegistry>(entityRegistry); // ecng.serialization invoke in several places IStorage obj ConfigManager.RegisterService(entityRegistry.Storage); var storageRegistry = ConfigManager.GetService <IStorageRegistry>(); var snapshotRegistry = new SnapshotRegistry(Path.Combine("Data", "Snapshots")); Connector = new Connector(entityRegistry, storageRegistry, snapshotRegistry); LogManager.Sources.Add(Connector); InitConnector(entityRegistry, snapshotRegistry); }
/// <summary> /// Initializes a new instance of the <see cref="Connector"/>. /// </summary> /// <param name="initAdapter">Initialize basket adapter.</param> /// <param name="initChannels">Initialize channels.</param> /// <param name="storageRegistry">The storage of market data.</param> /// <param name="snapshotRegistry">Snapshot storage registry.</param> /// <param name="initManagers">Initialize managers.</param> protected Connector(bool initAdapter, bool initChannels = true, IStorageRegistry storageRegistry = null, SnapshotRegistry snapshotRegistry = null, bool initManagers = true) { _entityCache = new EntityCache(this) { ExchangeInfoProvider = new InMemoryExchangeInfoProvider() }; _subscriptionManager = new SubscriptionManager(this); UpdateSecurityLastQuotes = UpdateSecurityByLevel1 = UpdateSecurityByDefinition = true; SupportLevel1DepthBuilder = true; SupportFilteredMarketDepth = true; if (initManagers) { //PnLManager = new PnLManager(); RiskManager = new RiskManager(); } _connectorStat.Add(this); if (initChannels) { InMessageChannel = new InMemoryMessageChannel($"Connector In ({Name})", RaiseError); OutMessageChannel = new InMemoryMessageChannel($"Connector Out ({Name})", RaiseError); } if (initAdapter) { InitAdapter(storageRegistry, snapshotRegistry); } }
private Connector MainPanel_OnCreateConnector(string path) { //HistoryPath.Folder = path; var entityRegistry = new CsvEntityRegistry(path); var exchangeInfoProvider = new StorageExchangeInfoProvider(entityRegistry, false); ConfigManager.RegisterService <IExchangeInfoProvider>(exchangeInfoProvider); var storageRegistry = new StorageRegistry(exchangeInfoProvider) { DefaultDrive = new LocalMarketDataDrive(path) }; ConfigManager.RegisterService <IEntityRegistry>(entityRegistry); ConfigManager.RegisterService <IStorageRegistry>(storageRegistry); // ecng.serialization invoke in several places IStorage obj ConfigManager.RegisterService(entityRegistry.Storage); INativeIdStorage nativeIdStorage = new CsvNativeIdStorage(Path.Combine(path, "NativeId")) { DelayAction = entityRegistry.DelayAction }; ConfigManager.RegisterService(nativeIdStorage); var snapshotRegistry = new SnapshotRegistry(Path.Combine(path, "Snapshots")); return(new Connector(entityRegistry.Securities, entityRegistry.PositionStorage, exchangeInfoProvider, storageRegistry, snapshotRegistry, new StorageBuffer())); }
public MainWindow() { InitializeComponent(); Instance = this; Title = Title.Put("Multi connection"); _ordersWindow.MakeHideable(); _myTradesWindow.MakeHideable(); _tradesWindow.MakeHideable(); _securitiesWindow.MakeHideable(); _stopOrdersWindow.MakeHideable(); _portfoliosWindow.MakeHideable(); _orderLogWindow.MakeHideable(); _newsWindow.MakeHideable(); var path = _defaultDataPath.ToFullPath(); _settingsFile = Path.Combine(path, "connection.xml"); var logManager = new LogManager(); logManager.Listeners.Add(new FileLogListener { LogDirectory = Path.Combine(path, "Logs") }); logManager.Listeners.Add(Monitor); HistoryPath.Folder = path; var entityRegistry = new CsvEntityRegistry(path); var storageRegistry = new StorageRegistry { DefaultDrive = new LocalMarketDataDrive(path) }; ConfigManager.RegisterService <IEntityRegistry>(entityRegistry); ConfigManager.RegisterService <IStorageRegistry>(storageRegistry); // ecng.serialization invoke in several places IStorage obj ConfigManager.RegisterService(entityRegistry.Storage); INativeIdStorage nativeIdStorage = new CsvNativeIdStorage(Path.Combine(path, "NativeId")) { DelayAction = entityRegistry.DelayAction }; ConfigManager.RegisterService(nativeIdStorage); var snapshotRegistry = new SnapshotRegistry(Path.Combine(path, "Snapshots")); Connector = new Connector(entityRegistry, storageRegistry, snapshotRegistry); logManager.Sources.Add(Connector); InitConnector(entityRegistry, snapshotRegistry, nativeIdStorage); }
/// <summary> /// Initializes a new instance of the <see cref="Connector"/>. /// </summary> /// <param name="securityStorage">Securities meta info storage.</param> /// <param name="positionStorage">Position storage.</param> /// <param name="storageRegistry">The storage of market data.</param> /// <param name="snapshotRegistry">Snapshot storage registry.</param> /// <param name="initManagers">Initialize managers.</param> public Connector(ISecurityStorage securityStorage, IPositionStorage positionStorage, IStorageRegistry storageRegistry, SnapshotRegistry snapshotRegistry, bool initManagers = true) : this(false, true, storageRegistry, snapshotRegistry, initManagers) { _entityCache.ExchangeInfoProvider = storageRegistry.ExchangeInfoProvider; SecurityStorage = securityStorage ?? throw new ArgumentNullException(nameof(securityStorage)); PositionStorage = positionStorage ?? throw new ArgumentNullException(nameof(positionStorage)); InitAdapter(storageRegistry, snapshotRegistry); }
public MainWindow() { InitializeComponent(); Instance = this; Title = Title.Put("Multi connection"); _ordersWindow.MakeHideable(); _myTradesWindow.MakeHideable(); _tradesWindow.MakeHideable(); _securitiesWindow.MakeHideable(); _stopOrdersWindow.MakeHideable(); _portfoliosWindow.MakeHideable(); var logManager = new LogManager(); logManager.Listeners.Add(new FileLogListener("sample.log")); var path = _defaultDataPath.ToFullPath(); HistoryPath.Folder = path; var entityRegistry = new CsvEntityRegistry(path); ConfigManager.RegisterService(entityRegistry.ProcessorProvider); var storageRegistry = new StorageRegistry { DefaultDrive = new LocalMarketDataDrive(path) }; ConfigManager.RegisterService <IEntityRegistry>(entityRegistry); ConfigManager.RegisterService <IStorageRegistry>(storageRegistry); // ecng.serialization invoke in several places IStorage obj ConfigManager.RegisterService(entityRegistry.Storage); var snapshotRegistry = new SnapshotRegistry(Path.Combine(path, "Snapshots")); Connector = new Connector(entityRegistry, storageRegistry, snapshotRegistry); logManager.Sources.Add(Connector); InitConnector(entityRegistry, snapshotRegistry); }
public MainWindow() { InitializeComponent(); Instance = this; Title = Title.Put(LocalizedStrings.Str1355); _ordersWindow.MakeHideable(); _myTradesWindow.MakeHideable(); _strategiesWindow.MakeHideable(); _securitiesWindow.MakeHideable(); _portfoliosWindow.MakeHideable(); LogManager = new LogManager(); LogManager.Listeners.Add(new FileLogListener("Data\\sample.log")); LogManager.Listeners.Add(new GuiLogListener(Monitor)); var entityRegistry = new CsvEntityRegistry("Data"); ConfigManager.RegisterService <IEntityRegistry>(entityRegistry); // ecng.serialization invoke in several places IStorage obj ConfigManager.RegisterService(entityRegistry.Storage); var storageRegistry = ServicesRegistry.StorageRegistry; var snapshotRegistry = new SnapshotRegistry(Path.Combine("Data", "Snapshots")); Connector = new Connector(entityRegistry.Securities, entityRegistry.PositionStorage, storageRegistry.ExchangeInfoProvider, storageRegistry, snapshotRegistry) { Adapter = { StorageSettings = { DaysLoad = TimeSpan.FromDays(3), } } }; LogManager.Sources.Add(Connector); InitConnector(entityRegistry, snapshotRegistry); }
public MainWindow() { InitializeComponent(); Instance = this; Title = Title.Put("Plaza II"); _ordersWindow.MakeHideable(); _ordersLogWindow.MakeHideable(); _myTradesWindow.MakeHideable(); _tradesWindow.MakeHideable(); _securitiesWindow.MakeHideable(); _portfoliosWindow.MakeHideable(); const string dataPath = "Data"; _entityRegistry = new CsvEntityRegistry(dataPath); ConfigManager.RegisterService <IEntityRegistry>(_entityRegistry); // ecng.serialization invoke in several places IStorage obj ConfigManager.RegisterService(_entityRegistry.Storage); _storageRegistry = new StorageRegistry { DefaultDrive = new LocalMarketDataDrive(dataPath) }; _snapshotRegistry = new SnapshotRegistry(Path.Combine(dataPath, "Snapshots")); //AppName.Text = Trader.AppName; Tables.SelectedTables = Trader.Tables.Select(t => t.Id); _logManager.Sources.Add(Trader); _logManager.Listeners.Add(new FileLogListener { LogDirectory = "StockSharp_Plaza" }); }
private void InitConnector(IEntityRegistry entityRegistry, SnapshotRegistry snapshotRegistry, INativeIdStorage nativeIdStorage) { // subscribe on connection successfully event Connector.Connected += () => { this.GuiAsync(() => ChangeConnectStatus(true)); if (Connector.Adapter.IsMarketDataTypeSupported(DataType.News) && !Connector.Adapter.IsSecurityNewsOnly) { Connector.SubscribeNews(); } }; // subscribe on connection error event Connector.ConnectionError += error => this.GuiAsync(() => { ChangeConnectStatus(false); MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2959); }); Connector.Disconnected += () => this.GuiAsync(() => ChangeConnectStatus(false)); // subscribe on error event //Connector.Error += error => // this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2955)); // subscribe on error of market data subscription event Connector.MarketDataSubscriptionFailed += (security, msg, error) => this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2956Params.Put(msg.DataType, security))); Connector.NewSecurity += _securitiesWindow.SecurityPicker.Securities.Add; Connector.NewTrade += _tradesWindow.TradeGrid.Trades.Add; Connector.NewOrderLogItem += _orderLogWindow.OrderLogGrid.LogItems.Add; Connector.NewOrder += _ordersWindow.OrderGrid.Orders.Add; Connector.NewMyTrade += _myTradesWindow.TradeGrid.Trades.Add; Connector.NewPortfolio += _portfoliosWindow.PortfolioGrid.Positions.Add; Connector.NewPosition += _portfoliosWindow.PortfolioGrid.Positions.Add; // subscribe on error of order registration event Connector.OrderRegisterFailed += _ordersWindow.OrderGrid.AddRegistrationFail; // subscribe on error of order cancelling event Connector.OrderCancelFailed += OrderFailed; // set market data provider _securitiesWindow.SecurityPicker.MarketDataProvider = Connector; // set news provider _newsWindow.NewsPanel.NewsProvider = Connector; Connector.LookupTimeFramesResult += (message, timeFrames, error) => { if (error == null) { this.GuiAsync(() => _securitiesWindow.UpdateTimeFrames(timeFrames)); } }; Connector.Adapter.NativeIdStorage = nativeIdStorage; try { nativeIdStorage.Init(); } catch (Exception ex) { MessageBox.Show(this, ex.ToString()); } if (Connector.StorageAdapter == null) { return; } try { entityRegistry.Init(); } catch (Exception ex) { MessageBox.Show(this, ex.ToString()); } Connector.Adapter.StorageProcessor.DaysLoad = TimeSpan.FromDays(3); Connector.Adapter.StorageProcessor.Mode = StorageModes.Snapshot; Connector.LookupAll(); snapshotRegistry.Init(); ConfigManager.RegisterService <IExchangeInfoProvider>(new StorageExchangeInfoProvider(entityRegistry)); ConfigManager.RegisterService <IMessageAdapterProvider>(new FullInMemoryMessageAdapterProvider(Connector.Adapter.InnerAdapters)); try { if (File.Exists(_settingsFile)) { var ctx = new ContinueOnExceptionContext(); ctx.Error += ex => ex.LogError(); using (ctx.ToScope()) Connector.Load(new XmlSerializer <SettingsStorage>().Deserialize(_settingsFile)); } } catch { } }
public MainWindow() { InitializeComponent(); Instance = this; Title = Title.Put(LocalizedStrings.Str1355); const string path = "Data"; _settingsFile = Path.Combine(path, $"connection{Paths.DefaultSettingsExt}"); LogManager = new LogManager(); LogManager.Listeners.Add(new FileLogListener { LogDirectory = Path.Combine(path, "Logs") }); LogManager.Listeners.Add(new GuiLogListener(Monitor)); var entityRegistry = new CsvEntityRegistry(path); ConfigManager.RegisterService <IEntityRegistry>(entityRegistry); var exchangeInfoProvider = new StorageExchangeInfoProvider(entityRegistry, false); ConfigManager.RegisterService <IExchangeInfoProvider>(exchangeInfoProvider); var storageRegistry = new StorageRegistry(exchangeInfoProvider) { DefaultDrive = new LocalMarketDataDrive(Path.Combine(path, "Storage")) }; var snapshotRegistry = new SnapshotRegistry(Path.Combine(path, "Snapshots")); Connector = new Connector(entityRegistry.Securities, entityRegistry.PositionStorage, storageRegistry.ExchangeInfoProvider, storageRegistry, snapshotRegistry, new StorageBuffer()) { Adapter = { StorageSettings = { DaysLoad = TimeSpan.FromDays(3), Mode = StorageModes.Snapshot, } }, CheckSteps = true, }; LogManager.Sources.Add(Connector); _securitiesWindow = new SecuritiesWindow(); _ordersWindow = new OrdersWindow(); _portfoliosWindow = new PortfoliosWindow(); _myTradesWindow = new MyTradesWindow(); InitConnector(entityRegistry, snapshotRegistry); _strategiesWindow = new StrategiesWindow(); _strategiesWindow.LoadStrategies(path); _ordersWindow.MakeHideable(); _myTradesWindow.MakeHideable(); _strategiesWindow.MakeHideable(); _securitiesWindow.MakeHideable(); _portfoliosWindow.MakeHideable(); }
private void InitConnector(IEntityRegistry entityRegistry, SnapshotRegistry snapshotRegistry) { // subscribe on connection successfully event Connector.Connected += () => { this.GuiAsync(() => ChangeConnectStatus(true)); }; // subscribe on connection error event Connector.ConnectionError += error => this.GuiAsync(() => { ChangeConnectStatus(false); MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2959); }); Connector.Disconnected += () => this.GuiAsync(() => ChangeConnectStatus(false)); // subscribe on error event Connector.Error += error => { this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2955)); }; // subscribe on error of market data subscription event Connector.MarketDataSubscriptionFailed += (security, msg, error) => { this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2956Params.Put(msg.DataType, security))); }; Connector.SecurityReceived += (sub, s) => _securitiesWindow.SecurityPicker.Securities.Add(s); Connector.NewOrder += order => { _ordersWindow.OrderGrid.Orders.Add(order); _securitiesWindow.ProcessOrder(order); }; // display order as own volume in quotes window Connector.OrderChanged += _securitiesWindow.ProcessOrder; // put the registration error into order's table Connector.OrderRegisterFailed += _ordersWindow.OrderGrid.AddRegistrationFail; Connector.NewMyTrade += _myTradesWindow.TradeGrid.Trades.Add; Connector.PositionReceived += (sub, p) => _portfoliosWindow.PortfolioGrid.Positions.TryAdd(p); // set market data provider _securitiesWindow.SecurityPicker.MarketDataProvider = Connector; if (Connector.StorageAdapter == null) { return; } entityRegistry.Init(); snapshotRegistry.Init(); Connector.LookupAll(); ConfigManager.RegisterService <IMessageAdapterProvider>(new FullInMemoryMessageAdapterProvider(Connector.Adapter.InnerAdapters)); try { if (File.Exists(_settingsFile) || File.Exists(_settingsFile.MakeLegacy())) { var ctx = new ContinueOnExceptionContext(); ctx.Error += ex => ex.LogError(); using (ctx.ToScope()) Connector.LoadIfNotNull(_settingsFile.DeserializeWithMigration <SettingsStorage>()); } } catch { } }
private void InitConnector(CsvEntityRegistry entityRegistry, SnapshotRegistry snapshotRegistry) { // subscribe on connection successfully event Connector.Connected += () => { this.GuiAsync(() => ChangeConnectStatus(true)); }; // subscribe on connection error event Connector.ConnectionError += error => this.GuiAsync(() => { ChangeConnectStatus(false); MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2959); }); Connector.Disconnected += () => this.GuiAsync(() => ChangeConnectStatus(false)); // subscribe on error event Connector.Error += error => { this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2955)); }; // subscribe on error of market data subscription event Connector.MarketDataSubscriptionFailed += (security, msg, error) => { this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2956Params.Put(msg.DataType, security))); }; Connector.NewSecurity += security => _securitiesWindow.SecurityPicker.Securities.Add(security); Connector.NewOrder += order => { _ordersWindow.OrderGrid.Orders.Add(order); _securitiesWindow.ProcessOrder(order); }; // display order as own volume in quotes window Connector.OrderChanged += _securitiesWindow.ProcessOrder; // put the registration error into order's table Connector.OrderRegisterFailed += _ordersWindow.OrderGrid.AddRegistrationFail; Connector.NewMyTrade += _myTradesWindow.TradeGrid.Trades.Add; Connector.NewPortfolio += _portfoliosWindow.PortfolioGrid.Portfolios.Add; Connector.NewPosition += _portfoliosWindow.PortfolioGrid.Positions.Add; // set market data provider _securitiesWindow.SecurityPicker.MarketDataProvider = Connector; try { if (File.Exists(_settingsFile)) { Connector.Load(new XmlSerializer <SettingsStorage>().Deserialize(_settingsFile)); } } catch { } if (Connector.StorageAdapter == null) { return; } entityRegistry.Init(); Connector.StorageAdapter.DaysLoad = TimeSpan.FromDays(3); //Connector.LookupAll(); snapshotRegistry.Init(); ConfigManager.RegisterService <IExchangeInfoProvider>(new StorageExchangeInfoProvider(entityRegistry)); }
private void InitConnector(CsvEntityRegistry entityRegistry, SnapshotRegistry snapshotRegistry) { // subscribe on connection successfully event Connector.Connected += () => { this.GuiAsync(() => ChangeConnectStatus(true)); }; // subscribe on connection error event Connector.ConnectionError += error => this.GuiAsync(() => { ChangeConnectStatus(false); MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2959); }); Connector.Disconnected += () => this.GuiAsync(() => ChangeConnectStatus(false)); // subscribe on error event Connector.Error += error => this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2955)); // subscribe on error of market data subscription event Connector.MarketDataSubscriptionFailed += (security, msg, error) => this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2956Params.Put(msg.DataType, security))); Connector.NewSecurity += _securitiesWindow.SecurityPicker.Securities.Add; Connector.NewTrade += _tradesWindow.TradeGrid.Trades.Add; Connector.NewOrder += _ordersWindow.OrderGrid.Orders.Add; Connector.NewStopOrder += _stopOrdersWindow.OrderGrid.Orders.Add; Connector.NewMyTrade += _myTradesWindow.TradeGrid.Trades.Add; Connector.NewPortfolio += _portfoliosWindow.PortfolioGrid.Portfolios.Add; Connector.NewPosition += _portfoliosWindow.PortfolioGrid.Positions.Add; // subscribe on error of order registration event Connector.OrderRegisterFailed += _ordersWindow.OrderGrid.AddRegistrationFail; // subscribe on error of order cancelling event Connector.OrderCancelFailed += OrderFailed; // subscribe on error of stop-order registration event Connector.OrderRegisterFailed += _stopOrdersWindow.OrderGrid.AddRegistrationFail; // subscribe on error of stop-order cancelling event Connector.StopOrderCancelFailed += OrderFailed; // set market data provider _securitiesWindow.SecurityPicker.MarketDataProvider = Connector; try { if (File.Exists(_settingsFile)) { var ctx = new ContinueOnExceptionContext(); ctx.Error += ex => ex.LogError(); using (new Scope <ContinueOnExceptionContext> (ctx)) Connector.Load(new XmlSerializer <SettingsStorage>().Deserialize(_settingsFile)); } } catch { } if (Connector.StorageAdapter == null) { return; } try { entityRegistry.Init(); } catch (Exception ex) { MessageBox.Show(this, ex.ToString()); } Connector.StorageAdapter.DaysLoad = TimeSpan.FromDays(3); Connector.LookupAll(); snapshotRegistry.Init(); ConfigManager.RegisterService <IExchangeInfoProvider>(new StorageExchangeInfoProvider(entityRegistry)); }
/// <summary> /// Initializes a new instance of the <see cref="Connector"/>. /// </summary> /// <param name="entityRegistry">The storage of trade objects.</param> /// <param name="storageRegistry">The storage of market data.</param> /// <param name="snapshotRegistry">Snapshot storage registry.</param> /// <param name="initManagers">Initialize managers.</param> public Connector(IEntityRegistry entityRegistry, IStorageRegistry storageRegistry, SnapshotRegistry snapshotRegistry, bool initManagers = true) : this(entityRegistry.Securities, entityRegistry.PositionStorage, storageRegistry, snapshotRegistry, initManagers) { #pragma warning disable 612 EntityRegistry = entityRegistry; #pragma warning restore 612 }
static void Main() { string tmpFile = Path.GetFullPath("tmp"); SnapshotFilesystem oldSnapshot = null; if (File.Exists(tmpFile)) { oldSnapshot = DeSerializeSingleObject <SnapshotFilesystem>(tmpFile); } SnapshotFilesystem snapshot = DetectorUtilitiesFS.MakeFsSnapshot(new DirectoryInfo(@"C:\Windows\System32")); SerializeSingleObject(tmpFile, snapshot); Console.WriteLine(snapshot.Items.Count + " items"); if (oldSnapshot != null) { List <Difference <SnapshotFilesystemItem> > differences = DetectorUtilities.GetDifferences(oldSnapshot.Items, snapshot.Items); Console.WriteLine("Differences ({0}): ", differences.Count); foreach (Difference <SnapshotFilesystemItem> difference in differences) { Console.WriteLine("Difference ({0}):", difference.DifferenceType); Console.WriteLine(" Path: {0}", (difference.Original ?? difference.New).RelativePath); WriteDiffToConsole(difference.Original, difference.New, "LastAccess", filesystem => filesystem.LastAccess); WriteDiffToConsole(difference.Original, difference.New, "LastModified", filesystem => filesystem.LastModified); WriteDiffToConsole(difference.Original, difference.New, "Attributes", filesystem => filesystem.Attributes); WriteDiffToConsole(difference.Original, difference.New, "Was Readable", filesystem => filesystem.WasReadable); if (difference.Original is SnapshotFileInfo || difference.New is SnapshotFileInfo) { WriteDiffToConsole(difference.Original as SnapshotFileInfo, difference.New as SnapshotFileInfo, "Hash", filesystem => filesystem.Hash); } Console.WriteLine(); } } SnapshotRegistry oldRegSnapshot = null; if (File.Exists(tmpFile)) { oldRegSnapshot = DeSerializeSingleObject <SnapshotRegistry>(tmpFile); } SnapshotRegistry regSnapshot = DetectorUtilitiesRegistry.MakeRegistrySnapshot(); SerializeSingleObject(tmpFile, regSnapshot); Console.WriteLine(regSnapshot.PartialSnapshots.Sum(s => s.Items.Count) + " items"); if (oldRegSnapshot != null) { // Iterate each hive foreach (SnapshotRegistryPartial registrySnapshot in oldRegSnapshot.PartialSnapshots) { SnapshotRegistryPartial corresponding = regSnapshot.PartialSnapshots.Single(s => s.BasePath == registrySnapshot.BasePath); Console.WriteLine("RegistryHive ({0} vs. {1} items): {2}", registrySnapshot.Items.Count, corresponding.Items.Count, registrySnapshot.BasePath); List <Difference <SnapshotRegistryItem> > differences = DetectorUtilities.GetDifferences(registrySnapshot.Items, corresponding.Items); Console.WriteLine("Differences ({0}): ", differences.Count); foreach (Difference <SnapshotRegistryItem> difference in differences) { Console.WriteLine("Difference ({0}):", difference.DifferenceType); Console.WriteLine(" Path: {0}", (difference.Original ?? difference.New).FullPath); WriteDiffToConsole(difference.Original, difference.New, "RegistryView", filesystem => filesystem.RegistryView); WriteDiffToConsole(difference.Original, difference.New, "Was Readable", filesystem => filesystem.WasReadable); if (difference.Original is SnapshotRegistryValue || difference.New is SnapshotRegistryValue) { WriteDiffToConsole(difference.Original as SnapshotRegistryValue, difference.New as SnapshotRegistryValue, "RegistryKeyType", filesystem => filesystem.RegistryKeyType); WriteDiffToConsole(difference.Original as SnapshotRegistryValue, difference.New as SnapshotRegistryValue, "Value", filesystem => filesystem.Value); } Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(); } } Console.WriteLine("Done"); Console.ReadLine(); }