Exemplo n.º 1
0
 public IsolatedStorageFileWrapper(string filename, IsolatedStorageFile storage, IsolatedStorageDirectory directory)
 {
     this.filename = filename;
     this.storage = storage;
     this.directory = directory;
     systemFilename = filename.Substring(2); // Skip the "~/" prefix.
 }
Exemplo n.º 2
0
 public InitialConfiguration(CassetteConfigurationSection configurationSection, bool globalIsDebuggingEnabled, string sourceDirectory, string virtualDirectory, IsolatedStorageFile storage)
 {
     this.configurationSection = configurationSection;
     this.globalIsDebuggingEnabled = globalIsDebuggingEnabled;
     this.sourceDirectory = sourceDirectory;
     this.virtualDirectory = virtualDirectory;
     this.storage = storage;
 }
Exemplo n.º 3
0
    /// <summary>
    /// Caches the reference to the app's isolated storage
    /// </summary>
    private static IsolatedStorageFile getStore()
    {
        if (localStorage == null)
        {
            localStorage = IsolatedStorageFile.GetUserStoreForApplication();
        }

        return localStorage;
    }
Exemplo n.º 4
0
 public IsolatedStorageFileWrapper_Tests()
 {
     storage = IsolatedStorageFile.GetUserStoreForAssembly();
     directory = new IsolatedStorageDirectory(storage);
     using (var stream = storage.CreateFile("exists.js"))
     {
         "content".AsStream().CopyTo(stream);
         stream.Flush();
     }
 }
Exemplo n.º 5
0
        public CassetteApplicationTests()
        {
            RemoveExistingCache();

            storage = IsolatedStorageFile.GetMachineStoreForAssembly();
            routes = new RouteCollection();
            httpContext = new Mock<HttpContextBase>();
            httpContextItems = new Dictionary<string, object>();
            httpContext.Setup(c => c.Items).Returns(httpContextItems);
        }
Exemplo n.º 6
0
 private static void SafeDeleteFile(IsolatedStorageFile store)
 {
     try
     {
         store.DeleteFile(filename);
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 7
0
    /**
     * implements of CCUserDefault
     */
    private CCUserDefault()
    {
        myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();

        // only create xml file once if it doesnt exist
        if ((!isXMLFileExist())) {
            createXMLFile();
        }

        using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(XML_FILE_NAME, FileMode.Open, FileAccess.Read)) {
            parseXMLFile(fileStream);
        }
    }
    // This method writes "Hello Isolated Storage" to the file.
    private static void writeToFile(IsolatedStorageFile isoStore)
    {
        // Declare a new StreamWriter.

          StreamWriter writer = null;

          // Assign the writer to the store and the file TestStore.

          writer = new StreamWriter(new IsolatedStorageFileStream("TestStore.txt", FileMode.CreateNew,isoStore));

          // Have the writer write "Hello Isolated Storage" to the store.

          writer.WriteLine("Hello Isolated Storage");

          writer.Close();

          Console.WriteLine("You have written to the file.");
    }
    // This method reads the first line in the "TestStore.txt" file.
    public static String readFromFile(IsolatedStorageFile isoStore)
    {
        // This code opens the TestStore.txt file and reads the string.

          StreamReader reader = new StreamReader(new IsolatedStorageFileStream("TestStore.txt", FileMode.Open,isoStore));

          // Read a line from the file and add it to sb.

          String sb = reader.ReadLine();

          // Close the reader.

          reader.Close();

          // Return the string.

          return sb.ToString();
    }
Exemplo n.º 10
0
    /**
     * implements of CCUserDefault
     */
    private CCUserDefault()
    {
        #if WINDOWS || MACOS || LINUX
        // only create xml file once if it doesnt exist
        if ((!isXMLFileExist())) {
            createXMLFile();
        }
        using (FileStream fileStream = new FileInfo(XML_FILE_NAME).OpenRead()){
            parseXMLFile(fileStream);
        }
        #else
        myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();

        // only create xml file once if it doesnt exist
        if ((!isXMLFileExist())) {
            createXMLFile();
        }

        using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(XML_FILE_NAME, FileMode.Open, FileAccess.Read)) {
            parseXMLFile(fileStream);
        }
        #endif
    }
 public ScriptModuleContainerBuilder(IsolatedStorageFile storage, string rootDirectory, ICoffeeScriptCompiler coffeeScriptCompiler)
     : base(storage, rootDirectory)
 {
     this.coffeeScriptCompiler = coffeeScriptCompiler;
 }
