public override IEnumerable <IDiagnostic> AnalyzeInternal(SemanticModel model) { var visitor = new ResourceVisitor(this, model); visitor.Visit(model.SourceFile.ProgramSyntax); return(visitor.diagnostics); }
void InternalizeReferences(Resource resource) { Visitor action = (element, name) => { if (element == null) { return; } if (element is ResourceReference) { ResourceReference reference = (ResourceReference)element; reference.Url = InternalizeReference(reference.Url); } else if (element is FhirUri) { FhirUri uri = (FhirUri)element; uri.Value = InternalizeReference(uri.Value); //((FhirUri)element).Value = LocalizeReference(new Uri(((FhirUri)element).Value, UriKind.RelativeOrAbsolute)).ToString(); } else if (element is Narrative) { Narrative n = (Narrative)element; n.Div = FixXhtmlDiv(n.Div); } }; Type[] types = { typeof(ResourceReference), typeof(FhirUri), typeof(Narrative) }; ResourceVisitor.VisitByType(resource, action, types); }
public void Write(ResourcePool resources) { XmlWriterSettings settings = new XmlWriterSettings(); settings.CloseOutput = false; settings.Indent = true; settings.IndentChars = " "; XmlWriter writer = XmlWriter.Create(stream, settings); try { writer.WriteStartDocument(); writer.WriteStartElement("resources"); ResourceVisitor visitor = new ResourceVisitor(writer); foreach (Resource resource in resources.Resources) { resource.AcceptVisitor(visitor); } writer.WriteEndElement(); writer.WriteEndDocument(); } finally { writer.Close(); } }
private void internalizeReferences(ResourceEntry entry) { Visitor action = (element, name) => { if (element == null) { return; } if (element is ResourceReference) { ResourceReference rr = (ResourceReference)element; if (rr.Url != null) { rr.Url = internalizeReference(rr.Url); } } else if (element is FhirUri) { ((FhirUri)element).Value = internalizeReference(new Uri(((FhirUri)element).Value, UriKind.RelativeOrAbsolute)).ToString(); } else if (element is Narrative) { ((Narrative)element).Div = fixXhtmlDiv(((Narrative)element).Div); } }; Type[] types = { typeof(ResourceReference), typeof(FhirUri), typeof(Narrative) }; ResourceVisitor.VisitByType(entry.Resource, action, types); }
public IndexService(IFhirModel fhirModel, ResourceVisitor resourceVisitor, ElementIndexer elementIndexer, IIndexStore indexStore) { _fhirModel = fhirModel; _resourceVisitor = resourceVisitor; _elementIndexer = elementIndexer; _indexStore = indexStore; }
public IndexService(IFhirModel fhirModel, FhirPropertyIndex propIndex, ResourceVisitor resourceVisitor, ElementIndexer elementIndexer, IIndexStore indexStore) { _fhirModel = fhirModel; _propIndex = propIndex; _resourceVisitor = resourceVisitor; _elementIndexer = elementIndexer; _indexStore = indexStore; }
public IndexService(IFhirModel fhirModel, FhirPropertyIndex propIndex, ResourceVisitor resourceVisitor, ElementIndexer elementIndexer, IIndexStore indexStore) { _fhirModel = fhirModel; _propIndex = propIndex; _resourceVisitor = resourceVisitor; _elementIndexer = elementIndexer; _indexStore = indexStore; }
public void TestInitialize() { _fhirModel = new FhirModel(); _index = new FhirPropertyIndex(_fhirModel, new List <Type> { typeof(Patient), typeof(ClinicalImpression), typeof(HumanName), typeof(CodeableConcept), typeof(Coding) }); _sut = new ResourceVisitor(_index); _patient = new Patient(); _patient.Name.Add(new HumanName().WithGiven("Sjors").AndFamily("Jansen")); }
public override IEnumerable <IDiagnostic> AnalyzeInternal(SemanticModel model) { Lazy <ImmutableDictionary <DeclaredSymbol, ImmutableHashSet <ResourceDependency> > > inferredDependenciesMap = new Lazy <ImmutableDictionary <DeclaredSymbol, ImmutableHashSet <ResourceDependency> > >( () => ResourceDependencyVisitor.GetResourceDependencies( model, new ResourceDependencyVisitor.Options { IgnoreExplicitDependsOn = true })); var visitor = new ResourceVisitor(this, inferredDependenciesMap, model); visitor.Visit(model.SourceFile.ProgramSyntax); return(visitor.diagnostics); }
public void Compile(ResourcePool resources, string outputFolder, CompilerParameters parameters) { if (resources == null) { throw new ArgumentNullException(nameof(resources)); } if (String.IsNullOrEmpty(outputFolder)) { throw new ArgumentNullException(nameof(outputFolder)); } ResourceVisitor visitor = new ResourceVisitor(outputFolder, parameters); visitor.Visit(resources); }
public void TestInitialize() { IFhirModel _fhirModel; FhirPropertyIndex _propIndex; ResourceVisitor _resourceVisitor; ElementIndexer _elementIndexer; var _indexStoreMock = new Mock <IIndexStore>(); var spPatientName = new SearchParamDefinition() { Resource = "Patient", Name = "name", Description = @"A portion of either family or given name of the patient", Type = SearchParamType.String, Path = new string[] { "Patient.name", } }; var searchParameters = new List <SearchParamDefinition> { spPatientName }; var resources = new Dictionary <Type, string> { { typeof(Patient), "Patient" }, { typeof(HumanName), "HumanName" } }; var enums = new List <Type>(); //CK: I use real objects: saves me a lot of mocking and provides for a bit of integration testing. _fhirModel = new FhirModel(resources, searchParameters, enums); _propIndex = new FhirPropertyIndex(_fhirModel, new List <Type> { typeof(Patient), typeof(HumanName) }); _resourceVisitor = new ResourceVisitor(_propIndex); _elementIndexer = new ElementIndexer(_fhirModel); //_indexStoreMock.Setup(ixs => ixs.Save(It.IsAny<IndexValue>)) sutLimited = new IndexService(_fhirModel, _propIndex, _resourceVisitor, _elementIndexer, _indexStoreMock.Object); _fhirModel = new FhirModel(); //For this test I want all available types and searchparameters. _propIndex = new FhirPropertyIndex(_fhirModel); _resourceVisitor = new ResourceVisitor(_propIndex); _elementIndexer = new ElementIndexer(_fhirModel); sutFull = new IndexService(_fhirModel, _propIndex, _resourceVisitor, _elementIndexer, _indexStoreMock.Object); }
public static void RemoveExtensionsFromElements(Resource resource) { ResourceVisitor.VisitByType(resource, ElementExtensionRemover, typeof(Element)); }