MongoDB.Bson.Serialization.Conventions.ConventionRegistry.Lookup C# (CSharp) Méthode

Lookup() public static méthode

Looks up the effective set of conventions that apply to a type.
public static Lookup ( Type type ) : IConventionPack
type System.Type The type.
Résultat IConventionPack
        public static IConventionPack Lookup(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            lock (__lock)
            {
                var pack = new ConventionPack();

                // append any attribute packs (usually just one) at the end so attributes are processed last
                var attributePacks = new List<IConventionPack>();
#pragma warning disable 618 //obsoleted by ConventionProfile
                ConventionProfile conventionProfile = null;
#pragma warning restore 618
                foreach (var container in __conventionPacks)
                {
                    if (container.Filter(type))
                    {
#pragma warning disable 618 //obsoleted by ConventionProfile
                        if (container.Pack is ConventionProfile)
                        {
                            conventionProfile = container.Pack as ConventionProfile;
                        }
#pragma warning restore 618

                        if (container.Name == "__attributes__")
                        {
                            attributePacks.Add(container.Pack);
                        }
                        else
                        {
                            pack.Append(container.Pack);
                        }
                    }
                }
                if (conventionProfile != null)
                {
                    // already includes the default attribute convention pack
                    return conventionProfile; 
                }

                foreach (var attributePack in attributePacks)
                {
                    pack.Append(attributePack);
                }

                return pack;
            }
        }