当前位置: 首页>>代码示例>>C#>>正文


C# Catalog.Load方法代码示例

本文整理汇总了C#中Catalog.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Catalog.Load方法的具体用法?C# Catalog.Load怎么用?C# Catalog.Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Catalog的用法示例。


在下文中一共展示了Catalog.Load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public void Run()
        {
            Catalog catalog = new Catalog();
            foreach(string fileName in Options.InputFiles)
            {
                Catalog temp = new Catalog();
                temp.Load(fileName);
                catalog.Append(temp);
            }

            using (ResourceWriter writer = new ResourceWriter(Options.OutFile))
            {
                foreach (CatalogEntry entry in catalog)
                {
                    try
                    {
                        writer.AddResource(entry.Key, entry.IsTranslated ? entry.GetTranslation(0) : entry.String);
                    }
                    catch (Exception e)
                    {
                        string message = String.Format("Error adding item {0}", entry.String);
                        if (!String.IsNullOrEmpty(entry.Context))
                            message = String.Format("Error adding item {0} in context '{1}'",
                                                    entry.String, entry.Context);
                        throw new Exception(message, e);
                    }
                }
                writer.Generate();
            }
        }
开发者ID:rzaitov,项目名称:GetTextNet,代码行数:30,代码来源:ResourcesGen.cs

示例2: ParsingTest

        public void ParsingTest()
        {
            Catalog cat = new Catalog();
            cat.Load("./Data/Test01.po");

            Assert.AreEqual(6, cat.Count, "Entries count");
            Assert.AreEqual(3, cat.PluralFormsCount, "Plurals entries count");

            int nonTranslatedCount = 0;
            int ctx = 0;
            foreach(CatalogEntry entry in cat)
            {
                if (!entry.IsTranslated)
                    nonTranslatedCount++;
                if (entry.HasPlural)
                {
                    Assert.AreEqual("{0} ошибка найдена", entry.GetTranslation(0));
                    Assert.AreEqual("{0} ошибки найдены", entry.GetTranslation(1));
                    Assert.AreEqual("{0} ошибок найдено", entry.GetTranslation(2));
                }
                if (entry.HasContext)
                    ctx++;
            }

            Assert.AreEqual(1, nonTranslatedCount, "Non translated strings count");
            Assert.AreEqual(2, ctx, "Contextes count");
        }
开发者ID:rzaitov,项目名称:GetTextNet,代码行数:27,代码来源:CatalogTest.cs

示例3: CatalogParseTest

        public void CatalogParseTest()
        {
            Catalog cat = new Catalog();
            cat.Load("./Data/Test01.po");

            PluralFormsCalculator pfc = PluralFormsCalculator.Make(cat.GetPluralFormsHeader());
            Assert.IsNotNull(pfc, "Parse failed");
            Assert.AreEqual(3, pfc.NPlurals, "Plurals count");

            Assert.AreEqual(0, pfc.Evaluate(1), "Case 1");
            Assert.AreEqual(1, pfc.Evaluate(3), "Case 2");
            Assert.AreEqual(2, pfc.Evaluate(7), "Case 3");
        }
开发者ID:rzaitov,项目名称:GetTextNet,代码行数:13,代码来源:PluralFormsTest.cs

示例4: Run

 public void Run()
 {
     catalog = new Catalog();
     catalog.Load(Options.InputFiles[0]);
     for(int i = 1; i < Options.InputFiles.Count; i++)
     {
         Catalog temp = new Catalog();
         temp.Load(Options.InputFiles[i]);
         catalog.Append(temp);
     }
     Check();
     Generate();
     SaveToFile();
     Compile();
     if (!Options.DebugMode)
         File.Delete(CsharpSourceFileName);
 }
开发者ID:rzaitov,项目名称:GetTextNet,代码行数:17,代码来源:AssemblyGen.cs

示例5: RemoveEntry

		public void RemoveEntry (string msgstr)
		{
			foreach (Translation translation in this.Translations) {
				string poFileName  = translation.PoFile;
				Catalog catalog = new Catalog (this);
				catalog.Load (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), poFileName);
				CatalogEntry entry = catalog.FindItem (msgstr);
				if (entry != null) {
					catalog.RemoveItem (entry);
					catalog.Save (poFileName);
				}
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:13,代码来源:TranslationProject.cs

示例6: Reload

		void Reload ()
		{
			Catalog newCatalog = new Catalog(project);
			newCatalog.Load (null, catalog.FileName);
			this.Catalog = newCatalog;
			UpdateTasks ();
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:POEditorWidget.cs

示例7: Initialize

        /// <summary>
        /// Inicializa leyendo todos los archivos *.sec en el directorio \section
        /// Se tiene que llamar después de crear Model
        /// </summary>
        public void Initialize(ref Catalog<Canguro.Model.Section.Section> modelSections)
        {
            catalogs.Clear();

            if (this["modelCatalog"] == null)
                this["modelCatalog"] = new Catalog<Canguro.Model.Section.Section>();
            modelSections = this["modelCatalog"];
            modelSections[DefaultFrameSection.Name] = DefaultFrameSection;

            // Create a reference to the current directory.
            DirectoryInfo di = new DirectoryInfo(System.Windows.Forms.Application.StartupPath + @"\RuntimeData\section");

            if (!di.Exists)
                di = new DirectoryInfo(@"section");

            // Create an array representing the files in the current directory.
            FileInfo[] fi = di.GetFiles();

            //Console.WriteLine("The following files exist in the current directory:");
            // Print out the names of the files in the current directory.
            foreach (FileInfo fiTemp in fi)
            {
                //                Console.WriteLine(fiTemp.Name);
                try
                {
                    if (fiTemp.Extension.Equals(".sec"))
                    {
                        Catalog<Section> tmp = new Catalog<Section>();
                        tmp.Load(fiTemp.FullName);
                        if (!catalogs.ContainsKey(tmp.Name))
                        {
                            catalogs.Add(tmp.Name, tmp);
                            tmp.CatalogChanged += new EventHandler(oneCatalogChanged);
                        }
                    }
                    else if (fiTemp.Extension.Equals(".txt"))
                    {
                        string name = fiTemp.Name;
                        name = name.Substring(0, name.Length - 4);
                        Catalog<Section> tmp = new Catalog<Section>(name, false);
                        LoadTxtCatalog(tmp, fiTemp.FullName);
                        if (!catalogs.ContainsKey(tmp.Name))
                        {
                            catalogs.Add(tmp.Name, tmp);
                            tmp.CatalogChanged += new EventHandler(oneCatalogChanged);
                        }
                        tmp.IsReadOnly = true;
                        //tmp.Save(fiTemp.Directory + "\\" + tmp.Name + ".sec");
                    }
                    else if (fiTemp.Extension.Equals(".xsec"))
                    {
                        if (!catalogs.ContainsKey(Culture.Get("userSectionsCatalog")))
                            catalogs.Add(Culture.Get("userSectionsCatalog"), new Catalog<Section>(Culture.Get("userSectionsCatalog"), false));
                        LoadXmlSections(fiTemp.FullName, catalogs[Culture.Get("userSectionsCatalog")]);
                    }
                }
                catch (System.IO.FileNotFoundException e)
                {
                    // Reconstruir catálogo
                    throw e;
                }
            }
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:67,代码来源:SectionManager.cs


注:本文中的Catalog.Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。