public SettingsList RegisterAssembly(LoadedLibrary library, Assembly assembly) { lock (_assemblies) { try { RegisteredAssembly localAssembly = new RegisteredAssembly(assembly, library); if (!_assemblies.Contains(assembly.FullName)) { SettingsList classes = GetClassList(assembly); foreach (SettingsItem setting in classes.Values) { RegisteredClass classValue = new RegisteredClass(setting.Name, library, localAssembly, setting.Value); _classes.Add(classValue); } _assemblies.Add(localAssembly); return(classes); } return(new SettingsList()); } catch { UnregisterAssembly(library, assembly); throw; } } }
public void CanPostRegisteredType() { RegisteredClass data = new RegisteredClass { Title = "The World" }; Request request = Session.Bind(XmlEchoTemplate); Response <RegisteredClass> response = request.Post <RegisteredClass>(data); Assert.AreEqual(data.Title, response.Body.Title); }
public void CanReadWriteDates() { RegisteredClass data = new RegisteredClass { Title = "The World", Date = DateTime.Now }; Request request = Session.Bind(XmlEchoTemplate); Response <RegisteredClass> response = request.Post <RegisteredClass>(data); Assert.AreEqual(data.Title, response.Body.Title); Assert.AreEqual(data.Date, response.Body.Date); }
public Type CreateType(CatalogDeviceSession session, ClassDefinition classDefinition) { RegisteredClass classValue = GetClass(session, classDefinition); string className = classValue.ClassName; try { return(Type.GetType(className, true)); } catch (Exception E) { throw new ServerException(ServerException.Codes.ClassLoadError, E, className); } }
public HttpResponseMessage RegisterForClass(int studentId, int classId) { var existingStudent = ApplicationDbContext.Instance.Students.Include(x => x.User).FindById(studentId); var existingClass = ApplicationDbContext.Instance.Classes.Include(x => x.Institution).FindById(classId); if (!ApplicationDbContext.Instance.RegisteredClasses.Include(x => x.Class).Exists(x => x.StudentId == studentId && x.Class.Id == classId)) { var registration = new RegisteredClass { Class = existingClass, StudentId = studentId }; ApplicationDbContext.Instance.RegisteredClasses.Insert(registration); return(Request.CreateResponse(HttpStatusCode.OK, registration)); } return(Request.CreateResponse(HttpStatusCode.NotFound)); }