public static string GetText(string key)
    {
        XmlTextReader reader = new XmlTextReader(new StringReader(copySource.text));

        string outString = "";

        // replace "EN" with language code, once implemented

        while(reader.Read()){
            if (reader.IsStartElement(key)){
                reader.ReadToFollowing("EN");
                outString = reader.ReadElementContentAsString("EN", reader.NamespaceURI);
            }
        }

        return outString;
    }
    private void ReadLocale(XmlTextReader reader)
    {
        TransfluentUtility util = TransfluentUtility.GetInstance();

        while (reader.Read())
        {
            if (reader.IsStartElement())
            {
                //util.AddMessage("Start locale entry element: " + reader.Name);

                if (reader.Name.Equals("id"))
                {
                    string id = reader.ReadString();
                    if (!int.TryParse(id, out m_languageId))
                        util.AddError("Couldn't parse language id from '" + id + "'");
                }
                if (reader.Name.Equals("code"))
                    m_languageCode = reader.ReadString();
                if (reader.Name.Equals("name"))
                    m_languageName = reader.ReadString();
                if (reader.Name.Equals("texts"))
                    ReadTexts(reader);
            }
            else if (reader.Name.Equals("locale"))
            {
                // Done reading locale
                //util.AddMessage("End of locale");
                break;
            }
            else
                util.AddWarning("Unexpected element closed: " + reader.Name);
        }

        if (m_languageId == -1)
            util.AddError("Couldn't parse language id");
        if (m_languageCode == null)
            util.AddError("Couldn't parse language code");
        if (m_languageName == null)
            util.AddError("Couldn't parse language name");
        if (m_texts.Count == 0)
            util.AddWarning("No texts parsed or found");
    }
        public static ObjectCategory[] ReadCategories(string filepath)
        {
            List <ObjectCategory> result = new List <ObjectCategory>();

            if (File.Exists(filepath))
            {
                StreamReader  rdr        = new StreamReader(filepath, Encoding.UTF8);         // чтобы не ругалось на кириллицу
                XmlTextReader textReader = new XmlTextReader(rdr);

                textReader.ReadStartElement("ThemeCategories");
                ObjectCategory current = null;
                while (textReader.Read())
                {
                    if (textReader.IsStartElement("Category"))
                    {
                        if (current != null)
                        {
                            result.Add(current);
                        }
                        // записываем предыдущую категорию и создаем новую
                        current = new ObjectCategory(textReader.GetAttribute("Name"));
                    }
                    else if (textReader.Name == "Include" || textReader.Name == "Exclude")
                    {
                        IncludeRule rule = new IncludeRule();
                        if (textReader.Name == "Exclude")
                        {
                            rule.Exclude = true;
                        }
                        rule.Rule    = (IncludeRule.IncludeRuleType)Enum.Parse(typeof(IncludeRule.IncludeRuleType), textReader.GetAttribute("Rule"), true);
                        rule.Pattern = textReader.ReadElementString();
                        current.Rules.Add(rule);
                    }
                }
                textReader.Close();
                result.Add(current);                 // добавляем последнюю категорию
            }
            return(result.ToArray());
        }
Example #4
0
    /// <summary>
    ///
    /// </summary>
    public void LoadData()
    {
        this.xmlFilePath = Application.dataPath + dataDirectory;

        TextAsset asset = (TextAsset)Resources.Load(dataPath, typeof(TextAsset));

        if (asset == null || asset.text == null)
        {
            this.AddEffect("NewEffect");
            return;
        }

        using (XmlTextReader reader = new XmlTextReader(new StringReader(asset.text)))
        {
            int currentID = 0;
            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case "length": int length = int.Parse(reader.ReadString()); this.names = new string[length]; this.effectClips = new EffectClip[length]; break;

                    case "id": currentID = int.Parse(reader.ReadString()); this.effectClips[currentID] = new EffectClip(); this.effectClips[currentID].realID = currentID; break;

                    case "name": this.names[currentID] = reader.ReadString(); break;

                    case "effectType": this.effectClips[currentID].effectType = (EffectType)Enum.Parse(typeof(EffectType), reader.ReadString()); break;

                    case "effectName": this.effectClips[currentID].effectName = reader.ReadString(); break;

                    case "effectPath": this.effectClips[currentID].effectPath = reader.ReadString(); break;

                    case "beHitEffectPath": this.effectClips[currentID].beHitEffect_Path = reader.ReadString(); break;
                    }
                }
            }
        }
    }
Example #5
0
        public static void wczytajKonfiguracje()
        {
            XmlReader reader = new XmlTextReader("konfiguracja.xml");

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    string   tmp;
                    string[] tmp2;
                    switch (reader.Name.ToString())
                    {
                    case "CZAS":
                        tmp           = reader.ReadString();
                        czasSymulacji = int.Parse(tmp);
                        break;

                    case "WEZEL":
                        tmp  = reader.ReadString();
                        tmp2 = tmp.Split(' ');
                        dodajWezel(new Wezel(int.Parse(tmp2[0]), double.Parse(tmp2[1], System.Globalization.NumberStyles.AllowDecimalPoint)));
                        break;

                    case "ZRODLO":
                        tmp  = reader.ReadString();
                        tmp2 = tmp.Split(' ');
                        if (int.Parse(tmp2[2]) == 0)
                        {
                            wezly[int.Parse(tmp2[0])].dodajZrodlo(new ZrodloRuchu(double.Parse(tmp2[1], System.Globalization.NumberStyles.AllowDecimalPoint), TypRuchu.podkladowy));
                        }
                        else
                        {
                            wezly[int.Parse(tmp2[0])].dodajZrodlo(new ZrodloRuchu(double.Parse(tmp2[1], System.Globalization.NumberStyles.AllowDecimalPoint), TypRuchu.testowy));
                        }
                        break;
                    }
                }
            }
        }
Example #6
0
        protected override List <TestResult> GetTestResults()
        {
            var testResults = new List <TestResult>();

            string changelogFullFilename = _archive.WorkingDirectory.Content()
                                           .WithFile(ArkadeConstants.ChangeLogXmlFileName).FullName;

            try
            {
                var logReader = new XmlTextReader(changelogFullFilename);

                while (logReader.Read())
                {
                    if (logReader.Name.Equals("referanseArkivenhet") && logReader.IsStartElement())
                    {
                        logReader.Read(); // Move to textnode containing the actual reference (systemID)

                        string loggedSystemId = logReader.Value;

                        if (!_systemIDs.Contains(loggedSystemId))
                        {
                            testResults.Add(new TestResult(ResultType.Error,
                                                           new Location(ArkadeConstants.ChangeLogXmlFileName),
                                                           string.Format(Noark5Messages.ChangeLogArchiveReferenceControlMessage, loggedSystemId))
                                            );
                        }
                    }
                }

                logReader.Close();
            }
            catch (Exception)
            {
                testResults.Add(new TestResult(ResultType.Error, new Location(string.Empty),
                                               string.Format(Noark5Messages.FileNotFound, ArkadeConstants.ChangeLogXmlFileName)));
            }

            return(testResults);
        }
Example #7
0
        public static AddIn Load(System.IO.TextReader textReader, string hintPath)
        {
            AddIn addIn = new AddIn();

            using (XmlTextReader xmlTextReader = new XmlTextReader(textReader))
            {
                while (xmlTextReader.Read())
                {
                    if (xmlTextReader.IsStartElement())
                    {
                        string localName;
                        if ((localName = xmlTextReader.LocalName) == null || !(localName == "AddIn"))
                        {
                            throw new System.NotSupportedException("Unknown add-in file.");
                        }
                        addIn.properties = Properties.ReadFromAttributes(xmlTextReader);
                        AddIn.SetupAddIn(xmlTextReader, addIn, hintPath);
                    }
                }
            }
            return(addIn);
        }
Example #8
0
        public static AbstractDrawing FromXml(XmlTextReader _xmlReader, PointF _scale)
        {
            DrawingPencil dp = new DrawingPencil();

            while (_xmlReader.Read())
            {
                if (_xmlReader.IsStartElement())
                {
                    if (_xmlReader.Name == "PointList")
                    {
                        ParsePointList(dp, _xmlReader, _scale);
                    }
                    else if (_xmlReader.Name == "LineStyle")
                    {
                        dp.m_PenStyle = LineStyle.FromXml(_xmlReader);
                    }
                    else if (_xmlReader.Name == "InfosFading")
                    {
                        dp.m_InfosFading.FromXml(_xmlReader);
                    }
                    else
                    {
                        // forward compatibility : ignore new fields.
                    }
                }
                else if (_xmlReader.Name == "Drawing")
                {
                    break;
                }
                else
                {
                    // Fermeture d'un tag interne.
                }
            }

            dp.RescaleCoordinates(dp.m_fStretchFactor, dp.m_DirectZoomTopLeft);
            return(dp);
        }
