public void Generate(Package sourcePackage, Package targetPackage, FileInfo outputFile)
        {
            var serializer = new XmlSerializer(typeof(DataSchemaModel));
            var uri = PackUriHelper.CreatePartUri(new Uri("/replication.xml", UriKind.Relative));

            var sourceModel = (DataSchemaModel)serializer.Deserialize(sourcePackage.GetPart(uri).GetStream());
            var targetModel = (DataSchemaModel)serializer.Deserialize(targetPackage.GetPart(uri).GetStream());

            var outputFileSql = new List<string>();

            foreach (var publicationToCreate in sourceModel.Model.Elements.Except(targetModel.Model.Elements, x => x.Name))
            {
                var createPublicationStep = new CreatePublicationStep(publicationToCreate);
                outputFileSql.AddRange(createPublicationStep.GenerateTSQL());
            }

            foreach (var publicationToAlter in sourceModel.Model.Elements.Intersect(targetModel.Model.Elements, x => x.Name))
            {
                var sqlPublicationComparer = new SqlPublicationComparer();
                var matchingPublicationInTarget = targetModel.Model.Elements.Single(x => x.Name == publicationToAlter.Name);

                var alterPublicationStep = new AlterPublicationStep(sqlPublicationComparer.Compare(publicationToAlter, matchingPublicationInTarget));
                outputFileSql.AddRange(alterPublicationStep.GenerateTSQL());
            }

            foreach (var publicationToDrop in targetModel.Model.Elements.Except(sourceModel.Model.Elements, x => x.Name))
            {
                var dropPublicationStep = new DropPublicationStep(publicationToDrop);
                outputFileSql.AddRange(dropPublicationStep.GenerateTSQL());
            }
        }
        public void Execute()
        {
            var outputSerializer = new XmlSerializer(typeof(DataSchemaModel));
            var model = (DataSchemaModel)outputSerializer.Deserialize(new FileStream(@"Samples\Extracted Model.xml", FileMode.Open));

            var step = new CreatePublicationStep(model.Model.Elements[0]);
            var sql = step.GenerateTSQL();

            foreach (var line in sql)
                Console.WriteLine(line);
        }
        public void RecreateExistingPublication()
        {
            using (var connection = new SqlConnection(@""))
            {
                connection.Open();

                var extractor = new SqlPublicationExtractor();
                var model = extractor.Extract(connection);

                var step = new CreatePublicationStep(model.Model.Elements[0]);
                var sql = step.GenerateTSQL();

                foreach (var line in sql)
                    Console.WriteLine(line);
            }
        }