Ejemplo n.º 1
0
 public static void enchant_dict_remove(SafeDictionaryHandle dict, string word)
 {
     using (Utf8Marshaller utf8Word = new Utf8Marshaller(word))
     {
         enchant_dict_remove(dict, utf8Word.MarshalledValue, utf8Word.MarshalledSize);
     }
 }
Ejemplo n.º 2
0
 public static int enchant_dict_check(SafeDictionaryHandle dict, string word)
 {
     using (Utf8Marshaller utf8Word = new Utf8Marshaller(word))
     {
         return(enchant_dict_check(dict, utf8Word.MarshalledValue, utf8Word.MarshalledSize));
     }
 }
Ejemplo n.º 3
0
        private Dictionary CreatePwlDictionary(string pwlFile)
        {
            SafeDictionaryHandle handle = Bindings.enchant_broker_request_pwl_dict(this._handle, pwlFile);

            VerifyNoErrors();
            if (handle.IsInvalid)
            {
                throw new ApplicationException("Unable to create pwl file " + pwlFile);
            }
            return(CreateAndRegisterDictionary(handle, this._pwlDictionaryCache, pwlFile));
        }
Ejemplo n.º 4
0
 internal Dictionary(SafeDictionaryHandle handle)
 {
     if (handle == null)
     {
         throw new ArgumentNullException("handle");
     }
     if (handle.IsInvalid)
     {
         throw new ArgumentException("handle is invalid");
     }
     _handle = handle;
 }
Ejemplo n.º 5
0
		internal Dictionary(SafeDictionaryHandle handle)
		{
			if (handle == null)
			{
				throw new ArgumentNullException("handle");
			}
			if (handle.IsInvalid)
			{
				throw new ArgumentException("handle is invalid");
			}
			_handle = handle;
		}
Ejemplo n.º 6
0
        private Dictionary CreateDictionary(string language_tag)
        {
            SafeDictionaryHandle handle = Bindings.enchant_broker_request_dict(this._handle, language_tag);

            VerifyNoErrors();
            if (handle.IsInvalid)
            {
                throw new ApplicationException("There is no provider that supplies a dictionary for " + language_tag);
            }

            return(CreateAndRegisterDictionary(handle, this._dictionaryCache, language_tag));
        }
Ejemplo n.º 7
0
        private Dictionary CreateAndRegisterDictionary(SafeDictionaryHandle handle, IDictionary <string, WeakReference> cache, string language_tag)
        {
            Dictionary dictionary;

            dictionary           = new Dictionary(handle);
            dictionary.Disposed += OnDictionaryDisposed;
            // always store the dictionaries we have created
            // so that we can dispose of them cleanly and give a
            // better error message (ObjectDisposed) instead of a crash
            // if someone tries to use a dictionary after the broker
            // that created it has been disposed.
            cache[language_tag] = new WeakReference(dictionary);
            return(dictionary);
        }
Ejemplo n.º 8
0
 public static void enchant_dict_store_replacement(SafeDictionaryHandle dict,
                                                   string mis,
                                                   string cor)
 {
     using (
         Utf8Marshaller utf8Mis = new Utf8Marshaller(mis),
         utf8Cor = new Utf8Marshaller(cor))
     {
         enchant_dict_store_replacement(dict,
                                        utf8Mis.MarshalledValue,
                                        utf8Mis.MarshalledSize,
                                        utf8Cor.MarshalledValue,
                                        utf8Cor.MarshalledSize);
     }
 }
Ejemplo n.º 9
0
        public static List <string> enchant_dict_suggest(SafeDictionaryHandle dict, string word)
        {
            int    suggsCount;
            IntPtr suggs;

            using (Utf8Marshaller utf8Word = new Utf8Marshaller(word))
            {
                suggs =
                    enchant_dict_suggest(dict,
                                         utf8Word.MarshalledValue,
                                         utf8Word.MarshalledSize,
                                         out suggsCount);
            }
            List <string> result = Utf8Marshaller.MarshalFromUtf8Array(suggs, suggsCount);

            enchant_dict_free_string_list(dict, suggs);
            return(result);
        }
