コード例 #1
0
 /// <summary>
 /// Copies the current key to clipboard.
 /// </summary>
 private void CopyCurrentKeyToClipboard()
 {
     if (1 == this.keysListView.SelectedItems.Count)
     {
         MsdnKey.IndividualKey key = (MsdnKey.IndividualKey) this.keysListView.SelectedItems[0].Tag;
         if (null != key)
         {
             Clipboard.SetText(key.Key);
         }
     }
 }
コード例 #2
0
        public void Load(string filename)
        {
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException("File not found", filename);
            }

            // Get rid of the existing set of keys
            this._keys = new Dictionary <Guid, MsdnKey>();

            // Load the document
            XDocument doc      = XDocument.Load(filename);
            var       keyNodes = from productKey in doc.Element("YourKey").Elements("Product_Key")
                                 let key = productKey.Element("Key")
                                           where (int)int.Parse((string)key.Attribute("ID"), CultureInfo.InvariantCulture) != -3
                                           select new
            {
                Name    = (string)productKey.Attribute("Name"),
                Id      = int.Parse((string)key.Attribute("ID")),
                KeyText = (string)key.Value,
                Keys    = productKey.Elements("Key")
            };

            foreach (var keyNode in keyNodes)
            {
                // Convert the anonymous object to an MsdnKey object
                MsdnKey key = new MsdnKey();
                key.Name    = keyNode.Name;
                key.Id      = keyNode.Id;
                key.KeyText = keyNode.KeyText;

                // If this is an actual key (versus some CDATA'd HTML), add each key
                if (key.HasKey)
                {
                    foreach (XElement indKey in keyNode.Keys)
                    {
                        MsdnKey.IndividualKey ik = new MsdnKey.IndividualKey();
                        ik.ClaimedDate = MsdnKey.TryParseDateTime((string)indKey.Attribute("ClaimedDate"));
                        ik.KeyType     = (string)indKey.Attribute("Type");
                        ik.Key         = (string)indKey.Value;

                        key.AddKey(ik);
                    }
                }

                this._keys.Add(Guid.NewGuid(), key);
            }
        }
コード例 #3
0
        public void Load(string filename)
        {
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException("File not found", filename);
            }

            // Get rid of the existing set of keys
            this._keys = new Dictionary<Guid, MsdnKey>();

            // Load the document
            XDocument doc = XDocument.Load(filename);
            var keyNodes = from productKey in doc.Element("YourKey").Elements("Product_Key")
                let key = productKey.Element("Key")
                where (int)int.Parse((string)key.Attribute("ID"), CultureInfo.InvariantCulture) != -3
                select new
                {
                    Name = (string)productKey.Attribute("Name"),
                    Id = int.Parse((string)key.Attribute("ID")),
                    KeyText = (string)key.Value,
                    Keys = productKey.Elements("Key")
                };

            foreach (var keyNode in keyNodes)
            {
                // Convert the anonymous object to an MsdnKey object
                MsdnKey key = new MsdnKey();
                key.Name = keyNode.Name;
                key.Id = keyNode.Id;
                key.KeyText = keyNode.KeyText;

                // If this is an actual key (versus some CDATA'd HTML), add each key
                if (key.HasKey)
                {
                    foreach (XElement indKey in keyNode.Keys)
                    {
                        MsdnKey.IndividualKey ik = new MsdnKey.IndividualKey();
                        ik.ClaimedDate = MsdnKey.TryParseDateTime((string)indKey.Attribute("ClaimedDate"));
                        ik.KeyType = (string)indKey.Attribute("Type");
                        ik.Key = (string)indKey.Value;

                        key.AddKey(ik);
                    }
                }

                this._keys.Add(Guid.NewGuid(), key);
            }
        }