Example #9
0
        //construct filter based on xml params
        public static List <Filter> BuildFromXML(RaceData raceData, string file, int width = -1, int height = -1)
        {
            var    filters = new List <Filter>();
            string name = null, sql = null;
            var    xml = new XmlTextReader(file);

            try
            {
                while (xml.Read())
                {
                    if (xml.IsStartElement())
                    {
                        if (xml.Name == "Name")
                        {
                            xml.Read();
                            name = xml.Value;
                        }
                        else if (xml.Name == "SQL")
                        {
                            xml.Read();
                            sql = xml.Value;
                        }
                    }
                    if (!string.IsNullOrEmpty(sql) && !string.IsNullOrEmpty(name) || (xml.IsEmptyElement && xml.Name == "Filter"))
                    {
                        filters.Add(new Filter(raceData, name, sql, width, height));
                        sql  = null;
                        name = null;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(null);
            }
            return(filters);
        }
Example #10
0
        /// <summary>
        /// Populates this <see cref="MovieInfo"/> with the specific data stored in it.
        /// </summary>
        /// <param name="dataBuffer">A byte array containing the iTunes Metadata Format data
        /// used to populate this <see cref="MovieInfo"/>.</param>
        internal override void Populate(byte[] dataBuffer)
        {
            Dictionary <string, object> map = null;

            using (MemoryStream stream = new MemoryStream(dataBuffer))
            {
                using (XmlTextReader reader = new XmlTextReader(stream))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    while (reader.Name != "plist" && !reader.IsStartElement())
                    {
                        reader.Read();
                    }

                    // Move to the first child of the plist element, which should be a "dict" element.
                    // NOTE: This is a very fragile algorithm based on a specific format of XML contained
                    // in the atom. Any changes to this XML format is likely to break this, severely.
                    reader.Read();
                    map = this.ProcessElement(reader) as Dictionary <string, object>;
                    while (!reader.EOF)
                    {
                        reader.Read();
                    }
                }
            }

            if (map != null)
            {
                this.cast          = ExtractList(map, "cast");
                this.directors     = ExtractList(map, "directors");
                this.producers     = ExtractList(map, "producers");
                this.screenwriters = ExtractList(map, "screenwriters");
                if (map.ContainsKey("studio"))
                {
                    this.Studio = map["studio"].ToString();
                }
            }
        }
Example #11
0
    Dictionary <String, Dictionary <string, string> > Initialization(string path)
    {
        TextAsset textAsset = Resources.Load(path) as TextAsset;

        XmlTextReader reader = new XmlTextReader(new StringReader(textAsset.text));

        Dictionary <String, Dictionary <string, string> > temp = new Dictionary <string, Dictionary <string, string> >();
        Dictionary <string, string> insideTemp = new Dictionary <string, string>();
        string lang = null;

        while (reader.Read())
        {
            if (reader.IsStartElement())
            {
                switch (reader.Name)
                {
                case "string":
                    insideTemp.Add(reader.GetAttribute("name"), reader.ReadString());
                    break;

                default:
                    if (reader.HasAttributes)
                    {
                        if (lang != null)
                        {
                            temp.Add(lang, insideTemp);
                        }

                        lang       = reader.GetAttribute("val");
                        insideTemp = new Dictionary <string, string>();
                    }
                    break;
                }
            }
        }

        return(temp);
    }
Example #12
0
        public static void SaveCnae()
        {
            var nameProject = Path.GetFileName(Assembly.GetExecutingAssembly().Location).Split('.')[0];
            //var path = AppDomain.CurrentDomain.BaseDirectory.Replace(nameProject, "Util") + "Cnae";
            var path = Environment.CurrentDirectory + "\\Cnae";

            const string fileCnae   = @"\CnaeSubClass2_1.xml";
            var          pathDocXml = path + fileCnae;

            using (var xml = new XmlTextReader(pathDocXml))
            {
                while (xml.Read())
                {
                    if (xml.IsStartElement())
                    {
                        switch (xml.Name)
                        {
                        case "_x0027_Est":

                            break;

                        case "Cnae":

                            if (xml["name"] != null)
                            {
                                //SEÇÃO

                                if (xml["name"] == "Secao")
                                {
                                    SecaoReader(xml);
                                }
                            }
                            break;
                        }
                    }
                }
            }
        }
        public override void FromXmlString(String _string)
        {
            // create parameters
            ElGamalParameters elgamal_params = new ElGamalParameters();

            XmlTextReader xml_text_reader = new XmlTextReader(new System.IO.StringReader(_string));

            while (xml_text_reader.Read())
            {
                if (true || xml_text_reader.IsStartElement())
                {
                    switch (xml_text_reader.Name)
                    {
                    case "P":
                        // set P
                        elgamal_params.P = Convert.FromBase64String(xml_text_reader.ReadString());
                        break;

                    case "G":
                        // set  G
                        elgamal_params.G = Convert.FromBase64String(xml_text_reader.ReadString());
                        break;

                    case "Y":
                        // set  Y
                        elgamal_params.Y = Convert.FromBase64String(xml_text_reader.ReadString());
                        break;

                    case "X":
                        // set  X
                        elgamal_params.X = Convert.FromBase64String(xml_text_reader.ReadString());
                        break;
                    }
                }
            }

            ImportParameters(elgamal_params);
        }
        public override void FromXmlString(String p_string)
        {
            ElGamalParameters x_params = new ElGamalParameters();

            XmlTextReader x_reader =
                new XmlTextReader(new System.IO.StringReader(p_string));

            while (x_reader.Read())
            {
                if (true || x_reader.IsStartElement())
                {
                    switch (x_reader.Name)
                    {
                    case "P":
                        x_params.P =
                            Convert.FromBase64String(x_reader.ReadString());
                        break;

                    case "G":
                        x_params.G =
                            Convert.FromBase64String(x_reader.ReadString());
                        break;

                    case "Y":
                        x_params.Y =
                            Convert.FromBase64String(x_reader.ReadString());
                        break;

                    case "X":
                        x_params.X =
                            Convert.FromBase64String(x_reader.ReadString());
                        break;
                    }
                }
            }

            ImportParameters(x_params);
        }
Example #15
0
        private static void LoadInternal(Stream stream)
        {
            if (BlockLocalizationLoading)
            {
                return;
            }

            XmlTextReader tr = new XmlTextReader(stream);

            tr.Read();
            tr.Read();
            tr.Read();
            if (tr.Name == "Localization")
            {
                language    = tr.GetAttribute("language");
                description = tr.GetAttribute("description");
                cultureName = tr.GetAttribute("cultureName");

                string category = string.Empty;

                while (tr.Read())
                {
                    if (tr.IsStartElement())
                    {
                        string name = tr.Name;
                        if (tr.Depth == 1)
                        {
                            category = name;
                        }
                        else
                        {
                            Add(category, name, tr.ReadString());
                        }
                    }
                    tr.Read();
                }
            }
        }
Example #16
0
 /// <summary>
 /// Returns an enumerator that iterates through the serialization tokens.
 /// </summary>
 /// <returns>
 /// An that can be used to iterate through the collection of serialization tokens.
 /// </returns>
 public IEnumerator <ISerializationToken> GetEnumerator()
 {
     while (reader.Read())
     {
         if (!reader.IsStartElement())
         {
             break;
         }
         IEnumerator <ISerializationToken> iterator;
         try {
             iterator = handlers[reader.Name].Invoke();
         }
         catch (KeyNotFoundException) {
             throw new PersistenceException(String.Format(
                                                "Invalid XML tag \"{0}\" in persistence file.",
                                                reader.Name));
         }
         while (iterator.MoveNext())
         {
             yield return(iterator.Current);
         }
     }
 }
Example #17
0
 public static GetLyricResult LoadGetLyricResult(Stream stream)
 {
     using (var reader = new XmlTextReader(stream))
     {
         reader.WhitespaceHandling = WhitespaceHandling.Significant;
         if (reader.IsStartElement(nameof(GetLyricResult)))
         {
             reader.ReadStartElement(nameof(GetLyricResult));
             try
             {
                 return(LoadGetLyricResult(reader));
             }
             finally
             {
                 if (reader.NodeType == XmlNodeType.EndElement)
                 {
                     reader.ReadEndElement();
                 }
             }
         }
     }
     return(null);
 }
Example #18
0
            internal static IPropertySet Load(string fileName)
            {
                if (!File.Exists(fileName))
                {
                    return(new PropertySet());
                }
                using (XmlTextReader reader = new XmlTextReader(fileName))
                {
                    while (reader.Read())
                    {
                        if (reader.IsStartElement())
                        {
                            switch (reader.LocalName)
                            {
                            case "Properties":
                                return(ReadProperties(reader, "Properties"));
                            }
                        }
                    }
                }

                return(new PropertySet());
            }
        private static void Initialize()
        {
            if (!File.Exists(ModConfigPath))
            {
                SaveConfig();
            }
            else
            {
                var xmlTextReader = new XmlTextReader(ModConfigPath);
                while (xmlTextReader.Read())
                {
                    if (!xmlTextReader.IsStartElement())
                    {
                        continue;
                    }

                    if (xmlTextReader.Name == "GuildName")
                    {
                        _guildName = xmlTextReader.ReadString();
                    }
                }
            }
        }
Example #20
0
        //lấy mã ngôn ngữ
        private void GetLanguage()
        {
            int           languagecode = 0;
            XmlTextReader reader       = new XmlTextReader(Application.StartupPath + @"\\AppSetting.xml");

            reader.WhitespaceHandling = WhitespaceHandling.None;
            reader.Read();
            while (!reader.EOF)
            {
                if (reader.Name == "appsetting" && !reader.IsStartElement())
                {
                    break;
                }
                reader.Read();
                reader.Read();
                languagecode = Convert.ToInt32(reader.ReadElementString("language"));
            }
            reader.Close();

            NhanNgonNguClient client = new NhanNgonNguClient();

            listlabel = new List <NhanNgonNgu>(client.NhanNgonNgu_GetLabelByLang(languagecode));
        }
Example #21
0
 public static Properties Load(string fileName)
 {
     if (File.Exists(fileName))
     {
         using (XmlTextReader reader = new XmlTextReader(fileName))
         {
             while (reader.Read())
             {
                 if (reader.IsStartElement())
                 {
                     string localName = reader.LocalName;
                     if ((localName != null) && (localName == "Properties"))
                     {
                         Properties properties = new Properties();
                         properties.ReadProperties(reader, "Properties");
                         return(properties);
                     }
                 }
             }
         }
     }
     return(null);
 }
Example #22
0
        public void Load()
        {
            using (XmlTextReader xml = new XmlTextReader("members.xml"))
            {
                while (xml.Read())
                {
                    if (xml.IsStartElement())
                    {
                        switch (xml.Name)
                        {
                        case "Member":
                            Member m = LoadMember(xml.ReadSubtree());
                            if (m != null)
                            {
                                InsertMember(m);
                            }

                            break;
                        }
                    }
                }
            }
        }
 void ReadXmlDoc(XmlTextReader reader)
 {
     //lastWriteDate = File.GetLastWriteTimeUtc(fileName);
     // Open up a second file stream for the line<->position mapping
     using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) {
         LinePositionMapper linePosMapper = new LinePositionMapper(fs, encoding);
         List <IndexEntry>  indexList     = new List <IndexEntry>();
         while (reader.Read())
         {
             if (reader.IsStartElement())
             {
                 switch (reader.LocalName)
                 {
                 case "members":
                     ReadMembersSection(reader, linePosMapper, indexList);
                     break;
                 }
             }
         }
         indexList.Sort();
         this.index = indexList.ToArray();                 // volatile write
     }
 }
Example #24
0
//		public void BinarySerialize(BinaryWriter writer)
//		{
//			writer.Write((byte)properties.Count);
//			foreach (KeyValuePair<string, object> entry in properties) {
//				writer.Write(PluginTree.GetNameOffset(entry.Key));
//				writer.Write(PluginTree.GetNameOffset(entry.Value.ToString()));
//			}
//		}

        public static Properties Load(string fileName)
        {
            if (!File.Exists(fileName))
            {
                return(null);
            }
            using (XmlTextReader reader = new XmlTextReader(fileName)) {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.LocalName)
                        {
                        case "Properties":
                            Properties properties = new Properties();
                            properties.ReadProperties(reader, "Properties");
                            return(properties);
                        }
                    }
                }
            }
            return(null);
        }
Example #25
0
        // tries to get to the first child element of body, ignoring details
        // such as the namespace of Envelope and Body (a version mismatch check will come later)
        protected XmlQualifiedName GetRequestElement()
        {
            SoapServerMessage message   = ServerProtocol.Message;
            long          savedPosition = message.Stream.Position;
            XmlTextReader reader        = GetXmlTextReader(message.ContentType, message.Stream);

            reader.MoveToContent();

            requestNamespace = reader.NamespaceURI;
            reader.ReadStartElement(Soap.Envelope, requestNamespace);
            reader.MoveToContent();

            while (!reader.EOF && !reader.IsStartElement(Soap.Body, requestNamespace))
            {
                reader.Skip();
            }

            if (reader.EOF)
            {
                throw new InvalidOperationException(Res.GetString(Res.WebMissingBodyElement));
            }

            XmlQualifiedName element;

            if (reader.IsEmptyElement)
            {
                element = new XmlQualifiedName("", "");
            }
            else
            {
                reader.ReadStartElement(Soap.Body, requestNamespace);
                reader.MoveToContent();
                element = new XmlQualifiedName(reader.LocalName, reader.NamespaceURI);
            }
            message.Stream.Position = savedPosition;
            return(element);
        }