Ejemplo n.º 10
0
 public static void enchant_dict_describe(SafeDictionaryHandle dict,
                                          EnchantDictDescribeDelegate describe)
 {
     enchant_dict_describe(dict,
                           delegate(IntPtr lang_tag,
                                    IntPtr provider_name,
                                    IntPtr provider_desc,
                                    IntPtr provider_dll_file,
                                    IntPtr user_data)
     {
         ProviderInfo provider =
             new ProviderInfo(
                 Utf8Marshaller.MarshalFromUtf8(provider_name),
                 Utf8Marshaller.MarshalFromUtf8(provider_desc),
                 Utf8Marshaller.MarshalFromUtf8(provider_dll_file));
         DictionaryInfo dictionary =
             new DictionaryInfo(
                 Utf8Marshaller.MarshalFromUtf8(lang_tag),
                 provider);
         describe(dictionary);
     },
                           IntPtr.Zero);
 }
Ejemplo n.º 11
0
 private static extern void enchant_dict_free_string_list(SafeDictionaryHandle dict,
                                                          IntPtr string_list);
Ejemplo n.º 12
0
        private static extern void enchant_dict_describe(SafeDictionaryHandle dict,
																										 [MarshalAs(UnmanagedType.FunctionPtr)] EnchantDictDescribeFn
																											 enchantDictDescribeFn,
																										 IntPtr user_data);
Ejemplo n.º 13
0
 public static List<string> enchant_dict_suggest(SafeDictionaryHandle dict, string word)
 {
     int suggsCount;
     IntPtr suggs;
     using (Utf8Marshaller utf8Word = new Utf8Marshaller(word))
     {
         suggs =
             enchant_dict_suggest(dict,
                                                      utf8Word.MarshalledValue,
                                                      utf8Word.MarshalledSize,
                                                      out suggsCount);
     }
     List<string> result = Utf8Marshaller.MarshalFromUtf8Array(suggs, suggsCount);
     enchant_dict_free_string_list(dict, suggs);
     return result;
 }
Ejemplo n.º 14
0
 private static extern IntPtr enchant_dict_get_error_(SafeDictionaryHandle dict);
Ejemplo n.º 15
0
	    private Dictionary CreateAndRegisterDictionary(SafeDictionaryHandle handle, IDictionary<string, WeakReference> cache, string language_tag) {
	        Dictionary dictionary;
	        dictionary = new Dictionary(handle);
	        dictionary.Disposed += OnDictionaryDisposed;
	        // always store the dictionaries we have created
	        // so that we can dispose of them cleanly and give a 
	        // better error message (ObjectDisposed) instead of a crash
	        // if someone tries to use a dictionary after the broker
	        // that created it has been disposed.
	        cache[language_tag] = new WeakReference(dictionary);
	        return dictionary;
	    }
Ejemplo n.º 16
0
 private static extern void enchant_dict_remove_from_session(SafeDictionaryHandle dict,
                                                             IntPtr word,
                                                             int len);
Ejemplo n.º 17
0
 private static extern void enchant_dict_store_replacement(SafeDictionaryHandle dict,
                                                           IntPtr mis,
                                                           int mis_len,
                                                           IntPtr cor,
                                                           int cor_len);
Ejemplo n.º 18
0
        private static extern IntPtr enchant_dict_suggest(SafeDictionaryHandle dict,
																											IntPtr word,
																											int len,
																											[MarshalAs(UnmanagedType.U4)] out int
																												out_n_suggs);
Ejemplo n.º 19
0
        private static extern void enchant_dict_add_to_session(SafeDictionaryHandle dict,
																													 IntPtr word,
																													 int len);
Ejemplo n.º 20
0
        private static extern void enchant_dict_remove_from_session(SafeDictionaryHandle dict,
																																IntPtr word,
																																int len);
Ejemplo n.º 21
0
        private static extern void enchant_dict_store_replacement(SafeDictionaryHandle dict,
																															IntPtr mis,
																															int mis_len,
																															IntPtr cor,
																															int cor_len);
Ejemplo n.º 22
0
        private static extern int enchant_dict_is_removed(SafeDictionaryHandle dict,
																											IntPtr word,
																											int len);
Ejemplo n.º 23
0
 private static extern IntPtr enchant_dict_get_error_(SafeDictionaryHandle dict);
