/// <summary>
        /// Parses the details of the index for a Core.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <returns>The <see cref="CoreIndexResult"/> that was parsed.</returns>
        private static CoreIndexResult ParseCoreIndex(XElement node)
        {
            var coreIndex = new CoreIndexResult();

            foreach (var indexNode in node.Elements()) {
                var nodeValue = indexNode.Value;

                switch (indexNode.Attribute("name").Value.ToLower()) {
                    case "numdocs":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.SearchableDocumentCount = long.Parse(nodeValue);
                        break;
                    case "maxdoc":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.TotalDocumentCount = long.Parse(nodeValue);
                        break;
                    case "version":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.Version = long.Parse(nodeValue);
                        break;
                    case "segmentcount":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.SegmentCount = int.Parse(nodeValue);
                        break;
                    case "current":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.IsCurrent = bool.Parse(nodeValue);
                        break;
                    case "hasdeletions":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.HasDeletions = bool.Parse(nodeValue);
                        break;
                    case "optimized":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.IsOptimized = bool.Parse(nodeValue);
                        break;
                    case "directory":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.Directory = nodeValue;
                        break;
                    case "lastmodified":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.LastModified = DateTime.Parse(nodeValue);
                        break;
                    case "sizeinbytes":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.SizeInBytes = long.Parse(nodeValue);
                        break;
                    case "size":
                        if (!string.IsNullOrEmpty(nodeValue))
                            coreIndex.Size = nodeValue;
                        break;
                }
            }

            return coreIndex;
        }
Esempio n. 2
0
        /// <summary>
        /// Parses the details of the index for a Core.
        /// </summary>
        /// <param name="node">The node to parse.</param>
        /// <returns>The <see cref="CoreIndexResult"/> that was parsed.</returns>
        public CoreIndexResult ParseCoreIndex(XElement node)
        {
            var    coreIndex = new CoreIndexResult();
            string nodeValue = string.Empty;

            foreach (var indexNode in node.Elements())
            {
                nodeValue = indexNode.Value;

                switch (indexNode.Attribute("name").Value.ToLower())
                {
                case "numdocs":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.SearchableDocumentCount = long.Parse(nodeValue);
                    }
                    break;

                case "maxdoc":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.TotalDocumentCount = long.Parse(nodeValue);
                    }
                    break;

                case "version":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.Version = long.Parse(nodeValue);
                    }
                    break;

                case "segmentcount":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.SegmentCount = int.Parse(nodeValue);
                    }
                    break;

                case "current":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.IsCurrent = bool.Parse(nodeValue);
                    }
                    break;

                case "hasdeletions":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.HasDeletions = bool.Parse(nodeValue);
                    }
                    break;

                case "optimized":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.IsOptimized = bool.Parse(nodeValue);
                    }
                    break;

                case "directory":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.Directory = nodeValue;
                    }
                    break;

                case "lastmodified":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.LastModified = DateTime.Parse(nodeValue);
                    }
                    break;

                case "sizeinbytes":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.SizeInBytes = long.Parse(nodeValue);
                    }
                    break;

                case "size":
                    if (!string.IsNullOrEmpty(nodeValue))
                    {
                        coreIndex.Size = nodeValue;
                    }
                    break;

                default:
                    // Unknown or new property.  Ignore.
                    break;
                }
            }

            return(coreIndex);
        }