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);
            }
        }