public static bool Load(object instance, string directory, string filename, string fileVersion, bool throwOnError = true) { Ensure.Argument.NotNull(instance, "instance"); Ensure.Argument.NotNullOrEmpty(filename, "filename"); Ensure.Argument.NotNullOrEmpty(fileVersion, "fileVersion"); try { var path = GetPath(directory, filename); var doc = XDocument.Load(path); var version = doc.Declaration.Version; if (version != fileVersion) { if (throwOnError) { throw new InvalidOperationException(string.Format( "Serialzied version({0}) not match({1}).", version, fileVersion)); } return(false); } XConvert.PopulateObject(instance, doc.Root); } catch (Exception) { if (throwOnError) { throw; } return(false); } return(true); }