Beispiel #1
0
        private static MemberInfo[] GetAccessors(SerializableLazyMemberInfo serializableLazyMemberInfo)
        {
            Type declaringType = Type.GetType(serializableLazyMemberInfo.DeclaringTypeAssemblyQualifiedName);

            if (declaringType == null)
            {
                throw new Exception("Could not find type " + serializableLazyMemberInfo.DeclaringTypeAssemblyQualifiedName);
            }

            switch (serializableLazyMemberInfo.MemberType)
            {
            //case MemberTypes.Constructor:
            //    return new[] { MefUtils.GetImportingConstructor(declaringType) };

            case MemberTypes.Field:
                var field = declaringType.GetField(serializableLazyMemberInfo.MemberName, MefUtils.DefaultBindingFlags);
                return(new[] { field });

            case MemberTypes.Property:
                var prop = declaringType.GetProperty(serializableLazyMemberInfo.MemberName, MefUtils.DefaultBindingFlags);
                return(new[] { prop.GetGetMethod(true), prop.GetSetMethod(true) });

            case MemberTypes.Method:
                var method = declaringType.GetMethod(serializableLazyMemberInfo.MemberName, MefUtils.DefaultBindingFlags);
                return(new[] { method });

            case MemberTypes.TypeInfo:
                return(new[] { declaringType });

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #2
0
 private static LazyMemberInfo CreateLazyMemberInfo(SerializableLazyMemberInfo serializableLazyMemberInfo)
 {
     return(new LazyMemberInfo(serializableLazyMemberInfo.MemberType, () => GetAccessors(serializableLazyMemberInfo)));
 }
Beispiel #3
0
 public SerializableExportDefinition(ExportDefinition exportDefinition)
 {
     ContractName    = exportDefinition.ContractName;
     Metadata        = new SerializableDictionary <string, object>(exportDefinition.Metadata);
     ExportingMember = new SerializableLazyMemberInfo(ReflectionModelServices.GetExportingMember(exportDefinition));
 }