Example #26
0
        private void Load()
        {
            _hl7ProfileStore = new Hashtable();

            try
            {
                XmlTextReader reader = new XmlTextReader(_directory + "/" + _filename);
                while (reader.EOF == false)
                {
                    reader.ReadStartElement("Hl7ProfileStore");

                    while ((reader.IsStartElement()) &&
                           (reader.Name == "Hl7Profile"))
                    {
                        reader.ReadStartElement("Hl7Profile");
                        reader.ReadStartElement("Hl7ProfileId");
                        System.String facility    = reader.ReadElementString("Facility");
                        System.String version     = reader.ReadElementString("Version");
                        System.String messageType = reader.ReadElementString("MessageType");
                        reader.ReadEndElement();

                        System.String filename = reader.ReadElementString("Filename");
                        reader.ReadEndElement();

                        Hl7Profile hl7Profile = new Hl7Profile(facility, version, messageType, _directory, filename);
                        _hl7ProfileStore.Add(hl7Profile.Id, hl7Profile);
                    }
                    reader.ReadEndElement();
                }
                reader.Close();
            }
            catch (System.Exception e)
            {
                System.String message = System.String.Format("Failed to read HL7 Profile: \"{0}\"", _directory + "/" + _filename);
                throw new System.SystemException(message, e);
            }
        }
Example #27
0
  public static void Main()
  {

    //Create the XML fragment to be parsed.
    string xmlFrag ="<book> " +
                    "<title>Pride And Prejudice</title>" +
                    "<bk:genre>novel</bk:genre>" +
                    "</book>"; 

    //Create the XmlNamespaceManager.
    NameTable nt = new NameTable();
    XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
    nsmgr.AddNamespace("bk", "urn:sample");

    //Create the XmlParserContext.
    XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

    //Create the reader. 
    XmlTextReader reader = new XmlTextReader(xmlFrag, XmlNodeType.Element, context);
  
    //Parse the XML.  If they exist, display the prefix and  
    //namespace URI of each element.
    while (reader.Read()){
      if (reader.IsStartElement()){
        if (reader.Prefix==String.Empty)
           Console.WriteLine("<{0}>", reader.LocalName);
        else{
            Console.Write("<{0}:{1}>", reader.Prefix, reader.LocalName);
            Console.WriteLine(" The namespace URI is " + reader.NamespaceURI);
        }
      }
    }
  
    //Close the reader.
    reader.Close();     
  
  }
        public void MarshalResponse(IConfig config, GetBucketTaggingRequest request, GetBucketTaggingResponse response, IDictionary <string, string> headers, Stream responseStream)
        {
            response.Tags = new Dictionary <string, string>();

            using (XmlTextReader xmlReader = new XmlTextReader(responseStream))
            {
                xmlReader.ReadToDescendant("TagSet");

                while (xmlReader.Read())
                {
                    if (!xmlReader.IsStartElement() || xmlReader.Name != "Tag")
                    {
                        continue;
                    }

                    //Read the next token
                    xmlReader.Read();

                    string key   = xmlReader.ReadElementContentAsString();
                    string value = xmlReader.ReadElementContentAsString();
                    response.Tags.Add(key, value);
                }
            }
        }
Example #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected ILineString ReadLineString(XmlTextReader reader)
        {
            ArrayList coordinates = new ArrayList();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (reader.IsStartElement("coord", GMLElements.gmlNS))
                    {
                        coordinates.Add(ReadCoordinate(reader));
                    }
                    break;

                case XmlNodeType.EndElement:
                    return(Factory.CreateLineString((ICoordinate[])coordinates.ToArray(typeof(ICoordinate))));

                default:
                    break;
                }
            }
            throw new ArgumentException("ShouldNeverReachHere!");
        }
Example #30
0
 private void readCatagoryList()
 {
     if (!File.Exists(subgroupListXml))
     {
         this.writeCatagoryList();
     }
     subgroupList = new List <Subgroup>();
     XmlReader    = new XmlTextReader(subgroupListXml);
     XmlReader.Read();
     XmlReader.Read();
     XmlReader.Read();
     XmlReader.Read();
     XmlReader.Read();
     XmlReader.Read();
     while (XmlReader.Read())
     {
         if (XmlReader.Name.Equals("subgroup"))
         {
             while (XmlReader.Read())
             {
                 if (XmlReader.IsStartElement())
                 {
                     switch (XmlReader.Name)
                     {
                     //parse everything into it
                     case "groupName":
                         subgroupList.Add(new Subgroup(XmlReader.ReadString()));
                         break;
                     }
                 }
             }
         }
     }
     XmlReader.Close();
     //reset ui prolly
 }
Example #31
0
        public static AddIn Load(TextReader textReader, string hintPath)
        {
            AddIn addIn = new AddIn();

            using (XmlTextReader reader = new XmlTextReader(textReader)) {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.LocalName)
                        {
                        case "AddIn":
                            addIn.properties = Properties.ReadFromAttributes(reader);
                            SetupAddIn(reader, addIn, hintPath);
                            break;

                        default:
                            throw new AddInLoadException("Unknown add-in file.");
                        }
                    }
                }
            }
            return(addIn);
        }
Example #32
0
 IEnumerable <HandlerData> IHandler.Parse(string filePath, CancellationToken ct)
 {
     using (var reader = new XmlTextReader(filePath))
     {
         while (reader.Read() && !ct.IsCancellationRequested)
         {
             if (reader.IsStartElement())
             {
                 if (reader.Name == "value")
                 {
                     yield return(new HandlerData
                     {
                         Date = reader.GetAttribute("date"),
                         Open = reader.GetAttribute("open"),
                         High = reader.GetAttribute("high"),
                         Low = reader.GetAttribute("low"),
                         Close = reader.GetAttribute("close"),
                         Volume = reader.GetAttribute("volume")
                     });
                 }
             }
         }
     }
 }
Example #33
0
	//
	private void Button2_Click(System.Object sender, System.EventArgs e)
	{
		verify.Visible = false;
		Button1.Visible = false;
		OpenFileDialog1.ShowDialog();
		if (string.IsNullOrEmpty(OpenFileDialog1.FileName)) {
			return;
		} else {
			spinny.Visible = true;
			Button2.Visible = false;
			Delay(1.5);
			try {
				//Parsing time baby!!!
				//Load up xml...
				XmlTextReader m_xmlr = null;
				m_xmlr = new XmlTextReader(OpenFileDialog1.FileName);
				m_xmlr.WhitespaceHandling = WhitespaceHandling.None;
				m_xmlr.Read();
				m_xmlr.Read();
				while (!m_xmlr.EOF) {
					m_xmlr.Read();
					if (!m_xmlr.IsStartElement()) {
						break; // TODO: might not be correct. Was : Exit While
					}
					dynamic iFaithAttribute = m_xmlr.GetAttribute("iFaith");
					m_xmlr.Read();
					xml_revision = m_xmlr.ReadElementString("revision");
					xml_ios = m_xmlr.ReadElementString("ios");
					xml_model = m_xmlr.ReadElementString("model");
					xml_board = m_xmlr.ReadElementString("board");
					xml_ecid = m_xmlr.ReadElementString("ecid");
					blob_logo = m_xmlr.ReadElementString("logo");
					blob_chg0 = m_xmlr.ReadElementString("chg0");
					blob_chg1 = m_xmlr.ReadElementString("chg1");
					blob_batf = m_xmlr.ReadElementString("batf");
					blob_bat0 = m_xmlr.ReadElementString("bat0");
					blob_bat1 = m_xmlr.ReadElementString("bat1");
					blob_dtre = m_xmlr.ReadElementString("dtre");
					blob_glyc = m_xmlr.ReadElementString("glyc");
					blob_glyp = m_xmlr.ReadElementString("glyp");
					blob_ibot = m_xmlr.ReadElementString("ibot");
					blob_illb = m_xmlr.ReadElementString("illb");
					if (xml_ios.Substring(0, 1) == "3") {
						blob_nsrv = m_xmlr.ReadElementString("nsrv");
					}
					blob_recm = m_xmlr.ReadElementString("recm");
					blob_krnl = m_xmlr.ReadElementString("krnl");
					xml_md5 = m_xmlr.ReadElementString("md5");
					xml_ipsw_md5 = m_xmlr.ReadElementString("ipsw_md5");
				}
				m_xmlr.Close();
			} catch (Exception Ex) {
				Interaction.MsgBox("Error while processing specified file!", MsgBoxStyle.Critical);
				spinny.Visible = false;
				Button2.Visible = true;
				return;
			}
		}

		//Were going to Check to see if this was made with a newer iFaith revision...
		if (xml_revision > MDIMain.VersionNumber) {
			Interaction.MsgBox("This iFaith SHSH Cache file was made with iFaith v" + xml_revision + Strings.Chr(13) + Strings.Chr(13) + "Please download the latest iFaith revision at http://ih8sn0w.com", MsgBoxStyle.Critical);
			spinny.Visible = false;
			Button2.Visible = true;
			return;
		}

		//Hashing time! :)
		if (MD5CalcString(blob_logo + xml_ecid + xml_revision) == xml_md5) {
			if (xml_board == "n72ap") {
				Interaction.MsgBox("iPod Touch 2G IPSW Creation is still being worked on.", MsgBoxStyle.Exclamation);
				spinny.Visible = false;
				Button2.Visible = true;
				return;
			}
			//Load IPSW Pwner...
			verify.Visible = false;
			//Hide Logo + Welcome txt...
			PictureBox1.Visible = false;
			spinny.Visible = false;
			Label1.Visible = false;
			//
			ORlabel.Visible = true;
			dl4mebtn.Visible = true;
			browse4ios.Visible = true;
			browse4ios.Text = "Browse for the " + xml_ios;
			browse4ios.ForeColor = Color.Cyan;
			browse4ios.Left = (Width / 2) - (browse4ios.Width / 2);
			if (xml_board == "n92ap") {
				Label2.Text = "IPSW for the iPhone 4 (CDMA)";
			} else {
				Label2.Text = "IPSW for the " + xml_model;
			}
			Label2.ForeColor = Color.Cyan;
			Label2.Left = (Width / 2) - (Label2.Width / 2);
			Button3.Text = "Browse for the iOS " + xml_ios + " IPSW";
			Button3.Left = (Width / 2) - (Button3.Width / 2);
			Button2.Visible = false;
			Button3.Visible = true;
			Button1.Visible = false;
			Stage = 1;
		} else {
			Interaction.MsgBox("Invalid iFaith Cache!", MsgBoxStyle.Critical);
			spinny.Visible = false;
			Button2.Visible = true;
			return;

		}


	}
