Пример #1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="TsStringComparer"/> class.
 /// </summary>
 /// <param name="icuLocale">The icu locale that is used to create a collating engine.
 /// </param>
 /// ------------------------------------------------------------------------------------
 public TsStringComparer(string icuLocale)
 {
     m_collatingEngine   = LgIcuCollatorClass.Create();
     m_IcuCleanupManager = IcuCleanupManagerClass.Create();
     m_IcuCleanupManager.RegisterCleanupCallback(this);
     m_icuLocale = icuLocale;
 }
Пример #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="TsStringComparer"/> class.
		/// </summary>
		/// <param name="icuLocale">The icu locale that is used to create a collating engine.
		/// </param>
		/// ------------------------------------------------------------------------------------
		public TsStringComparer(string icuLocale)
		{
			m_collatingEngine = LgIcuCollatorClass.Create();
			m_IcuCleanupManager = IcuCleanupManagerClass.Create();
			m_IcuCleanupManager.RegisterCleanupCallback(this);
			m_icuLocale = icuLocale;
		}
Пример #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">set to <c>true</c> if called from the Dispose() method,
        /// set to <c>false</c> if called by GC. If this parameter is <c>false</c> we shouldn't
        /// access any managed objects since these might already have been destroyed.</param>
        /// ------------------------------------------------------------------------------------
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (m_textBoxControl != null)
                {
                    m_textBoxControl.Dispose();
                }
                if (m_collatingEngine != null)
                {
                    m_collatingEngine.Close();
                }
                if (m_fontCache != null && m_fontCache.Count > 0)
                {
                    foreach (Font fnt in m_fontCache.Values)
                    {
                        fnt.Dispose();
                    }

                    m_fontCache.Clear();
                }
            }

            m_textBoxControl  = null;
            m_cache           = null;
            m_collatingEngine = null;
            m_fontCache       = null;
            base.Dispose(disposing);
        }
Пример #4
0
        /// <summary>
        /// Get the lead character, either a single character or a composite matching something
        /// in the sort rules.  (We need to support multi-graph letters.  See LT-9244.)
        /// </summary>
        private string GetLeadChar(string sEntryNFD, string sWs)
        {
            if (string.IsNullOrEmpty(sEntryNFD))
            {
                return("");
            }
            string sEntry = Icu.ToLower(sEntryNFD, sWs);
            Dictionary <string, string> mapChars;
            Set <string> sortChars = GetDigraphs(sWs, out mapChars);
            string       sEntryT   = sEntry;
            bool         fChanged  = false;

            do
            {
                foreach (string key in mapChars.Keys)
                {
                    sEntry = sEntry.Replace(key, mapChars[key]);
                }
                fChanged = sEntryT != sEntry;
                sEntryT  = sEntry;
            } while (fChanged);
            string sFirst = sEntry.Substring(0, 1);

            foreach (string sChar in sortChars)
            {
                if (sEntry.StartsWith(sChar))
                {
                    if (sFirst.Length < sChar.Length)
                    {
                        sFirst = sChar;
                    }
                }
            }
            // We don't want sFirst for an ignored first character or digraph.
            ILgCollatingEngine lce = LgIcuCollatorClass.Create();

            lce.Open(sWs);
            byte[] ka = (byte[])lce.get_SortKeyVariant(sFirst, LgCollatingOptions.fcoDefault);
            if (ka[0] == 1)
            {
                string sT = sEntry.Substring(sFirst.Length);
                return(GetLeadChar(sT, sWs));
            }
            return(sFirst);
        }
Пример #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="disposing"></param>
        /// ------------------------------------------------------------------------------------
        protected void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (m_collatingEngine != null && m_fCollatingEngineIsOpen)
                {
                    m_collatingEngine.Close();
                }

                if (m_IcuCleanupManager != null)
                {
                    m_IcuCleanupManager.UnregisterCleanupCallback(this);
                }
            }

            m_collatingEngine   = null;
            m_IcuCleanupManager = null;

            m_fDisposed = true;
        }
Пример #6
0
		/// ------------------------------------------------------------------------------------------
		/// <summary>
		/// Closes the collating engine.
		/// </summary>
		/// ------------------------------------------------------------------------------------------
		public void CloseCollatingEngine()
		{
			if (m_lce != null)
			{
				m_lce.Close();
				//Marshal.ReleaseComObject(m_lce);
				var disposable = m_lce as IDisposable;
				if (disposable != null)
					disposable.Dispose();
				m_lce = null;
			}
			if (m_htskey != null)
				m_htskey.Clear();
		}
Пример #7
0
		/// ------------------------------------------------------------------------------------------
		/// <summary>
		/// Opens the collating engine.
		/// </summary>
		/// ------------------------------------------------------------------------------------------
		public void OpenCollatingEngine()
		{
			if (m_lce == null)
			{
				m_lce = new ManagedLgIcuCollator();
			}
			else
			{
				m_lce.Close();
			}
			m_lce.Open(m_sWs);
		}
