Esempio n. 1
0
            void SetSnapshot(DataRenderer dataRenderer, PackedMemorySnapshot snapshot)
            {
                if (snapshot == null)
                {
                    m_RawSnapshot   = null;
                    m_RawSchema     = null;
                    SchemaToDisplay = null;
                    UpdateTableSelectionNames();
                    return;
                }

                m_RawSnapshot = snapshot;

                ProgressBarDisplay.ShowBar(string.Format("Opening snapshot: {0}", System.IO.Path.GetFileNameWithoutExtension(snapshot.filePath)));

                var cachedSnapshot = new CachedSnapshot(snapshot);

                using (Profiling.GetMarker(Profiling.MarkerId.CrawlManagedData).Auto())
                {
                    var crawling = Crawler.Crawl(cachedSnapshot);
                    crawling.MoveNext(); //start execution

                    var   status          = crawling.Current as EnumerationStatus;
                    float progressPerStep = 1.0f / status.StepCount;
                    while (crawling.MoveNext())
                    {
                        ProgressBarDisplay.UpdateProgress(status.CurrentStep * progressPerStep, status.StepStatus);
                    }
                }
                ProgressBarDisplay.ClearBar();

                m_RawSchema = new RawSchema();
                m_RawSchema.SetupSchema(cachedSnapshot, dataRenderer);

                SchemaToDisplay = m_RawSchema;
                if (k_DefaultViewFilePath.Length > 0)
                {
                    using (ScopeDebugContext.Func(() => { return("File '" + k_DefaultViewFilePath + "'"); }))
                    {
                        Database.View.ViewSchema.Builder builder = null;
                        using (Profiling.GetMarker(Profiling.MarkerId.LoadViewDefinitionFile).Auto())
                        {
                            builder = Database.View.ViewSchema.Builder.LoadFromXMLFile(k_DefaultViewFilePath);
                        }
                        if (builder != null)
                        {
                            using (Profiling.GetMarker(Profiling.MarkerId.BuildViewDefinitionFile).Auto())
                            {
                                ViewSchema = builder.Build(m_RawSchema);
                            }
                            if (ViewSchema != null)
                            {
                                SchemaToDisplay = ViewSchema;
                            }
                        }
                    }
                }

                UpdateTableSelectionNames();
            }
Esempio n. 2
0
 public IEnumerable <SkycoreHRM.Shared.Department> GetData()
 {
     foreach (var strategy in Strategies)
     {
         try
         {
             IDbDataAdapter adapter       = null;
             var            accessContext = new DataAccessContext(strategy);
             adapter = accessContext.EstablishDataAccess(adapter);
             var myRenderer = new DataRenderer(adapter);
             var writer     = new StringWriter();
             myRenderer.Render(writer);
             var result      = writer.ToString().Replace(" ", string.Empty);
             var rows        = result.Split("\r\n").Where(e => !string.IsNullOrEmpty(e));
             var departments = rows.Select(e => new SkycoreHRM.Shared.Department {
                 Name = e
             });
             return(departments);
         }
         catch (Exception)
         {
             continue;
         }
     }
     return(null);
 }
        public void ShouldRenderTwoRowsGivenOleDbDataAdapter()
        {
            const int expectedNumberOfLines = 4;

            var adapter = new OleDbDataAdapter
            {
                SelectCommand = new OleDbCommand("SELECT * FROM Pattern")
                {
                    Connection =
                        new OleDbConnection(
                            @"Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=AdapterSampleDb.sdf")
                }
            };

            var myRenderer = new DataRenderer(adapter);

            var writer = new StringWriter();

            myRenderer.Render(writer);

            var result = writer.ToString();

            Console.WriteLine(result);

            var numberOfLines = result.Count(r => r == '\n');

            Assert.AreEqual(expectedNumberOfLines, numberOfLines);
        }
        public string ListPatterns(IEnumerable <Pattern> patterns)
        {
            _dataRenderer = new DataRenderer(new PatternCollectionDbAdapter(patterns));
            var writer = new StringWriter();

            _dataRenderer.Render(writer);
            return(writer.ToString());
        }
Esempio n. 5
0
    static int Main()
    {
        var dataRenderer = new DataRenderer();
        SaveAndRenderData(dataRenderer);

        var htmlRendererAdapter = new HtmlRendererAdapter(dataRenderer);
        SaveAndRenderData(htmlRendererAdapter);
        return 0;
    }
        public DatabaseSpreadsheet(DataRenderer dataRenderer, Database.Table table, IViewEventListener listener, State state)
            : base(listener)
        {
            m_TableSource  = table;
            m_TableDisplay = table;
            m_DataRenderer = dataRenderer;

            InitSplitter();
            CurrentState = state;
        }
        public string ListPatterns(IEnumerable<Pattern> patterns)
        {
            var adapter = new PatternCollectionDbAdapter(patterns);
            _dataRenderer = new DataRenderer(adapter);

            var writer = new StringWriter();
            _dataRenderer.Render(writer);

            return writer.ToString();
        }
