Exemple #1
0
        /// <summary>
        /// Get words and definitions for dictionary, usually from an Oracle database
        /// </summary>
        /// <param name="dict"></param>
        /// <returns></returns>

        public void GetDefinitions(DictionaryMx dict)
        {
            if (ServiceFacade.UseRemoteServices)
            {
                //Mobius.Data.DictionaryMx expects to be used to maintain the local cache
                // -- and I expect the static member that holds that cache is not null
                if (DictionaryMx.Dictionaries == null)
                {
                    throw new Exception("Dictionary XML not loaded");
                }

                if (dict != null && !String.IsNullOrEmpty(dict.Name))
                {
                    Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy();
                    Services.Native.NativeMethodTransportObject resultObject = ServiceFacade.InvokeNativeMethod(nativeClient,
                                                                                                                (int)Native.ServiceCodes.MobiusDictionaryService,
                                                                                                                (int)Native.ServiceOpCodes.MobiusDictionaryService.GetDictionaryByName,
                                                                                                                new Services.Native.NativeMethodTransportObject(new object[] { dict.Name }));
                    ((System.ServiceModel.IClientChannel)nativeClient).Close();

                    if (resultObject == null || resultObject.Value == null)
                    {
                        return;
                    }

                    string txt = resultObject.Value.ToString();
                    DictionaryMx.Deserialize(txt, dict);

                    return;
                }
            }

            else
            {
                DictionaryFactoryInstance.GetDefinitions(dict);
                string txt = dict.Serialize();
                DictionaryMx.Deserialize(txt, dict);
            }
        }
Exemple #2
0
/// <summary>
/// Get a dictionary
/// </summary>
/// <param name="dictName"></param>
/// <returns></returns>

        public static DictionaryMx GetWithException(         // lookup or read dictionary and return
            string dictName)
        {
            string sql, tok;

            //if (Lex.Eq(dictName, "DIT_PERSON")) dictName = dictName; // debug

            if (dictName == null || dictName == "")
            {
                throw new Exception("Dictionary name not defined");
            }

            if (RootTable.IsDatabaseListDictionaryName(dictName))
            {             // dict of root tables move to factory after Mobius 2.4 is deactivated
                return(RootTable.GetDictionary(dictName));
            }

            dictName = dictName.ToLower();
            DictionaryMx dict = Dictionaries[dictName];

            if (dict == null)
            {
                throw new Exception("Dictionary not defined: " + dictName);
            }

            if (dict.Words == null)
            {
                if (DictionaryFactory == null)
                {
                    throw new Exception("DictionaryFactory not defined");
                }
                int t0 = TimeOfDay.Milliseconds();
                DictionaryFactory.GetDefinitions(dict);
                t0 = TimeOfDay.Milliseconds() - t0;
                //DebugLog.Message("DictionaryMx.Get " + dictName + ", time: " + t0);
            }

            return(dict);
        }