Example #34
0
    bool GetCharacterInfo(char m_character, ref CustomCharacterInfo char_info)
    {
        if(m_character.Equals('\n') || m_character.Equals('\r'))
        {
            return true;
        }

        #if !UNITY_3_5
        if(m_font != null)
        {
            CharacterInfo font_char_info = new CharacterInfo();
            m_font.GetCharacterInfo(m_character, out font_char_info);

            char_info.flipped = font_char_info.flipped;
            char_info.uv = font_char_info.uv;
            char_info.vert = font_char_info.vert;
            char_info.width = font_char_info.width;

            // Scale char_info values
            char_info.vert.x /= FontScale;
            char_info.vert.y /= FontScale;
            char_info.vert.width /= FontScale;
            char_info.vert.height /= FontScale;
            char_info.width /= FontScale;

            if(font_char_info.width == 0)
            {
                // Invisible character info returned because character is not contained within the font
                Debug.LogWarning("Character '" + GetHumanReadableCharacterString(m_character) + "' not found. Check that font '" + m_font.name + "' supports this character.");
            }

            return true;
        }
        #endif

        if(m_font_data_file != null)
        {
            if(m_custom_font_data == null || !m_font_data_file.name.Equals(m_current_font_data_file_name))
            {
                // Setup m_custom_font_data for the custom font.
                if(m_font_data_file.text.Substring(0,5).Equals("<?xml"))
                {
                    // Text file is in xml format

                    m_current_font_data_file_name = m_font_data_file.name;
                    m_custom_font_data = new CustomFontCharacterData();

                    XmlTextReader reader = new XmlTextReader(new StringReader(m_font_data_file.text));

                    int texture_width = 0;
                    int texture_height = 0;
                    int uv_x, uv_y;
                    float width, height, xoffset, yoffset, xadvance;
                    CustomCharacterInfo character_info;

                    while(reader.Read())
                    {
                        if(reader.IsStartElement())
                        {
                            if(reader.Name.Equals("common"))
                            {
                                texture_width = int.Parse(reader.GetAttribute("scaleW"));
                                texture_height = int.Parse(reader.GetAttribute("scaleH"));
                            }
                            else if(reader.Name.Equals("char"))
                            {
                                uv_x = int.Parse(reader.GetAttribute("x"));
                                uv_y = int.Parse(reader.GetAttribute("y"));
                                width = float.Parse(reader.GetAttribute("width"));
                                height = float.Parse(reader.GetAttribute("height"));
                                xoffset = float.Parse(reader.GetAttribute("xoffset"));
                                yoffset = float.Parse(reader.GetAttribute("yoffset"));
                                xadvance = float.Parse(reader.GetAttribute("xadvance"));

                                character_info = new CustomCharacterInfo();
                                character_info.flipped = false;
                                character_info.uv = new Rect((float) uv_x / (float) texture_width, 1 - ((float)uv_y / (float)texture_height) - (float)height/(float)texture_height, (float)width/(float)texture_width, (float)height/(float)texture_height);
                                character_info.vert = new Rect(xoffset,-yoffset,width, -height);
                                character_info.width = xadvance;

                                m_custom_font_data.m_character_infos.Add( int.Parse(reader.GetAttribute("id")), character_info);
                            }
                        }
                    }
                }
                else if(m_font_data_file.text.Substring(0,4).Equals("info"))
                {
                    // Plain txt format
                    m_current_font_data_file_name = m_font_data_file.name;
                    m_custom_font_data = new CustomFontCharacterData();

                    int texture_width = 0;
                    int texture_height = 0;
                    int uv_x, uv_y;
                    float width, height, xoffset, yoffset, xadvance;
                    CustomCharacterInfo character_info;
                    string[] data_fields;

                    string[] text_lines = m_font_data_file.text.Split(new char[]{'\n'});

                    foreach(string font_data in text_lines)
                    {
                        if(font_data.Length >= 5 && font_data.Substring(0,5).Equals("char "))
                        {
                            // character data line
                            data_fields = ParseFieldData(font_data, new string[]{"id=", "x=", "y=", "width=", "height=", "xoffset=", "yoffset=", "xadvance="});
                            uv_x = int.Parse(data_fields[1]);
                            uv_y = int.Parse(data_fields[2]);
                            width = float.Parse(data_fields[3]);
                            height = float.Parse(data_fields[4]);
                            xoffset = float.Parse(data_fields[5]);
                            yoffset = float.Parse(data_fields[6]);
                            xadvance = float.Parse(data_fields[7]);

                            character_info = new CustomCharacterInfo();
                            character_info.flipped = false;
                            character_info.uv = new Rect((float) uv_x / (float) texture_width, 1 - ((float)uv_y / (float)texture_height) - (float)height/(float)texture_height, (float)width/(float)texture_width, (float)height/(float)texture_height);
                            character_info.vert = new Rect(xoffset,-yoffset +1,width, -height);
                            character_info.width = xadvance;

                            m_custom_font_data.m_character_infos.Add( int.Parse(data_fields[0]), character_info);
                        }
                        else if(font_data.Length >= 6 && font_data.Substring(0,6).Equals("common"))
                        {
                            data_fields = ParseFieldData(font_data, new string[]{"scaleW=", "scaleH=", "lineHeight="});
                            texture_width = int.Parse(data_fields[0]);
                            texture_height = int.Parse(data_fields[1]);
                        }
                    }
                }

            }

            if(m_custom_font_data.m_character_infos.ContainsKey((int) m_character))
            {
                ((CustomCharacterInfo) m_custom_font_data.m_character_infos[(int)m_character]).ScaleClone(FontScale, ref char_info);

                return true;
            }
        }

        return false;
    }
Example #35
0
	public void LoadFromXML(System.IO.Stream oStream)
	{
		xtr = new System.Xml.XmlTextReader(oStream);

		while (xtr.Read())
		{
			if (xtr.IsStartElement())
			{
				if ((xtr.LocalName.ToUpper() == "TREEVIEWSTYLES") && (this.TreeViewStyle))
					LoadObject(oTV, xtr.ReadInnerXml(), oTV.Style.NodeStyle);

				if ((xtr.LocalName.ToUpper() == "TREEVIEWCONTENT") && (this.TreeViewContent))
					LoadNodes(oTV, xtr.ReadInnerXml());
			}
		}
	}
	// Use this for initialization
	public static void Load () {
		using(XmlTextReader reader = new XmlTextReader("strijps"))
//		using (XmlReader reader = XmlReader.Create("Assets/Maps/andorra"))
		{
			while (reader.Read())
			{
				// Only detect start elements.
				if (reader.IsStartElement())
				{
					//Debug.Log (reader.Name);
					// Get element name and switch on it.
					switch (reader.Name)
					{
					case "osm":
						// Detect this element.
						break;
					case "bounds":
						break;
					case "node":
						long nodeId = long.Parse (reader ["id"]);
						float lat = float.Parse (reader ["lat"]);
						float lon = float.Parse (reader ["lon"]);

						List<OsmTag> nodeTags = new List<OsmTag> ();
						XmlReader nodeSubtree = reader.ReadSubtree ();
						readNodeSubtree (nodeSubtree, nodeTags);
						OsmNode node = new OsmNode (nodeId, nodeTags, lon, lat);
						Data.Instance.nodes.Add (nodeId, node);
						break;
					case "tag":
						break;
					case "member": 
						break;
					case "nd":
						break;
					case "way":
						long wayId = long.Parse (reader ["id"]);
						List<OsmTag> wayTags = new List<OsmTag> ();
						List<OsmNodeReference> wayNodes = new List<OsmNodeReference> ();
						XmlReader waySubtree = reader.ReadSubtree ();
						readWaySubtree (waySubtree, wayNodes, wayTags);
						OsmWay way = new OsmWay (wayId, wayTags, wayNodes);
						foreach (OsmTag tag in wayTags) {
							if (tag.getKey () == "building") {
								Data.Instance.buildings.Add (wayId, new OsmBuilding (wayId, wayTags, wayNodes));
							}
							if (tag.getKey () == "highway") {
								Data.Instance.streets.Add (wayId, new OsmStreet (wayId, wayTags, wayNodes));
							}
							if (tag.getKey () == "landuse" || tag.getKey() == "natural"  ){ //|| tag.getKey() == "surface") {
								if (!Data.Instance.surfaces.ContainsKey(wayId))
									Data.Instance.surfaces.Add (wayId, new OsmSurface (wayId, wayTags, wayNodes, tag.getValue()));
							}
						}
						Data.Instance.ways.Add(wayId, way);
						break;
					case "relation": 
						long relationId = long.Parse (reader ["id"]);
						List<OsmRelationMember> members = new List<OsmRelationMember> ();
						List<OsmTag> relationTags = new List<OsmTag> ();
						XmlReader relationSubtree = reader.ReadSubtree ();
						readRelationSubtree (relationSubtree, members, relationTags);
						OsmRelation relation = new OsmRelation (relationId, relationTags, members);
						Data.Instance.relations.Add(relationId, relation);
						break;
					default:
						Debug.Log (reader.Name);
						break;
					}


				}
			}
		}
		foreach(long key in Data.Instance.ways.Keys)
		{
			OsmWay w = (OsmWay) Data.Instance.ways[key];
			for(int i = 0; i < w.getNumberOfNodes(); i++) {
				OsmNodeReference nodeRef = w.getNodeReference (i);
				if (!Data.Instance.nodes.ContainsKey (nodeRef.getId ()))
					continue;
				OsmNode n = (OsmNode) Data.Instance.nodes [nodeRef.getId()];
				n.addContainedIn (w);
				nodeRef.setLattitudeAndLongitude (n.getLatitude (), n.getLongitude ());
			}
		}
		Debug.Log ("Nodes: " + Data.Instance.nodes.Count);
		Debug.Log ("Ways: " + Data.Instance.ways.Count);
		Debug.Log ("Relations: " + Data.Instance.relations.Count);
		Debug.Log("Buildings: " + Data.Instance.buildings.Count);
		Debug.Log("Streets: " + Data.Instance.streets.Count);
			
		Debug.Log ("Done");
		Data.Instance.dataLoaded = true;
	}
