Was.OrcSearch – Rev 1

Subversion Repositories:
Rev:
using System;
using System.Collections.Generic;
using System.Linq;
using Was.OrcSearch.Models.Interfaces;

namespace Was.OrcSearch.Models
{
    public class ReflectionMetadataCollection : MetadataCollectionBase
    {
        #region Fields

        private static readonly Dictionary<Type, IEnumerable<IMetadata>> MetadataCache =
            new Dictionary<Type, IEnumerable<IMetadata>>();

        #endregion

        #region Constructors

        public ReflectionMetadataCollection(Type type)
        {
            if (MetadataCache.TryGetValue(type, out var storedMetadata))
            {
                All = storedMetadata;
                return;
            }

            var metadata = type.GetProperties().Select(x => new ReflectionMetadata(x)).ToArray();
            MetadataCache.Add(type, metadata);
            All = metadata;
        }

        #endregion

        #region Properties

        public override IEnumerable<IMetadata> All { get; }

        #endregion
    }
}

Generated by GNU Enscript 1.6.5.90.