Ejemplo n.º 24
0
        private static extern void enchant_dict_free_string_list(SafeDictionaryHandle dict,
																														 IntPtr string_list);
Ejemplo n.º 25
0
 private static extern void enchant_dict_add_to_session(SafeDictionaryHandle dict,
                                                        IntPtr word,
                                                        int len);
Ejemplo n.º 26
0
 private static extern void enchant_dict_describe(SafeDictionaryHandle dict,
                                                  [MarshalAs(UnmanagedType.FunctionPtr)] EnchantDictDescribeFn
                                                  enchantDictDescribeFn,
                                                  IntPtr user_data);
Ejemplo n.º 27
0
        public static void enchant_dict_describe(SafeDictionaryHandle dict,
																						 EnchantDictDescribeDelegate describe)
        {
            enchant_dict_describe(dict,
                                                        delegate(IntPtr lang_tag,
                                                                         IntPtr provider_name,
                                                                         IntPtr provider_desc,
                                                                         IntPtr provider_dll_file,
                                                                         IntPtr user_data)
                                                            {
                                                                ProviderInfo provider =
                                                                    new ProviderInfo(
                                                                        Utf8Marshaller.MarshalFromUtf8(provider_name),
                                                                        Utf8Marshaller.MarshalFromUtf8(provider_desc),
                                                                        Utf8Marshaller.MarshalFromUtf8(provider_dll_file));
                                                                DictionaryInfo dictionary =
                                                                    new DictionaryInfo(
                                                                        Utf8Marshaller.MarshalFromUtf8(lang_tag),
                                                                        provider);
                                                                describe(dictionary);
                                                            },
                                                        IntPtr.Zero);
        }
Ejemplo n.º 28
0
 public static void enchant_dict_remove_from_session(SafeDictionaryHandle dict, string word)
 {
     using (Utf8Marshaller utf8Word = new Utf8Marshaller(word))
     {
         enchant_dict_remove_from_session(dict,
                                                                          utf8Word.MarshalledValue,
                                                                          utf8Word.MarshalledSize);
     }
 }
Ejemplo n.º 29
0
 private static extern int enchant_dict_is_removed(SafeDictionaryHandle dict,
                                                   IntPtr word,
                                                   int len);
Ejemplo n.º 30
0
 private static extern int enchant_dict_check(SafeDictionaryHandle dict, IntPtr word, int len);
Ejemplo n.º 31
0
        public static void enchant_dict_store_replacement(SafeDictionaryHandle dict,
																											string mis,
																											string cor)
        {
            using (
                Utf8Marshaller utf8Mis = new Utf8Marshaller(mis),
                                             utf8Cor = new Utf8Marshaller(cor))
            {
                enchant_dict_store_replacement(dict,
                                                                             utf8Mis.MarshalledValue,
                                                                             utf8Mis.MarshalledSize,
                                                                             utf8Cor.MarshalledValue,
                                                                             utf8Cor.MarshalledSize);
            }
        }
Ejemplo n.º 32
0
 public static string enchant_dict_get_error(SafeDictionaryHandle dict)
 {
     IntPtr message = enchant_dict_get_error_(dict);
     return Utf8Marshaller.MarshalFromUtf8(message);
 }
Ejemplo n.º 33
0
        public static string enchant_dict_get_error(SafeDictionaryHandle dict)
        {
            IntPtr message = enchant_dict_get_error_(dict);

            return(Utf8Marshaller.MarshalFromUtf8(message));
        }
Ejemplo n.º 34
0
 private static extern IntPtr enchant_dict_suggest(SafeDictionaryHandle dict,
                                                   IntPtr word,
                                                   int len,
                                                   [MarshalAs(UnmanagedType.U4)] out int
                                                   out_n_suggs);
Ejemplo n.º 35
0
 public static int enchant_dict_is_removed(SafeDictionaryHandle dict, string word)
 {
     using (Utf8Marshaller utf8Word = new Utf8Marshaller(word))
     {
         return
             enchant_dict_is_removed(dict,
                                                             utf8Word.MarshalledValue,
                                                             utf8Word.MarshalledSize);
     }
 }
Ejemplo n.º 36
0
 private static extern int enchant_dict_check(SafeDictionaryHandle dict, IntPtr word, int len);