コード例 #1
0
 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();
     }));
 }
コード例 #2
0
ファイル: CourseWithChapters.cs プロジェクト: atnartur/Ulearn
 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();
     }));
 }
コード例 #3
0
 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();
     }));
 }
コード例 #4
0
 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();
     }));
 }
コード例 #5
0
ファイル: EdxCourse.cs プロジェクト: epeshk/uLearn
        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);
        }
コード例 #6
0
 public override Component LoadComponent(string folderName, string urlName, EdxLoadOptions options)
 {
     return(SlideProblemComponent.Load(folderName, urlName, options));
 }
コード例 #7
0
 public virtual Component LoadComponent(string folderName, string urlName, EdxLoadOptions options)
 {
     return(null);
 }
コード例 #8
0
 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);
     }
 }