Example #1
0
        public void CreateProfile(DeviceProfile profile)
        {
            profile = ReserializeProfile(profile);

            if (string.IsNullOrWhiteSpace(profile.Name))
            {
                throw new ArgumentException("Profile is missing Name");
            }

            var newFilename = _fileSystem.GetValidFilename(profile.Name) + ".xml";
            var path        = Path.Combine(UserProfilesPath, newFilename);

            _xmlSerializer.SerializeToFile(profile, path);
        }
Example #2
0
 public static void CreateFileCopy(object obj, string filePath, IXmlSerializer serializer)
 {
     Directory.CreateDirectory(Path.GetDirectoryName(filePath));
     if (obj != null)
     {
         serializer.SerializeToFile(obj, filePath);
     }
 }
Example #3
0
 private void SaveProfile(DeviceProfile profile, string path, DeviceProfileType type)
 {
     lock (_profiles)
     {
         _profiles[path] = new Tuple <InternalProfileInfo, DeviceProfile>(GetInternalProfileInfo(_fileSystem.GetFileInfo(path), type), profile);
     }
     _xmlSerializer.SerializeToFile(profile, path);
 }
Example #4
0
 public static void CreateFileCopy(object obj, string filePath, IXmlSerializer serializer)
 {
         Directory.CreateDirectory(Path.GetDirectoryName(filePath));
         if (obj != null)
         {
             serializer.SerializeToFile(obj, filePath);
         }
 }
Example #5
0
 private void SaveProfile(DeviceProfile profile, string path)
 {
     lock (_profiles)
     {
         _profiles[path] = profile;
     }
     _xmlSerializer.SerializeToFile(profile, path);
 }
Example #6
0
        public void UpdateConfiguration(User user, UserConfiguration newConfiguration)
        {
            var xmlPath = user.ConfigurationFilePath;

            Directory.CreateDirectory(Path.GetDirectoryName(xmlPath));
            _xmlSerializer.SerializeToFile(newConfiguration, xmlPath);

            EventHelper.FireEventIfNotNull(UserConfigurationUpdated, this, new GenericEventArgs <User> {
                Argument = user
            }, _logger);
        }
Example #7
0
        private async Task UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent)
        {
            // The xml serializer will output differently if the type is not exact
            if (userPolicy.GetType() != typeof(UserPolicy))
            {
                var json = _jsonSerializer.SerializeToString(userPolicy);
                userPolicy = _jsonSerializer.DeserializeFromString <UserPolicy>(json);
            }

            var path = GetPolifyFilePath(user);

            _fileSystem.CreateDirectory(Path.GetDirectoryName(path));

            lock (_policySyncLock)
            {
                _xmlSerializer.SerializeToFile(userPolicy, path);
                user.Policy = userPolicy;
            }

            await UpdateConfiguration(user, user.Configuration, true).ConfigureAwait(false);
        }
Example #8
0
        private void MigrateNetworkConfiguration()
        {
            string path = Path.Combine(ConfigurationManager.CommonApplicationPaths.ConfigurationDirectoryPath, "network.xml");

            if (!File.Exists(path))
            {
                var networkSettings = new NetworkConfiguration();
                ClassMigrationHelper.CopyProperties(ConfigurationManager.Configuration, networkSettings);
                _xmlSerializer.SerializeToFile(networkSettings, path);
                Logger.LogDebug("Successfully migrated network settings.");
            }
        }
Example #9
0
        private void DumpProfiles()
        {
            var list = new List <DeviceProfile>
            {
                new SamsungSmartTvProfile(),
                new Xbox360Profile(),
                new XboxOneProfile(),
                new SonyPs3Profile(),
                new SonyBravia2010Profile(),
                new SonyBravia2011Profile(),
                new SonyBravia2012Profile(),
                new SonyBravia2013Profile(),
                new SonyBlurayPlayer2013Profile(),
                new SonyBlurayPlayerProfile(),
                new PanasonicVieraProfile(),
                new WdtvLiveProfile(),
                new DenonAvrProfile(),
                new LinksysDMA2100Profile(),
                new LgTvProfile(),
                new Foobar2000Profile(),
                new MediaMonkeyProfile(),
                new Windows81Profile(),
                //new WindowsMediaCenterProfile(),
                new WindowsPhoneProfile(),
                new AndroidProfile(),
                new DirectTvProfile(),
                new DishHopperJoeyProfile(),
                new DefaultProfile()
            };

            foreach (var item in list)
            {
                var path = Path.Combine(_appPaths.ProgramDataPath, _fileSystem.GetValidFilename(item.Name) + ".xml");

                _xmlSerializer.SerializeToFile(item, path);
            }
        }
Example #10
0
 internal void SerializeToXml(DeviceProfile profile, string path)
 {
     _xmlSerializer.SerializeToFile(profile, path);
 }
Example #11
0
 /// <summary>
 /// Saves the current configuration to the file system
 /// </summary>
 public void SaveConfiguration(IXmlSerializer serializer)
 {
     serializer.SerializeToFile(Configuration, ConfigurationFilePath);
 }
Example #12
0
 /// <summary>
 /// Saves the current configuration to the file system
 /// </summary>
 public void SaveConfiguration(IXmlSerializer serializer)
 {
     serializer.SerializeToFile(Configuration, ConfigurationFilePath);
 }
Example #13
0
 /// <summary>
 /// Saves the current configuration to the file system
 /// </summary>
 public void SaveConfiguration(IXmlSerializer serializer)
 {
     var xmlPath = ConfigurationFilePath;
     Directory.CreateDirectory(System.IO.Path.GetDirectoryName(xmlPath));
     serializer.SerializeToFile(Configuration, xmlPath);
 }