Пример #8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">set to <c>true</c> if called from the Dispose() method,
		/// set to <c>false</c> if called by GC. If this parameter is <c>false</c> we shouldn't
		/// access any managed objects since these might already have been destroyed.</param>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (m_textBoxControl != null)
					m_textBoxControl.Dispose();
				if (m_collatingEngine != null)
					m_collatingEngine.Close();
				if (m_fontCache != null && m_fontCache.Count > 0)
				{
					foreach (Font fnt in m_fontCache.Values)
						fnt.Dispose();

					m_fontCache.Clear();
				}
			}

			m_textBoxControl = null;
			m_cache = null;
			m_collatingEngine = null;
			m_fontCache = null;
			base.Dispose(disposing);
		}
Пример #9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="disposing"></param>
		/// ------------------------------------------------------------------------------------
		protected void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (m_collatingEngine != null && m_fCollatingEngineIsOpen)
					m_collatingEngine.Close();

				if (m_IcuCleanupManager != null)
					m_IcuCleanupManager.UnregisterCleanupCallback(this);
			}

			m_collatingEngine = null;
			m_IcuCleanupManager = null;

			m_fDisposed = true;
		}
Пример #10
0
			/// --------------------------------------------------------------------------------
			/// <summary>
			/// Closes the collating engine.
			/// </summary>
			/// --------------------------------------------------------------------------------
			public void CloseCollatingEngine()
			{
				CheckDisposed();

				if (m_lce != null)
				{
					m_lce.Close();
					m_lce = null;
				}
			}
Пример #11
0
			/// --------------------------------------------------------------------------------
			/// <summary>
			/// Opens the collating engine.
			/// </summary>
			/// <param name="sWs">The s ws.</param>
			/// --------------------------------------------------------------------------------
			public void OpenCollatingEngine(string sWs)
			{
				CheckDisposed();

				if (m_lce == null)
				{
					m_lce = LgIcuCollatorClass.Create();
				}
				else
				{
					m_lce.Close();
				}
				m_lce.Open(sWs);
			}
Пример #12
0
			/// <summary>
			/// Executes in two distinct scenarios.
			///
			/// 1. If disposing is true, the method has been called directly
			/// or indirectly by a user's code via the Dispose method.
			/// Both managed and unmanaged resources can be disposed.
			///
			/// 2. If disposing is false, the method has been called by the
			/// runtime from inside the finalizer and you should not reference (access)
			/// other managed objects, as they already have been garbage collected.
			/// Only unmanaged resources can be disposed.
			/// </summary>
			/// <param name="disposing"></param>
			/// <remarks>
			/// If any exceptions are thrown, that is fine.
			/// If the method is being done in a finalizer, it will be ignored.
			/// If it is thrown by client code calling Dispose,
			/// it needs to be handled by fixing the bug.
			///
			/// If subclasses override this method, they should call the base implementation.
			/// </remarks>
			protected virtual void Dispose(bool disposing)
			{
				//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
				// Must not be run more than once.
				if (m_isDisposed)
					return;

				if (disposing)
				{
					// Dispose managed resources here.
					if (m_values != null)
					{
						m_values.Clear();
					}
					if (m_values2 != null)
					{
						m_values2.Clear();
					}
				}

				// Dispose unmanaged resources here, whether disposing is true or false.
				CloseCollatingEngine();
				m_values = null;
				m_values2 = null;
				m_propertyName = null;
				m_lce = null;

				m_isDisposed = true;
			}
Пример #13
0
			private void Init()
			{
				m_values = new System.Collections.Hashtable();
				m_values2 = new System.Collections.Hashtable();
				m_lce = null;
			}
Пример #14
0
		/// ------------------------------------------------------------------------------------------
		/// <summary>
		/// Closes the collating engine.
		/// </summary>
		/// ------------------------------------------------------------------------------------------
		public void CloseCollatingEngine()
		{
			CheckDisposed();

			if (m_lce != null)
			{
				m_lce.Close();
				//Marshal.ReleaseComObject(m_lce);
				m_lce = null;
			}
			if (m_htskey != null)
				m_htskey.Clear();
		}
Пример #15
0
		/// ------------------------------------------------------------------------------------------
		/// <summary>
		/// Opens the collating engine.
		/// </summary>
		/// ------------------------------------------------------------------------------------------
		public void OpenCollatingEngine()
		{
			CheckDisposed();

			if (m_lce == null)
			{
				m_lce = LgIcuCollatorClass.Create();
			}
			else
			{
				m_lce.Close();
			}
			// Ensure that ICU has been initialzed before we dump anything.  This should
			// help fix LT-3970.
			Icu.InitIcuDataDir();
			m_lce.Open(m_sWs);
		}