public DatabaseObjectMultipartName(string?currentDatabase, string?name) { if (name != null) { var parser = new IdentifierParser(new StringReader(name)); string?[] parts = parser.Parse().ToArray(); var i = parts.Length - 1; var commandBuilder = new SqlCommandBuilder(); if (i >= 0) { Name = parts[i]; i--; if (i >= 0) { Schema = parts[i]; i--; if (i >= 0) { Database = parts[i]; i--; if (i >= 0) { _server = parts[i]; } } } } } if (Database == null) { Database = currentDatabase; } if (string.IsNullOrEmpty(Schema)) { Schema = null; } if (Name != null) { var length = Name.Length; if (length > 0 && Name[0] == '[') { Name = Name.Substring(1); length--; } if (length > 0 && Name[length - 1] == ']') { Name = Name.Substring(0, length - 1); } } }
private void AddCode(Composition header, XElement element) { if (header == null || element == null) { return; } header.Type = new CodeableConceptParser().FromXml(element, Errors); var type = header.Type?.Coding.FirstOrDefault()?.Code; if (string.IsNullOrEmpty(type)) { return; } if (type == "34133-9") { header.Meta.ProfileElement.Add(new FhirUri( "http://hl7.org/fhir/us/ccda/StructureDefinition/CCDA-on-FHIR-Continuity-of-Care-Document")); } else { var templateIdElement = element.Parent.CdaElement("templateId"); var templateId = new IdentifierParser().FromXml(templateIdElement)?.System; if (!string.IsNullOrEmpty(templateId) && header.Meta.ProfileElement.All(p => p.Value != templateId)) { header.Meta.ProfileElement.Add(new FhirUri(templateId)); } } }
public void Parse_empty_string_returns_empty_list() { var parser = new IdentifierParser(); var result = parser.Parse(""); Assert.IsNotNull(result); Assert.IsFalse(result.Any()); }
public void Parse_ShouldParseLocalIdentifier() { var expected = new LocalIdentifier("123"); var actual = IdentifierParser.Parse("lcl|123") as LocalIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Value, actual.Value); }
public void Parse_ShouldParseIntegratedDatabaseIdentifier() { var expected = new IntegratedDatabaseIdentifier(123); var actual = IdentifierParser.Parse("gi|123") as IntegratedDatabaseIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Value, actual.Value); }
public void Identifer_VariableArgument_IsValidIdentifier() { IdentifierParser parser = new IdentifierParser(); string token = "..."; IdentifierNode node = (IdentifierNode)parser.Parse(token); Assert.AreEqual(token, node.Name); }
void AddIdentifierTokens() { IdentifierParser ip = new IdentifierParser(); foreach (var item in codeTxtBox.Lines) { lstIdTokens = ip.GenerateTokens(item); } }
public void Parse_ShouldParseImportIdIdentifier() { var expected = new ImportIdIdentifier(123); var actual = IdentifierParser.Parse("gim|123") as ImportIdIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Value, actual.Value); }
public void Identifer_CannotContain_CloseParenthesis() { IdentifierParser parser = new IdentifierParser(); string token = ")"; IdentifierNode node = (IdentifierNode)parser.Parse(token); Assert.IsNull(node); }
public void Identifer_CannotStartWithDash() { IdentifierParser parser = new IdentifierParser(); string token = "-"; IdentifierNode node = (IdentifierNode)parser.Parse(token); Assert.AreEqual(token, node.Name); }
public void Identifer_MultipleCharacters_IsValidIdentifier() { IdentifierParser parser = new IdentifierParser(); string token = "ab"; IdentifierNode node = (IdentifierNode)parser.Parse(token); Assert.AreEqual(token, node.Name); }
public void Parse_ShouldParseBackboneSeqIdIdentifier() { var expected = new BackboneSeqIdIdentifier(123); var actual = IdentifierParser.Parse("bbs|123") as BackboneSeqIdIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Value, actual.Value); }
public void Identifer_Operator_IsValidIdentifer() { IdentifierParser parser = new IdentifierParser(); string token = "<="; IdentifierNode node = (IdentifierNode)parser.Parse(token); Assert.AreEqual(token, node.Name); }
public void Identifer_CanContainQuestionMark_IsValidIdentifier() { IdentifierParser parser = new IdentifierParser(); string token = "ab?"; IdentifierNode node = (IdentifierNode)parser.Parse(token); Assert.AreEqual(token, node.Name); }
public void Identifer_CannotContain_SingleNumber() { IdentifierParser parser = new IdentifierParser(); string token = "2"; IdentifierNode node = (IdentifierNode)parser.Parse(token); Assert.IsNull(node); }
public void ElementWithoutCodeSystemAttributeShallRenturnNull() { var xml = @"<id extension=""TT988""/>"; var element = XElement.Parse(xml); var result = new IdentifierParser().FromXml(element); result.Should().BeNull(); }
public void Parse_word() { var parser = new IdentifierParser(); var result = parser.Parse("word").ToArray(); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count()); Assert.AreEqual(IdentifierPartTypeEnum.Word, result[0].Type); Assert.AreEqual("word", result[0].Value); }
public void Parse_ShouldParseSWISSPROTIdentifier() { var expected = new SWISSPROTIdentifier("M73307", "AGMA13GT"); var actual = IdentifierParser.Parse("sp|M73307|AGMA13GT") as SWISSPROTIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Accession, actual.Accession); Assert.AreEqual(expected.Name, actual.Name); }
public void Parse_ShouldParsePRFIdentifier() { var expected = new PRFIdentifier("ACCESSION", "0806162C"); var actual = IdentifierParser.Parse("prf|ACCESSION|0806162C") as PRFIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Accession, actual.Accession); Assert.AreEqual(expected.Name, actual.Name); }
public void Parse_ShouldParseEMBLIdentifier() { var expected = new EMBLIdentifier("M73307", "AGMA13GT"); var actual = IdentifierParser.Parse("emb|M73307|AGMA13GT") as EMBLIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Accession, actual.Accession); Assert.AreEqual(expected.Locus, actual.Locus); }
public void Parse_ShouldParseDDBJIdentifier() { var expected = new DDBJIdentifier("BAC85684.1", "1"); var actual = IdentifierParser.Parse("dbj|BAC85684.1|1") as DDBJIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Accession, actual.Accession); Assert.AreEqual(expected.Locus, actual.Locus); }
public void Parse_ShouldParseTrEMBLIdentifier() { var expected = new TrEMBLIdentifier("Q90RT2", "Q90RT2_9HIV1"); var actual = IdentifierParser.Parse("tr|Q90RT2|Q90RT2_9HIV1") as TrEMBLIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Accession, actual.Accession); Assert.AreEqual(expected.Name, actual.Name); }
public void Parse_ShouldParseThirdPartyGenBankIdentifier() { var expected = new ThirdPartyGenBankIdentifier("BK003456", "NAME"); var actual = IdentifierParser.Parse("tpg|BK003456|NAME") as ThirdPartyGenBankIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Accession, actual.Accession); Assert.AreEqual(expected.Name, actual.Name); }
public void Parse_ShouldParseThirdPartyEMBLIdentifier() { var expected = new ThirdPartyEMBLIdentifier("BN000123", "NAME"); var actual = IdentifierParser.Parse("tpe|BN000123|NAME") as ThirdPartyEMBLIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Accession, actual.Accession); Assert.AreEqual(expected.Name, actual.Name); }
public void Parse_ShouldParsePDBIdentifier() { var expected = new PDBIdentifier("1I4L", "D"); var actual = IdentifierParser.Parse("pdb|1I4L|D") as PDBIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Entry, actual.Entry); Assert.AreEqual(expected.Chain, actual.Chain); }
public void Parse_ShouldParseGeneralDatabaseReferenceIdentifier() { var expected = new GeneralDatabaseReferenceIdentifier("taxon", "9606"); var actual = IdentifierParser.Parse("gnl|taxon|9606") as GeneralDatabaseReferenceIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Database, actual.Database); Assert.AreEqual(expected.Value, actual.Value); }
public void Parse_ShouldParsePatentIdentifier() { var expected = new PatentIdentifier("US", "RE33188", "1"); var actual = IdentifierParser.Parse("pat|US|RE33188|1") as PatentIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Country, actual.Country); Assert.AreEqual(expected.Patent, actual.Patent); Assert.AreEqual(expected.SequenceNumber, actual.SequenceNumber); }
public void ShallRenturnIdentifier() { var xml = @"<id extension=""TT988"" root=""2.16.840.1.113883.19.5.99999.1""/>"; var element = XElement.Parse(xml); var result = new IdentifierParser().FromXml(element); result.Should().NotBeNull(); result.Value.Should().Be("TT988"); result.System.Should().Be("urn:oid:2.16.840.1.113883.19.5.99999.1"); }
public void Parse_ShouldParsePreGrantPatentIdentifier() { var expected = new PreGrantPatentIdentifier("EP", "0238993", "7"); var actual = IdentifierParser.Parse("pgp|EP|0238993|7") as PreGrantPatentIdentifier; Assert.IsNotNull(actual); Assert.AreEqual(expected.Code, actual.Code); Assert.AreEqual(expected.Country, actual.Country); Assert.AreEqual(expected.ApplicationNumber, actual.ApplicationNumber); Assert.AreEqual(expected.SequenceNumber, actual.SequenceNumber); }
public override bool TryBypass(CompilationPool compilationPool) { var line = 1; while (compilationPool.CodePosition < compilationPool.Code.Length) { if (Constraints.Instance.Tokens.SkippedSymbols.Contains( compilationPool.Code[compilationPool.CodePosition])) { if (compilationPool.Code[compilationPool.CodePosition] == '\n') { line++; } compilationPool.CodePosition++; continue; } if (_stateMachines.Any(stateMachine => stateMachine.FindToken(compilationPool))) { OnTokenFounded(compilationPool.Tokens.Last(), compilationPool.FileName, line); continue; } if (LiteralParser.IsLiteral(compilationPool)) { OnTokenFounded(compilationPool.Tokens.Last(), compilationPool.FileName, line); continue; } if (IdentifierParser.IsIndentifier(compilationPool)) { OnTokenFounded(compilationPool.Tokens.Last(), compilationPool.FileName, line); continue; } Errors.Add(string.Format(Resources.Messages.UnexpectedSymbol, compilationPool.FileName, GetNextPartOfLexem(compilationPool), line)); return(false); } DetermineIdentifierTypes(compilationPool); compilationPool.Identifiers.ForEach(identifier => { Messages.Add(string.Format(Resources.Messages.IndentifierFounded, compilationPool.FileName, identifier.Type, identifier.Identity)); }); return(true); }