private void Parse(string timeSpanValue) { if (string.IsNullOrEmpty(timeSpanValue)) { throw new ArgumentException("Could not parse TimeSpan -- string was empty", "timeSpanValue"); } else { try { if (timeSpanValue.StartsWith("P")) { this.Value = ParseIso8601TimeSpan(timeSpanValue); } else { this.Value = ParseCmiTimeSpan(timeSpanValue); } } catch (ArgumentException) { // Be kind and give them one last shot with the built-in parser, // even though it's not strictly SCORM try { this.Value = (long)TimeSpan.Parse(timeSpanValue).TotalSeconds *HUNDREDTHS_PER_SECOND; } catch { throw new ArgumentException("Could not parse ScormTimeSpan, invalid format", "timeSpanValue"); } } } this.Description = new LanguageString(); }
/// <summary> /// Creates a new instance of the class from an string adhering various SCORM formats. This function will attempt /// to use the ISO 8601 format, then the CMI format. If neither of those succeed, then it will try to parse the time span /// using the built-in .NET TimeSpan object. /// </summary> /// <param name="timeSpanValue">The value to instantiate this class with</param> /// <param name="allowNull">If true allow empty string to translate to ScormTimeSpan.UNDEFINED</param> /// <exception cref="ManifestFormatException">If the format is not recognizable.</exception> public ScormTimeSpan(string timeSpanValue, bool allowNull) { this.Value = ScormTimeSpan.UNDEFINED; this.Description = new LanguageString(); if (timeSpanValue.Length > 0 || !allowNull) { this.Parse(timeSpanValue); } }
public LanguageString(LanguageString source) { this.text = source.text; this.language = source.language; }
/// <summary> /// Creates a new instance of the class from an integer representing hundredths of a second. Hundredths of a /// second is how this data type is stored in the database. /// </summary> /// <param name="hundredths">The value to instantiate this class with</param> public ScormTimeSpan(long hundredths) { this.Value = hundredths; this.Description = new LanguageString(); }
private void Parse(string timeSpanValue) { if (String.IsNullOrEmpty(timeSpanValue)) { throw new InvalidArgumentException("Could not parse TimeSpan -- String was empty"); } else try { if (timeSpanValue.StartsWith("P")) { this.Value = ParseIso8601TimeSpan(timeSpanValue); } else { this.Value = ParseCmiTimeSpan(timeSpanValue); } } catch (InvalidArgumentException) { // Be kind and give them one last shot with the built-in parser, // even though it's not strictly SCORM try { this.Value = (long)TimeSpan.Parse(timeSpanValue).TotalSeconds * HUNDREDTHS_PER_SECOND; } catch { throw new InvalidArgumentException("Could not parse ScormTimeSpan, invalid format"); } } this.Description = new LanguageString(); }
/// <summary> /// Creates a new instance of the class from an string adhering various SCORM formats. This function will attempt /// to use the ISO 8601 format, then the CMI format. If neither of those succeed, then it will try to parse the time span /// using the built-in .NET TimeSpan object. /// </summary> /// <param name="timeSpanValue">The value to instantiate this class with</param> /// <exception cref="ManifestFormatException">If the format is not recognizable.</exception> public ScormTimeSpan(string timeSpanValue) { this.Value = ScormTimeSpan.UNDEFINED; this.Description = new LanguageString(); this.Parse(timeSpanValue); }
/// <summary> /// Creates a new instance of the class from an string adhering various SCORM formats. This function will attempt /// to use the ISO 8601 format, then the CMI format. If neither of those succeed, then it will try to parse the time span /// using the built-in .NET TimeSpan object. /// </summary> /// <param name="timeSpanValue">The value to instantiate this class with</param> /// <param name="allowNull">If true allow empty string to translate to ScormTimeSpan.UNDEFINED</param> /// <exception cref="ManifestFormatException">If the format is not recognizable.</exception> public ScormTimeSpan(string timeSpanValue, bool allowNull) { this.Value = ScormTimeSpan.UNDEFINED; this.Description = new LanguageString(); if (timeSpanValue.Length > 0 || !allowNull) { this.Parse(timeSpanValue); } }
public ScormTimeSpan(ScormTimeSpan other) { this.Value = other.Value; this.Description = new LanguageString(other.Description); }
public LanguageString(LanguageString source) { this.text = source.text; this.language = source.language; }
public ScormTimeSpan(ScormTimeSpan other) { this.Value = other.Value; this.Description = new LanguageString(other.Description); }
/// <summary> /// Creates a new instance of the class from an integer representing hundredths of a second. Hundredths of a /// second is how this data type is stored in the database. /// </summary> /// <param name="hundredths">The value to instantiate this class with</param> public ScormTimeSpan(long hundredths) { this.Value = hundredths; this.Description = new LanguageString(); }
/// <summary> /// Creates a new instance of the class from an string adhering various SCORM formats. This function will attempt /// to use the ISO 8601 format, then the CMI format. If neither of those succeed, then it will try to parse the time span /// using the built-in .NET TimeSpan object. /// </summary> /// <param name="timeSpanValue">The value to instantiate this class with</param> /// <exception cref="ManifestFormatException">If the format is not recognizable.</exception> public ScormTimeSpan(string timeSpanValue) { this.Value = ScormTimeSpan.UNDEFINED; this.Description = new LanguageString(); this.Parse(timeSpanValue); }