示例#1
0
		public static FileInfo Export(ClilocLNG lng)
		{
			if (lng == ClilocLNG.NULL)
			{
				lng = DefaultLanguage;
			}

			var list = new XmlDataStore<int, ClilocData>(VitaNexCore.DataDirectory + "/Exported Clilocs/", lng.ToString());
			ClilocTable table = Tables[lng];

			list.OnSerialize = doc =>
			{
				XmlNode node;
				XmlCDataSection cdata;
				ClilocInfo info;

				XmlNode root = doc.CreateElement("clilocs");

				XmlAttribute attr = doc.CreateAttribute("len");
				attr.Value = table.Count.ToString(CultureInfo.InvariantCulture);

				if (root.Attributes != null)
				{
					root.Attributes.Append(attr);
				}

				attr = doc.CreateAttribute("lng");
				attr.Value = table.Language.ToString();

				if (root.Attributes != null)
				{
					root.Attributes.Append(attr);
				}

				foreach (ClilocData d in table.Where(d => d.Length > 0))
				{
					info = d.Lookup(table.InputFile, true);

					if (info == null || String.IsNullOrWhiteSpace(info.Text))
					{
						continue;
					}

					node = doc.CreateElement("cliloc");

					attr = doc.CreateAttribute("idx");
					attr.Value = d.Index.ToString(CultureInfo.InvariantCulture);

					if (node.Attributes != null)
					{
						node.Attributes.Append(attr);
					}

					attr = doc.CreateAttribute("len");
					attr.Value = d.Length.ToString(CultureInfo.InvariantCulture);

					if (node.Attributes != null)
					{
						node.Attributes.Append(attr);
					}

					cdata = doc.CreateCDataSection(info.Text);
					node.AppendChild(cdata);

					root.AppendChild(node);
				}

				doc.AppendChild(root);
				table.Clear();

				return true;
			};

			list.Export();
			list.Clear();

			return list.Document;
		}
示例#2
0
        public static FileInfo Export(ClilocLNG lng)
        {
            if (lng == ClilocLNG.NULL)
            {
                lng = DefaultLanguage;
            }

            var list  = new XmlDataStore <int, ClilocData>(VitaNexCore.DataDirectory + "/Exported Clilocs/", lng.ToString());
            var table = Tables[lng];

            list.OnSerialize = doc =>
            {
                XmlNode         node;
                XmlCDataSection cdata;
                ClilocInfo      info;

                XmlNode root = doc.CreateElement("clilocs");

                var attr = doc.CreateAttribute("len");
                attr.Value = table.Count.ToString(CultureInfo.InvariantCulture);

                if (root.Attributes != null)
                {
                    root.Attributes.Append(attr);
                }

                attr       = doc.CreateAttribute("lng");
                attr.Value = table.Language.ToString();

                if (root.Attributes != null)
                {
                    root.Attributes.Append(attr);
                }

                foreach (var d in table.Where(d => d.Length > 0))
                {
                    info = d.Lookup(table.InputFile, true);

                    if (info == null || String.IsNullOrWhiteSpace(info.Text))
                    {
                        continue;
                    }

                    node = doc.CreateElement("cliloc");

                    attr       = doc.CreateAttribute("idx");
                    attr.Value = d.Index.ToString(CultureInfo.InvariantCulture);

                    if (node.Attributes != null)
                    {
                        node.Attributes.Append(attr);
                    }

                    attr       = doc.CreateAttribute("len");
                    attr.Value = d.Length.ToString(CultureInfo.InvariantCulture);

                    if (node.Attributes != null)
                    {
                        node.Attributes.Append(attr);
                    }

                    cdata = doc.CreateCDataSection(info.Text);
                    node.AppendChild(cdata);

                    root.AppendChild(node);
                }

                doc.AppendChild(root);
                table.Clear();

                return(true);
            };

            list.Export();
            list.Clear();

            return(list.Document);
        }