public ClassModel GetClassByID(int id) { var classModel = ClassModel.FromDbObject(_entities.classes.FirstOrDefault(x => x.pk_id == id)); if (classModel == null) { throw ClassNotFoundException.FromId(id); } return(classModel); }
public ClassModel GetClassByName(string className) { var classModel = ClassModel.FromDbObject(_entities.classes.FirstOrDefault(x => x.name.Equals(className))); if (classModel == null) { throw ClassNotFoundException.FromName(className); } return(classModel); }
public void DeleteClassByID(int id) { var classToRemove = _entities.classes.FirstOrDefault(x => x.pk_id == id); if (classToRemove == null) { throw ClassNotFoundException.FromId(id); } _entities.classes.Remove(classToRemove); _entities.SaveChanges(); }
public void DeleteClassByName(string className) { var classToRemove = _entities.classes.FirstOrDefault(x => x.name.Equals(className)); if (classToRemove == null) { throw ClassNotFoundException.FromName(className); } _entities.classes.Remove(classToRemove); _entities.SaveChanges(); }
private Type TaskClass(/*Config config, // LUCENENET: Not referenced */ string taskName) { foreach (string pkg in taskPackages) { Type result = LoadType(pkg, taskName + "Task"); if (result != null) { return(result); } } // can only get here if failed to instantiate throw ClassNotFoundException.Create(taskName + " not found in packages " + Arrays.ToString(taskPackages)); }
public void AddPlayer(PlayerModelDto dto, int userId) { if (_entities.classes.FirstOrDefault(x => x.pk_id == dto.ClassId) == null) { throw ClassNotFoundException.FromId(dto.ClassId); } if (_entities.factions.FirstOrDefault(x => x.pk_id == dto.FactionId) == null) { throw FactionNotFoundException.FromId(dto.FactionId); } if (_entities.races.FirstOrDefault(x => x.pk_id == dto.RaceId) == null) { throw RaceNotFoundException.FromId(dto.RaceId); } if (_entities.players.FirstOrDefault(x => x.name.Equals(dto.Name)) != null) { throw new PlayerAlreadyExistsException(); } _entities.players.Add(dto.ToDbObject(userId)); _entities.SaveChanges(); }
/// <summary> /// This method looks up a class with its fully qualified name (FQN), or a short-name /// class-simplename, or with a package suffix, assuming "Lucene.Net.Analysis." /// as the namespace prefix (e.g. "standard.ClassicTokenizerFactory" -> /// "Lucene.Net.Analysis.Standard.ClassicTokenizerFactory"). /// </summary> /// <remarks> /// If <paramref name="className"/> contains a period, the class is first looked up as-is, assuming that it /// is an FQN. If this fails, lookup is retried after prepending the Lucene analysis /// package prefix to the class name. /// <para/> /// If <paramref name="className"/> does not contain a period, the analysis SPI *Factory.LookupClass() /// methods are used to find the class. /// </remarks> /// <param name="className">The namespace qualified name or the short name of the class.</param> /// <param name="expectedType">The superclass <paramref name="className"/> is expected to extend. </param> /// <returns>The loaded type.</returns> /// <exception cref="TypeLoadException">If lookup fails.</exception> public virtual Type LookupAnalysisClass(string className, Type expectedType) { if (className.Contains(".")) { // First, try className == FQN Type result = Type.GetType(className); if (result is null) { // Second, retry lookup after prepending the Lucene analysis package prefix result = Type.GetType(LUCENE_ANALYSIS_PACKAGE_PREFIX + className); if (result is null) { throw ClassNotFoundException.Create("Can't find class '" + className + "' or '" + LUCENE_ANALYSIS_PACKAGE_PREFIX + className + "'"); } } return(result); } // No dot - use analysis SPI lookup string analysisComponentName = ANALYSIS_COMPONENT_SUFFIX_PATTERN.Replace(className, "", 1); if (typeof(CharFilterFactory).IsAssignableFrom(expectedType)) { return(CharFilterFactory.LookupClass(analysisComponentName)); } else if (typeof(TokenizerFactory).IsAssignableFrom(expectedType)) { return(TokenizerFactory.LookupClass(analysisComponentName)); } else if (typeof(TokenFilterFactory).IsAssignableFrom(expectedType)) { return(TokenFilterFactory.LookupClass(analysisComponentName)); } throw ClassNotFoundException.Create("Can't find class '" + className + "'"); }
public void TestParseExamples() { // LUCENENET specific // Rather than relying on a file path somewhere, we store the // files zipped in an embedded resource and unzip them to a // known temp directory for the test. DirectoryInfo examplesDir = CreateTempDir("test-parse-examples"); using (var stream = GetType().getResourceAsStream("conf.zip")) { TestUtil.Unzip(stream, examplesDir); } // hackedy-hack-hack bool foundFiles = false; foreach (FileInfo algFile in examplesDir.EnumerateFiles("*.alg")) { try { Config config = new Config(new StreamReader(new FileStream(algFile.FullName, FileMode.Open, FileAccess.Read), Encoding.UTF8)); String contentSource = config.Get("content.source", null); if (contentSource != null) { if (Type.GetType(contentSource) == null) { throw ClassNotFoundException.Create(contentSource); } } config.Set("work.dir", CreateTempDir(LuceneTestCase.GetTestClass().Name).FullName); config.Set("content.source", typeof(MockContentSource).AssemblyQualifiedName); String dir = config.Get("content.source", null); if (dir != null) { if (Type.GetType(dir) == null) { throw ClassNotFoundException.Create(dir); } } config.Set("directory", typeof(RAMDirectory).AssemblyQualifiedName); if (config.Get("line.file.out", null) != null) { config.Set("line.file.out", CreateTempFile("linefile", ".txt").FullName); } string queryMaker = config.Get("query.maker", null); if (queryMaker != null) { if (Type.GetType(queryMaker) == null) { throw ClassNotFoundException.Create(queryMaker); } config.Set("query.maker", typeof(MockQueryMaker).AssemblyQualifiedName); } PerfRunData data = new PerfRunData(config); new Algorithm(data); } catch (Exception t) when(t.IsThrowable()) { throw AssertionError.Create("Could not parse sample file: " + algFile, t); } foundFiles = true; } if (!foundFiles) { fail("could not find any .alg files!"); } }