public static IDictionary<string, object> WriteImportDefinition(ComposablePartDefinition owner, ContractBasedImportDefinition importDefinition)
        {
            Assumes.NotNull(owner);
            Assumes.NotNull(importDefinition);

            Lazy<Type> partType = ReflectionModelServices.GetPartType(owner);

            IDictionary<string, object> cache = new Dictionary<string, object>();
            cache.WriteContractName(importDefinition.ContractName);
            cache.WriteValue(AttributedCacheServices.CacheKeys.RequiredTypeIdentity, importDefinition.RequiredTypeIdentity, null);
            cache.WriteRequiredMetadata(importDefinition.RequiredMetadata);
            cache.WriteValue(AttributedCacheServices.CacheKeys.RequiredCreationPolicy, importDefinition.RequiredCreationPolicy, CreationPolicy.Any);
            cache.WriteValue(AttributedCacheServices.CacheKeys.Cardinality, importDefinition.Cardinality, ImportCardinality.ExactlyOne);
            if (ReflectionModelServices.IsImportingParameter(importDefinition))
            {
                cache.WriteValue(AttributedCacheServices.CacheKeys.ImportType, AttributedCacheServices.ImportTypes.Parameter);
                cache.WriteLazyParameter(
                        ReflectionModelServices.GetImportingParameter(importDefinition),
                        partType);
            }
            else
            {
                // don't write anything for import type - member assumed
                LazyMemberInfo importingMemberInfo = ReflectionModelServices.GetImportingMember(importDefinition);
                cache.WriteValue(AttributedCacheServices.CacheKeys.IsRecomposable, importDefinition.IsRecomposable, false);
                cache.WriteValue(AttributedCacheServices.CacheKeys.MemberType, importingMemberInfo.MemberType , MemberTypes.Property);
                cache.WriteLazyAccessors(
                        importingMemberInfo.GetAccessors(),
                        partType);
            }

            return cache;
        }
        public static IDictionary<string, object> WriteExportDefinition(ComposablePartDefinition owner, ExportDefinition exportDefinition)
        {
            Assumes.NotNull(owner);
            Assumes.NotNull(exportDefinition);

            LazyMemberInfo exportingMemberInfo = ReflectionModelServices.GetExportingMember(exportDefinition);

            IDictionary<string, object> cache = new Dictionary<string, object>();
            cache.WriteContractName(exportDefinition.ContractName);
            cache.WriteMetadata(exportDefinition.Metadata);
            cache.WriteValue(AttributedCacheServices.CacheKeys.MemberType, exportingMemberInfo.MemberType, MemberTypes.TypeInfo);
            cache.WriteLazyAccessors(exportingMemberInfo.GetAccessors(), ReflectionModelServices.GetPartType(owner));

            return cache;
        }
        public static IDictionary<string, object> WritePartDefinition(ComposablePartDefinition part, bool writeAssembly)
        {
            Assumes.NotNull(part);

            IDictionary<string, object> cache = new Dictionary<string, object>();
            Lazy<Type> partType = ReflectionModelServices.GetPartType(part);

            cache.WriteMetadata(part.Metadata);
            cache.WriteLazyTypeForPart(partType, writeAssembly);
            cache.WriteValue<bool>(AttributedCacheServices.CacheKeys.IsDisposalRequired, ReflectionModelServices.IsDisposalRequired(part), false);

            return cache;
        }