Example #1
0
        /// <summary>
        /// Importa la información de un fichero de mapa de alturas
        /// </summary>
        /// <param name="filename">Nombre del fichero</param>
        /// <param name="context">Contexto</param>
        /// <returns>Devuelve el descriptor del terreno cargado a partir del fichero</returns>
        public override SceneryFile Import(string filename, ContentImporterContext context)
        {
            // Obtiene el directorio del fichero de definición
            string directory = Path.GetDirectoryName(filename);

            // Importador XML
            XmlImporter importer = new XmlImporter();

            // Lectura del fichero
            SceneryFile info = importer.Import(filename, context) as SceneryFile;

            // Completar los nombres de los ficheros con el directorio del fichero de definición
            info.HeightMapFile             = Path.Combine(directory, info.HeightMapFile);
            info.EffectFile                = Path.Combine(directory, info.EffectFile);
            info.Texture1File              = Path.Combine(directory, info.Texture1File);
            info.Texture2File              = Path.Combine(directory, info.Texture2File);
            info.Texture3File              = Path.Combine(directory, info.Texture3File);
            info.Texture4File              = Path.Combine(directory, info.Texture4File);
            info.DetailTexture1File        = Path.Combine(directory, info.DetailTexture1File);
            info.DetailTexture2File        = Path.Combine(directory, info.DetailTexture2File);
            info.DetailTexture3File        = Path.Combine(directory, info.DetailTexture3File);
            info.DetailTexture4File        = Path.Combine(directory, info.DetailTexture4File);
            info.BillboardEffectFile       = Path.Combine(directory, info.BillboardEffectFile);
            info.BillboardTreeTextureFile  = Path.Combine(directory, info.BillboardTreeTextureFile);
            info.BillboardGrassTextureFile = Path.Combine(directory, info.BillboardGrassTextureFile);

            // Devuelve la definición
            return(info);
        }
Example #2
0
        private static void BuildSkill()
        {
            Console.Write("Xml: "); // Xml from Editor

            var input = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(input))
            {
                return;
            }

            var skill = XmlImporter.Import(input, Database);

            var obj = Database.CopyObject(9864);

            var component = new LwoComponent(ComponentId.SkillComponent);

            obj.Add(component);

            var entry = Database["ObjectSkills"].Create(obj.Row.Key);

            var skillEntry = new ObjectSkillsTable(entry);

            skillEntry.castOnType = 0;

            skillEntry.skillID = (int)skill;
        }
Example #3
0
 private ImportResult PerformImport()
 {
     using (var stream = OpenStream())
     {
         return(_importer.Import(stream));
     }
 }
Example #4
0
        public void IntegrateFile(string filename)
        {
            LoadDbFiles();
            BuildReferenceCache();
            Console.WriteLine("Integrating schema file {0}", filename);
            XmlImporter importer = null;

            using (var stream = File.OpenRead(filename)) {
                importer = new XmlImporter(stream);
                importer.Import();
            }

            if (IntegrateExisting)
            {
                foreach (TypeInfo type in importer.Imported)
                {
                    TypeInfo replaced = null;
                    foreach (TypeInfo existing in DBTypeMap.Instance.GetVersionedInfos(type.Name, type.Version))
                    {
                        if (existing.SameTypes(type))
                        {
                            replaced = existing;
                            break;
                        }
                    }
                    if (replaced != null)
                    {
                        DBTypeMap.Instance.AllInfos.Remove(replaced);
                    }
                    DBTypeMap.Instance.AllInfos.Add(type);
                }
            }
        }
