private static bool IsValidVersionRange(string minVersionString, string maxVersionString) { Version version = SupportedToolsData.GetVersion(minVersionString, SupportedToolsData.MinimumVersion); Version version2 = SupportedToolsData.GetVersion(maxVersionString, SupportedToolsData.MaximumVersion); return(version <= version2); }
private void ValidateToolEntries() { foreach (ToolInfoData toolInfoData in this.toolData.toolInformation) { if (toolInfoData.defaultSupportedVersion != null && !SupportedToolsData.IsValidVersionRange(toolInfoData.defaultSupportedVersion.minSupportedVersion, toolInfoData.defaultSupportedVersion.latestVersion)) { SupportedToolsData.ReportInconsistentDataException(Strings.SupportedToolsDataInvalidToolVersionRange(toolInfoData.id.ToString())); } if (toolInfoData.customSupportedVersion != null) { foreach (CustomSupportedVersion customSupportedVersion2 in toolInfoData.customSupportedVersion) { if (!SupportedToolsData.IsValidVersionRange(customSupportedVersion2.minSupportedVersion, customSupportedVersion2.latestVersion)) { SupportedToolsData.ReportInconsistentDataException(Strings.SupportedToolsDataInvalidToolVersionRange(toolInfoData.id.ToString())); } if (!SupportedToolsData.IsValidVersionRange(customSupportedVersion2.minTenantVersion, customSupportedVersion2.maxTenantVersion)) { SupportedToolsData.ReportInconsistentDataException(Strings.SupportedToolsDataInvalidTenantVersionRange(toolInfoData.id.ToString())); } } if (SupportedToolsData.ContainsOverlappingVersionRanges(toolInfoData.customSupportedVersion)) { SupportedToolsData.ReportInconsistentDataException(Strings.SupportedToolsDataOverlappingTenantVersionRanges(toolInfoData.id.ToString())); } } } }
internal static SupportedToolsData GetSupportedToolData(string dataFile, string schemaFile) { SupportedToolsData supportedToolsData = new SupportedToolsData(dataFile, schemaFile); supportedToolsData.ReadFile(); supportedToolsData.Validate(); return(supportedToolsData); }
private static bool Overlap(CustomSupportedVersion range1, CustomSupportedVersion range2) { Version version = SupportedToolsData.GetVersion(range1.minTenantVersion, SupportedToolsData.MinimumVersion); Version version2 = SupportedToolsData.GetVersion(range1.maxTenantVersion, SupportedToolsData.MaximumVersion); Version version3 = SupportedToolsData.GetVersion(range2.minTenantVersion, SupportedToolsData.MinimumVersion); Version version4 = SupportedToolsData.GetVersion(range2.maxTenantVersion, SupportedToolsData.MaximumVersion); return(version2 >= version3 && version <= version4); }
private void LoadSupportedToolsData() { try { this.toolsData = SupportedToolsData.GetSupportedToolData(GetToolInformation.GetFilePath("SupportedTools.xml"), GetToolInformation.GetFilePath("SupportedTools.xsd")); } catch (Exception e) { this.HandleInvalidSupportedToolsData(e); } }
private static bool IsInRange(CustomSupportedVersion versionInfo, Version tenantVersion) { if (versionInfo == null || tenantVersion == null) { return(false); } Version version = SupportedToolsData.GetVersion(versionInfo.minTenantVersion, SupportedToolsData.MinimumVersion); Version version2 = SupportedToolsData.GetVersion(versionInfo.maxTenantVersion, SupportedToolsData.MaximumVersion); return(version2 >= tenantVersion && version <= tenantVersion); }
internal SupportedVersion GetSupportedVersion(ToolId toolId, Version tenantVersion) { foreach (ToolInfoData toolInfoData in this.toolData.toolInformation) { if (toolInfoData.id == toolId) { return(SupportedToolsData.GetSupportedVersion(toolInfoData, tenantVersion)); } } return(null); }
internal bool RequiresTenantVersion() { foreach (ToolInfoData toolInfo in this.toolData.toolInformation) { if (SupportedToolsData.ContainsTenantVersionInformation(toolInfo)) { return(true); } } return(false); }
private static bool Overlap(CustomSupportedVersion newRange, IEnumerable <CustomSupportedVersion> existingRanges) { foreach (CustomSupportedVersion range in existingRanges) { if (SupportedToolsData.Overlap(newRange, range)) { return(true); } } return(false); }
private static bool ContainsOverlappingVersionRanges(CustomSupportedVersion[] versions) { List <CustomSupportedVersion> list = new List <CustomSupportedVersion>(); foreach (CustomSupportedVersion customSupportedVersion in versions) { if (SupportedToolsData.Overlap(customSupportedVersion, list)) { return(true); } list.Add(customSupportedVersion); } return(false); }
private void ValidateDuplicatedToolEntries() { HashSet <ToolId> hashSet = new HashSet <ToolId>(); foreach (ToolInfoData toolInfoData in this.toolData.toolInformation) { if (hashSet.Contains(toolInfoData.id)) { SupportedToolsData.ReportInconsistentDataException(Strings.SupportedToolsDataMultipleToolEntries(toolInfoData.id.ToString())); } else { hashSet.Add(toolInfoData.id); } } }
private static SupportedVersion GetSupportedVersion(ToolInfoData toolInfo, Version tenantVersion) { SupportedVersion supportedVersion = null; if (tenantVersion != null && toolInfo.customSupportedVersion != null) { foreach (CustomSupportedVersion customSupportedVersion2 in toolInfo.customSupportedVersion) { if (SupportedToolsData.IsInRange(customSupportedVersion2, tenantVersion)) { supportedVersion = customSupportedVersion2; break; } } } return(supportedVersion ?? toolInfo.defaultSupportedVersion); }
private ToolInformation ConstructOutputObject(SupportedVersion supportedVersion) { ToolInformation result; try { Version version = SupportedToolsData.GetVersion(supportedVersion.minSupportedVersion, SupportedToolsData.MinimumVersion); Version version2 = SupportedToolsData.GetVersion(supportedVersion.latestVersion, SupportedToolsData.MaximumVersion); ToolVersionStatus versionStatus = GetToolInformation.GetVersionStatus(version, version2, this.Version); Uri updateInformationUrl = (versionStatus != ToolVersionStatus.LatestVersion) ? new Uri(supportedVersion.updateUrl) : null; result = new ToolInformation(this.Identity, versionStatus, version, version2, updateInformationUrl); } catch (Exception e) { this.HandleInvalidSupportedToolsData(e); result = null; } return(result); }
private void ReadFile() { if (!File.Exists(this.dataFile)) { throw new FileNotFoundException(Strings.SupportedToolsCannotFindFile, this.dataFile); } if (!File.Exists(this.schemaFile)) { throw new FileNotFoundException(Strings.SupportedToolsCannotFindFile, this.schemaFile); } try { XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); xmlReaderSettings.Schemas.Add(string.Empty, this.schemaFile); xmlReaderSettings.ValidationType = ValidationType.Schema; using (XmlReader xmlReader = XmlReader.Create(this.dataFile, xmlReaderSettings)) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(supportedTools)); this.toolData = (supportedTools)xmlSerializer.Deserialize(xmlReader); } } catch (IOException e) { SupportedToolsData.HandleDataReadException(e); } catch (XmlException e2) { SupportedToolsData.HandleDataReadException(e2); } catch (XmlSchemaException e3) { SupportedToolsData.HandleDataReadException(e3); } catch (InvalidOperationException ex) { SupportedToolsData.HandleDataReadException(ex.InnerException ?? ex); } }