/// <summary>
        /// Creates a generic instance accessor from a generic declaration
        /// and a parent property that is itself an indirect property specialization.
        /// </summary>
        /// <param name="declaration">
        /// The generic declaration to specialize.
        /// </param>
        /// <param name="parentProperty">
        /// A specialization of the generic declaration's parent type.
        /// </param>
        /// <returns>A specialization of the generic declaration.</returns>
        internal static IndirectAccessorSpecialization Create(
            IAccessor declaration,
            IndirectPropertySpecialization parentProperty)
        {
            var accessor = (IAccessor)declaration;

            return((IndirectAccessorSpecialization)instanceCache.Intern(
                       new IndirectAccessorSpecialization(
                           accessor,
                           parentProperty)));
        }
        private static IndirectPropertySpecialization InitializeInstance(
            IndirectPropertySpecialization instance)
        {
            instance.qualName = instance.Declaration.Name.Qualify(
                instance.ParentType.FullName);
            instance.propType = instance.specializedParentType.InstantiatingVisitor.Visit(
                instance.Declaration.PropertyType);
            instance.indexerParamCache = new Lazy <IReadOnlyList <Parameter> >(
                instance.CreateIndexerParameters);
            instance.accessorCache = new Lazy <IReadOnlyList <IAccessor> >(
                instance.CreateAccessors);

            return(instance);
        }
 /// <summary>
 /// Creates a generic instance method from a generic declaration
 /// and a parent type that is itself an (indirect) generic type.
 /// </summary>
 /// <param name="declaration">
 /// The generic declaration to specialize.
 /// </param>
 /// <param name="parentType">
 /// A specialization of the generic declaration's parent type.
 /// </param>
 /// <returns>A specialization of the generic declaration.</returns>
 internal static IndirectMethodSpecialization Create(
     IMethod declaration,
     TypeSpecialization parentType)
 {
     if (declaration is IAccessor)
     {
         var accessor = (IAccessor)declaration;
         return(Create(
                    accessor,
                    IndirectPropertySpecialization.Create(
                        accessor.ParentProperty,
                        parentType)));
     }
     else
     {
         return(instanceCache.Intern(
                    new IndirectMethodSpecialization(declaration, parentType)));
     }
 }