public void Apply(LicenseInfo licenseInfo) { if (Name != null) licenseInfo.Product = Name; if (Url != null) licenseInfo.Url = Url; if (License != null) licenseInfo.LicenseType = License; if (ParentProduct != null) licenseInfo.ParentProduct = ParentProduct; if (Version != null) licenseInfo.Version = Version; }
public void ApplyToSubProduct(LicenseInfo licenseInfo) { if (Name != null) licenseInfo.ParentProduct = Name; }
public void LoadXml(FileInfo src) { XmlDocument doc = new XmlDocument(); doc.Load(src.FullName); XmlElement root = doc.DocumentElement; XmlNodeList licensesNodes = root.ChildNodes; for (int nodeIndex = 0; nodeIndex < licensesNodes.Count; nodeIndex++) { XmlNode licenseNode = licensesNodes.Item(nodeIndex); if (licenseNode.NodeType != XmlNodeType.Element) { continue; } XmlNamedNodeMap licenseAttributes = licenseNode.Attributes; LicenseInfo licenseInfo = new LicenseInfo(); for (int attributeIndex = 0; attributeIndex < licenseAttributes.Count; attributeIndex++) { XmlNode attribute = licenseAttributes.Item(attributeIndex); if (attribute.LocalName.Equals("productName")) licenseInfo.Product = attribute.Value; else if (attribute.LocalName.Equals("productVersion")) licenseInfo.Version = attribute.Value; else if (attribute.LocalName.Equals("parentProduct")) licenseInfo.ParentProduct = attribute.Value; else if (attribute.LocalName.Equals("filename")) licenseInfo.LicenseFilename = attribute.Value; else if (attribute.LocalName.Equals("licenseType")) licenseInfo.LicenseType = attribute.Value; else if (attribute.LocalName.Equals("url")) licenseInfo.Url = attribute.Value; } Add(licenseInfo); } }
private LicenseInfo getLicenseInfo(String external, ILicense licenseFound) { LicenseInfo licenseInfo = new LicenseInfo(); licenseInfo.LicenseFilename = licenseFound.LicenseFilename; licenseInfo.LicenseType = licenseFound.LicenseType; licenseInfo.Product = licenseFound.Product; licenseInfo.ParentProduct = licenseFound.ParentProduct; licenseInfo.Version = licenseFound.Version; if (_externals != null) { External externalDefinition; _externals.TryGetValue(external, out externalDefinition); if (externalDefinition != null) { if (String.IsNullOrEmpty(licenseInfo.ParentProduct)) { externalDefinition.Apply(licenseInfo); } else { externalDefinition.ApplyToSubProduct(licenseInfo); } } // subproduct external if (!String.IsNullOrEmpty(licenseInfo.ParentProduct)) { External childExternalDefinition; _externals.TryGetValue(licenseInfo.Product, out childExternalDefinition); if (childExternalDefinition != null) { childExternalDefinition.Apply(licenseInfo); } } } if (_folders != null) { foreach (Folder folder in _folders) { licenseInfo.Product = folder.Replace(licenseInfo.Product); licenseInfo.ParentProduct = folder.Replace(licenseInfo.ParentProduct); licenseInfo.LicenseFilename = folder.Replace(licenseInfo.LicenseFilename); } } return licenseInfo; }
public void Add(LicenseInfo license) { if (!_licenses.ContainsKey(license.GetKey())) _licenses.Add(license.GetKey(), license); }