Esempio n. 8
0
 protected DiffMode(DiffMode copy)
 {
     m_DataRenderer = copy.m_DataRenderer;
     m_DataRenderer.PrettyNamesOptionChanged += UpdateTableSelectionNames;
     modeFirst      = copy.modeFirst;
     modeSecond     = copy.modeSecond;
     m_SchemaFirst  = copy.m_SchemaFirst;
     m_SchemaSecond = copy.m_SchemaSecond;
     m_SchemaDiff   = copy.m_SchemaDiff;
 }
        public DatabaseSpreadsheet(DataRenderer dataRenderer, Database.Table table, IViewEventListener listener)
            : base(listener)
        {
            m_TableSource  = table;
            m_TableDisplay = table;
            m_DataRenderer = dataRenderer;

            InitSplitter();
            InitDefaultTableFilter();
        }
Esempio n. 10
0
    static int Main()
    {
        var dataRenderer = new DataRenderer();

        SaveAndRenderData(dataRenderer);

        var htmlRendererAdapter = new HtmlRendererAdapter(dataRenderer);

        SaveAndRenderData(htmlRendererAdapter);
        return(0);
    }
        public string ToString(List <Superhero> heroes)
        {
            _adapter = new SuperHeroDbAdapter(heroes);
            var renderer = new DataRenderer(_adapter);

            var textWriter = new StringWriter();

            renderer.Render(textWriter);

            return(textWriter.ToString());
        }
Esempio n. 12
0
        public void Souldbe4Lines()
        {
            DataRenderer dataRenderer = new DataRenderer(new StubDBDataAdabter());
            var          textWriter   = new StringWriter();

            dataRenderer.Render(textWriter);
            var result = textWriter.ToString();

            Console.Write(result);
            Assert.AreEqual(3, result.Count(x => x == '\n'));
        }
Esempio n. 13
0
            public DiffMode(DataRenderer dataRenderer, PackedMemorySnapshot snapshotFirst, PackedMemorySnapshot snapshotSecond)
            {
                m_DataRenderer = dataRenderer;
                m_DataRenderer.PrettyNamesOptionChanged += UpdateTableSelectionNames;
                modeFirst      = new SnapshotMode(dataRenderer, snapshotFirst);
                modeSecond     = new SnapshotMode(dataRenderer, snapshotSecond);
                m_SchemaFirst  = modeFirst.GetSchema();
                m_SchemaSecond = modeSecond.GetSchema();

                m_SchemaDiff = new Database.Operation.DiffSchema(m_SchemaFirst, m_SchemaSecond);
                UpdateTableSelectionNames();
            }