Example #37
0
	private void LoadNodes(object objParent, string sXML)
	{
		if (sXML.Length == 0) return;

		XmlTextReader tr = new XmlTextReader(sXML, System.Xml.XmlNodeType.Element , null);

		while (tr.ReadState != ReadState.EndOfFile)
		{

			while (tr.Read())
				if (tr.IsStartElement()) break;

			string ElementName = tr.LocalName;

			if (ElementName.Length == 0) break;

			switch (ElementName.ToUpper())
			{
				case "BEHAVIOR" :

					for (int i = 0; i < tr.AttributeCount; i++)
					{						

						tr.MoveToAttribute(i);						

						SetProperty(oTV, tr.Name, tr.Value);

					}
					
					break;

				case "NODE" :

					while (tr.ReadState != ReadState.EndOfFile)
					{
						if (tr.LocalName.ToUpper() == "NODE")
						{
							Node n = null;

							string s = tr.ReadOuterXml();

							if (s.Length > 0)
							{
								n = LoadNode(s);
					
								if (n != null) oTV.Nodes.Add(n);
							}
						}
						else tr.Read();
					}

					break;
			}

		}
	}
    private static List<StandardOperatingProcedureData> LoadDefaultStandardOperatingProcedureData()
    {
        List<StandardOperatingProcedureData> data = new List<StandardOperatingProcedureData>();
        if (File.Exists(ServerPath + StandardOperatingProcedureDataConfigPath))
        {
            using (XmlTextReader reader = new XmlTextReader(ServerPath + StandardOperatingProcedureDataConfigPath))
            {
                string ID = null;
                string title = null;
                bool? isMetadata = null;
                bool? isRequired = null;
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.Name)
                        {
                            case "ID":
                                if (reader.Read())
                                {
                                    ID = reader.Value.Trim();
                                }
                                break;

                            case "Title":
                                if (reader.Read())
                                {
                                    title = reader.Value.Trim();
                                }
                                break;

                            case "IsMetadata":
                                if (reader.Read())
                                {
                                    switch (reader.Value.Trim().ToLower())
                                    {
                                        case "false":
                                            isMetadata = false;
                                            break;

                                        case "true":
                                            isMetadata = true;
                                            break;

                                        default:
                                            throw new FileFormatException("Error: True/false incorrectly specified for field IsMetadata of data ID " + ID + ".");
                                    }
                                }
                                break;

                            case "IsRequired":
                                if (reader.Read())
                                {
                                    switch (reader.Value.Trim().ToLower())
                                    {
                                        case "false":
                                            isRequired = false;
                                            break;

                                        case "true":
                                            isRequired = true;
                                            break;

                                        default:
                                            throw new FileFormatException("Error: True/false incorrectly specified for field IsRequired of data ID " + ID);
                                    }
                                }
                                break;

                            default:
                                break;
                        }
                    }
                    if (!String.IsNullOrWhiteSpace(ID) && !String.IsNullOrEmpty(title) && isMetadata != null && isRequired != null)
                    {
                        data.Add(new StandardOperatingProcedureData(ID, title, (bool)isMetadata, (bool)isRequired));
                        ID = null;
                        title = null;
                        isMetadata = null;
                        isRequired = null;
                    }
                }
            }
        }
        else
        {
            throw new FileNotFoundException("Error: SOPData configuration file 'config/sopdata.xml' not found.");
        }
        return data;
    }
    private void ReadXML(string filePath)
    {
        TransfluentUtility util = TransfluentUtility.GetInstance();

        //util.AddWarning("Reading " + filePath);

        XmlTextReader reader = new XmlTextReader(filePath);

        while (reader.Read())
        {
            if (reader.IsStartElement())
            {
                if (reader.IsEmptyElement)
                    util.AddMessage("Empty element: " + reader.Name);
                else
                {
                    if (reader.Name.Equals("locale"))
                        ReadLocale(reader);
                    else
                        util.AddMessage("Start of an element: " + reader.Name);
                }
            }
            else
            {
                util.AddMessage("End of an element: " + reader.Name);
            }
        }

        util.AddMessage("Done reading " + filePath + "\nLanguage Id=" + m_languageId + ", Code='" + m_languageCode + "', Name='" + m_languageName + "', Found " + m_texts.Count + " text entries");
    }
    public void LoadStandardOperatingProcedure(String xmlToLoadFileName)
    {
        if (File.Exists(ServerPath + SopFolder + xmlToLoadFileName))
        {
            var data = new List<StandardOperatingProcedureData>();
            using (XmlTextReader reader = new XmlTextReader(ServerPath + SopFolder + xmlToLoadFileName))
            {
                string ID = null;
                string title = null;
                bool? isMetadata = null;
                bool? isRequired = null;
                string value = null;
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.Name)
                        {
                            case "SOPTitle":
                                if (reader.Read())
                                {
                                    this.Title = reader.Value.Trim();
                                }
                                break;

                            case "ID":
                                if (reader.Read())
                                {
                                    ID = reader.Value.Trim();
                                }
                                break;

                            case "Title":
                                if (reader.Read())
                                {
                                    title = reader.Value.Trim();
                                }
                                break;

                            case "IsMetadata":
                                if (reader.Read())
                                {
                                    switch (reader.Value.Trim().ToLower())
                                    {
                                        case "false":
                                            isMetadata = false;
                                            break;

                                        case "true":
                                            isMetadata = true;
                                            break;

                                        default:
                                            throw new FileFormatException("Error: True/false incorrectly specified for field IsMetadata of data ID " + ID + " in " + xmlToLoadFileName + ".");
                                    }
                                }
                                break;

                            case "IsRequired":
                                if (reader.Read())
                                {
                                    switch (reader.Value.Trim().ToLower())
                                    {
                                        case "false":
                                            isRequired = false;
                                            break;

                                        case "true":
                                            isRequired = true;
                                            break;

                                        default:
                                            throw new FileFormatException("Error: True/false incorrectly specified for field IsRequired of data ID " + ID + " in " + xmlToLoadFileName + ".");
                                    }
                                }
                                break;

                            case "Value":
                                if (reader.Read() && reader.NodeType == XmlNodeType.CDATA)
                                {
                                    value = reader.Value;
                                }
                                break;

                            default:
                                break;
                        }
                    }
                    if (!String.IsNullOrWhiteSpace(ID) && !String.IsNullOrEmpty(title) && isMetadata != null && isRequired != null && value != null)
                    {
                        data.Add(new StandardOperatingProcedureData(ID, title, (bool)isMetadata, (bool)isRequired, value));
                        ID = null;
                        title = null;
                        isMetadata = null;
                        isRequired = null;
                        value = null;
                    }
                }
            }
            this.Data = data;
        }
        else
        {
            throw new FileNotFoundException("SOP file " + xmlToLoadFileName + " cannot be found.");
        }
    }
Example #41
0
    public List<House.Item> LoadItems(string toRead, List<House.Item> list)
    {
        House.Item temp = new House.Item();
        House.Item temp1;

        int i = 0;
        using (XmlReader reader = new XmlTextReader(new System.IO.StringReader(toRead)))
        {
            while (reader.Read())
            {
                // Only detect start elements.
                if (reader.IsStartElement())
                {
                    // Get element name and switch on it.
                    switch (reader.Name)
                    {
                        case "Item":
                            temp1 = list[i];
                            temp.usage = temp1.usage;
                            temp.state = temp1.state;

                            break;
                        case "Type":
                            if (reader.Read())
                            {
                                temp.type = int.Parse(reader.Value.Trim());
                            }
                            break;
                        case "ID":
                            if (reader.Read())
                            {
                                temp.id = int.Parse(reader.Value.Trim());
                            }
                            break;
                        case "Name":
                            if (reader.Read())
                            {
                                temp.name = reader.Value.Trim();
                            }
                            break;
                        case "PositionX":
                            if (reader.Read())
                            {
                                temp.position.x = int.Parse(reader.Value.Trim());
                            }
                            break;
                        case "PositionY":
                            if (reader.Read())
                            {
                                temp.position.y = int.Parse(reader.Value.Trim());
                            }
                            break;
                        case "Floor":
                            if (reader.Read())
                            {
                                temp.floor = int.Parse(reader.Value.Trim());
                            }
                            list[i] = temp;
                            i++;
                            break;
                    }
                }
            }
        }
        return list;
    }