Example #5
0
        public static void Main(string[] args)
        {
            var context = new FootballEntities();

            // Problem 1.Entity Framework Mappings (Database First)
            //var teamsQuery = context.Teams.Select(t => t.TeamName);
            //foreach (var team in teamsQuery)
            //{
            //    Console.WriteLine(team);
            //}

            // Problem 2.Export the Leagues and Teams as JSON
            //var leaguesQuery =
            //    context.Leagues.OrderBy(l => l.LeagueName)
            //        .Select(
            //            l =>
            //            new LeagueDto
            //                {
            //                    LeagueName = l.LeagueName,
            //                    Teams = l.Teams.OrderBy(t => t.TeamName).Select(t => t.TeamName)
            //                })
            //        .ToList();

            //const string FilePathNameJson = "../../leagues-and-teams.json";

            //var jsonExporter = new JsonExporter();
            //jsonExporter.Export(FilePathNameJson, leaguesQuery);

            // Problem 3.Export International Matches as XML
            //var internationalMatchesQuery = context.InternationalMatches
            //    .OrderBy(im => im.MatchDate)
            //    .ThenBy(im => im.Countries)
            //    .ThenBy(im => im.Countries1)
            //    .Select(im => new InternationalMatchesDto()
            //    {
            //        HomeCountry = im.Countries1.CountryName,
            //        AwayCountry = im.Countries.CountryName,
            //        MatchDate = im.MatchDate.ToString(),
            //        Score = im.HomeGoals.ToString() + "-" + im.AwayGoals.ToString(),
            //        League = im.Leagues.LeagueName,
            //        HomeCountryCode = im.HomeCountryCode,
            //        AwayCountryCode = im.AwayCountryCode
            //    }).ToList();

            //const string FilePathNameXml = "../../international-matches.xml ";

            //var xmlExporter = new XmlExporter();
            //xmlExporter.Export(FilePathNameXml, internationalMatchesQuery);

            // Problem 4.Import Leagues and Teams from XML
            // Import rivers from Xml file
            var xmlImporter = new XmlImporter();
            var xmlDoc      = XDocument.Load(@"..\..\leagues-and-teams.xml ");

            xmlImporter.Import(xmlDoc, context);
        }
Example #6
0
 /// <summary>
 /// Write XML string to a temporary file and import it.  This
 /// process may throw; if so the exception bubbles out for
 /// assertion that that was expected downstream
 /// </summary>
 /// <param name="xml">Xml.</param>
 public static void RunImporter(System.Data.IDbConnection dbConn, String xml)
 {
     using (var tmp = new TempFile(".xml"))
     {
         using (var writer = new System.IO.StreamWriter(tmp.FullName))
         {
             writer.WriteLine(xml);
         }
         var importer = new XmlImporter();
         importer.Import(dbConn, tmp.Value);
     }
 }
Example #7
0
        public void Go()
        {
            Console.WriteLine("--> DataCapture.Workflow.Yeti.Importer()");
            var         dbConn   = ConnectionFactory.Create();
            XmlImporter importer = new XmlImporter();

            foreach (var f in files_)
            {
                importer.Import(dbConn, f);
            }
            Console.WriteLine("<-- DataCapture.Workflow.Yeti.Importer()");
        }
Example #8
0
 public void AddSchemaFile(string file)
 {
     using (var stream = File.OpenRead(file)) {
         XmlImporter importer = new XmlImporter(stream);
         importer.Import();
         foreach (TypeInfo info in importer.Imported)
         {
             Console.WriteLine("adding {0}", info.Name);
             DBTypeMap.Instance.AllInfos.Add(info);
         }
     }
 }
        private void Add(bool keepExistingNames)
        {
            FileDialog fileDlg = new OpenFileDialog();

            if (fileDlg.ShowDialog() == DialogResult.OK)
            {
                using (var stream = File.OpenRead(fileDlg.FileName)) {
                    XmlImporter importer = new XmlImporter(stream);
                    importer.Import(true);
                    foreach (TypeInfo info in importer.Imported)
                    {
                        bool exists = false;
                        foreach (TypeInfo existing in DBTypeMap.Instance.GetAllInfos(info.Name))
                        {
                            if (existing.Version == info.Version && existing.SameTypes(info))
                            {
                                Console.WriteLine("imported type info {0}/{1} already exists with those fields",
                                                  info.Name, info.Version);
                                exists = true;
                                if (!keepExistingNames)
                                {
                                    for (int j = 0; j < existing.Fields.Count; j++)
                                    {
                                        if (!existing.Fields[j].Name.Equals(info.Fields[j].Name))
                                        {
                                            SchemaFieldNameChooser f = new SchemaFieldNameChooser();
                                            f.LeftInfo  = existing;
                                            f.RightInfo = info;
                                            if (f.ShowDialog() == DialogResult.OK)
                                            {
                                                TypeInfo result = f.MergedInfo;
                                                for (int i = 0; i < result.Fields.Count; i++)
                                                {
                                                    existing.Fields[i].Name = result.Fields[i].Name;
                                                }
                                            }
                                            break;
                                        }
                                    }
                                }
                                break;
                            }
                        }
                        if (!exists)
                        {
                            Console.WriteLine("imported type info {0}/{1} into schema", info.Name, info.Version);
                            DBTypeMap.Instance.AllInfos.Add(info);
                        }
                    }
                }
                SetTypeInfos();
            }
        }