Exemplo n.º 12
0
        public void Deserialize()
        {
            bool seriesDataFresh = false;

            try
            {
                IsolatedStorageFile store     = IsolatedStorageFile.GetUserStoreForApplication();
                string[]            dataFiles = store.GetFileNames(Constants._dataFilePattern);

                string mangaId = null;
                if (IsolatedStorageSettings.ApplicationSettings.Contains(_savedCurrentlyViewingChapter))
                {
                    mangaId = (string)IsolatedStorageSettings.ApplicationSettings[_savedCurrentlyViewingChapter];
                }

                var latestChaptersInDB = from MangaAbstractModel chapter in _mangaDB.Chapters where chapter.IsRecentChapter == true select chapter;
                List <MangaAbstractModel> latestChapters = new List <MangaAbstractModel>(latestChaptersInDB);
                UpdateLatestChapters(latestChapters);

                var seriesInDB            = from SeriesModel seriesModel in _mangaDB.Series select seriesModel;
                List <SeriesModel> series = new List <SeriesModel>(seriesInDB);
                UpdateSeries(series);
                if (series.Count > 0)
                {
                    seriesDataFresh = IsCreationTimeFresh(series[0].CreationTime, _oneWeekRetention);

                    // Also try to check if user was viewing a particular series
                    if (IsolatedStorageSettings.ApplicationSettings.Contains(_savedCurrentlyViewingSeries))
                    {
                        string seriesId = (string)IsolatedStorageSettings.ApplicationSettings[_savedCurrentlyViewingSeries];
                        foreach (SeriesModel viewModel in series)
                        {
                            if (viewModel.SeriesId.Equals(seriesId))
                            {
                                ViewSeries(viewModel);

                                // Also try to check if user was viewing a particular chapter in series
                                if (_currentlyViewingSeries != null && mangaId != null)
                                {
                                    bool foundChapter = false;

                                    if (!foundChapter)
                                    {
                                        foreach (MangaAbstractModel chapterViewModel in LatestChapters)
                                        {
                                            if (chapterViewModel.MangaId.Equals(mangaId))
                                            {
                                                ViewChapter(chapterViewModel);
                                                foundChapter = true;
                                                break;
                                            }
                                        }
                                    }

                                    if (!foundChapter)
                                    {
                                        foreach (MangaAbstractModel chapterViewModel in ChaptersInSeries)
                                        {
                                            if (chapterViewModel.MangaId.Equals(mangaId))
                                            {
                                                ViewChapter(chapterViewModel);
                                                foundChapter = true;
                                                break;
                                            }
                                        }
                                    }

                                    if (foundChapter)
                                    {
                                        if (IsolatedStorageSettings.ApplicationSettings.Contains(_savedCurrentlyViewingPage))
                                        {
                                            string page = (string)IsolatedStorageSettings.ApplicationSettings[_savedCurrentlyViewingPage];
                                            try
                                            {
                                                _currentlyViewingPage = int.Parse(page) - 1;
                                            }
                                            catch
                                            {
                                            }
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            if (Series.Count > 0 && seriesDataFresh)
            {
                IsSeriesLoaded = true;
            }

            if (LatestChapters.Count > 0 && IsCreationTimeFresh(LatestChapters[0].CreationTime, _oneDayRetention))
            {
                IsLatestChaptersLoaded = true;
            }

            if (ChaptersInSeries.Count > 0)
            {
                IsChaptersInSeriesLoaded = true;
            }

            if (Manga != null)
            {
                IsChapterLoaded = true;
            }
        }
Exemplo n.º 13
0
 private static void SaveToBinaryFormat(T serializableObject, string path, IsolatedStorageFile isolatedStorageFolder)
 {
     using (FileStream fileStream = CreateFileStream(isolatedStorageFolder, path))
     {
         BinaryFormatter binaryFormatter = new BinaryFormatter();
         binaryFormatter.Serialize(fileStream, serializableObject);
     }
 }
Exemplo n.º 14
0
 public _IsolatedStorageFile(IsolatedStorageFile isolatedStorageFile)
 {
     _isolatedStorageFile = isolatedStorageFile;
 }
Exemplo n.º 15
0
 public static String ReadTextFile(this IsolatedStorageFile isoStorage, String filePath)
 {
     return(isoStorage.ReadTextFile(filePath, Encoding.Default));
 }
Exemplo n.º 16
0
        // This runs *after* Global.asax Application_Start.
        public static void PostApplicationStart()
        {
            storage = IsolatedStorageFile.GetMachineStoreForAssembly();

            configurations = CreateConfigurations();
            applicationContainer = ShouldOptimizeOutput() ? new CassetteApplicationContainer<CassetteApplication>(CreateCassetteApplication)
                                                          : new CassetteApplicationContainer<CassetteApplication>(CreateCassetteApplication, HttpRuntime.AppDomainAppPath);

            Assets.GetApplication = () => CassetteApplication;
        }
		public void GetUserStoreForApplication_AssemblyIdentity ()
		{
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
			object o = isf.AssemblyIdentity;
		}
		public void CopyFile ()
		{
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
			if (isf.FileExists ("file"))
				isf.DeleteFile ("file");
			if (isf.FileExists ("file-new"))
				isf.DeleteFile ("file-new");

			isf.CreateFile ("file").Close ();
			isf.CopyFile ("file", "file-new");
			Assert.AreEqual (true, isf.FileExists ("file"), "#A0");
			Assert.AreEqual (true, isf.FileExists ("file-new"), "#A1");

			// At this point 'file-exists' already exists.
			isf.CopyFile ("file", "file-new", true);
			Assert.AreEqual (true, isf.FileExists ("file"), "#B0");
			Assert.AreEqual (true, isf.FileExists ("file-new"), "#B1");

			isf.CreateDirectory ("subdir");
			isf.CreateFile ("subdir/subfile").Close ();
			isf.CopyFile ("subdir/subfile", "subdir/subfile-new");
			Assert.AreEqual (true, isf.FileExists ("subdir/subfile"), "#C0");
			Assert.AreEqual (true, isf.FileExists ("subdir/subfile-new"), "#C1");

			try {
				isf.CopyFile ("file", "file-new");
				Assert.Fail ("#Exc0");
			} catch (IsolatedStorageException) {
			}

			// Using the same file name is failing for even when passing override=true.
			try {
				isf.CopyFile ("file-new", "file-new", true);
				Assert.Fail ("#Exc1");
			} catch (IsolatedStorageException) {
			}

			try {
				isf.CopyFile ("file-new", "file-new", false);
				Assert.Fail ("#Exc2");
			} catch (IsolatedStorageException) {
			}

			// Remove 'file-new' for cleaness purposes.
			isf.DeleteFile ("file-new");

			try {
				isf.CopyFile ("doesntexist", "file-new", false);
				Assert.Fail ("#Exc3");
			} catch (FileNotFoundException) {
			}

			try {
				isf.CopyFile ("doesnexist/doesntexist", "file-new", false);
				Assert.Fail ("#Exc4");
			} catch (DirectoryNotFoundException) {
			}

			// I'd have expected a DirectoryNotFoundException here.
			try {
				isf.CopyFile ("file", "doesntexist/doesntexist");
				Assert.Fail ("#Exc5");
			} catch (IsolatedStorageException) {
			}

			// Out of storage dir
			try {
				isf.CopyFile ("file", "../../file");
				Assert.Fail ("#Exc6");
			} catch (IsolatedStorageException) {
			}

			try {
				isf.CopyFile ("../file", "file-new");
				Assert.Fail ("#Exc7");
			} catch (IsolatedStorageException) {
			}

			// We are creating a subdirectory and files within it, so remove it just in case.
			isf.Remove ();

			isf.Close ();
			isf.Dispose ();
		}
		public void GetUserStoreForAssembly_DomainIdentity ()
		{
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
			object o = isf.DomainIdentity;
		}
		public void GetUserStoreForApplication_WithoutApplicationIdentity ()
		{
			// note: a manifest is required
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
		}
Exemplo n.º 21
0
        //Wird am Anfang ausgeführt
        //--------------------------------------------------------------------------------------------------------------------
        static ScheduledAgent()
        {
            //Vorbereitung
            //-----------------------------------------------------------------------------------------------------------------

            //Variabeln erstellen
            bool   FullVersion = false;
            bool   Run         = true;
            string Settings;
            string SetFolder     = "*";
            string SetBgColor    = "#FF000000";
            string SetFrameColor = "NO";
            string SetAlphaColor = "NO";
            int    SetFrameSize  = 0;
            int    SetInfoAlpha  = 0;
            int    SwapImage     = 1;
            string FoldersAll    = "/";

            string[] Folders;
            string   ImagesAll = "/";
            string   DatFile;
            string   InfoSize     = "4";
            bool     InfoTop      = false;
            bool     SetCycleTile = true;
            bool     SetLogoStart = true;
            //Anzahl der Styles
            int cStyles = 4;
            //IsoStore file erstellen
            IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
            //bool IsLockscreenApp = true;
            DateTime dt     = DateTime.Now;
            DateTime dt_Now = DateTime.Now;
            //Prüfen ob CycleTile schon erstellt wurde
            ShellTile oTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("flip".ToString()));

            //Prüfen ob momentan Lockscreen App
            bool IsLockscreenApp = true;

            if (Windows.Phone.System.UserProfile.LockScreenManager.IsProvidedByCurrentApplication)
            {
                //IsLockscreenApp auf true stellen
                IsLockscreenApp = true;
            }
            else
            {
                IsLockscreenApp = false;
            }


            //FullVersion laden
            IsolatedStorageFileStream filestream = file.OpenFile("Settings/FullVersion.txt", FileMode.Open);
            StreamReader sr   = new StreamReader(filestream);
            string       temp = sr.ReadToEnd();

            filestream.Close();
            int temp2 = Convert.ToInt32(temp);

            if (temp2 == 1)
            {
                FullVersion = true;
            }

            if (FullVersion == false)
            {
                //FirstTime laden //Zeit der Installation
                filestream = file.OpenFile("Settings/FirstTime.txt", FileMode.Open);
                sr         = new StreamReader(filestream);
                temp       = sr.ReadToEnd();
                filestream.Close();
                dt = Convert.ToDateTime(temp);

                //Prüfen ob Trial Zeit abgelaufen
                TimeSpan diff    = dt_Now - dt;
                int      MinToGo = 1440 - Convert.ToInt32(diff.TotalMinutes);
                //Wenn Zeit abgelaufen
                if (MinToGo <= 0)
                {
                    //Angeben das Bild auf Leer gestellt wird
                    Run = false;
                }
            }


            //Settings laden //Einstellungen
            filestream = file.OpenFile("Settings/Settings.txt", FileMode.Open);
            sr         = new StreamReader(filestream);
            Settings   = sr.ReadToEnd();
            filestream.Close();


            //Folders.dat laden //Ordner Dateien
            filestream = file.OpenFile("Folders.dat", FileMode.Open);
            sr         = new StreamReader(filestream);
            FoldersAll = sr.ReadToEnd();
            filestream.Close();
            FoldersAll = FoldersAll.TrimEnd(new char[] { '\r', '\n' });


            //Einstellungen umsetzen
            string[] aSettings = Regex.Split(Settings, ";");
            //Ordner
            SetFolder = aSettings[0];
            //Hintergrundfarbe
            SetBgColor = aSettings[1];
            //Rahmenfarbe
            SetFrameColor = aSettings[2];
            //Alphafarbe
            SetAlphaColor = aSettings[3];
            //Rahmen Größe
            SetFrameSize = Convert.ToInt32(aSettings[4]);
            //Info Bereich Alpha
            SetInfoAlpha = Convert.ToInt32(aSettings[5]);
            //Swap Image
            SwapImage = Convert.ToInt32(aSettings[6]);
            //InfoSize
            InfoSize = Convert.ToString(aSettings[7]);
            //InfoTop
            InfoTop = Convert.ToBoolean(aSettings[8]);
            //Logo beim Start
            SetLogoStart = Convert.ToBoolean(aSettings[9]);


            //StyleSettings laden
            filestream = file.OpenFile("Settings/StylesSettings.txt", FileMode.Open);
            sr         = new StreamReader(filestream);
            string stylesSettings = sr.ReadToEnd();

            filestream.Close();

            //Variablen erstellen
            string iStyle  = "1.txt";
            int    iMirrow = 1;
            Random rand    = new Random();

            //Prüfen ob Settings vorhanden
            stylesSettings = stylesSettings.Trim(new char[] { '\r', '\n' });
            if (stylesSettings.Length > 1)
            {
                //StyleSettings zerlegen
                string[] splitStylesSettings = Regex.Split(stylesSettings, ";");
                int      selectedStyle       = rand.Next(1, splitStylesSettings.Count());
                if (selectedStyle == splitStylesSettings.Count())
                {
                    selectedStyle--;
                }
                //Nach hintern verschobenen Style zurücksetzen
                selectedStyle--;
                //Auswahl zerlegen
                splitStylesSettings[selectedStyle] = splitStylesSettings[selectedStyle].Trim(new char[] { '\r', '\n' });
                string[] splitTemp = Regex.Split(splitStylesSettings[selectedStyle], ",");
                //Auswahl erstellen
                iStyle  = splitTemp[0];
                iMirrow = Convert.ToInt32(splitTemp[1]);
            }

            //Set Spiegelung erstellen
            int MH = 1;
            int MV = 1;

            if (iMirrow == 2)
            {
                MH = 2;
            }
            if (iMirrow == 3)
            {
                MH = 2;
                MV = 2;
            }
            if (iMirrow == 4)
            {
                MV = 2;
            }

            //Style laden
            filestream = file.OpenFile("Styles/" + iStyle, FileMode.Open);
            sr         = new StreamReader(filestream);
            string style = sr.ReadToEnd();

            filestream.Close();


            //Style Datei zerlegen
            string[] images = Regex.Split(style, ";");
            //Anzahl der Bilder erstellen
            int cImages = images.Count() - 1;


            //Bilderliste erstellen
            bool noImage = true;

            string[] lImages = new string[cImages];


            //Ordner auswählen
            string loadFolder = "*";
            //Dat File
            string datFile = "";



            //Prüfen ob Random Bilder ausgewählt ist
            if (SetFolder == "**")
            {
                //Ordner Datei laden
                filestream = file.OpenFile("Folders.dat", FileMode.Open);
                sr         = new StreamReader(filestream);
                string FoldersDat = sr.ReadToEnd();
                FoldersDat = FoldersDat.TrimEnd(new char[] { '\r', '\n' });
                filestream.Close();

                //Ordnerdatei aufteilen
                string[] FoldersSplit  = Regex.Split(FoldersDat, "/");
                int      cFoldersSplit = FoldersSplit.Count();
                string   AllPictures   = "";

                //Unterordner Dateien laden
                for (int i = 1; i < (cFoldersSplit - 1); i++)
                {
                    //Pictures.Dat laden
                    filestream = file.OpenFile("Thumbs/" + FoldersSplit[i] + ".dat", FileMode.Open);
                    sr         = new StreamReader(filestream);
                    string ImagesDat = sr.ReadToEnd();
                    ImagesDat = ImagesDat.TrimEnd(new char[] { '\r', '\n' });
                    ImagesDat = ImagesDat.Trim(new char[] { '/' });
                    filestream.Close();

                    //Prüfen ob Bilder vorhanden
                    if (ImagesDat.Length >= 1)
                    {
                        //Pictures.Dat trennen
                        string[] ImagesSplit  = Regex.Split(ImagesDat, "/");
                        int      cImagesSplit = ImagesSplit.Count();
                        //Bilder durchlaufen und All Pictures erstellen
                        for (int i2 = 0; i2 < cImagesSplit; i2++)
                        {
                            AllPictures += "Folders/" + FoldersSplit[i] + "/" + ImagesSplit[i2] + "///";
                        }
                    }
                }

                //Doppelte Trennzeichen entfernen
                AllPictures = AllPictures.Trim(new char[] { '/' });

                //Wenn Bilder vorhanden
                if (AllPictures.Length >= 1)
                {
                    //Alle Bilder aus Ordner laden
                    string[] tImages  = Regex.Split(AllPictures, "///");
                    int      ctImages = tImages.Count();

                    //Bilder verarbeiten
                    string[] sImages = new string[ctImages];
                    for (int i = 0; i < ctImages; i++)
                    {
                        sImages[i] = tImages[i];
                    }
                    //Bilder aus Bilderliste wählen und Bilder liste dabei verkleinern
                    for (int i = 0; i < cImages; i++)
                    {
                        //Bild auswählen
                        int csImages = sImages.Count();
                        int c        = rand.Next(1, (csImages + 1));
                        if (c == (csImages + 1))
                        {
                            c--;
                        }
                        c--;

                        lImages[i] = sImages[c];
                        //Bilderliste neu erstellen
                        if (sImages.Count() == 1)
                        {
                            sImages = new string[ctImages];
                            for (int i2 = 0; i2 < ctImages; i2++)
                            {
                                sImages[i2] = tImages[i2];
                            }
                        }
                        else
                        {
                            int      cs       = sImages.Count();
                            int      x        = 0;
                            string[] nsImages = new string[(cs - 1)];
                            for (int i3 = 0; i3 < cs; i3++)
                            {
                                if (i3 != c)
                                {
                                    nsImages[x] = sImages[i3];
                                    x++;
                                }
                            }
                            sImages = new string[(cs - 1)];
                            for (int i3 = 0; i3 < sImages.Count(); i3++)
                            {
                                sImages[i3] = nsImages[i3];
                            }
                        }
                    }
                }
                //Wenn keine Bilder existieren
                else
                {
                    //Immer no Image laden
                    for (int i = 0; i < cImages; i++)
                    {
                        lImages[i] = "NoImage.jpg";
                    }
                }
            }



            //Wenn Ordner oder Random Ordner ausgewählt wurde
            else
            {
                //Prüfen ob Settings Folder besteht
                if (SetFolder != "*")
                {
                    string[] tFolders = Regex.Split(FoldersAll, "/" + SetFolder + "/");
                    if (tFolders.Count() <= 1)
                    {
                        //Settings neu erstellen
                        SetFolder = "*";
                        Settings  = SetFolder + ";" + SetBgColor + ";" + SetFrameColor + ";" + SetAlphaColor + ";" + SetFrameSize + ";" + SetInfoAlpha + ";" + SwapImage + ";" + InfoSize + ";" + Convert.ToString(InfoTop) + ";" + Convert.ToString(SetLogoStart) + ";";
                        //Einstellungen speichern
                        filestream = file.CreateFile("Settings/Settings.txt");
                        StreamWriter sw = new StreamWriter(filestream);
                        sw.WriteLine(Settings);
                        sw.Flush();
                        filestream.Close();
                    }
                    else
                    //Prüfen ob Dateien in Ordner
                    {
                        //Images.dat laden //Bilder Dateien
                        filestream = file.OpenFile("Thumbs/" + SetFolder + ".dat", FileMode.Open);
                        sr         = new StreamReader(filestream);
                        ImagesAll  = sr.ReadToEnd();
                        filestream.Close();
                        ImagesAll = ImagesAll.TrimEnd(new char[] { '\r', '\n' });

                        string[] tImages = Regex.Split(ImagesAll, "/");
                        if (tImages.Count() < 3)
                        {
                            //Settings neu erstellen
                            SetFolder = "*";
                            Settings  = Settings = SetFolder + ";" + SetBgColor + ";" + SetFrameColor + ";" + SetAlphaColor + ";" + SetFrameSize + ";" + SetInfoAlpha + ";" + SwapImage + ";" + InfoSize + ";" + Convert.ToString(InfoTop) + ";" + Convert.ToString(SetLogoStart) + ";";
                            //Einstellungen speichern
                            filestream = file.CreateFile("Settings/Settings.txt");
                            StreamWriter sw = new StreamWriter(filestream);
                            sw.WriteLine(Settings);
                            sw.Flush();
                            filestream.Close();
                        }
                        else
                        {
                            //LoadFolder erstellen
                            loadFolder = "Folders/" + SetFolder + "/";
                            //Images.dat laden //Bilder Dateien
                            filestream = file.OpenFile("Thumbs/" + SetFolder + ".dat", FileMode.Open);
                            sr         = new StreamReader(filestream);
                            ImagesAll  = sr.ReadToEnd();
                            filestream.Close();
                            ImagesAll = ImagesAll.TrimEnd(new char[] { '\r', '\n' });
                            noImage   = false;
                        }
                    }
                }


                //Wenn Loading Folder nicht besteht //Random
                if (loadFolder == "*")
                {
                    //Ordner Liste erstellen
                    string   tFolders = "";
                    string[] tf       = Regex.Split(FoldersAll, "/");
                    string[] lFolders = new string[(tf.Count() - 2)];
                    for (int i21 = 1; i21 < tf.Count() - 1; i21++)
                    {
                        lFolders[(i21 - 1)] = tf[i21];
                    }

                    //Ordner Anzahl erstellen
                    int cFolders = lFolders.Count();

                    //Ordner durchlaufen und prüfen ob Bilder vorhanden
                    for (int i2 = 0; i2 < cFolders; i2++)
                    {
                        //Images.dat laden //Bilder Dateien
                        filestream = file.OpenFile("/Thumbs/" + lFolders[i2] + ".dat", FileMode.Open);
                        sr         = new StreamReader(filestream);
                        ImagesAll  = sr.ReadToEnd();
                        filestream.Close();
                        ImagesAll = ImagesAll.TrimEnd(new char[] { '\r', '\n' });

                        //Bilder aufsplitten
                        string[] tImages = Regex.Split(ImagesAll, "/");
                        if (tImages.Count() > 2)
                        {
                            tFolders += i2 + ";";
                        }
                    }

                    if (tFolders.Length > 0)
                    {
                        string[] tlFolders  = Regex.Split(tFolders, ";");
                        int      ctlFolders = tlFolders.Count() - 1;
                        int      iFolder    = rand.Next(1, tlFolders.Count());

                        int temp22 = Convert.ToInt32(tlFolders[iFolder - 1]);
                        //loadFolder erstellen
                        loadFolder = "Folders/" + lFolders[temp22] + "/";
                        datFile    = "Thumbs/" + lFolders[temp22] + ".dat";
                        //Images.dat laden //Bilder Dateien
                        filestream = file.OpenFile(datFile, FileMode.Open);
                        sr         = new StreamReader(filestream);
                        ImagesAll  = sr.ReadToEnd();
                        filestream.Close();
                        ImagesAll = ImagesAll.TrimEnd(new char[] { '\r', '\n' });
                        noImage   = false;
                    }
                }

                //Wenn Bilder existieren
                if (noImage == false & Run == true)
                {
                    //Alle Bilder aus Ordner laden
                    string[] tI      = Regex.Split(ImagesAll, "/");
                    string[] tImages = new string[(tI.Count() - 2)];
                    for (int i27 = 1; i27 < (tI.Count() - 1); i27++)
                    {
                        tImages[(i27 - 1)] = tI[i27];
                    }
                    int      ctImages = tImages.Count();
                    string[] sImages  = new string[ctImages];
                    for (int i = 0; i < ctImages; i++)
                    {
                        sImages[i] = tImages[i];
                    }
                    //Bilder aus Bilderliste wählen und Bilder liste dabei verkleinern
                    for (int i = 0; i < cImages; i++)
                    {
                        //Bild auswählen
                        int csImages = sImages.Count();
                        int c        = rand.Next(1, (csImages + 1));
                        if (c == (csImages + 1))
                        {
                            c--;
                        }
                        c--;

                        lImages[i] = loadFolder + sImages[c];
                        //Bilderliste neu erstellen
                        if (sImages.Count() == 1)
                        {
                            sImages = new string[ctImages];
                            for (int i2 = 0; i2 < ctImages; i2++)
                            {
                                sImages[i2] = tImages[i2];
                            }
                        }
                        else
                        {
                            int      cs       = sImages.Count();
                            int      x        = 0;
                            string[] nsImages = new string[(cs - 1)];
                            for (int i3 = 0; i3 < cs; i3++)
                            {
                                if (i3 != c)
                                {
                                    nsImages[x] = sImages[i3];
                                    x++;
                                }
                            }
                            sImages = new string[(cs - 1)];
                            for (int i3 = 0; i3 < sImages.Count(); i3++)
                            {
                                sImages[i3] = nsImages[i3];
                            }
                        }
                    }
                }


                //Wenn keine Bilder existieren
                else
                {
                    //Immer no Image laden
                    for (int i = 0; i < cImages; i++)
                    {
                        lImages[i] = "NoImage.jpg";
                    }
                }
            }
            //-----------------------------------------------------------------------------------------------------------------



            //Bild erstellen
            //-----------------------------------------------------------------------------------------------------------------
            Deployment.Current.Dispatcher.BeginInvoke(delegate
            {
                //Bild erstellen
                var Background = new WriteableBitmap(480, 800);

                //Hintergrundfarbe erstellen
                Color backgroundColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                if (SetBgColor != "NO")
                {
                    if (SetBgColor == "AC")
                    {
                        backgroundColor = (Color)Application.Current.Resources["PhoneAccentColor"];
                    }
                    else if (SetBgColor == "BC")
                    {
                        backgroundColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                    }
                    else
                    {
                        if (SetBgColor.Length == 9)
                        {
                            byte A             = Convert.ToByte(SetBgColor.Substring(1, 2), 16);
                            byte R             = Convert.ToByte(SetBgColor.Substring(3, 2), 16);
                            byte G             = Convert.ToByte(SetBgColor.Substring(5, 2), 16);
                            byte B             = Convert.ToByte(SetBgColor.Substring(7, 2), 16);
                            SolidColorBrush sb = new SolidColorBrush(Color.FromArgb(A, R, G, B));
                            backgroundColor    = sb.Color;
                        }
                    }
                }
                Background.Clear(backgroundColor);

                //Rahmenfarbe erstellen
                Color frameColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                if (SetFrameColor != "NO")
                {
                    if (SetFrameColor == "AC")
                    {
                        frameColor = (Color)Application.Current.Resources["PhoneAccentColor"];
                    }
                    else if (SetFrameColor == "BC")
                    {
                        frameColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                    }
                    else
                    {
                        if (SetFrameColor.Length == 9)
                        {
                            byte A             = Convert.ToByte(SetFrameColor.Substring(1, 2), 16);
                            byte R             = Convert.ToByte(SetFrameColor.Substring(3, 2), 16);
                            byte G             = Convert.ToByte(SetFrameColor.Substring(5, 2), 16);
                            byte B             = Convert.ToByte(SetFrameColor.Substring(7, 2), 16);
                            SolidColorBrush sb = new SolidColorBrush(Color.FromArgb(A, R, G, B));
                            frameColor         = sb.Color;
                        }
                    }
                }

                //Tiles durchlaufen und erstellen
                for (int i = 0; i < lImages.Count(); i++)
                {
                    //Daten aus Style verarbeiten
                    string[] splitImage = Regex.Split(images[i], ",");
                    int x1   = Convert.ToInt32(splitImage[0]);
                    int y1   = Convert.ToInt32(splitImage[1]);
                    int x2   = Convert.ToInt32(splitImage[2]);
                    int y2   = Convert.ToInt32(splitImage[3]);
                    int size = x2 - x1;

                    //Spiegelung errechnen
                    if (MH == 2)
                    {
                        x1 = 480 - x1 - size;
                        x2 = x1 + size;
                    }
                    if (MV == 2)
                    {
                        y1 = 800 - y1 - size;
                        y2 = y1 + size;
                    }

                    //Prüfen welches File geladen wird
                    string LoadFile = lImages[i];
                    if (size == 100)
                    {
                        LoadFile = Regex.Replace("/" + LoadFile, "/Folders/", "/Thumbs/");
                    }

                    //Tile erstellen
                    byte[] tempData;
                    MemoryStream tempMs;
                    var tile = new WriteableBitmap(0, 0);
                    using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        using (IsolatedStorageFileStream isfs = isf.OpenFile(LoadFile, FileMode.Open, FileAccess.Read))
                        {
                            tempData = new byte[isfs.Length];
                            isfs.Read(tempData, 0, tempData.Length);
                            isfs.Close();
                        }
                    }
                    tempMs = new MemoryStream(tempData);
                    tile   = new WriteableBitmap(0, 0);
                    tile.SetSource(tempMs);

                    if (size != 320)
                    {
                        tile = tile.Resize(size, size, WriteableBitmapExtensions.Interpolation.Bilinear);
                    }

                    //Tile in Bild schneiden
                    Background.Blit(new Rect(x1, y1, size, size), tile, new Rect(0, 0, size, size));

                    //Tempomäre Bilder löschen
                    tempData = null;
                    tempMs   = null;
                    tile     = null;

                    //Rahmen erstellen, wenn eingestellt
                    if (SetFrameColor != "NO" & SetFrameSize != 0)
                    {
                        for (int i5 = 0; i5 < SetFrameSize; i5++)
                        {
                            Background.DrawRectangle((x1 + i5), (y1 + i5), (x2 - i5), (y2 - i5), frameColor);
                        }
                    }
                }

                //Infofarbe erstellen
                Color alphaColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                if (SetAlphaColor != "NO")
                {
                    if (SetAlphaColor == "AC")
                    {
                        alphaColor = (Color)Application.Current.Resources["PhoneAccentColor"];
                    }
                    else if (SetAlphaColor == "BC")
                    {
                        alphaColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                    }
                    else
                    {
                        if (SetAlphaColor.Length == 9)
                        {
                            byte A             = Convert.ToByte(SetAlphaColor.Substring(1, 2), 16);
                            byte R             = Convert.ToByte(SetAlphaColor.Substring(3, 2), 16);
                            byte G             = Convert.ToByte(SetAlphaColor.Substring(5, 2), 16);
                            byte B             = Convert.ToByte(SetAlphaColor.Substring(7, 2), 16);
                            SolidColorBrush sb = new SolidColorBrush(Color.FromArgb(A, R, G, B));
                            alphaColor         = sb.Color;
                        }
                    }
                }
                //Farbe mit Alpha erstellen
                byte a = Convert.ToByte(0);
                if (SetInfoAlpha != 9)
                {
                    a = Convert.ToByte(255 - (28 * SetInfoAlpha));
                }
                byte r = alphaColor.R;
                byte g = alphaColor.G;
                byte b = alphaColor.B;
                SolidColorBrush sb2 = new SolidColorBrush(Color.FromArgb(a, r, g, b));
                alphaColor          = sb2.Color;

                //Infofarbe in Bild schneiden
                if (SetAlphaColor != "NO" & InfoSize != "0")
                {
                    //Info Größe bestimmen
                    int tSize = 455;
                    if (InfoSize == "3")
                    {
                        tSize = 345;
                    }
                    else if (InfoSize == "2")
                    {
                        tSize = 235;
                    }
                    else if (InfoSize == "1")
                    {
                        tSize = 125;
                    }
                    var tile = new WriteableBitmap(480, tSize);
                    tile.Clear(alphaColor);
                    //Tile in Bild schneiden
                    Background.Blit(new Rect(0, (800 - tSize), 480, tSize), tile, new Rect(0, 0, 480, tSize));
                    tile = null;
                }

                //InfoTop erstellen
                if (InfoTop == true & SetAlphaColor != "NO")
                {
                    //Tile erstellen
                    var tile = new WriteableBitmap(480, 30);
                    tile.Clear(alphaColor);
                    //Tile in Bild schneiden
                    Background.Blit(new Rect(0, 0, 480, 30), tile, new Rect(0, 0, 480, 30));
                    tile = null;
                }

                //Prüfen ob Ordner schon vorhanden
                if (!file.DirectoryExists("Background"))
                {
                    file.CreateDirectory("Background");
                }
                //Prüfen ob Bild vorhanden
                string SaveFile;
                if (file.FileExists("Background/" + (SwapImage - 1) + ".jpg"))
                {
                    file.DeleteFile("Background/" + (SwapImage - 1) + ".jpg");
                }
                if (file.FileExists("Background/" + (SwapImage - 2) + ".jpg"))
                {
                    file.DeleteFile("Background/" + (SwapImage - 2) + ".jpg");
                }
                //Swap Image erhöhen
                SwapImage++;
                //SaveFile neu erstellen
                SaveFile = "Background/" + SwapImage + ".jpg";

                //Einstellungen neu erstellen
                Settings = SetFolder + ";" + SetBgColor + ";" + SetFrameColor + ";" + SetAlphaColor + ";" + SetFrameSize + ";" + SetInfoAlpha + ";" + SwapImage + ";" + InfoSize + ";" + Convert.ToString(InfoTop) + ";" + Convert.ToString(SetLogoStart) + ";";
                //Einstellungen speichern
                filestream       = file.CreateFile("Settings/Settings.txt");
                StreamWriter sw2 = new StreamWriter(filestream);
                sw2.WriteLine(Settings);
                sw2.Flush();
                filestream.Close();

                //Datei in Isolated Storage schreiben
                var isolatedStorageFileStream = file.CreateFile(SaveFile);
                Background.SaveJpeg(isolatedStorageFileStream, 480, 800, 0, 100);
                isolatedStorageFileStream.Close();
                Background = null;

                //Lockscreen erstellen
                string filePathOfTheImage = SaveFile;
                var schema = "ms-appdata:///Local/";
                var uri    = new Uri(schema + filePathOfTheImage, UriKind.RelativeOrAbsolute);
                //Wenn Lockscreen App, Lockscreen setzen
                if (IsLockscreenApp == true)
                {
                    Windows.Phone.System.UserProfile.LockScreen.SetImageUri(uri);
                }



                //Cycle Tyle updaten
                if (oTile != null && oTile.NavigationUri.ToString().Contains("flip"))
                {
                    //Cycle Bilder erstellen
                    List <Uri> list = new List <Uri>();
                    for (int i = 0; i < 9; i++)
                    {
                        if (lImages[i] != "false")
                        {
                            if (file.FileExists("Shared/ShellContent/myImage" + i + ".jpg"))
                            {
                                file.DeleteFile("Shared/ShellContent/myImage" + i + ".jpg");
                            }
                            file.CopyFile(lImages[i], "Shared/ShellContent/myImage" + i + ".jpg");
                            list.Add(new Uri("isostore:/Shared/ShellContent/myImage" + i + ".jpg", UriKind.Absolute));
                        }
                    }


                    //CycleTile erstellen
                    CycleTileData tileData = new CycleTileData()
                    {
                        Title = "",
                        Count = null,
                        SmallBackgroundImage = new Uri("Icon.png", UriKind.RelativeOrAbsolute),
                        CycleImages          = list
                    };

                    oTile.Update(tileData);
                }
            });
            //-----------------------------------------------------------------------------------------------------------------
        }
Exemplo n.º 22
0
 public DbTableStorage(IsolatedStorageFile storage, string path, string name)
 {
     _storage   = storage;
     _indexName = Path.Combine(path, name + ".index");
     _dataName  = Path.Combine(path, name + ".data");
 }
Exemplo n.º 23
0
        private void OnPhotoChosen(object sender, PhotoResult photoResult)
        {
            var tcs = Interlocked.Exchange(ref completionSource, null);

            if (photoResult.TaskResult == TaskResult.Cancel)
            {
                tcs.SetResult(null);
                return;
            }

            string path = photoResult.OriginalFileName;

            long pos     = photoResult.ChosenPhoto.Position;
            var  options = tcs.Task.AsyncState as StoreCameraMediaOptions;

            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                path = options.GetUniqueFilepath((options == null) ? "temp" : null, p => store.FileExists(p));

                string dir = Path.GetDirectoryName(path);
                if (!String.IsNullOrWhiteSpace(dir))
                {
                    store.CreateDirectory(dir);
                }

                using (var fs = store.CreateFile(path))
                {
                    byte[] buffer = new byte[20480];
                    int    len;
                    while ((len = photoResult.ChosenPhoto.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        fs.Write(buffer, 0, len);
                    }

                    fs.Flush(flushToDisk: true);
                }
            }

            Action <bool> dispose = null;

            if (options == null)
            {
                dispose = d =>
                {
                    using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                        store.DeleteFile(path);
                };
            }

            switch (photoResult.TaskResult)
            {
            case TaskResult.OK:
                photoResult.ChosenPhoto.Position = pos;
                tcs.SetResult(new MediaFile(path, () => photoResult.ChosenPhoto, dispose: dispose));
                break;

            case TaskResult.None:
                photoResult.ChosenPhoto.Dispose();
                if (photoResult.Error != null)
                {
                    tcs.SetResult(null);
                }

                break;
            }
        }
		public void GetFilesInSubdirs ()
		{
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
			string pattern = Path.Combine ("..", "*");
			isf.GetFileNames (pattern);
		}
		public void GetUserStoreForApplication_DomainIdentity ()
		{
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
			object o = isf.DomainIdentity;
		}
		public void GetDirsInSubDirs ()
		{
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
			isf.CreateDirectory ("subdir");
			string [] dir_names = isf.GetDirectoryNames ("subdir/../*");
		}
		public void GetUserStoreForSite ()
		{
			IsolatedStorageFile.GetUserStoreForSite ();
		}
		public void MoveFile ()
		{
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
			// Mare sure to remove them if they exist already
			if (isf.FileExists ("file"))
				isf.DeleteFile ("file");
			if (isf.FileExists ("file-new"))
				isf.DeleteFile ("file-new");
			if (isf.FileExists ("subdir/subfile"))
				isf.DeleteFile ("subdir/subfile");
			if (isf.FileExists ("subdir/subfile-new"))
				isf.DeleteFile ("subdir/subfile-new");

			isf.CreateFile ("file").Close ();
			Assert.AreEqual (true, isf.FileExists ("file"), "#A0");

			// Same file
			isf.MoveFile ("file", "file");
			Assert.AreEqual (true, isf.FileExists ("file"), "#A0-1");

			isf.MoveFile ("file", "file-new");
			Assert.AreEqual (false, isf.FileExists ("file"), "#A1");
			Assert.AreEqual (true, isf.FileExists ("file-new"), "#A2");

			isf.CreateDirectory ("subdir");
			isf.CreateFile ("subdir/subfile").Close ();
			isf.MoveFile ("subdir/subfile", "subdir/subfile-new");
			Assert.AreEqual (false, isf.FileExists ("subdir/subfile"), "#B0");
			Assert.AreEqual (true, isf.FileExists ("subdir/subfile-new"), "#B1");

			try {
				isf.MoveFile (String.Empty, "file-new-new");
				Assert.Fail ("#Exc1");
			} catch (ArgumentException) {
			}

			try {
				isf.MoveFile ("  ", "file-new-new");
				Assert.Fail ("#Exc2");
			} catch (ArgumentException e) {
			}

			try {
				isf.MoveFile ("doesntexist", "file-new-new");
				Assert.Fail ("#Exc3");
			} catch (FileNotFoundException) {
			}

			// CopyFile is throwing a DirectoryNotFoundException here.
			try {
				isf.MoveFile ("doesnexist/doesntexist", "file-new-new");
				Assert.Fail ("#Exc4");
			} catch (FileNotFoundException) {
			}

			// I'd have expected a DirectoryNotFoundException here.
			try {
				isf.MoveFile ("file-new", "doesntexist/doesntexist");
				Assert.Fail ("#Exc5");
			} catch (IsolatedStorageException) {
			}

			// Out of storage dir
			try {
				isf.MoveFile ("file-new", "../../file-new");
				Assert.Fail ("#Exc6");
			} catch (IsolatedStorageException) {
			}

			isf.Remove ();
			isf.Close ();
			isf.Dispose ();
		}
	public IsolatedStorageFileStream(string path, System.IO.FileMode mode, IsolatedStorageFile isf) {}
Exemplo n.º 30
0
        void ExtractEntry(ZipEntry entry)
        {
            bool   doExtraction = entry.IsCompressionMethodSupported();
            string targetName   = entry.Name;

            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (doExtraction)
                {
                    if (entry.IsFile)
                    {
                        targetName = extractNameTransform_.TransformFile(targetName);
                    }
                    else if (entry.IsDirectory)
                    {
                        targetName = extractNameTransform_.TransformDirectory(targetName);
                    }

                    doExtraction = !string.IsNullOrEmpty(targetName);
                }

                // TODO: Fire delegate/throw exception were compression method not supported, or name is invalid?

                string dirName = null;

                if (doExtraction)
                {
                    if (entry.IsDirectory)
                    {
                        dirName = targetName;
                    }
                    else
                    {
                        dirName = Path.GetDirectoryName(targetName);
                    }
                }

                if (doExtraction && !store.DirectoryExists(dirName))
                {
                    if (!entry.IsDirectory || CreateEmptyDirectories)
                    {
                        try {
                            store.CreateDirectory(dirName);
                        }
                        catch (Exception ex) {
                            doExtraction = false;
                            if (events_ != null)
                            {
                                if (entry.IsDirectory)
                                {
                                    continueRunning_ = events_.OnDirectoryFailure(targetName, ex);
                                }
                                else
                                {
                                    continueRunning_ = events_.OnFileFailure(targetName, ex);
                                }
                            }
                            else
                            {
                                continueRunning_ = false;
                                throw;
                            }
                        }
                    }
                }
            }

            if (doExtraction && entry.IsFile)
            {
                ExtractFileEntry(entry, targetName);
            }
        }
Exemplo n.º 31
0
 public IsolatedStorageDirectory(IsolatedStorageFile storage)
     : this(storage, "~/")
 {
 }
Exemplo n.º 32
0
        void ExtractFileEntry(ZipEntry entry, string targetName)
        {
            bool proceed = true;

            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (overwrite_ != Overwrite.Always)
                {
                    if (store.FileExists(targetName))
                    {
                        if ((overwrite_ == Overwrite.Prompt) && (confirmDelegate_ != null))
                        {
                            proceed = confirmDelegate_(targetName);
                        }
                        else
                        {
                            proceed = false;
                        }
                    }
                }

                if (proceed)
                {
                    if (events_ != null)
                    {
                        continueRunning_ = events_.OnProcessFile(entry.Name);
                    }

                    if (continueRunning_)
                    {
                        try {
                            using (var outputStream = store.CreateFile(targetName))
                            {
                                if (buffer_ == null)
                                {
                                    buffer_ = new byte[4096];
                                }
                                if ((events_ != null) && (events_.Progress != null))
                                {
                                    StreamUtils.Copy(zipFile_.GetInputStream(entry), outputStream, buffer_,
                                                     events_.Progress, events_.ProgressInterval, this, entry.Name, entry.Size);
                                }
                                else
                                {
                                    StreamUtils.Copy(zipFile_.GetInputStream(entry), outputStream, buffer_);
                                }

                                if (events_ != null)
                                {
                                    continueRunning_ = events_.OnCompletedFile(entry.Name);
                                }
                            }
                        }
                        catch (Exception ex) {
                            if (events_ != null)
                            {
                                continueRunning_ = events_.OnFileFailure(targetName, ex);
                            }
                            else
                            {
                                continueRunning_ = false;
                                throw;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 33
0
                private static T LoadFromDocumentFormat(System.Type[] extraTypes, string path, IsolatedStorageFile isolatedStorageFolder)
                {
                    T serializableObject = null;

                    using (TextReader textReader = CreateTextReader(isolatedStorageFolder, path))
                    {
                        XmlSerializer xmlSerializer = CreateXmlSerializer(extraTypes);
                        serializableObject = xmlSerializer.Deserialize(textReader) as T;
                    }

                    return(serializableObject);
                }
Exemplo n.º 34
0
 private static void SaveToDocumentFormat(T serializableObject, System.Type[] extraTypes, string path, IsolatedStorageFile isolatedStorageFolder)
 {
     using (TextWriter textWriter = CreateTextWriter(isolatedStorageFolder, path))
     {
         XmlSerializer xmlSerializer = CreateXmlSerializer(extraTypes);
         xmlSerializer.Serialize(textWriter, serializableObject);
     }
 }
Exemplo n.º 35
0
 public IIsolatedStorageFile GetUserStoreForApplication()
 {
     return(new _IsolatedStorageFile(IsolatedStorageFile.GetUserStoreForApplication()));
 }
Exemplo n.º 36
0
 IsolatedStorageDirectory(IsolatedStorageFile storage, string basePath)
 {
     this.storage = storage;
     this.basePath = basePath;
 }
Exemplo n.º 37
0
 public void Reset()
 { 
     m_Current = null; 
     m_fReset  = true;
     m_fEnd    = false; 
     m_fileEnum.Reset();
 }
Exemplo n.º 38
0
 /// <summary>
 /// Saves an object to an XML file in Document format, located in a specified isolated storage area, and supplying extra data types to enable serialization of custom types within the object.
 /// </summary>
 /// <example>
 /// <code>
 /// SerializableObject serializableObject = new SerializableObject();
 ///
 /// ObjectXMLSerializer&lt;SerializableObject&gt;.Save(serializableObject, "XMLObjects.xml", IsolatedStorageFile.GetUserStoreForAssembly(), new Type[] { typeof(MyCustomType) });
 /// </code>
 /// </example>
 /// <param name="serializableObject">Serializable object to be saved to file.</param>
 /// <param name="fileName">Name of the file in the isolated storage area to save the object to.</param>
 /// <param name="isolatedStorageDirectory">Isolated storage area directory containing the XML file to save the object to.</param>
 /// <param name="extraTypes">Extra data types to enable serialization of custom types within the object.</param>
 public static void Save(T serializableObject, string fileName, IsolatedStorageFile isolatedStorageDirectory, System.Type[] extraTypes)
 {
     SaveToDocumentFormat(serializableObject, null, fileName, isolatedStorageDirectory);
 }
		public void CreateDirectory_Null ()
		{
			IsolatedStorageFile.GetUserStoreForAssembly ().CreateDirectory (null);
		}
		public void GetStore_Domain_NonPresentEvidences ()
		{
			IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
			IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, typeof (StrongName), typeof (Publisher));
		}
Exemplo n.º 41
0
        private async void SubmitApplicationBarIconButton_OnClick(object sender, EventArgs e)
        {
            if (placeIndex < 2)
            {
                StaticData.CurrentErrollments.CompletedPlace = placeIndex + 1;
                try
                {
                    await
                    UserAPI.AnswerScalingQuestionTask(ScalingSlider.Value.ToString(),
                                                      StaticData.CurrentUser.Id.ToString(),
                                                      StaticData.CurrentErrollments.Places[placeIndex].Id.ToString(), this);
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
            else
            {
                try
                {
                    await
                    UserAPI.AnswerOpenEndedQuestionTask(MainTextBox.Text,
                                                        StaticData.CurrentUser.Id.ToString(),
                                                        StaticData.CurrentErrollments.Places[placeIndex].Id.ToString(), this);
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }


            XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();

            xmlWriterSettings.Indent = true;

            using (IsolatedStorageFile isoStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                //Create a file stream to open or create file
                using (
                    IsolatedStorageFileStream stream = new IsolatedStorageFileStream("EnrollmentHistory.xml",
                                                                                     FileMode.OpenOrCreate, isoStorage))
                {
                    XmlSerializer serializer = new XmlSerializer(StaticData.ErrollmentHistory.GetType());
                    using (XmlWriter xmlWriter = XmlWriter.Create(stream, xmlWriterSettings))
                    {
                        // Viết dữ liệu theo Serialize
                        serializer.Serialize(xmlWriter, StaticData.ErrollmentHistory);
                    }
                }
            }

            if (placeIndex == 2)
            {
                //Last diamond collected
                NavigationService.RemoveBackEntry();
                NavigationService.RemoveBackEntry();
                NavigationService.Navigate(new Uri("/PageGroups/QuestionGroup/GiftCodePage.xaml", UriKind.Relative));
            }
            else
            {
                NavigationService.RemoveBackEntry();
                NavigationService.GoBack();
            }
        }
	public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, IsolatedStorageFile isf) {}
		public void GetStore_Assembly_AssemblyNullObject ()
		{
			IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
			IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, new Zone (SecurityZone.MyComputer), (object)null);
		}
Exemplo n.º 44
0
        public bool MoveNext()
        { 
            IsolatedStorageFile  isf; 
            IsolatedStorageScope scope;
            bool     fDomain; 
            TwoPaths tp;
            Stream   domain, assem, app;
            String   domainName, assemName, appName;
 
            m_fiop.Assert();
 
            m_fReset = false; 

            do { 

                if (m_fileEnum.MoveNext() == false)
                {
                    m_fEnd = true; 
                    break;
                } 
 
                // Create the store
                isf = new IsolatedStorageFile(); 

                tp   = (TwoPaths) m_fileEnum.Current;
                fDomain = false;
 
                if (IsolatedStorageFile.NotAssemFilesDir(tp.Path2) &&
                    IsolatedStorageFile.NotAppFilesDir(tp.Path2)) 
                    fDomain = true; 

                // Create Roaming Store 
                domain   = null;
                assem = null;
                app = null;
 
                if (fDomain)
                { 
                    if (!GetIDStream(tp.Path1, out domain)) 
                        continue;
 
                    if (!GetIDStream(tp.Path1 + s_SepExternal + tp.Path2,
                            out assem))
                        continue;
 
                    domain.Position = 0;
 
                    if (IsolatedStorage.IsRoaming(m_Scope)) 
                        scope = IsolatedStorage.c_DomainRoaming;
                    else if (IsolatedStorage.IsMachine(m_Scope)) 
                        scope = IsolatedStorage.c_MachineDomain;
                    else
                        scope = IsolatedStorage.c_Domain;
 
                    domainName = tp.Path1;
                    assemName = tp.Path2; 
                    appName = null; 
                }
                else 
                {
                    if (IsolatedStorageFile.NotAppFilesDir(tp.Path2))
                    {
                        // Assembly 
                        if (!GetIDStream(tp.Path1, out assem))
                            continue; 
 
                        if (IsolatedStorage.IsRoaming(m_Scope))
                            scope = IsolatedStorage.c_AssemblyRoaming; 
                        else if(IsolatedStorage.IsMachine(m_Scope))
                            scope = IsolatedStorage.c_MachineAssembly;
                        else
                            scope = IsolatedStorage.c_Assembly; 

                        domainName   = null; 
                        assemName = tp.Path1; 
                        appName = null;
                        assem.Position = 0; 
                    }
                    else
                    {
                        // Application 
                        if (!GetIDStream(tp.Path1, out app))
                            continue; 
 
                        if (IsolatedStorage.IsRoaming(m_Scope))
                            scope = IsolatedStorage.c_AppUserRoaming; 
                        else if(IsolatedStorage.IsMachine(m_Scope))
                            scope = IsolatedStorage.c_AppMachine;
                        else
                            scope = IsolatedStorage.c_AppUser; 

                        domainName   = null; 
                        assemName = null; 
                        appName = tp.Path1;
                        app.Position = 0; 
                    }

                }
 
                if (!isf.InitStore(scope, domain, assem, app, domainName, assemName, appName))
                    continue; 
 
                if (!isf.InitExistingStore(scope))
                    continue; 

                m_Current = isf;

                return true; 

            } while (true); 
            return false; 
        }
		public void GetStore_Application_NullObject ()
		{
			IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Application;
			IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, (object)null);
		}
		public void GetStore_Application_NullType ()
		{
			IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Application;
			IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, (Type)null);
			// again it's the lack of a manifest
		}
Exemplo n.º 47
0
                /// <summary>
                /// Loads an object from an XML file in Document format, located in a specified isolated storage area, and supplying extra data types to enable deserialization of custom types within the object.
                /// </summary>
                /// <example>
                /// <code>
                /// serializableObject = ObjectXMLSerializer&lt;SerializableObject&gt;.Load("XMLObjects.xml", IsolatedStorageFile.GetUserStoreForAssembly(), new Type[] { typeof(MyCustomType) });
                /// </code>
                /// </example>
                /// <param name="fileName">Name of the file in the isolated storage area to load the object from.</param>
                /// <param name="isolatedStorageDirectory">Isolated storage area directory containing the XML file to load the object from.</param>
                /// <param name="extraTypes">Extra data types to enable deserialization of custom types within the object.</param>
                /// <returns>Object loaded from an XML file located in a specified isolated storage area, using a specified serialized format.</returns>
                public static T Load(string fileName, IsolatedStorageFile isolatedStorageDirectory, System.Type[] extraTypes)
                {
                    T serializableObject = LoadFromDocumentFormat(null, fileName, isolatedStorageDirectory);

                    return(serializableObject);
                }