Example #42
0
        void readConfig(string path)
        {
            int i = 0;
            int j = 0;
            int k = 0;
            uint lastZoneTemp = 10;
            uint firstZoneTemp;
            XmlTextReader reader = new XmlTextReader(path);
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.NodeType)
                        {
                            case XmlNodeType.Element:
                                reader.ReadToFollowing("expander");//Configure Expanders
                                do
                                {
                                    swampExpanderTypes[i] = reader.GetAttribute("Type");
                                    expanderIDs[i] = Convert.ToUInt16(reader.GetAttribute("ID"));

                                    if (swampExpanderTypes[i] == "swampE4")
                                    {
                                        lastZoneTemp += 4;
                                        firstZoneTemp = lastZoneTemp - 3;
                                    }
                                    else
                                    {
                                        lastZoneTemp += 8;
                                        firstZoneTemp = lastZoneTemp - 7;
                                    }
                                    expanderLastZone[i] = lastZoneTemp;
                                    expanderFirstZone[i] = firstZoneTemp;
                                    i++;
                                } while (reader.ReadToNextSibling("expander"));
                                numberOfExpanders = (ushort)i;
                                i = 0;

                                reader.ReadToFollowing("audioZone"); //Audio Zone Names & Numbers
                                do
                                {
                                    zoneNameArray[i] = reader.GetAttribute("Name");
                                    zoneNumberArray[i] = Convert.ToUInt16(reader.GetAttribute("zoneNumber"));
                                    i++;
                                    if (zoneNameArray[i] != " ")
                                    {
                                        k++;
                                    }
                                } while (reader.ReadToNextSibling("audioZone"));
                                numberOfZones = (ushort)k;

                                i = 1;
                                reader.ReadToFollowing("audioSource"); //Audio Source Names & Numbers
                                sourceNameArray[0] = "Off";
                                do
                                {
                                    sourceNameArray[i] = reader.GetAttribute("Name");
                                    i++;
                                } while (reader.ReadToNextSibling("audioSource"));

                                i = 0;
                                reader.ReadToFollowing("group");//group numbers
                                do
                                {
                                    groupNames[i] = reader.GetAttribute("Name");
                                    reader.ReadToFollowing("zone");
                                    do
                                    {
                                        UItoZone.zoneNumbersInGroups[i, j] = Convert.ToUInt16(reader.GetAttribute("zoneNumber"));//add zone numbers per floor/group
                                        j++;
                                    } while (reader.ReadToNextSibling("zone"));
                                    UItoZone.groupSizes[i] = (ushort)j;//Number of zones in groups
                                    j = 0;
                                    i++;
                                } while (reader.ReadToNextSibling("group"));
                                UItoZone.numberOfGroups = i;
                                break;
                        } break;

                    }

                }
            }
        }
	//loads all the objects in the cell
	public void Load()
	{
		if(File.Exists(fileName) && status != CellStatus.active)
		{
			if(positions.Count <= 0 && perlin.Count <= 0)
			{
				positions = new List<Vector2>();
				perlin = new List<float>();

				XmlTextReader reader = new XmlTextReader(fileName);

				while(reader.Read())
				{
					if(reader.IsStartElement() && reader.NodeType == XmlNodeType.Element)
					{
						switch(reader.Name)
						{
							case "AsteroidPosition" :
								positions.Add(new Vector2(float.Parse(reader.GetAttribute(0)), float.Parse(reader.GetAttribute(1))));
								break;

							case "PerlinValue":
								perlin.Add( float.Parse(reader.ReadElementString()));
								break;
						}
					}
				}
				reader.Close ();
			}
			children.Clear ();
			Vector2 indexes = ObjectPool.Pool.Redirect(positions, perlin, this);

			if(indexes.x >= 0 && indexes.x < positions.Count)
			{
				for(int i = (int)indexes.x, j = (int)indexes.y; i < positions.Count && j < perlin.Count; i++,j++)
				{
					GameObject asteroidOBJ = GameObject.Instantiate(Resources.Load("Asteroid/Asteroid")) as GameObject;
					asteroidOBJ.transform.parent = parent.transform;
					Asteroid temp =	asteroidOBJ.AddComponent<Asteroid>();
					temp.assignedPosition = positions[i];
					temp.perlinValue = perlin[j];
					temp.parentCell = this;
					temp.Change();
					children.Add(asteroidOBJ);
					if(ObjectPool.Pool.CanPoolMore())
					{
						ObjectPool.Pool.Register(asteroidOBJ);
					}
				}
			}
		}
	}
    private void ReadText(XmlTextReader reader)
    {
        TransfluentUtility util = TransfluentUtility.GetInstance();

        string textId = null;
        string textString = null;

        while (reader.Read())
        {
            if (reader.IsStartElement())
            {
                //util.AddMessage("Start text entry element: " + reader.Name);

                if (reader.Name.Equals("textId"))
                    textId = reader.ReadString();
                else if (reader.Name.Equals("textString"))
                    textString = reader.ReadString();
                else
                    util.AddWarning("Unexpected element started: " + reader.Name);
            }
            else if (reader.Name.Equals("text"))
            {
                // Done reading this element
                //util.AddMessage("End of text entry");
                break;
            }
            else
                util.AddWarning("Unexpected element closed: " + reader.Name);
        }

        if (textId != null && textString != null)
        {
            //util.AddMessage("XML: Found text entry: Id='" + textId + "', String='" + textString + "'");
            m_texts.Add(textId, textString);
        }
        else
            util.AddError("XML: Error reading text entry: Id='" + textId + "', String='" + textString + "'");
    }
    private void ReadTexts(XmlTextReader reader)
    {
        TransfluentUtility util = TransfluentUtility.GetInstance();

        while (reader.Read())
        {
            if (reader.IsStartElement())
            {
                if (reader.Name.Equals("text"))
                {
                    //util.AddMessage("Text entry found");
                    ReadText(reader);
                }
                else
                    util.AddWarning("Unexpected element started: " + reader.Name);
            }
            else if (reader.Name.Equals("texts"))
            {
                // Done reading texts
                //util.AddMessage("End of texts");
                break;
            }
            else
                util.AddWarning("Unexpected element closed: " + reader.Name);
        }
    }
    //Used for loading saved player information
    public void LoadData()
    {
        XMLFileManager.DecryptFile(savePath);

        XmlReader reader = new XmlTextReader(savePath);
        while(reader.Read())
        {
            if(reader.IsStartElement() && reader.NodeType == XmlNodeType.Element)
            {
                switch(reader.Name)
                {
                    case "deviceID":
                        deviceID = reader.ReadElementString();
                        break;
                    case "ship":
                        ship = reader.ReadElementString();
                        break;
                    case "playerPosition":
                        string[] positions = reader.ReadElementString().Split(',');
                        transform.position = new Vector2(float.Parse(positions[0]), float.Parse(positions[1]) );
                        break;
                    case "maxHealth":
                        maxHealth = int.Parse(reader.ReadElementString());
                        break;
                    case "currentHealth":
                        currentHealth = int.Parse(reader.ReadElementString());
                        break;
                    case "maxShields":
                        maxShields = int.Parse(reader.ReadElementString());
                        break;
                    case "currentShields":
                        currentShields = int.Parse(reader.ReadElementString());
                        break;
                    case "shieldRechargeDelay":
                        shieldRechargeDelay = int.Parse(reader.ReadElementString());
                        break;
                    case "shieldRechargeRate":
                        shieldRechargeRate = int.Parse(reader.ReadElementString());
                        break;
                    case "maxFuel":
                        maxFuel = float.Parse(reader.ReadElementString());
                        break;
                    case "currentFuel":
                        currentFuel = float.Parse(reader.ReadElementString());
                        break;
                    case "fuelConsumptionRate":
                        fuelConsumptionRate = float.Parse(reader.ReadElementString());
                        break;
                    case "acceleration":
                        acceleration = float.Parse(reader.ReadElementString());
                        break;
                    case "speed":
                        speed = float.Parse(reader.ReadElementString());
                        break;
                    case "maxSpeed":
                        maxSpeed = float.Parse(reader.ReadElementString());
                        break;
                    case "thrusterDelay":
                        thrusterDelay = float.Parse(reader.ReadElementString());
                        break;
                    case "rotationSpeed":
                        rotationSpeed = float.Parse(reader.ReadElementString());
                        break;
                    case "currentWeapon":
                        WeaponManager.Instance.ChangeStartUpAmmoType( (WeaponManager.ammoType)Enum.Parse(typeof(WeaponManager.ammoType),reader.ReadElementString()));
                        break;
                    case "currentMaxAmmo":
                        WeaponManager.Instance.MaxAmmo = float.Parse(reader.ReadElementString());
                        break;
                    case "currentAmmo":
                        WeaponManager.Instance.CurrentAmmo = float.Parse(reader.ReadElementString());
                        break;
                    case "beam_MAX":
                        WeaponManager.Instance.totalMaxAmmo[WeaponManager.ammoType.beam] = float.Parse(reader.ReadElementString());
                        break;
                    case "chaser_MAX":
                        WeaponManager.Instance.totalMaxAmmo[WeaponManager.ammoType.chaser] = float.Parse(reader.ReadElementString());
                        break;
                    case "standard_MAX":
                        WeaponManager.Instance.totalMaxAmmo[WeaponManager.ammoType.standard] = float.Parse(reader.ReadElementString());
                        break;
                    case "beam_CURRENT":
                        WeaponManager.Instance.totalCurrentAmmo[WeaponManager.ammoType.beam] = float.Parse(reader.ReadElementString());
                        break;
                    case "chaser_CURRENT":
                        WeaponManager.Instance.totalCurrentAmmo[WeaponManager.ammoType.chaser] = float.Parse(reader.ReadElementString());
                        break;
                    case "standard_CURRENT":
                        WeaponManager.Instance.totalCurrentAmmo[WeaponManager.ammoType.standard] = float.Parse(reader.ReadElementString());
                        break;
                    default:
                        Debug.Log(reader.Name);
                        break;
                }
            }
        }

        reader.Close();

        if(deviceID != SystemInfo.deviceUniqueIdentifier)
        {
            Initialize();
            AutoSave();
        }

        XMLFileManager.EncryptFile(savePath);
    }
Example #47
0
    public void start_load()
    {
        click_col_blocker.SetActive (true);
        foreach (node item in nodes) {
            Destroy (item.gameObject);
        }
        nodes.Clear ();

        WWWForm wwwform = new WWWForm ();
        System.Text.Encoding encoding = new System.Text.UTF8Encoding ();
        Hashtable postHeader = new Hashtable ();
        postHeader.Add ("Content-Type", "text/json");
        int s = 10;
        postHeader.Add ("Content-Length", s);
        wwwform.AddField ("schid", (SLOT_FIELD.GetComponent<Dropdown> ().value + 1).ToString ());
        WWW www = new WWW ("http://h2385854.stratoserver.net/smartsps/get_schematic.php", wwwform);
        StartCoroutine (WaitForRequest (www));

        float t = 0.0f;
        while (!www.isDone) {
        //	Debug.Log ("Downloading XML DataSet: " + t.ToString ());
            t += Time.deltaTime;
            if (t > 60) {
                break;
            }
        }

        //		StringReader textreader = new StringReader (www.text);
        int highes_node_id = 0;
        XmlReader xml_reader = new XmlTextReader ("http://h2385854.stratoserver.net/smartsps/get_schematic.php?schid=" + (SLOT_FIELD.GetComponent<Dropdown> ().value + 1).ToString ());
        List<node_database_information> ndi = new List<node_database_information> ();
        while (xml_reader.Read()) {
            if (xml_reader.IsStartElement ("node")) {
                // get attributes from npc tag
                node_database_information tmp = new node_database_information ();
                tmp.node_id = int.Parse (xml_reader.GetAttribute ("nid"));
                if(tmp.node_id > highes_node_id){highes_node_id = tmp.node_id;}
                tmp.NSI = xml_reader.GetAttribute ("nsi");
                string pos = xml_reader.GetAttribute ("npos");
                tmp.pos_x = float.Parse (pos.Split (',') [0]);
                tmp.pos_y = float.Parse (pos.Split (',') [1]);
                tmp.node_connections = xml_reader.GetAttribute ("ncon");
                tmp.node_parameters = xml_reader.GetAttribute ("nparam");
                ndi.Add (tmp);
                //Debug.Log ("load node : " + tmp.node_id);
            }
        }

        //Debug.Log (ndi.Count + " Nodes loaded");
        id_creator.node_id_count = highes_node_id+1;
        //instanziate them
        for (int j = 0; j < ndi.Count; j++) {
            for (int i = 0; i < input_manager.GetComponent<input_connector>().nodes.Length; i++) {
                //Debug.Log(ndi[j].NSI);
                if (input_manager.GetComponent<input_connector> ().nodes [i].gameObject.GetComponent<node> ().NSI == ndi [j].NSI) {
                    GameObject tmp_to_add = input_manager.GetComponent<input_connector> ().nodes [i].gameObject;
                    tmp_to_add.GetComponent<node>().node_id = ndi [j].node_id;
                    GameObject tmp = (GameObject)Instantiate (tmp_to_add, new Vector3 (ndi [j].pos_x, ndi [j].pos_y, 0.0f), Quaternion.identity);
                    tmp.transform.SetParent (node_parent.transform);
                }
            }
        }

        float t1 = 0.0f;
        while (true) {
            //	Debug.Log ("Downloading XML DataSet: " + t.ToString ());
            t1 += Time.deltaTime;
            if (t1 > 5.0f) {
                break;
            }
        }

        //make konnections
        for (int k = 0; k < ndi.Count; k++) {
            string con_raw = ndi[k].node_connections;
            if(con_raw != ""){
            string[] con_split = con_raw.Split(trenner.ToCharArray());
            //	Debug.Log(	"123123    " + con_split.Length);
            for (int i = 0; i < con_split.Length; i++) {
                    if(con_split[i] == ""){break;}
                string[] con_att = con_split[i].Split(node_con_trenner.ToCharArray());
                int source_node_id = int.Parse (con_att[0]);
                int source_connection_position = int.Parse (con_att[1]);
                int dest_node_id = int.Parse(con_att[2]);
                int dest_connection_position = int.Parse(con_att[3]);
                Debug.Log(source_node_id + "-" + source_connection_position + " nach " + dest_node_id + "-" + dest_connection_position);
                    //source connecion suchen
                    foreach (GameObject con in GameObject.FindGameObjectsWithTag("connection")) {
                        if(con.GetComponent<node_conection>().associated_node == source_node_id && con.GetComponent<node_conection>().connection_position == source_connection_position){
                            Debug.Log("1");
                            //DEST CONNECTION SUCHEN
                            foreach (GameObject dcon in GameObject.FindGameObjectsWithTag("connection")) {
                                if(dcon.GetComponent<node_conection>().associated_node == dest_node_id && dcon.GetComponent<node_conection>().connection_position == dest_connection_position){
                                    Debug.Log("2");
                                    dcon.GetComponent<node_conection>().connection_destination_input_id = con.GetComponent<node_conection>().connection_id;
                                    dcon.GetComponent<node_conection>().redraw_curve();
                                }
                            }
                        }
                    }
            }
            }//ende con != ""
        }

        //SET PARAMETERS
        for (int l = 0; l < ndi.Count; l++) {
            string param_raw = ndi[l].node_parameters;
            if(param_raw != ""){
                string[] param_split = param_raw.Split(trenner.ToCharArray());
                int nid = ndi[l].node_id;
                Debug.Log("pl " +  param_split.Length);
                for (int m = 0; m < nodes.Count; m++) {
                    if(nodes[m].node_id == nid){
                        for (int n = 0; n < nodes[m].parameters.Count; n++) {
                            nodes[m].parameters[n].GetComponent<Text>().text = param_split[n];
                        }
                    }
                }
            }
        }

        click_col_blocker.SetActive (false);
    }
