예제 #1
0
 /// <summary>
 /// Merge the current profile with the new profile
 /// </summary>
 /// <param name="currentProfile">The current profile</param>
 /// <param name="newProfile">The new profile</param>
 /// <returns>The current profile</returns>
 public static Profile Merge(Profile currentProfile, Profile newProfile)
 {
     foreach (ProfileDrive drive in newProfile.ProfileDriveList)
     {
         ProfileDrive curDrive = currentProfile.FindProfileDriveFromGUID(drive.Guid);
         if (curDrive == null)
         {
             currentProfile.AddProfileDrive(drive);
         }
         else
         {
             if (drive.DriveName.ToLower().Equals(curDrive.DriveName.ToLower()))
             {
                 continue;
             }
             if (drive.LastUpdated > curDrive.LastUpdated)
             {
                 curDrive.DriveName = drive.DriveName;
                 curDrive.LastUpdated = DateTime.UtcNow.Ticks;
             }
         }
     }
     return currentProfile;
 }
예제 #2
0
        /// <summary>
        /// Create a profile from the attributes of the given profile xml element
        /// </summary>
        /// <param name="profileElement">The xml element for which the profile is to be created from</param>
        /// <returns>The profile created from the given profile xml element</returns>
        private static Profile CreateProfile(XmlElement profileElement)
        {
            string profileName = profileElement.GetAttribute(ATTR_PROFILE_NAME);
            Profile profile = new Profile(profileName);
            XmlNodeList driveList = profileElement.GetElementsByTagName(ELE_PROFILE_DRIVE_ROOT);
            foreach (XmlNode drive in driveList)
            {
                XmlElement driveElement = drive as XmlElement;
                if (driveElement != null)
                {
                    ProfileDrive driveObj = CreateProfileDrive(driveElement);
                    if (driveObj == null)
                    {
                        //Fail Load
                        return null;
                    }
                    profile.AddProfileDrive(driveObj);
                }
            }

            return profile;
        }