public static Chapter Load(string folderName, string urlName, EdxLoadOptions options) { return(Load <Chapter>(folderName, "chapter", urlName, options, c => { c.Sequentials = c.SequentialReferences.Select(x => Sequential.Load(folderName, x.UrlName, options)).ExceptNulls().ToArray(); c.SequentialReferences = c.Sequentials.Select(v => v.GetReference()).ToArray(); })); }
public static CourseWithChapters Load(string folderName, string urlName, EdxLoadOptions options) { return(Load <CourseWithChapters>(folderName, "course", urlName, options, c => { c.Chapters = c.ChapterReferences.Select(x => Chapter.Load(folderName, x.UrlName, options)).ExceptNulls().ToArray(); c.ChapterReferences = c.Chapters.Select(v => v.GetReference()).ToArray(); })); }
public static Sequential Load(string folderName, string urlName, EdxLoadOptions options) { return(Load <Sequential>(folderName, "sequential", urlName, options, seq => { seq.Verticals = seq.VerticalReferences.Select(x => Vertical.Load(folderName, x.UrlName, options)).ExceptNulls().ToArray(); seq.VerticalReferences = seq.Verticals.Select(v => v.GetReference()).ToArray(); })); }
public static Vertical Load(string folderName, string urlName, EdxLoadOptions options) { return(Load <Vertical>(folderName, "vertical", urlName, options, v => { v.Components = v.ComponentReferences.Select(x => x.LoadComponent(folderName, x.UrlName, options)).ExceptNulls().ToArray(); v.ComponentReferences = v.Components.Select(c => c.GetReference()).ToArray(); })); }
public static EdxCourse Load(string folderName, EdxLoadOptions options = null) { options = options ?? new EdxLoadOptions(); var course = new FileInfo($"{folderName}/course.xml").DeserializeXml <EdxCourse>(); course.StaticFiles = $"{folderName}/static".GetFiles(); course.CourseWithChapters = CourseWithChapters.Load(folderName, course.UrlName, options); return(course); }
public override Component LoadComponent(string folderName, string urlName, EdxLoadOptions options) { return(SlideProblemComponent.Load(folderName, urlName, options)); }
public virtual Component LoadComponent(string folderName, string urlName, EdxLoadOptions options) { return(null); }
public static TComponent Load <TComponent>(string folderName, string type, string urlName, EdxLoadOptions options, Action <TComponent> loadInner = null) where TComponent : EdxItem { try { var fileInfo = new FileInfo($"{folderName}/{type}/{urlName}.xml"); if (!fileInfo.Exists) { if (options.FailOnNonExistingItem) { throw new FileNotFoundException($"File {fileInfo.FullName} not found."); } else { options.HandleNonExistentItemTypeName?.Invoke(type, urlName); return(null); } } var component = fileInfo.DeserializeXml <TComponent>(); component.UrlName = urlName; loadInner?.Invoke(component); return(component); } catch (Exception e) { throw new Exception($"{type} {urlName} load error", e); } }