Example #48
0
	private Node LoadNode(string sXML)
	{
		Node ReturnedNode = null;

		if (sXML.Length == 0) return ReturnedNode;

		ReturnedNode = new Node();
		ReturnedNode.TreeView = oTV;

		XmlTextReader tr = new XmlTextReader(sXML, System.Xml.XmlNodeType.Element , null);		

		while (tr.Read())
			if (tr.IsStartElement()) break;

		//nastavi atributy nodu
		for (int i = 0; i < tr.AttributeCount; i++)
		{

			tr.MoveToAttribute(i);

			SetProperty(ReturnedNode, tr.Name, tr.Value);

		}

		bool NextElement = true;


		while (NextElement)
		{
			while (tr.Read())
				if (tr.IsStartElement()) break;

			string ElementName = tr.LocalName;

			if (ElementName.Length == 0) break;

			switch (ElementName.ToUpper())
			{
				case "TEXT" :
					string s = this.LoadMultiLineText(tr.ReadString());
					
					SetProperty(ReturnedNode, "Text", s);

					break;

				case "FLAG" :
					for (int i = 0; i < tr.AttributeCount; i++)
					{
						tr.MoveToAttribute(i);

						SetProperty(ReturnedNode.Flag, tr.Name, tr.Value);
					}
					break;

				case "NODESTYLE" :
					this.LoadObject(ReturnedNode, tr.ReadOuterXml(), ReturnedNode.NodeStyle);
					break;

				case "NODE" :				
					Node n = LoadNode(tr.ReadOuterXml());					
					if (n != null)
					{
						ReturnedNode.Nodes.Add(n);
						//n.Parent = ReturnedNode;
						//n.TreeView = ReturnedNode.TreeView;
					}
					break;

			}
		}

		return ReturnedNode;
	}
Example #49
0
 // Load language file description
 private string LoadFileDesc(string File)
 {
     XmlTextReader xmlr = new XmlTextReader(File);
     xmlr.WhitespaceHandling = WhitespaceHandling.None;
     try {
         while (!xmlr.EOF) {
             xmlr.Read();
             if (xmlr.IsStartElement() && xmlr.Name == "ew-language")
                 return xmlr.GetAttribute("desc");
         }
     }	finally {
         xmlr.Close();
     }
     return "";
 }
Example #50
0
	private void LoadObject(object objParent, string sXML, NodeStyle ns)
	{
		if (sXML.Length == 0) return;

		XmlTextReader tr = new XmlTextReader(sXML, System.Xml.XmlNodeType.Element , null);		

		bool NextElement = true;

		while (NextElement)
		{
			while (tr.Read())
				if (tr.IsStartElement()) break;

			string ElementName = tr.LocalName;

			if (ElementName.Length == 0) break;

			Type t1 = objParent.GetType();			
			
			PropertyInfo pi1 = t1.GetProperty(ElementName);
			
			this.SetPropertyObject(objParent, pi1, tr, ns);

			//hledani koncoveho tagu
			int j = 0;
			while (tr.Read())
				if (tr.LocalName.ToUpper() == ElementName.ToUpper())
				{
					if (tr.IsStartElement()) j++;
					else j--;
			
					if (j == -1) break;
				}
			
			if (tr.ReadState == ReadState.EndOfFile) NextElement = false;						

		}
		
		tr.Close();

		//zpracovani child tagu
		tr = new XmlTextReader(sXML, System.Xml.XmlNodeType.Element , null);

		NextElement = true;

		while (NextElement)
		{
			while (tr.Read())
				if (tr.IsStartElement()) break;

			string ElementName = tr.LocalName;

			if (ElementName.Length == 0) break;

			Type t1 = objParent.GetType();
			
			PropertyInfo pi1 = t1.GetProperty(ElementName);			

			object obj = (System.Type.GetType(pi1.GetType().Name));
			obj = pi1.GetValue(objParent,null);
			
			this.LoadObject(obj, tr.ReadInnerXml(), ns);

		}

		tr.Close();

	}
Example #51
0
 // Convert XML to Collection
 private void XmlToCollection(string File)
 {
     string Key = "/";
     string Id;
     string Name;
     int Index;
     XmlTextReader xmlr = new XmlTextReader(File);
     xmlr.WhitespaceHandling = WhitespaceHandling.None;
     try {
         while (!xmlr.EOF) {
             xmlr.Read();
             Name = xmlr.Name;
             Id = xmlr.GetAttribute("id");
             if (Name == "ew-language")
                 continue;
             switch (xmlr.NodeType) {
                 case XmlNodeType.Element:
                     if (xmlr.IsStartElement() && !xmlr.IsEmptyElement) {
                         Key += Name + "/";
                         if (Id != null)
                             Key += Id + "/";
                     }
                     if (Id != null && xmlr.IsEmptyElement) {	// phrase
                         Id = Name + "/" + Id;
                         if (xmlr.GetAttribute("client") == "1")
                             Id += "/1";
                         if (Id != null)
                             Col[Key + Id] = xmlr.GetAttribute("value");
                     }
                     break;
                 case XmlNodeType.EndElement:
                     Index = Key.LastIndexOf("/" + Name + "/");
                     if (Index > -1)
                         Key = Key.Substring(0, Index + 1);
                     break;
             }
         }
     }	finally {
         xmlr.Close();
     }
 }
    /// <summary>
    /// Gets the created worlds.
    /// </summary>
    /// <returns>The created worlds.</returns>
    public static List<WorldSpecs> GetCreatedWorlds()
    {
        if(File.Exists(directory + "CreatedWorlds.xml"))
        {
            List<WorldSpecs> existingSpecs = new List<WorldSpecs> ();
            XmlTextReader reader = new XmlTextReader(directory + "CreatedWorlds.xml");

            while(reader.Read())
            {
                if(reader.IsStartElement() && reader.NodeType == XmlNodeType.Element)
                {
                    switch(reader.Name)
                    {
                        case "WorldSpec":
                            if(reader.AttributeCount >= 10)
                            {
                                WorldSpecs tempSpec = new WorldSpecs();
                                tempSpec.spaceName = reader.GetAttribute(0);
                                tempSpec.spaceArea = int.Parse(reader.GetAttribute(1));
                                tempSpec.mapLength = int.Parse(reader.GetAttribute(2));
                                tempSpec.cellLength = float.Parse(reader.GetAttribute(3));
                                tempSpec.start = new Vector2(float.Parse(reader.GetAttribute(4)),float.Parse(reader.GetAttribute(5)));
                                tempSpec.degreeJumpStep = float.Parse(reader.GetAttribute(6));
                                tempSpec.subdivisions = int.Parse(reader.GetAttribute(7));
                                tempSpec.totalNumberOfCells = int.Parse(reader.GetAttribute(8));
                                tempSpec.seed = int.Parse(reader.GetAttribute(9));
                                tempSpec.planetPositions = new Vector2[(reader.AttributeCount - 10) / 2];
                                if(reader.AttributeCount > 11)
                                {
                                    float maxPosition = (reader.AttributeCount - 10)/2.0f;
                                    int maxP = Mathf.CeilToInt(maxPosition);
                                    for(int i = 0, j = 0; j < maxP; j++)
                                    {
                                        tempSpec.planetPositions[j].Set(float.Parse(reader.GetAttribute(i+10)), float.Parse(reader.GetAttribute(i+11)));
                                     	i+= 2;
                                    }
                                }
                                existingSpecs.Add(tempSpec);
                            }
                            else
                            {
                                Debug.Log("Data is missing from 1 of the worlds. Not Saving it anymore");
                            }
                            break;
                        case "Root":
                            break;
                        default:
                            Debug.Log(reader.Name + " : possible invalid data in save file ignoring, please review file");
                            break;
                    }
                }
            }

            reader.Close();
            return existingSpecs;
        }
        else
        {
            return new List<WorldSpecs>(1);
        }
    }
    // Charge l'objectif id du fichier XML au chemin path dans l'objectif courant
    void load(string path, int id)
    {
        // Variables servant à récupérer l'information
        int tag = 0;
        Vector2 coords = new Vector2 ();
        Regex coordRegexX = new Regex (@"[0-9]+,[0-9]+;$");
        Match coordMatchX;
        Regex coordRegexY = new Regex (@";[0-9]+,[0-9]+$");
        Match coordMatchY;

        //Variable de test
        Boolean aTrouve = false;

        XmlTextReader myXmlTextReader = new XmlTextReader (path);
        while(myXmlTextReader.Read()){
            if(myXmlTextReader.IsStartElement() && myXmlTextReader.Name == "objectifs")
            {
                Debug.Log(nbObjectifs);
                nbObjectifs = int.Parse(myXmlTextReader.GetAttribute("number"));
                Debug.Log(nbObjectifs);
            }
            if(myXmlTextReader.IsStartElement() && myXmlTextReader.Name == "objectif"){
                if (int.Parse(myXmlTextReader.GetAttribute("id")) == id){

                    aTrouve = true;
                    ObjectifId = id;
                    initialObjective.description = myXmlTextReader.GetAttribute("description");
                    currentObjective.description = myXmlTextReader.GetAttribute("description");

                    tag = int.Parse(myXmlTextReader.GetAttribute("tag"));

                    //Si le tag est 10, il s'agit d'un blend de caméra
                    if(tag == 14)
                    {
                        StartCoroutine(waitObjectif(float.Parse(myXmlTextReader.GetAttribute("time"))));
                        currentObjective.tableDesObjectifs.Add(tag, -1);
                        return;
                    }
                    else if(tag == 10)
                    {
                        Debug.Log("Blend");
                        currentObjective.tableDesObjectifs.Add(tag, -1);

                        float x = float.Parse(myXmlTextReader.GetAttribute("x"));
                        float y = float.Parse(myXmlTextReader.GetAttribute("y"));
                        float z = float.Parse(myXmlTextReader.GetAttribute("z"));

                        float duration = float.Parse(myXmlTextReader.GetAttribute("duration"));
                        float size = float.Parse(myXmlTextReader.GetAttribute("size"));

                        bool enableControlAfter =  bool.Parse(myXmlTextReader.GetAttribute("enableControlAfter"));

                        StartCoroutine(CameraControl.BlendCameraTo(new Vector3(x,y,z),size,duration,enableControlAfter));

                    }
                    else if(tag == 11) // Si c'est 11, il s'agit d'un affichage de panneau
                    {
                        currentObjective.tableDesObjectifs.Add(tag, -1);

                        string learning = myXmlTextReader.GetAttribute("learning");
                        GameObject panelLearning = GameObject.Find(learning);
                        if (panelLearning != null)
                        {
                            if(panelLearning.GetComponent<PanelController>()!= null)
                                panelLearning.GetComponent<PanelController> ().isPanelActive = true;
                        }
                        else
                        {
                            Debug.Log("Panneau Learning " + learning +" non trouvé, penser à activer l'objet !");
                            loadNextObjectif();
                            return;
                        }
                    }
                    else if(tag == 8)
                    {
                        initialObjective.tableDesObjectifs.Add(tag, (int)int.Parse(myXmlTextReader.GetAttribute("value")));
                        currentObjective.tableDesObjectifs.Add(tag, 0);

                        string cutsceneName = myXmlTextReader.GetAttribute("cutsceneName");
                        GameObject cutscene = GameObject.Find(cutsceneName);
                        if(cutscene != null)
                        {
                            Cutscene scriptCutscene = cutscene.GetComponent<Cutscene>();
                            if(scriptCutscene != null)
                                cutscene.GetComponent<Cutscene>().enabled = true;
                            else
                            {
                                Debug.Log("Aucun script cutscene n'est attaché à l'objet");
                                loadNextObjectif();
                                return;
                            }
                        }
                        else
                        {
                            Debug.Log("Cutscene " + cutsceneName +" non trouvé, penser à activer l'objet !");
                            loadNextObjectif();
                            return;
                        }

                    }
                    else if(tag == 0 || tag == 1 || tag == 3 || tag == 4 || tag == 6 || tag == 7 || tag == 9 || tag == 12 || tag == 13)
                    { // Si on a ces tags, on a forcément un int dans value
                        initialObjective.tableDesObjectifs.Add(tag, (int)int.Parse(myXmlTextReader.GetAttribute("value")));
                        currentObjective.tableDesObjectifs.Add(tag, 0);
                        break;
                    }
                    else if(tag == 2)
                    { // Pour le tag 2, on récupère un vector2 dans value sous forme "float;float"
                        coordMatchX = coordRegexX.Match(myXmlTextReader.GetAttribute("value"));
                        coordMatchY = coordRegexY.Match(myXmlTextReader.GetAttribute("value"));
                        coords.Set(float.Parse(coordMatchX.Value), float.Parse(coordMatchY.Value));
                        initialObjective.tableDesObjectifs.Add(tag, (Vector2)coords);
                        currentObjective.tableDesObjectifs.Add(tag, (Vector2)coords);
                        break;
                    }
                    else if(tag == 5)
                    { // Pour le tag 5 on a un float dans value
                        initialObjective.tableDesObjectifs.Add(tag, (float)float.Parse(myXmlTextReader.GetAttribute("value")));
                        currentObjective.tableDesObjectifs.Add(tag, (float)float.Parse(myXmlTextReader.GetAttribute("value")));
                        StartCoroutine(TimeObjectif());
                        break;
                    }
                }
            }
        }

        if (aTrouve) {
            //StartCoroutine(GameManager.gameManager.GetComponent<LevelBacteriaManager>().makeTransition (1, 1));
        } else {
            Debug.Log ("N'a pas trouvé.\n");
        }
    }
