static void initWrappers() { // Initialize the wrappers used for this sample. ctx = ws.getContextWrapper(); crs = ws.getCourseWrapper(); crm = ws.getCourseMembershipWrapper(); usr = ws.getUserWrapper(); }
/// <inheritdoc/> public override byte[] CourseToByteArray(ICourse course) { CourseWrapper wrapper = new CourseWrapper(course); JObject jObject = JObject.FromObject(wrapper, JsonSerializer.Create(CourseSerializerSettings)); jObject.Add("$serializerVersion", Version); // This line is required to undo the changes applied to the course. wrapper.GetCourse(); return(new UTF8Encoding().GetBytes(jObject.ToString())); }
/// <inheritdoc/> public override ICourse CourseFromByteArray(byte[] data) { string stringData = new UTF8Encoding().GetString(data); JObject dataObject = JsonConvert.DeserializeObject <JObject>(stringData, CourseSerializerSettings); // Check if course was serialized with version 1 int version = dataObject.GetValue("$serializerVersion").ToObject <int>(); if (version == 1) { return(base.CourseFromByteArray(data)); } CourseWrapper wrapper = Deserialize <CourseWrapper>(data, CourseSerializerSettings); return(wrapper.GetCourse()); }
public CourseContext GetCourse(string courseName, EventHandler onFinishedEventHandler, bool createIfNotFound) { CourseWrapper foundCourse; foundCourse = _courses.FirstOrDefault(c => c.name == courseName); if (foundCourse == null) { foundCourse = new CourseWrapper(courseName); _courses.Add(foundCourse); } if (foundCourse == null) { throw new ArgumentNullException(); } onFinishedEventHandler += foundCourse.releaseHandler; return(createIfNotFound ? foundCourse.createContext() : foundCourse.context); }
private async Task OnClicked(CourseWrapper obj) { await _navigation.Navigate <CourseViewModel, CourseDTO>(obj.Model); }