예제 #1
0
        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);
        }
예제 #2
0
 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()));
             }
         }
     }
 }
예제 #3
0
        internal static SupportedToolsData GetSupportedToolData(string dataFile, string schemaFile)
        {
            SupportedToolsData supportedToolsData = new SupportedToolsData(dataFile, schemaFile);

            supportedToolsData.ReadFile();
            supportedToolsData.Validate();
            return(supportedToolsData);
        }
예제 #4
0
        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);
        }
예제 #5
0
 private void LoadSupportedToolsData()
 {
     try
     {
         this.toolsData = SupportedToolsData.GetSupportedToolData(GetToolInformation.GetFilePath("SupportedTools.xml"), GetToolInformation.GetFilePath("SupportedTools.xsd"));
     }
     catch (Exception e)
     {
         this.HandleInvalidSupportedToolsData(e);
     }
 }
예제 #6
0
        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);
        }
예제 #7
0
 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);
 }
예제 #8
0
 internal bool RequiresTenantVersion()
 {
     foreach (ToolInfoData toolInfo in this.toolData.toolInformation)
     {
         if (SupportedToolsData.ContainsTenantVersionInformation(toolInfo))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #9
0
 private static bool Overlap(CustomSupportedVersion newRange, IEnumerable <CustomSupportedVersion> existingRanges)
 {
     foreach (CustomSupportedVersion range in existingRanges)
     {
         if (SupportedToolsData.Overlap(newRange, range))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #10
0
        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);
        }
예제 #11
0
        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);
                }
            }
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
 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);
     }
 }