Example #54
0
    public void LoadData()
    {
        int setIndex = 0;

        if (!File.Exists(savePath))
        {
            Debug.Log("PlayerInfo.xml not found @ " + savePath);
            return;
        }
        else
        {
            Debug.Log("Loading PlayerInfo.xml @ \n" + savePath);
        }

        XmlReader reader = new XmlTextReader (savePath);

        items.Clear();

        while (reader.Read())
        {
            if (reader.IsStartElement() && reader.NodeType == XmlNodeType.Element)
            {
                switch (reader.Name)
                {
                    case "bDisplayTutorial":
                    {
                        bDisplayTutorial = bool.Parse(reader.ReadElementString());
                        break;
                    }
                    case "CurrentScene":
                    {
                        currentScene = reader.ReadElementString();
                        break;
                    }
                    case "PlayerPos":
                    {
                        float x = float.Parse(reader.GetAttribute(0));
                        float y = float.Parse(reader.GetAttribute(1));
                        float z = float.Parse(reader.GetAttribute(2));

                        playerPos = new Vector3 (x, y, z);
                        break;
                    }
                    case "CameraPos":
                    {
                        float x = float.Parse(reader.GetAttribute(0));
                        float y = float.Parse(reader.GetAttribute(1));
                        float z = float.Parse(reader.GetAttribute(2));

                        cameraPos = new Vector3 (x, y, z);
                        break;
                    }
                    case "Item":
                    {
                        items.Add(new Item());
                        setIndex = items.Count - 1;
                        break;
                    }
                    case "ItemName":
                    {
                        items[setIndex].itemName = reader.ReadElementString();
                        break;
                    }
                    case "ItemID":
                    {
                        items[setIndex].itemID = int.Parse(reader.ReadElementString());
                        break;
                    }
                    case "ItemDescription":
                    {
                        items[setIndex].itemDescription = reader.ReadElementString();
                        break;
                    }
                    case "SpriteName":
                    {
                        items[setIndex].spriteName = reader.ReadElementString();
                        break;
                    }
                    case "HasItem":
                    {
                        items[setIndex].hasItem = bool.Parse(reader.ReadElementString());
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
        }
    }
Example #55
0
	private bool GetCharacterInfo(char m_character, ref CustomCharacterInfo char_info)
	{
		if (m_character.Equals('\n') || m_character.Equals('\r'))
			return true;

#if !UNITY_3_5
		if (m_font != null)
		{
			if (!m_current_font_name.Equals(m_font.name))
			{
				// Recalculate font's baseline value
				// Checks through all available alpha characters and uses the most common bottom y_axis value as the baseline for the font.

				var baseline_values = new Dictionary<float, int>();
				float baseline;
				foreach (var character in m_font.characterInfo)
					// only check alpha characters (a-z, A-Z)
					if ((character.index >= 97 && character.index < 123) || (character.index >= 65 && character.index < 91))
					{
						baseline = -character.vert.y - character.vert.height;
						if (baseline_values.ContainsKey(baseline))
							baseline_values[baseline] ++;
						else
							baseline_values[baseline] = 1;
					}

				// Find most common baseline value used by the letters
				var idx = 0;
				int highest_num = 0, highest_idx = -1;
				float most_common_baseline = -1;
				foreach (var num in baseline_values.Values)
				{
					if (highest_idx == -1 || num > highest_num)
					{
						highest_idx = idx;
						highest_num = num;
					}
					idx++;
				}

				// Retrieve the most common value and use as baseline value
				idx = 0;
				foreach (var baseline_key in baseline_values.Keys)
				{
					if (idx == highest_idx)
					{
						most_common_baseline = baseline_key;
						break;
					}
					idx++;
				}

				m_font_baseline = most_common_baseline;

				// Set font name to current, to ensure this check doesn't happen each time
				m_current_font_name = m_font.name;
			}

			var font_char_info = new CharacterInfo();
			m_font.GetCharacterInfo(m_character, out font_char_info);

			char_info.flipped = font_char_info.flipped;
			char_info.uv = font_char_info.uv;
			char_info.vert = font_char_info.vert;
			char_info.width = font_char_info.width;

			// Scale char_info values
			char_info.vert.x /= FontScale;
			char_info.vert.y /= FontScale;
			char_info.vert.width /= FontScale;
			char_info.vert.height /= FontScale;
			char_info.width /= FontScale;

			if (font_char_info.width == 0)
				// Invisible character info returned because character is not contained within the font
				Debug.LogWarning("Character '" + GetHumanReadableCharacterString(m_character) + "' not found. Check that font '" + m_font.name + "' supports this character.");

			return true;
		}
#endif

		if (m_font_data_file != null)
		{
			if (m_custom_font_data == null || !m_font_data_file.name.Equals(m_current_font_data_file_name))
				// Setup m_custom_font_data for the custom font.
#if !UNITY_WINRT
				if (m_font_data_file.text.Substring(0, 5).Equals("<?xml"))
				{
					// Text file is in xml format

					m_current_font_data_file_name = m_font_data_file.name;
					m_custom_font_data = new CustomFontCharacterData();

					var reader = new XmlTextReader(new StringReader(m_font_data_file.text));

					var texture_width = 0;
					var texture_height = 0;
					int uv_x, uv_y;
					float width, height, xoffset, yoffset, xadvance;
					CustomCharacterInfo character_info;

					while (reader.Read())
						if (reader.IsStartElement())
							if (reader.Name.Equals("common"))
							{
								texture_width = int.Parse(reader.GetAttribute("scaleW"));
								texture_height = int.Parse(reader.GetAttribute("scaleH"));

								m_font_baseline = int.Parse(reader.GetAttribute("base"));
							}
							else if (reader.Name.Equals("char"))
							{
								uv_x = int.Parse(reader.GetAttribute("x"));
								uv_y = int.Parse(reader.GetAttribute("y"));
								width = float.Parse(reader.GetAttribute("width"));
								height = float.Parse(reader.GetAttribute("height"));
								xoffset = float.Parse(reader.GetAttribute("xoffset"));
								yoffset = float.Parse(reader.GetAttribute("yoffset"));
								xadvance = float.Parse(reader.GetAttribute("xadvance"));

								character_info = new CustomCharacterInfo();
								character_info.flipped = false;
								character_info.uv = new Rect(uv_x / (float)texture_width, 1 - (uv_y / (float)texture_height) - height / texture_height, width / texture_width, height / texture_height);
								character_info.vert = new Rect(xoffset, -yoffset, width, -height);
								character_info.width = xadvance;

								m_custom_font_data.m_character_infos.Add(int.Parse(reader.GetAttribute("id")), character_info);
							}
				}
				else
#endif
					if (m_font_data_file.text.Substring(0, 4).Equals("info"))
					{
						// Plain txt format
						m_current_font_data_file_name = m_font_data_file.name;
						m_custom_font_data = new CustomFontCharacterData();

						var texture_width = 0;
						var texture_height = 0;
						int uv_x, uv_y;
						float width, height, xoffset, yoffset, xadvance;
						CustomCharacterInfo character_info;
						string[] data_fields;

						var text_lines = m_font_data_file.text.Split('\n');

						foreach (var font_data in text_lines)
							if (font_data.Length >= 5 && font_data.Substring(0, 5).Equals("char "))
							{
								// character data line
								data_fields = ParseFieldData(font_data, new[] { "id=", "x=", "y=", "width=", "height=", "xoffset=", "yoffset=", "xadvance=" });
								uv_x = int.Parse(data_fields[1]);
								uv_y = int.Parse(data_fields[2]);
								width = float.Parse(data_fields[3]);
								height = float.Parse(data_fields[4]);
								xoffset = float.Parse(data_fields[5]);
								yoffset = float.Parse(data_fields[6]);
								xadvance = float.Parse(data_fields[7]);

								character_info = new CustomCharacterInfo();
								character_info.flipped = false;
								character_info.uv = new Rect(uv_x / (float)texture_width, 1 - (uv_y / (float)texture_height) - height / texture_height, width / texture_width, height / texture_height);
								character_info.vert = new Rect(xoffset, -yoffset + 1, width, -height);
								character_info.width = xadvance;

								m_custom_font_data.m_character_infos.Add(int.Parse(data_fields[0]), character_info);
							}
							else if (font_data.Length >= 6 && font_data.Substring(0, 6).Equals("common"))
							{
								data_fields = ParseFieldData(font_data, new[] { "scaleW=", "scaleH=", "base=" });
								texture_width = int.Parse(data_fields[0]);
								texture_height = int.Parse(data_fields[1]);

								m_font_baseline = int.Parse(data_fields[2]);
							}
					}

			if (m_custom_font_data.m_character_infos.ContainsKey(m_character))
			{
				m_custom_font_data.m_character_infos[m_character].ScaleClone(FontScale, ref char_info);

				return true;
			}
		}

		return false;
	}