public CloningTypeMetadata CreateMetadataForType(Type type) { ClonableAttribute attribute = type.GetType().GetCustomAttributes(typeof(ClonableAttribute), true) .OfType<ClonableAttribute>() .SingleOrDefault(); IFactory factory = GetFactory(attribute); CloningTypeMetadata metadata = new CloningTypeMetadata(type, factory, this); metadata.Clonable = attribute != null; return metadata; }
public object CreateNew(CloningTypeMetadata metadata) { return Activator.CreateInstance(metadata.TargetType); }