コード例 #1
0
 static void initWrappers()
 {
     // Initialize the wrappers used for this sample.
     ctx = ws.getContextWrapper();
     crs = ws.getCourseWrapper();
     crm = ws.getCourseMembershipWrapper();
     usr = ws.getUserWrapper();
 }
コード例 #2
0
        /// <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()));
        }
コード例 #3
0
        /// <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());
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 private async Task OnClicked(CourseWrapper obj)
 {
     await _navigation.Navigate <CourseViewModel, CourseDTO>(obj.Model);
 }