Example #1
0
        public void RemoveLinkedFile()
        {
            if (!String.IsNullOrWhiteSpace(DataFile))
            {
                string filePath = String.Format(CacheStore.CacheFilePathFormat, DBCacheStore.CacheDirectory, dataFile, DBCacheStore.CacheFileExtension);

                if (IsolatedStorageHelper.FileExists(filePath))
                {
                    IsolatedStorageHelper.DeleteFile(filePath);
                }
            }
        }
Example #2
0
        public bool LoadFromStream(Stream str)
        {
            if (str != null)
            {
                if (str.ReadByte() == 0)
                {
                    long  id        = str.ReadLong();
                    short entType   = str.ReadShort();
                    short cacheMode = str.ReadShort();

                    if ((id != -1) && (entType != -1) && (cacheMode != -1))
                    {
                        int ciidLength = str.ReadByte();

                        if (ciidLength != -1)
                        {
                            byte[] ciid = null;

                            if (ciidLength > 0)
                            {
                                ciid = str.ReadBytes(ciidLength);
                            }

                            short keyLength = str.ReadShort();

                            if (keyLength != -1)
                            {
                                byte[] key = null;

                                if (keyLength > 0)
                                {
                                    key = str.ReadBytes(keyLength);
                                }

                                short dataFileLength = str.ReadShort();

                                if (dataFileLength != -1)
                                {
                                    string dataFileName = null;

                                    if (dataFileLength > 0)
                                    {
                                        byte[] dataFileBytes = str.ReadBytes(dataFileLength);

                                        if (dataFileBytes != null)
                                        {
                                            dataFileName = StringHelper.GetString(dataFileBytes);
                                        }
                                    }

                                    if (!String.IsNullOrEmpty(dataFileName) &&
                                        (id != CacheStore.BadRecordID) &&
                                        IsolatedStorageHelper.FileExists(
                                            String.Format(
                                                CacheStore.CacheFilePathFormat,
                                                FileCacheStore.CacheDirectory, dataFileName, FileCacheStore.CacheFileExtension)))
                                    {
                                        ID         = id;
                                        EntityType = (CacheEntityType)entType;
                                        CacheMode  = (CacheMode)cacheMode;

                                        if (ciid != null)
                                        {
                                            CIID = new CacheItemID(ciid);
                                        }
                                        else
                                        {
                                            CIID = null;
                                        }

                                        Key      = key;
                                        dataFile = dataFileName;

                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(false);
        }