コード例 #1
0
        /// <summary>
        /// Initialize routine
        /// </summary>
        /// <returns>
        /// Pointer to the instance
        /// </returns>
        /// <param name='affFile'>
        /// Affix file.
        /// </param>
        /// <param name='dictFile'>
        /// Dict file.
        /// </param>
        /// <param name="handleInit">Handle initialize call</param>
        protected IntPtr Initialize(string affFile, string dictFile, InitHandle handleInit)
        {
            this.WriteTrace("Initialize");
            this.WriteTrace(affFile);
            this.WriteTrace(dictFile);
            byte[] affixData;
            using (FileStream stream = File.OpenRead(affFile))
            {
                using (var reader = new BinaryReader(stream))
                {
                    affixData = reader.ReadBytes((int)stream.Length);
                }
            }

            this.WriteTrace("Read affFile successfully");
            byte[] dictionaryData;
            using (FileStream stream = File.OpenRead(dictFile))
            {
                using (var reader = new BinaryReader(stream))
                {
                    dictionaryData = reader.ReadBytes((int)stream.Length);
                }
            }

            this.WriteTrace("Read dictFile successfully");
            var affixDataPointer = new IntPtr(affixData.Length);

            this.WriteTrace(affixDataPointer.ToString());
            var dictDataPointer = new IntPtr(dictionaryData.Length);

            this.WriteTrace(dictDataPointer.ToString());
            return(handleInit(affixData, affixDataPointer, dictionaryData, dictDataPointer, null));
        }
コード例 #2
0
        /// <summary>
        /// Initialize routine
        /// </summary>
        /// <returns>
        /// Pointer to the instance
        /// </returns>
        /// <param name='affFile'>
        /// Affix file.
        /// </param>
        /// <param name='dictFile'>
        /// Dict file.
        /// </param>
        /// <param name="handleInit">Handle initialize call</param>
        protected IntPtr Initialize(string affFile, string dictFile, InitHandle handleInit)
        {
            this.WriteTrace("Initialize");
            this.WriteTrace(affFile);
            this.WriteTrace(dictFile);
            byte[] affixData;
            using (FileStream stream = File.OpenRead(affFile))
            {
                using (var reader = new BinaryReader(stream))
                {
                    affixData = reader.ReadBytes((int)stream.Length);
                }
            }

            this.WriteTrace("Read affFile successfully");
            byte[] dictionaryData;
            using (FileStream stream = File.OpenRead(dictFile))
            {
                using (var reader = new BinaryReader(stream))
                {
                    dictionaryData = reader.ReadBytes((int)stream.Length);
                }
            }

            this.WriteTrace("Read dictFile successfully");
            var affixDataPointer = new IntPtr(affixData.Length);
            this.WriteTrace(affixDataPointer.ToString());
            var dictDataPointer = new IntPtr(dictionaryData.Length);
            this.WriteTrace(dictDataPointer.ToString());
            return handleInit(affixData, affixDataPointer, dictionaryData, dictDataPointer, null);
        }