private static void AddOSInformation(NativeCodeAnalyzer analyzer, OsVersion os) { switch (os) { case OsVersion.WindowsXP: analyzer.AddInitialMacro(new Macro("WINVER", "0x0501")); analyzer.AddInitialMacro(new Macro("_WIN32_WINNT", "0x0501")); break; case OsVersion.Windows2000: analyzer.AddInitialMacro(new Macro("WINVER", "0x0500")); analyzer.AddInitialMacro(new Macro("_WIN32_WINNT", "0x0500")); break; case OsVersion.Windows2003: analyzer.AddInitialMacro(new Macro("WINVER", "0x0502")); analyzer.AddInitialMacro(new Macro("_WIN32_WINNT", "0x0502")); break; case OsVersion.WindowsVista: analyzer.AddInitialMacro(new Macro("WINVER", "0x0600")); analyzer.AddInitialMacro(new Macro("_WIN32_WINNT", "0x0600")); break; default: ThrowInvalidEnumValue(os); break; } }
public override int GetHashCode() { int hash = 1; if (SdkInstanceId.Length != 0) { hash ^= SdkInstanceId.GetHashCode(); } if (ArcoreSdkVersion.Length != 0) { hash ^= ArcoreSdkVersion.GetHashCode(); } if (OsVersion.Length != 0) { hash ^= OsVersion.GetHashCode(); } if (unity_ != null) { hash ^= Unity.GetHashCode(); } if (SdkSessionId.Length != 0) { hash ^= SdkSessionId.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private void _read() { _magic = m_io.ReadBytes(8); if (!((KaitaiStream.ByteArrayCompare(Magic, new byte[] { 65, 78, 68, 82, 79, 73, 68, 33 }) == 0))) { throw new ValidationNotEqualError(new byte[] { 65, 78, 68, 82, 79, 73, 68, 33 }, Magic, M_Io, "/seq/0"); } _kernel = new Load(m_io, this, m_root); _ramdisk = new Load(m_io, this, m_root); _second = new Load(m_io, this, m_root); _tagsLoad = m_io.ReadU4le(); _pageSize = m_io.ReadU4le(); _headerVersion = m_io.ReadU4le(); _osVersion = new OsVersion(m_io, this, m_root); _name = System.Text.Encoding.GetEncoding("ASCII").GetString(KaitaiStream.BytesTerminate(m_io.ReadBytes(16), 0, false)); _cmdline = System.Text.Encoding.GetEncoding("ASCII").GetString(KaitaiStream.BytesTerminate(m_io.ReadBytes(512), 0, false)); _sha = m_io.ReadBytes(32); _extraCmdline = System.Text.Encoding.GetEncoding("ASCII").GetString(KaitaiStream.BytesTerminate(m_io.ReadBytes(1024), 0, false)); if (HeaderVersion > 0) { _recoveryDtbo = new SizeOffset(m_io, this, m_root); } if (HeaderVersion > 0) { _bootHeaderSize = m_io.ReadU4le(); } if (HeaderVersion > 1) { _dtb = new LoadLong(m_io, this, m_root); } }
public override int GetHashCode() { int hash = 1; if (SdkInstanceId.Length != 0) { hash ^= SdkInstanceId.GetHashCode(); } if (SdkSessionId.Length != 0) { hash ^= SdkSessionId.GetHashCode(); } if (ArcoreSdkVersion.Length != 0) { hash ^= ArcoreSdkVersion.GetHashCode(); } if (SdkType != 0) { hash ^= SdkType.GetHashCode(); } if (OsVersion.Length != 0) { hash ^= OsVersion.GetHashCode(); } if (engineCase_ == EngineOneofCase.Unity) { hash ^= Unity.GetHashCode(); } hash ^= (int)engineCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void OsVersion_Basic() { // I'm not going to do much of a test here at this point. var ver = new OsVersion(); Assert.AreEqual(Environment.OSVersion.Version.Major, ver.OSVersion.Major); Assert.AreEqual(Environment.OSVersion.Version.Minor, ver.OSVersion.Minor); }
private static OsVersionInfo GetOsVersionInfo(OsVersion osVersion) { OsVersionInfo osVersionInfo = Versions.FirstOrDefault(v => v.OsVersion == osVersion); if (osVersionInfo == null) { throw new NotImplementedException("OSVersion:" + osVersion); } return(osVersionInfo); }
/// <inheritdoc /> public override int GetHashCode() { unchecked { int hashCode = (OsVersion != null ? OsVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Manufacturer != null ? Manufacturer.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Model != null ? Model.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// 実行環境のログ出力 /// </summary> static void DumpEnvironmentLog() { var osVersion = new OsVersion(); LOG.Info(osVersion.GetOsDisplayString()); LOG.Info(osVersion.GetEnvironmentString()); string clrVersionRuntime = System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion(); LOG.Info("実行中のCLR = " + clrVersionRuntime); }
public override int GetHashCode() { int hash = 1; if (Raw.Length != 0) { hash ^= Raw.GetHashCode(); } if (Platform.Length != 0) { hash ^= Platform.GetHashCode(); } if (Os.Length != 0) { hash ^= Os.GetHashCode(); } if (OsVersion.Length != 0) { hash ^= OsVersion.GetHashCode(); } if (Engine.Length != 0) { hash ^= Engine.GetHashCode(); } if (EngineVersion.Length != 0) { hash ^= EngineVersion.GetHashCode(); } if (Browser.Length != 0) { hash ^= Browser.GetHashCode(); } if (BrowserVersion.Length != 0) { hash ^= BrowserVersion.GetHashCode(); } if (Localization.Length != 0) { hash ^= Localization.GetHashCode(); } if (Mobile != false) { hash ^= Mobile.GetHashCode(); } if (WalletCompatible != false) { hash ^= WalletCompatible.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Sometimes you want to parse out a snippet of code without doing the full windows /// parse. In this case you'll need to have certain Macros already defined since /// they are defined at the begining of the windows header files. This will add /// in all of those macros /// </summary> /// <param name="osVersion"></param> /// <returns></returns> /// <remarks></remarks> public static NativeCodeAnalyzer CreateForMiniParse(OsVersion osVersion, IEnumerable <Macro> initialMacroList) { NativeCodeAnalyzer analyzer = Create(osVersion); Debug.Assert(analyzer.IncludeInitialMacrosInResult); // Should be the default analyzer.IncludeInitialMacrosInResult = false; foreach (Macro m in initialMacroList) { analyzer.AddInitialMacro(m); } return(analyzer); }
private async void WindowsSettingsAllAccessibilityOptionsClicked(object sender, RoutedEventArgs e) { string settingsUrlAsPath = null !; // required to quiet the "not initialized error" var windowsVersion = OsVersion.GetWindowsVersion(); if (windowsVersion is not null) { switch (windowsVersion) { case WindowsVersion.Win10_v1809: case WindowsVersion.Win10_v1903: case WindowsVersion.Win10_v1909: case WindowsVersion.Win10_v2004: case WindowsVersion.Win10_v20H2: case WindowsVersion.Win10_v21H1: case WindowsVersion.Win10_v21H2: // Windows 10 1809, 1903, 1909, 2004, 20H2, 21H1, 21H2 // NOTE: we should re-evaluate this path in all versions of Windows (to verify that it shouldn't be simply "ms-settings:easeofaccess" instead) settingsUrlAsPath = "ms-settings:easeofaccess-display"; break; case WindowsVersion.Win10_vFuture: // OBSERVATION: this may be the wrong path for future verisons of Windows (especially since Win10 and Win11 _may_ treat this differently post-21H1); re-evaluate this logic settingsUrlAsPath = "ms-settings:easeofaccess-display"; break; case WindowsVersion.Win11_v21H2: case WindowsVersion.Win11_vFuture: // Windows 11 21H2 (and assumed for the future) settingsUrlAsPath = "ms-settings:easeofaccess"; break; default: // not supported Debug.Assert(false, "This build of Windows is not supported"); return; } } else { // not supported Debug.Assert(false, "This build of Windows is not supported"); return; } MorphicMenuItem.OpenMenuItemPath(settingsUrlAsPath); await MorphicMenuItem.RecordMenuItemTelemetryAsync(settingsUrlAsPath, ((MorphicMenuItem)sender).ParentMenuType, ((MorphicMenuItem)sender).TelemetryType, ((MorphicMenuItem)sender).TelemetryCategory); }
public override int GetHashCode() { int hash = 1; if (PlatformType != global::AcFunDanmu.DeviceInfo.Types.PlatformType.KInvalid) { hash ^= PlatformType.GetHashCode(); } if (OsVersion.Length != 0) { hash ^= OsVersion.GetHashCode(); } if (DeviceModel.Length != 0) { hash ^= DeviceModel.GetHashCode(); } if (ImeiMd5.Length != 0) { hash ^= ImeiMd5.GetHashCode(); } if (DeviceId.Length != 0) { hash ^= DeviceId.GetHashCode(); } if (SoftDid.Length != 0) { hash ^= SoftDid.GetHashCode(); } if (KwaiDid.Length != 0) { hash ^= KwaiDid.GetHashCode(); } if (Manufacturer.Length != 0) { hash ^= Manufacturer.GetHashCode(); } if (DeviceName.Length != 0) { hash ^= DeviceName.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private static IPhoneDeviceInfo PhoneDeviceInfoFromFileContents(string filePath, string infoFileContents) { string backupPath = Path.GetDirectoryName(filePath); IOsVersion DefaultOsVersion = new OsVersion("4.0.0"); try { XmlReaderSettings readerSettings = new XmlReaderSettings(); readerSettings.DtdProcessing = DtdProcessing.Ignore; using (XmlReader infoXml = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes((infoFileContents))), readerSettings)) { return(PhoneDeviceInfoFromXmlReader(backupPath, infoXml)); } } catch (Exception) { return(new PhoneDeviceInfo(backupPath, null, null, DefaultOsVersion, null)); } }
public override int GetHashCode() { int hash = 1; if (TargetEnvId.Length != 0) { hash ^= TargetEnvId.GetHashCode(); } if (ClientVersion.Length != 0) { hash ^= ClientVersion.GetHashCode(); } if (ClientOs != 0) { hash ^= ClientOs.GetHashCode(); } if (OsVersion.Length != 0) { hash ^= OsVersion.GetHashCode(); } if (DeviceModel.Length != 0) { hash ^= DeviceModel.GetHashCode(); } if (deviceInfoCase_ == DeviceInfoOneofCase.IosDeviceInfo) { hash ^= IosDeviceInfo.GetHashCode(); } if (deviceInfoCase_ == DeviceInfoOneofCase.AndroidDeviceInfo) { hash ^= AndroidDeviceInfo.GetHashCode(); } if (BuildNumber.Length != 0) { hash ^= BuildNumber.GetHashCode(); } hash ^= (int)deviceInfoCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public VolumeManager(params string[] processName) { string[] processNames = processName; volumeControls = new List <IVolumeControl>(); OS = SysInfo.Os; using (ServiceController process = new ServiceController("AudioSrv")) { if (process.Status != ServiceControllerStatus.Running) { process.Start(); process.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 5)); } } switch (OS) { case OsVersion.XP: { volumeControls.Add(new Drivers.XP.VolumeControl(processNames[0])); break; } case OsVersion.Vista: { volumeControls.Add(new Drivers.Vista.VolumeControl(processNames[0])); break; } case OsVersion.Seven: case OsVersion.Eight: { foreach (string _processName in processNames) { volumeControls.Add(new Drivers.Seven.VolumeControl(_processName)); } break; } } //volume = Volume; //mute = Mute; }
/// <summary> /// This will create an analyzer for parsing out a full header file /// </summary> /// <param name="osVersion"></param> /// <returns></returns> /// <remarks></remarks> public static NativeCodeAnalyzer Create(OsVersion osVersion) { NativeCodeAnalyzer analyzer = new NativeCodeAnalyzer(); Debug.Assert(analyzer.IncludeInitialMacrosInResult); // Should be the default // Ignore 64 bit settings. 64 bit types are emitted as SysInt or IntPtr analyzer.AddInitialMacro(new Macro("__w64", string.Empty)); analyzer.AddInitialMacro(new Macro("_X86_", string.Empty)); analyzer.AddInitialMacro(new Macro("_WIN32", string.Empty)); analyzer.AddInitialMacro(new Macro("WINAPI", "__winapi", true)); analyzer.AddInitialMacro(new Macro("UNICODE", "1")); analyzer.AddInitialMacro(new Macro("__STDC__", "1")); // Add the operating system macros AddOSInformation(analyzer, osVersion); // Common information AddCommonMacros(analyzer); return(analyzer); }
public async Task InstallAppRuntimeAsync(OsVersion osVersion, AppRuntimeVersion appRuntimeVersion) { try { await _feedbackChannel.SendFeedback($"- - - - Installing AppRuntimeVersion: {appRuntimeVersion} on Os: {osVersion} - - - -"); using (var client = _sshClient) { client.Connect(); if (_scriptManager.GetScript(osVersion, appRuntimeVersion, out List <string> scriptLines)) { foreach (var scriptLine in scriptLines) { await _feedbackChannel.SendFeedback($"$ {scriptLine}"); var output = await client.RunCommandAsync(scriptLine); await _feedbackChannel.SendFeedback(output); } await _feedbackChannel.SendFeedback($"- - - - Finished installing AppRuntimeVersion: {appRuntimeVersion} on Os: {osVersion} - - - -"); } else { await _feedbackChannel.SendFeedback($"{nameof(osVersion)} combined with {nameof(appRuntimeVersion)} is currently not a supported combination."); } } } catch (Exception e) { await _feedbackChannel.SendFeedback($"- - - - Failed installing AppRuntimeVersion: {appRuntimeVersion} on Os: {osVersion}, with error: {e.Message} - - - - "); _logger.LogWarning(e.Message); } }
public ScriptKey(OsVersion osVersion, AppRuntimeVersion appRuntimeVersion) { OsVersion = osVersion; AppRuntimeVersion = appRuntimeVersion; }
public async Task <object> PostDevice(DeviceNameModel device) { dynamic cResponse = new ExpandoObject(); try { if (!ModelState.IsValid) { cResponse.Result = "-1"; cResponse.Description = ModelState; return(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(cResponse))); } // get DeviceType and create new if not exist DeviceType dbDeviceType = await db.DeviceType.Where(x => x.Name == device.DeviceTypeName).SingleOrDefaultAsync(); if (dbDeviceType == null) { dbDeviceType = new DeviceType(); dbDeviceType.Name = device.DeviceTypeName; db.DeviceType.Add(dbDeviceType); await db.SaveChangesAsync(); } // get OsVersion and create new if not exist OsVersion dbOsVersion = await db.OsVersion.Where(x => x.Name == device.OsVersionName).SingleOrDefaultAsync(); if (dbOsVersion == null) { dbOsVersion = new OsVersion(); dbOsVersion.Name = device.OsVersionName; db.OsVersion.Add(dbOsVersion); await db.SaveChangesAsync(); } // get OsVersion and create new if not exist AppVersion dbAppVersion = await db.AppVersion.Where(x => x.Name == device.AppVersionName).SingleOrDefaultAsync(); if (dbAppVersion == null) { dbAppVersion = new AppVersion(); dbAppVersion.Name = device.AppVersionName; string[] dateTime = device.AppVersionDatePublish.Split('-'); int year = Convert.ToInt16(dateTime[0]); int month = Convert.ToInt16(dateTime[1]); int day = Convert.ToInt16(dateTime[2]); DateTime dt = new DateTime(year, month, day); dbAppVersion.DatePublish = dt; db.AppVersion.Add(dbAppVersion); await db.SaveChangesAsync(); } Language dbLanguage = await db.Language.Where(x => x.Name == device.DeviceLanguageName).SingleOrDefaultAsync(); if (dbLanguage == null) { dbLanguage = new Language(); dbLanguage.Name = device.DeviceLanguageName; db.Language.Add(dbLanguage); } Device isFoundDevice = await db.Device.Where(x => x.DeviceToken == device.DeviceToken && x.IsActive == true && x.DeviceTypeID == dbDeviceType.DeviceTypeID).SingleOrDefaultAsync(); if (isFoundDevice != null) { bool isChanged = false; if (isFoundDevice.OsVersionID != dbOsVersion.VersionID) { isChanged = true; } if (isFoundDevice.AppVersionID != dbAppVersion.VersionID) { isChanged = true; } if (isFoundDevice.DeviceOsID != device.DeviceOsID) { isChanged = true; } if (isFoundDevice.DeviceLanguageID != dbLanguage.LanguageID) { isChanged = true; } if (isFoundDevice.PersonID != device.PersonID) { isChanged = true; } if (isChanged) { isFoundDevice.IsActive = false; await db.SaveChangesAsync(); await InsertNewDevice(device, dbDeviceType, dbOsVersion, dbAppVersion, dbLanguage); } else { isFoundDevice.DateLastLogin = DateTime.Now; await db.SaveChangesAsync(); } cResponse.Result = "0"; cResponse.Description = "Device Updated"; return(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(cResponse))); } else { await InsertNewDevice(device, dbDeviceType, dbOsVersion, dbAppVersion, dbLanguage); cResponse.Result = "0"; cResponse.Description = "Device added to database"; return(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(cResponse))); } } catch { cResponse.Result = "-1"; cResponse.Description = "Exception, your request could not be executed"; return(JsonConvert.DeserializeObject(JsonConvert.SerializeObject(cResponse))); } }
private async Task InsertNewDevice(DeviceNameModel device, DeviceType dbDeviceType, OsVersion dbOsVersion, AppVersion dbAppVersion, Language dbLanguage) { Device dvc = new Device(); // Insert to table first then get ID if not exists dvc.DeviceTypeID = dbDeviceType.DeviceTypeID; dvc.OsVersionID = dbOsVersion.VersionID; dvc.AppVersionID = dbAppVersion.VersionID; dvc.DeviceToken = device.DeviceToken; dvc.IsActive = true; dvc.DateLogin = DateTime.Now; dvc.DateLastLogin = DateTime.Now; dvc.PersonID = device.PersonID; dvc.DeviceOsID = device.DeviceOsID; dvc.DeviceLanguageID = dbLanguage.LanguageID; db.Device.Add(dvc); await db.SaveChangesAsync(); }
/// <summary> /// Compares the major/minor version of <paramref name="os" /> and <paramref name="osVersion" />. /// </summary> /// <example><see cref="System.Environment.OSVersion" />.Equals(OSVersion.Win7)</example> public static bool IsEqualTo(this OperatingSystem os, OsVersion osVersion) { OsVersionInfo osVersionInfo = GetOsVersionInfo(osVersion); return(GetMajorMinorVersion(os.Version) == GetMajorMinorVersion(osVersionInfo.OperatingSystem.Version)); }
private async void WindowsSettingsPointerSizeClicked(object sender, RoutedEventArgs e) { string settingsUrlAsPath = null !; // required to quiet the "not initialized error" var windowsVersion = OsVersion.GetWindowsVersion(); if (windowsVersion is not null) { switch (windowsVersion) { case WindowsVersion.Win10_v1809: case WindowsVersion.Win10_v1903: case WindowsVersion.Win10_v1909: // Windows 10 1809, 1903, 1909 settingsUrlAsPath = "ms-settings:easeofaccess-cursorandpointersize"; break; case WindowsVersion.Win10_v2004: // Windows 10 2004 settingsUrlAsPath = "ms-settings:easeofaccess-MousePointer"; break; case WindowsVersion.Win10_v20H2: // Windows 10 20H2 // NOTE: Microsoft changed the URL for this link somwhere between 10.0.19042.986 and 10.0.19042.1052; // if we get any bug reports that this link doesn't work with v20H2, be sure to get the "winver" full version #...so we can adjust the revision # below (to something between 986 and 1051) as appropriate uint?updateBuildRevision; var getUpdateBuildRevisionResult = Morphic.WindowsNative.OsVersion.OsVersion.GetUpdateBuildRevision(); if (getUpdateBuildRevisionResult.IsSuccess == true) { updateBuildRevision = getUpdateBuildRevisionResult.Value !; } else { // NOTE: if we could not get the update build revision, we fail gracefully by assuming that the user's computer is updated to the OS version's most recent updates updateBuildRevision = null; } if (updateBuildRevision.HasValue == true && updateBuildRevision.Value < 1052) { // NOTE: this link was verified in Windows 10 19042.985 settingsUrlAsPath = "ms-settings:easeofaccess-MousePointer"; } else { // NOTE: this link was verified in Windows 10 19042.1052 settingsUrlAsPath = "ms-settings:easeofaccess-mousepointer"; } break; case WindowsVersion.Win10_v21H1: case WindowsVersion.Win10_v21H2: case WindowsVersion.Win10_vFuture: // Windows 10 21H1, Windows 10 21H2 (and assumed for the future) settingsUrlAsPath = "ms-settings:easeofaccess-mousepointer"; break; case WindowsVersion.Win11_v21H2: case WindowsVersion.Win11_vFuture: // Windows 11 21H2 (and assumed for the future) settingsUrlAsPath = "ms-settings:easeofaccess-mousepointer"; break; default: // not supported Debug.Assert(false, "This build of Windows is not supported"); return; } } else { // not supported Debug.Assert(false, "This build of Windows is not supported"); return; } MorphicMenuItem.OpenMenuItemPath(settingsUrlAsPath); await MorphicMenuItem.RecordMenuItemTelemetryAsync(settingsUrlAsPath, ((MorphicMenuItem)sender).ParentMenuType, ((MorphicMenuItem)sender).TelemetryType, ((MorphicMenuItem)sender).TelemetryCategory); }
private static IPhoneDeviceInfo PhoneDeviceInfoFromXmlReader(string backupPath, XmlReader infoXmlReader) { string displayName = null; DateTime? lastBackupDate = null; IOsVersion osVersion = null; Guid? deviceGuid = null; try { infoXmlReader.ReadToDescendant("dict"); if (!infoXmlReader.IsStartElement()) { throw new InvalidDataException("Value dictionary not found."); } infoXmlReader.ReadToDescendant("key"); while (!infoXmlReader.EOF) { try { string keyName = infoXmlReader.ReadString(); switch (keyName) { case "Display Name": displayName = ReadNextStringNode(infoXmlReader); break; case "Last Backup Date": lastBackupDate = ReadNextDateNode(infoXmlReader); break; case "Product Version": string versionString = ReadNextStringNode(infoXmlReader); osVersion = new OsVersion(versionString); break; case "GUID": deviceGuid = new Guid(ReadNextStringNode(infoXmlReader)); break; default: break; } infoXmlReader.ReadToNextSibling("key"); } catch (XmlException) { throw; } catch (Exception) { ; } } } catch (Exception) { ; } return(new PhoneDeviceInfo(backupPath, displayName, lastBackupDate, osVersion, deviceGuid)); }
/// <summary> /// Compares the major/minor version of <paramref name="os" /> and <paramref name="osVersion" />. /// </summary> /// <example><see cref="System.Environment.OSVersion" />.IsGreaterThan(OSVersion.Win7)</example> public static bool IsGreaterThan(this OperatingSystem os, OsVersion osVersion) { OsVersionInfo osVersionInfo = GetOsVersionInfo(osVersion); return(GetMajorMinorVersion(os.Version) > GetMajorMinorVersion(osVersionInfo.OperatingSystem.Version)); }
public bool GetScript(OsVersion osVersion, AppRuntimeVersion appRuntimeVersion, out List <string> scriptLines) { return(ScriptDictionary.TryGetValue(new ScriptKey(osVersion, appRuntimeVersion), out scriptLines)); }
private static IPhoneDeviceInfo PhoneDeviceInfoFromFileContents(string filePath, string infoFileContents) { string backupPath = Path.GetDirectoryName(filePath); IOsVersion DefaultOsVersion = new OsVersion("4.0.0"); try { XmlReaderSettings readerSettings = new XmlReaderSettings(); readerSettings.DtdProcessing = DtdProcessing.Ignore; using (XmlReader infoXml = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes((infoFileContents))), readerSettings)) { return PhoneDeviceInfoFromXmlReader(backupPath, infoXml); } } catch (Exception) { return new PhoneDeviceInfo(backupPath, null, null, DefaultOsVersion, null); } }
private static IPhoneDeviceInfo PhoneDeviceInfoFromXmlReader(string backupPath, XmlReader infoXmlReader) { string displayName = null; DateTime? lastBackupDate = null; IOsVersion osVersion = null; Guid? deviceGuid = null; try { infoXmlReader.ReadToDescendant("dict"); if (!infoXmlReader.IsStartElement()) { throw new InvalidDataException("Value dictionary not found."); } infoXmlReader.ReadToDescendant("key"); while (!infoXmlReader.EOF) { try { string keyName = infoXmlReader.ReadString(); switch (keyName) { case "Display Name": displayName = ReadNextStringNode(infoXmlReader); break; case "Last Backup Date": lastBackupDate = ReadNextDateNode(infoXmlReader); break; case "Product Version": string versionString = ReadNextStringNode(infoXmlReader); osVersion = new OsVersion(versionString); break; case "GUID": deviceGuid = new Guid(ReadNextStringNode(infoXmlReader)); break; default: break; } infoXmlReader.ReadToNextSibling("key"); } catch (XmlException) { throw; } catch (Exception) { ; } } } catch (Exception) { ; } return new PhoneDeviceInfo(backupPath, displayName, lastBackupDate, osVersion, deviceGuid); }