Esempio n. 14
0
        public void TestMethod2()
        {
            IDbDataAdapter oleDbAdapter = new SqlDataAdapter(@"SELECT Id, Nome, Descrizione FROM TestTable", new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\FabrizioDiNunzio\source\repos\OData\AdapterDemo\TestDatabase.mdf;Integrated Security=True"));
            DataRenderer   renderer     = new DataRenderer(oleDbAdapter);
            StringWriter   writer       = new StringWriter();

            renderer.Render(writer);
            string result = writer.ToString();

            Console.WriteLine(result);
            Assert.AreEqual(6, result.Count(c => c == '\n'));
        }
Esempio n. 15
0
            public DiffMode(DataRenderer dataRenderer, BaseMode snapshotFirst, BaseMode snapshotSecond)
            {
                m_DataRenderer = dataRenderer;
                m_DataRenderer.PrettyNamesOptionChanged += UpdateTableSelectionNames;
                modeFirst      = snapshotFirst;
                modeSecond     = snapshotSecond;
                m_SchemaFirst  = modeFirst.GetSchema();
                m_SchemaSecond = modeSecond.GetSchema();

                m_SchemaDiff = new Database.Operation.DiffSchema(m_SchemaFirst, m_SchemaSecond);
                UpdateTableSelectionNames();
            }
Esempio n. 16
0
        public void TestMethod1()
        {
            IDbDataAdapter adapter  = new StubDbAdapter();
            DataRenderer   renderer = new DataRenderer(adapter);
            StringWriter   writer   = new StringWriter();

            renderer.Render(writer);
            string result = writer.ToString();

            Console.WriteLine(result);
            Assert.AreEqual(5, result.Count(c => c == '\n'));
        }
Esempio n. 17
0
        public void RenderOneRowGivenStubDataAdapter()
        {
            var myRenderer = new DataRenderer(new StubDbAdapter());

            var writer = new StringWriter();
            myRenderer.Render(writer);

            string result = writer.ToString();
            Console.Write(result);

            int lineCount = result.Count(c => c == '\n');
            Assert.AreEqual(3, lineCount);
        }
Esempio n. 18
0
        public void UseSqlDataAdapter()
        {
            var          conString  = ConfigurationManager.ConnectionStrings["SqlCon"].ConnectionString;
            var          sqlString  = "SELECT * FROM Patterns";
            var          adapter    = new SqlDataAdapter(sqlString, conString);
            var          textWriter = new StringWriter();
            DataRenderer renderer   = new DataRenderer(adapter);

            renderer.Render(textWriter);
            var result = textWriter.ToString();

            Console.Write(result);
            Assert.AreEqual(4, result.Count(x => x == '\n'));
        }
Esempio n. 19
0
        public void RenderOneRowGivenStubDataAdapter()
        {
            var myRenderer = new DataRenderer(new StudDbAdapter());
            var writer     = new StringWriter();

            myRenderer.Render(writer);

            var result = writer.ToString();

            Console.Write(result);

            var lineCount = result.Count(c => c == '\n');

            Assert.AreEqual(3, lineCount);
        }
Esempio n. 20
0
        public void ShouldRenderFromStubDataAdapter()
        {
            var dataAdapter = new StubDataDbAdapter();
            var renderer    = new DataRenderer(dataAdapter);

            var writer = new StringWriter();

            renderer.Render(writer);

            var result = writer.ToString();

            Console.Write(result);

            Assert.IsNotNull(result);
        }
        public void render_one_row_given_a_StubDbDataAdapter()
        {
            var dataRenderer = new DataRenderer(new StubDataAdapter());

            var writer = new StringWriter();

            dataRenderer.Render(writer);

            string result = writer.ToString();

            output.WriteLine(result);

            int lineCount = result.Count(c => c == '\n');

            lineCount.ShouldBe(3);
        }
        public void ShouldRenderOneRowGivenStubDataAdapter()
        {
            const int expectedNumberOfLines = 3;
            var       myRenderer            = new DataRenderer(new StubDbAdapter());

            var writer = new StringWriter();

            myRenderer.Render(writer);

            var result = writer.ToString();

            Console.WriteLine(result);

            var numberOfLines = result.Count(r => r == '\n');

            Assert.AreEqual(expectedNumberOfLines, numberOfLines);
        }
Esempio n. 23
0
        public void Render_GivenDataAdapter_RenderRows()
        {
            var stubAdapter = new Mock <IDbDataAdapter>();

            stubAdapter.Setup(s => s.Fill(It.IsAny <DataSet>()))
            .Callback <DataSet>(x =>
            {
                x.Tables.Add(RendererTestData.GetData());
                x.AcceptChanges();
            });
            var dataRenderer = new DataRenderer(stubAdapter.Object);
            var writer       = new StringWriter();

            dataRenderer.Render(writer);
            var result = writer.ToString();

            Assert.Equal(3, result.Count(c => c == '\n'));
        }
Esempio n. 24
0
        public void RenderTwoRowsGivenOleDbDataAdapter()
        {
            var adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand("SELECT * FROM Pattern");
            adapter.SelectCommand.Connection =
                new SqlConnection(
                    @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=f:\Naruto Images\Sample.mdf;Integrated Security=True;Connect Timeout=30");
            var myRenderer = new DataRenderer(adapter);

            var writer = new StringWriter();
            myRenderer.Render(writer);

            string result = writer.ToString();
            Console.Write(result);

            int lineCount = result.Count(c => c == '\n');
            Assert.AreEqual(4, lineCount);
        }
Esempio n. 25
0
        public void RenderTwoRowsGivenOleDbDataAdapter()
        {
            var adapter = new OleDbDataAdapter();

            adapter.SelectCommand            = new OleDbCommand("SELECT * FROM Pattern");
            adapter.SelectCommand.Connection = new OleDbConnection();
            var renderer = new DataRenderer(adapter);
            var writer   = new StringWriter();

            renderer.Render(writer);

            var result = writer.ToString();

            Console.Write(result);

            var lineCount = result.Count(c => c == '\n');

            Assert.AreEqual(4, lineCount);
        }
        static void Main(string[] args)
        {
            List <Person> persons = new List <Person>()
            {
                new Person()
                {
                    Name = "Foo", Age = 25
                },
                new Person()
                {
                    Name = "Bar", Age = 25
                }
            };

            var renderer = new DataRenderer(new PersonCollectionDbAdapter(persons));

            renderer.Render(Console.Out);
            Console.ReadLine();
        }
Esempio n. 27
0
        public void RenderTwoRowsGivenOleDbDataAdapter()
        {
            var adapter = new OleDbDataAdapter();

            adapter.SelectCommand            = new OleDbCommand("SELECT * FROM Pattern");
            adapter.SelectCommand.Connection = new OleDbConnection(
                @"Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=D:\Work\Amitac\Design Patterns Library\Design_Patterns_Library\01_Adapter_Pattern\Sample.sdf");
            var myRenderer = new DataRenderer(adapter);

            var writer = new StringWriter();

            myRenderer.Render(writer);

            string result = writer.ToString();

            Console.Write(result);

            int lineCount = result.Count(c => c == '\n');

            Assert.AreEqual(4, lineCount);
        }
Esempio n. 28
0
        public MainWindow()
        {
            ResizeMode = ResizeMode.CanMinimize;
            InitializeComponent();

            _game = new Game();

            _dispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal)
            {
                Interval = TimeSpan.FromMilliseconds(1000)
            };

            _canvasRenderer = new CanvasRenderer(canvas, _game);
            _dataRenderer   = new DataRenderer(_game.logger, this);

            _dispatcherTimer.Tick += (source, args) => canvas.Children.Clear();
            _dispatcherTimer.Tick += DrawGame;

            _game.Initialize(_dispatcherTimer);
            _dispatcherTimer.Start();
        }
        public void render_two_rows_given_an_OleDbDataAdapter()
        {
            var sqlDataAdapter = new SqlDataAdapter();

            sqlDataAdapter.SelectCommand            = new SqlCommand("SELECT * FROM tbl_Pattern");
            sqlDataAdapter.SelectCommand.Connection = new SqlConnection(@"Data Source=(localdb)\LocalDBApp;Initial Catalog=Sample;Integrated Security=True");

            var dataRenderer = new DataRenderer(sqlDataAdapter);

            var writer = new StringWriter();

            dataRenderer.Render(writer);

            string result = writer.ToString();

            output.WriteLine(result);

            int lineCount = result.Count(c => c == '\n');

            lineCount.ShouldBe(4);
        }
Esempio n. 30
0
 protected void UpdateTableSelectionNamesFromSchema(DataRenderer dataRenderer, Database.Schema schema)
 {
     if (schema == null)
     {
         m_TableNames    = new string[1];
         m_TableNames[0] = "none";
         m_Tables        = new Database.Table[1];
         m_Tables[0]     = null;
         return;
     }
     m_TableNames    = new string[schema.GetTableCount() + 1];
     m_Tables        = new Database.Table[schema.GetTableCount() + 1];
     m_TableNames[0] = "none";
     m_Tables[0]     = null;
     for (long i = 0; i != schema.GetTableCount(); ++i)
     {
         var  tab      = schema.GetTableByIndex(i);
         long rowCount = tab.GetRowCount();
         m_TableNames[i + 1] = (dataRenderer.ShowPrettyNames ? tab.GetDisplayName() : tab.GetName()) + " (" + (rowCount >= 0 ? rowCount.ToString() : "?") + ")";
         m_Tables[i + 1]     = tab;
     }
 }
Esempio n. 31
0
        public void RenderTwoRowsGivenOleDbDataAdapter()
        {
            var adapter = new SqlDataAdapter();

            adapter.SelectCommand            = new SqlCommand("SELECT * FROM Pattern");
            adapter.SelectCommand.Connection =
                new SqlConnection(
                    @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=f:\Naruto Images\Sample.mdf;Integrated Security=True;Connect Timeout=30");
            var myRenderer = new DataRenderer(adapter);

            var writer = new StringWriter();

            myRenderer.Render(writer);

            string result = writer.ToString();

            Console.Write(result);

            int lineCount = result.Count(c => c == '\n');

            Assert.AreEqual(4, lineCount);
        }
        public void RenderTwoRowsGivenOleDbDataAdapter()
        {
            var adapter = new OleDbDataAdapter();

            adapter.SelectCommand            = new OleDbCommand("SELECT * FROM Pattern");
            adapter.SelectCommand.Connection =
                new OleDbConnection(
                    @"Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=E:\Study Materials\DesignPattern\DesignPatternSamples\AdapterPattern\CSharpLib.AdapterPattern\Pluralsight_AdapterSample\DB\Sample.sdf");
            var myRenderer = new DataRenderer(adapter);

            var writer = new StringWriter();

            myRenderer.Render(writer);

            string result = writer.ToString();

            Console.Write(result);

            int lineCount = result.Count(c => c == '\n');

            Assert.AreEqual(4, lineCount);
        }
Esempio n. 33
0
 public SnapshotMode(DataRenderer dataRenderer, PackedMemorySnapshot snapshot)
 {
     dataRenderer.PrettyNamesOptionChanged += UpdateTableSelectionNames;
     SetSnapshot(dataRenderer, snapshot);
 }
Esempio n. 34
0
        public override void Link(IEntity entity)
        {
            base.Link(entity);

            _dataRenderer = entity.Get <DataRenderer>();
        }