private string CopyIfFileReference(string source)
        {
            FileReference sourceReference = FileReference.Parse(source);

            if (sourceReference == null)
            {
                return(source);
            }

            string destinationPath = CreateUniqueFilename(Path.GetExtension(sourceReference.Path));

            using (IsolatedStorageFile userStore = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream outputStream = new IsolatedStorageFileStream(destinationPath, FileMode.CreateNew, userStore))
                {
                    using (IsolatedStorageFileStream inputStream = new IsolatedStorageFileStream(sourceReference.Path, FileMode.Open, userStore))
                    {
                        inputStream.CopyTo(outputStream);
                    }
                }
            }

            FileReference destinationReference = new FileReference(destinationPath, sourceReference.Context);

            logger.TraceFormat("Copied {0} to {1}", sourceReference, destinationReference);

            return(destinationReference.ToString());
        }
        private string ExtractFileData(string source)
        {
            FileData fileData = FileData.Parse(source);

            if (fileData == null)
            {
                return(source);
            }

            string        path          = CreateUniqueFilename(".bin");
            FileReference fileReference = new FileReference(path, null);

            WriteContent(path, fileData.Data);

            logger.TraceFormat("Wrote file data of {0} bytes to file referred to by {1}", fileData.Data.Length, fileReference);

            return(fileReference.ToString());
        }