Ejemplo n.º 1
0
 public static SymbolDictionary Create(string name, string defaultContents)
 {
     lock ( locker) {
         string storageFolder  = Factory.Settings["AppDataFolder"];
         string dictionaryPath = storageFolder + @"\Dictionary\" + name + ".tzdict";
         Directory.CreateDirectory(Path.GetDirectoryName(dictionaryPath));
         SymbolDictionary dictionary;
         if (File.Exists(dictionaryPath))
         {
             using (StreamReader streamReader = new StreamReader(new FileStream(dictionaryPath, FileMode.Open, FileAccess.Read, FileShare.Read))) {
                 dictionary = SymbolDictionary.Create(streamReader);
             }
             return(dictionary);
         }
         else
         {
             string contents = BeautifyXML(defaultContents);
             using (StreamWriter sw = new StreamWriter(dictionaryPath))
             {
                 // Add some text to the file.
                 sw.Write(contents);
             }
             Thread.Sleep(1000);
             dictionary = SymbolDictionary.Create(new StreamReader(dictionaryPath));
         }
         return(dictionary);
     }
 }
Ejemplo n.º 2
0
 public static SymbolDictionary Create(TextReader projectXML)
 {
     lock ( locker) {
         SymbolDictionary project = new SymbolDictionary();
         project.Load(projectXML);
         return(project);
     }
 }
Ejemplo n.º 3
0
        public SymbolLibrary()
        {
            SymbolDictionary dictionary           = SymbolDictionary.Create("universal", SymbolDictionary.UniversalDictionary);
            IEnumerable <SymbolProperties> enumer = dictionary;

            symbolMap = new Dictionary <string, SymbolProperties>();
            foreach (SymbolProperties symbolProperties in dictionary)
            {
                symbolMap[symbolProperties.Symbol] = symbolProperties;
            }
            dictionary = SymbolDictionary.Create("user", SymbolDictionary.UserDictionary);
            foreach (SymbolProperties symbolProperties in dictionary)
            {
                symbolMap[symbolProperties.Symbol] = symbolProperties;
            }
            AddAbbreviations();
            AdjustSessions();
            CreateUniversalIds();
        }