当前位置: 首页>>代码示例>>C#>>正文


C# System.Collections.IDictionary.Add方法代码示例

本文整理汇总了C#中System.Collections.IDictionary.Add方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.IDictionary.Add方法的具体用法?C# System.Collections.IDictionary.Add怎么用?C# System.Collections.IDictionary.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.IDictionary的用法示例。


在下文中一共展示了System.Collections.IDictionary.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

        /// <summary> Read a particular segmentFileName.  Note that this may
        /// throw an IOException if a commit is in process.
        /// 
        /// </summary>
        /// <param name="directory">-- directory containing the segments file
        /// </param>
        /// <param name="segmentFileName">-- segment file to load
        /// </param>
        /// <throws>  CorruptIndexException if the index is corrupt </throws>
        /// <throws>  IOException if there is a low-level IO error </throws>
        public void Read(Directory directory, System.String segmentFileName)
        {
            bool success = false;

            // Clear any previous segments:
            Clear();

            ChecksumIndexInput input = new ChecksumIndexInput(directory.OpenInput(segmentFileName));

            generation = GenerationFromSegmentsFileName(segmentFileName);

            lastGeneration = generation;

            try
            {
                int format = input.ReadInt();
                if (format < 0)
                {
                    // file contains explicit format info
                    // check that it is a format we can understand
                    if (format < CURRENT_FORMAT)
                        throw new CorruptIndexException("Unknown format version: " + format);
                    version = input.ReadLong(); // read version
                    counter = input.ReadInt(); // read counter
                }
                else
                {
                    // file is in old format without explicit format info
                    counter = format;
                }

                for (int i = input.ReadInt(); i > 0; i--)
                {
                    // read segmentInfos
                    Add(new SegmentInfo(directory, format, input));
                }

                if (format >= 0)
                {
                    // in old format the version number may be at the end of the file
                    if (input.GetFilePointer() >= input.Length())
                        version = System.DateTime.Now.Millisecond;
                    // old file format without version number
                    else
                        version = input.ReadLong(); // read version
                }

                if (format <= FORMAT_USER_DATA)
                {
                    if (format <= FORMAT_DIAGNOSTICS)
                    {
                        userData = input.readStringStringMap();
                    }
                    else if (0 != input.ReadByte())
                    {
                        userData = new System.Collections.Hashtable();
                        userData.Add("userData", input.ReadString());
                    }
                    else
                    {
                        userData = (System.Collections.IDictionary) new System.Collections.Hashtable();
                    }
                }
                else
                {
                    userData = (System.Collections.IDictionary) new System.Collections.Hashtable();
                }

                if (format <= FORMAT_CHECKSUM)
                {
                    long checksumNow = input.GetChecksum();
                    long checksumThen = input.ReadLong();
                    if (checksumNow != checksumThen)
                        throw new CorruptIndexException("checksum mismatch in segments file");
                }
                success = true;
            }
            finally
            {
                input.Close();
                if (!success)
                {
                    // Clear any segment infos we had loaded so we
                    // have a clean slate on retry:
                    Clear();
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:lyra2-svn,代码行数:98,代码来源:SegmentInfos.cs


注:本文中的System.Collections.IDictionary.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。