internal TMain() { versionNumber += ", " + PrismApi.NiceVersionString; SavePath += "/Prism"; PlayerPath = SavePath + "/Players"; WorldPath = SavePath + "/Worlds"; PrismApi.ModDirectory = SavePath + "/Mods"; CloudPlayerPath = "players_Prism"; CloudWorldPath = "worlds_Prism"; LocalFavoriteData = new FavoritesFile(SavePath + "/favorites.json", false); CloudFavoritesData = new FavoritesFile("/favorites_Prism.json", false); Configuration = new Preferences(SavePath + "/config.json", false, false); ElapsedTime = 0; if (Environment.OSVersion.Platform == PlatformID.Win32NT && graphics.GraphicsProfile == GraphicsProfile.Reach && GraphicsAdapter.DefaultAdapter.IsProfileSupported(GraphicsProfile.HiDef)) { graphics.GraphicsProfile = GraphicsProfile.HiDef; } }
public AppFiles() { favoritesFile = new FavoritesFile(); settingsFile = new SettingsFile(); favoritesSerializer = new XmlSerializer(typeof(FavoritesFile)); settingsSerializer = new XmlSerializer(typeof(SettingsFile)); }
public static void SaveFavorites() { var file = new FavoritesFile { Favorites = Favorites.ToArray() }; File.WriteAllText(FavoritesPath, JsonConvert.SerializeObject(file, Formatting.Indented)); }
private static FavoritesFile CreateTestFile(params Favorite[] favorites) { var file = new FavoritesFile(); file.Favorites = favorites; file.Groups = CreateGroups(); file.FavoritesInGroups = SelectFavoriteIds(favorites); return(file); }
public void RdpOnlyPlugin_Deserialize_LoadsRdpGroupMembershipAsKnown() { SerializationContext loaded = SerializeRdpVncDeserializeRdpOnly(); FavoritesFile favoritesFile = loaded.File; bool rdpInGroup = favoritesFile.FavoritesInGroups.Where(fg => fg.GroupId == GROUP_GUID) .Any(gm => gm.Favorites.Contains(RDP_GUID)); Assert.IsTrue(rdpInGroup, "Known favorites membership should be identified."); }
private static bool RestoreXmlSerializedFavorite(Tuple <string, Type> testCase) { var serializer = new FavoritesFileSerializer(TestConnectionManager.Instance); FavoritesFile file = CreateTestFile(testCase.Item1); var context = new SerializationContext(file, new UnknonwPluginElements()); serializer.Serialize(context, FILE_NAME); SerializationContext loaded = serializer.Deserialize(FILE_NAME); Favorite target = loaded.File.Favorites[0]; return(target.ProtocolProperties.GetType().FullName == testCase.Item2.FullName); }
private static SerializationContext SerializeRdpVncDeserializeRdpOnly() { var fullSerializer = new FavoritesFileSerializer(TestConnectionManager.Instance); FavoritesFile file = CreateTestFile(RDP_FAVORITE, VNC_FAVORITE); var context = new SerializationContext(file, new UnknonwPluginElements()); fullSerializer.Serialize(context, FILE_NAME); var rdpOnlyManager = TestConnectionManager.CreateRdpOnlyManager(); var limitedSerializer = new FavoritesFileSerializer(rdpOnlyManager); return(limitedSerializer.Deserialize(FILE_NAME)); }
public void LoadFavoritesFile() { if (!File.Exists(AppDirectories.FavoritesFile)) { SaveFavoritesFile(); } using (var reader = new StreamReader(AppDirectories.FavoritesFile)) { favoritesFile = (FavoritesFile)favoritesSerializer.Deserialize(reader); } }
private SerializationContext TryDeserialize(string fileLocation) { var availableProtocols = this.connectinManager.GetAvailableProtocols(); FavoritesXmlFile document = FavoritesXmlFile.LoadXmlDocument(fileLocation); UnknonwPluginElements unknown = document.RemoveUnknownFavorites(availableProtocols); XmlSerializer serializer = this.CreateSerializer(); FavoritesFile loaded = DeSerialize(document, serializer); if (loaded != null) { return(new SerializationContext(loaded, unknown)); } return(new SerializationContext()); }
private static string SerializeAndLoadSavedContent() { var rdpOnlyManager = TestConnectionManager.CreateRdpOnlyManager(); FavoritesFile file = CreateTestFile(KnownConnectionConstants.RDP); var unknownElements = new UnknonwPluginElements(); unknownElements.Favorites.Add(vncCachedFavorite); unknownElements.GroupMembership[GROUP_ID] = new List <XElement>() { UNKNOWN_VNC }; var context = new SerializationContext(file, unknownElements); var limitedSerializer = new FavoritesFileSerializer(rdpOnlyManager); limitedSerializer.Serialize(context, FILE_NAME); string saved = File.ReadAllText(FILE_NAME); return(saved); }
public SerializationContext(FavoritesFile file, UnknonwPluginElements unknown) { this.File = file; this.Unknown = unknown; }