public static LinkerData Get(string dataPath)
        {
            LinkerData result = null;

            if (File.Exists(dataPath))
            {
                XmlSerializer xs = new XmlSerializer(typeof(LinkerData));
                using (StreamReader sr = new StreamReader(dataPath))
                {
                    result = xs.Deserialize(sr) as LinkerData;
                }
            }

            if (result == null) { result = new LinkerData { }; }
            else
            {
                result.Password = Encryption.Decrypt(result.Password, Encryption.EncryptionKey);
            }

            return result;
        }
        private void PublishUnmappedResource(LinkerData existing)
        {
            if (this.webresources.SelectedNode != null && this.webresources.SelectedNode.Tag != null)
            {
                // tag is only set internally so we should be ok without an error check here :P
                Guid webresourceId = new Guid(this.webresources.SelectedNode.Tag.ToString());

                // get rid of anything that's mapped with this sourcefile/webresourceid and add a clean one to avoid corruption on the mapping file
                existing.Mappings.RemoveAll(a =>
                    {
                        return a.WebResourceId == webresourceId
                            // check both the id and sourcepath because we now have to support re-linking
                            || a.SourceFilePath.Equals(this.UnmappedFile.FriendlyFilePath, StringComparison.InvariantCultureIgnoreCase);
                    });

                // add a clean mapping for this webresource and file
                existing.Mappings.Add(new LinkerDataItem
                    {
                        WebResourceId = webresourceId,
                        SourceFilePath = this.UnmappedFile.FriendlyFilePath
                    });

                Publish(new Guid[] { webresourceId }, new string[] { this.UnmappedFile.FilePath });

                this.PublishedFiles.Add(this.UnmappedFile);
                this.UnmappedFile = null;

                this.currentmapping.Text = "";
            }
        }
        private void PublishMappedResources(LinkerData existing, List<SelectedFile> alreadyMappednMatching)
        {
            Guid[] webresourceIds = new Guid[alreadyMappednMatching.Count];
            string[] filePaths = new string[alreadyMappednMatching.Count];

            for (int i = 0; i < alreadyMappednMatching.Count; i++)
            {
                // bit of logic to figure out the webresourceid of the file basd on the filepath
                webresourceIds[i] = existing.Mappings
                    .Where(a => a.SourceFilePath.Equals(alreadyMappednMatching[i].FriendlyFilePath, StringComparison.InvariantCultureIgnoreCase))
                    .Select(a => a.WebResourceId).Take(1).SingleOrDefault();

                filePaths[i] = alreadyMappednMatching[i].FilePath;
            }

            Publish(webresourceIds, filePaths);

            this.PublishedFiles.AddRange(alreadyMappednMatching);
        }