### CSW Pagination Example Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/csw-endpoints.md Demonstrates how to retrieve search results and paginate through them using the CSW API. Shows how to access total matched records, returned records, and the starting position for the next page. ```csharp SearchResultsType results = api.Search("water", startPosition: 1, limit: 20); // First page Console.WriteLine($"Total matched: {results.numberOfRecordsMatched}"); // 147 Console.WriteLine($"Returned: {results.numberOfRecordsReturned}"); // 20 Console.WriteLine($"Next page starts at: {results.nextRecord}"); // 21 // Get next page if (results.nextRecord > 0) { SearchResultsType page2 = api.Search("water", startPosition: results.nextRecord, limit: 20); // Process page2... } ``` -------------------------------- ### Set Bounding Box Example Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Example of how to instantiate and set the BoundingBox property with specific longitude and latitude values. ```csharp simple.BoundingBox = new SimpleBoundingBox { EastBoundLongitude = 31.0, WestBoundLongitude = 4.0, NorthBoundLatitude = 71.0, SouthBoundLatitude = 57.0 }; ``` -------------------------------- ### GetRecordsWithFilter Example Usage Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestfactory-class.md Example demonstrating how to use GetRecordsWithFilter with a PropertyIsLike filter to search for records containing 'water'. ```csharp RequestFactory factory = new RequestFactory(); var likeFilter = new PropertyIsLikeType { PropertyName = new PropertyNameType { Text = new[] { "AnyText" } }, Literal = new LiteralType { Text = new[] { "%water%" } } }; GetRecordsType request = factory.GetRecordsWithFilter( new object[] { likeFilter }, new ItemsChoiceType23[] { ItemsChoiceType23.PropertyIsLike }, startPosition: 1, limit: 50 ); ``` -------------------------------- ### MetadataDelete Example Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestfactory-class.md Example demonstrating how to use the MetadataDelete method to create a CSW Transaction request for deleting a metadata record with a specified UUID. ```csharp RequestFactory factory = new RequestFactory(); TransactionType request = factory.MetadataDelete("12345-abcd-6789"); // Creates delete request for record with specified UUID ``` -------------------------------- ### Send GET Request and Get Full Response Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestrunner-httpexecutor.md Sends a GET request and returns the full HttpWebResponse object, including headers and status information. ```csharp public HttpWebResponse FullGetRequest( string url, string accept, string contentType) ``` -------------------------------- ### CSW GetRecordById Success Response Example Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/csw-endpoints.md This is an example of a successful XML response from the GetRecordById operation, containing the full ISO 19139 metadata for the requested record. ```xml ``` -------------------------------- ### Example CSW ExceptionReport XML Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/errors.md An example of the XML structure returned by a CSW service when an error occurs, indicating issues like invalid parameters. ```xml Duplicate outputSchema element ``` -------------------------------- ### Get Capabilities (WFS) Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Fetches the capabilities document for a WFS service. Ensure the baseUrl is correctly set. ```csharp public async Task GetCapabilitiesWFSAsync(string serviceUrl) { var requestUrl = $"{serviceUrl}?request=GetCapabilities&service=WFS&version=2.0.0"; using (var client = new HttpClient()) { return await client.GetStringAsync(requestUrl); } } ``` -------------------------------- ### Authenticate and Insert Metadata Source: https://github.com/kartverket/geonorgeapi/blob/master/README.md Example demonstrating how to authenticate with GeoNorgeAPI using username and password for insert/update/delete operations. Requires credentials from Kartverket. ```csharp GeoNorgeAPI.GeoNorge api = new GeoNorgeAPI.GeoNorge("myusername", "mypassword"); MD_Metadata_Type metadata = new MD_Metadata_Type(); // ... add information to the metadata object var transaction = _geonorge.MetadataInsert(metadata); Console.WriteLine(transaction.TotalInserted + " metadata inserted."); ``` -------------------------------- ### Example: Using RequestRunner Logging Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestrunner-httpexecutor.md Demonstrates how to set up and use the RequestRunner's logging events for debugging and informational messages. Attach handlers to OnLogEventDebug, OnLogEventInfo, and OnLogEventError. ```csharp RequestRunner runner = new RequestRunner(); runner.OnLogEventDebug += msg => System.Diagnostics.Debug.WriteLine(msg); runner.OnLogEventInfo += msg => Console.WriteLine($"[INFO] {msg}"); runner.OnLogEventError += (msg, ex) => Console.WriteLine($"[ERROR] {msg}: {ex.Message}"); SearchResultsType results = runner.RunGetRecordsRequest(request).SearchResults; // Debug output shows HTTP request/response details ``` -------------------------------- ### Get Capabilities (WMS) Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Fetches the capabilities document for a WMS service. Ensure the baseUrl is correctly set. ```csharp public async Task GetCapabilitiesWMSAsync(string serviceUrl) { var requestUrl = $"{serviceUrl}?request=GetCapabilities&service=WMS&version=1.3.0"; using (var client = new HttpClient()) { return await client.GetStringAsync(requestUrl); } } ``` -------------------------------- ### ProcessHistory Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets a description of the process history for the dataset. ```csharp public string ProcessHistory { get; set; } ``` -------------------------------- ### CSW GetRecords Request Example Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/csw-endpoints.md This snippet shows a POST request to the CSW /csw endpoint to retrieve records. It specifies the query type, constraint, and pagination parameters. ```xml POST /geonetwork/csw Content-Type: application/xml AnyText %water% ``` -------------------------------- ### QualitySpecifications Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets a list of quality specifications for the dataset. ```csharp public List QualitySpecifications { get; set; } ``` -------------------------------- ### GetRecordByUuid Example Usage Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Demonstrates how to call GetRecordByUuid and check if a record was found. Requires a valid UUID string. ```csharp MD_Metadata_Type record = api.GetRecordByUuid("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); if (record != null) { Console.WriteLine("Found record"); } ``` -------------------------------- ### MetadataStandardVersion Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the version of the metadata standard. Typically '2003'. ```csharp public string MetadataStandardVersion { get; set; } ``` -------------------------------- ### EnglishProcessHistory Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the English translation of the dataset's process history. ```csharp public string EnglishProcessHistory { get; set; } ``` -------------------------------- ### Search and Display Results Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/types.md Demonstrates how to perform a search using the GeoNorge API and process the returned SearchResultsType. Shows how to access matched and returned record counts, and iterate through individual records. Includes an example of using `nextRecord` for pagination. ```csharp SearchResultsType results = api.Search("water"); Console.WriteLine($"Matched: {results.numberOfRecordsMatched}"); Console.WriteLine($"Returned: {results.numberOfRecordsReturned}"); if (results.numberOfRecordsMatched > results.numberOfRecordsReturned) { // More results available - use nextRecord for pagination SearchResultsType page2 = api.Search("water", startPosition: results.nextRecord); } foreach (var record in results.Record) { Console.WriteLine(record.title); } ``` -------------------------------- ### ResourceReference Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets metadata reference information. Uses SimpleResourceReference type. ```csharp public SimpleResourceReference ResourceReference { get; set; } ``` -------------------------------- ### FullGetRequest Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestrunner-httpexecutor.md Sends a GET request and returns the full HttpWebResponse object, providing access to the response status, headers, and stream. It requires the URL, Accept, and Content-Type headers. ```APIDOC ## FullGetRequest ### Description Sends a GET request and returns the full HttpWebResponse object. This method provides access to the response status, headers, and stream. ### Method GET ### Endpoint [URL provided in the 'url' parameter] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Headers - **Accept** (string) - Required - Value for the Accept header. - **Content-Type** (string) - Required - Value for the Content-Type header. ### Request Example ```csharp HttpRequestExecutor executor = new HttpRequestExecutor(); HttpWebResponse response = executor.FullGetRequest(url, "application/json", "application/json"); // Process the response object ``` ### Response #### Success Response (200) - **HttpWebResponse** - The full response object, including status code, headers, and response stream. The caller is responsible for disposing of this object. ``` -------------------------------- ### Handle Transaction Failures in C# Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/errors.md Example of performing a metadata insert operation and catching potential exceptions like authentication failures or validation errors. ```csharp GeoNorge api = new GeoNorge("user", "wrongpassword"); try { var metadata = SimpleMetadata.CreateDataset(); metadata.Title = "Test"; var result = api.MetadataInsert(metadata.GetMetadata()); } catch (InvalidOperationException ex) { if (ex.Message.Contains("401")) Console.WriteLine("Authentication failed"); else if (ex.Message.Contains("validation")) Console.WriteLine("Metadata validation error"); else Console.WriteLine($"Insert failed: {ex.Message}"); } ``` -------------------------------- ### Multiple Distribution Formats Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets a list of multiple distribution formats. Use this property when a dataset is available in various formats. ```csharp public List DistributionFormats { get; set; } ``` -------------------------------- ### Constraints Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the usage constraints, such as legal or security restrictions, for the dataset. ```csharp public SimpleConstraints Constraints { get; set; } ``` -------------------------------- ### Reference System Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the primary spatial reference system. This property expects an object of type SimpleReferenceSystem. ```csharp public SimpleReferenceSystem ReferenceSystem { get; set; } ``` -------------------------------- ### CSW GetRecords Success Response (Dublin Core) Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/csw-endpoints.md Example of a successful GetRecords response using the Dublin Core output schema. It includes search status and a list of records with basic metadata. ```xml Water Management Dataset Description of dataset... 12345-abcd-6789 ``` -------------------------------- ### Distribution Format Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the primary distribution format information. This property holds details about how the data is distributed. ```csharp public SimpleDistributionFormat DistributionFormat { get; set; } ``` -------------------------------- ### Search GeoNorge Metadata Source: https://github.com/kartverket/geonorgeapi/blob/master/README.md Basic example of searching for metadata using the GeoNorgeAPI. Requires the GeoNorgeAPI and www.opengis.net namespaces. ```csharp using www.opengis.net; using GeoNorgeAPI; public class MyClass { public void MyMethod() { GeoNorge api = new GeoNorge(); SearchResultsType result = api.Search("flomsone"); Console.WriteLine(result.numberOfRecordsMatched + " metadata found"); } } ``` -------------------------------- ### Insert Metadata and Get Transaction Result Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/types.md Demonstrates inserting metadata using the GeoNorgeAPI and retrieving the transaction result, which includes the number of inserted records and their identifiers. ```csharp GeoNorge api = new GeoNorge("username", "password"); var metadata = SimpleMetadata.CreateDataset(); metadata.Title = "Test Dataset"; var result = api.MetadataInsert(metadata.GetMetadata()); Console.WriteLine($"Inserted: {result.TotalInserted}"); Console.WriteLine($"New ID: {result.Identifiers[0]}"); ``` -------------------------------- ### Create a JSESSIONID Cookie Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/configuration.md Example of creating a JSESSIONID cookie for session handling. Cookies are automatically added to requests when provided. ```csharp Cookie sessionCookie = new Cookie("JSESSIONID", cookieValue, "/geonetwork", cookieDomain); ``` -------------------------------- ### Send POST Request and Get Response Body Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestrunner-httpexecutor.md Sends a POST request with specified parameters and returns the response body as a string. Supports optional username, password, cookie, and additional headers. ```csharp public string PostRequest( string url, string accept, string contentType, string postData, string username = null, string password = null, Cookie cookie = null, Dictionary additionalRequestHeaders = null) ``` ```csharp HttpRequestExecutor executor = new HttpRequestExecutor(); string response = executor.PostRequest( url: "https://www.geonorge.no/geonetwork/csw", accept: "application/xml", contentType: "application/xml", postData: "...", username: "user", password: "pass" ); ``` -------------------------------- ### Send POST Request and Get Full Response Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestrunner-httpexecutor.md Sends a POST request and returns the complete HttpWebResponse object. This method applies default configurations like TLS 1.2, a 60-second timeout, and supports authentication and custom headers. ```csharp public HttpWebResponse FullPostRequest( string url, string accept, string contentType, string postData, string username = null, string password = null, Cookie cookie = null, Dictionary additionalRequestHeaders = null) ``` ```csharp HttpWebResponse response = executor.FullPostRequest(url, "application/xml", "application/xml", body); Console.WriteLine($"Status: {response.StatusCode} - {response.StatusDescription}"); StreamReader reader = new StreamReader(response.GetResponseStream()); string content = reader.ReadToEnd(); response.Close(); ``` -------------------------------- ### Insert SimpleMetadata using GeoNorgeAPI Source: https://github.com/kartverket/geonorgeapi/blob/master/README.md Example of inserting a SimpleMetadata object into GeoNorge using the MetadataInsert method. The GetMetadata() method converts the SimpleMetadata object to the required MD_Metadata_Type. ```csharp var transaction = _geonorge.MetadataInsert(simpleMetadata.GetMetadata()); ``` -------------------------------- ### Multiple Reference Systems Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets a list of multiple reference systems. This property is used when a dataset adheres to more than one coordinate system. ```csharp public List ReferenceSystems { get; set; } ``` -------------------------------- ### Create and Populate SimpleMetadata Source: https://github.com/kartverket/geonorgeapi/blob/master/README.md Demonstrates using the SimpleMetadata wrapper to create and populate a dataset's metadata. This simplifies the complex MD_Metadata_Type object. ```csharp GeoNorge api = new GeoNorge("myusername", "mypassword"); SimpleMetadata simpleMetadata = SimpleMetadata.CreateDataset(); simpleMetadata.Title = "This is my dataset!"; simpleMetadata.Abstract = "This is the abstract telling you everything you need to know about this dataset."; simpleMetadata.ContactPublisher = new SimpleContact { Name = "John Smith", Email = "nothing@example.com", Organization = "My organization", Role = "publisher" }; ``` -------------------------------- ### Initialize SimpleKeyword List Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/types.md Demonstrates how to create and populate a list of SimpleKeyword objects, associating keywords with their respective thesauri. This is used for the Keywords property of SimpleMetadata. ```csharp metadata.Keywords = new List { new SimpleKeyword { Keyword = "water", ThesaurusTitle = "GEMET" }, new SimpleKeyword { Keyword = "environment", ThesaurusTitle = "INSPIRE" } }; ``` -------------------------------- ### Get Feature Information Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Retrieves feature information from a WFS service for a specified layer and bounding box. Requires valid service URL, layer name, and bounding box coordinates. ```csharp public async Task GetFeatureInfoAsync(string serviceUrl, string layerName, string bbox) { var requestUrl = $"{serviceUrl}?service=WFS&version=2.0.0&request=GetFeature&typeName={layerName}&bbox={bbox}"; using (var client = new HttpClient()) { return await client.GetStringAsync(requestUrl); } } ``` -------------------------------- ### Initialize SimpleDistributionFormat Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/types.md Shows how to create a SimpleDistributionFormat object to specify the name and version of a dataset's distribution format. This is used for the DistributionFormat property of SimpleMetadata. ```csharp metadata.DistributionFormat = new SimpleDistributionFormat { Name = "GML", Version = "3.2" }; ``` -------------------------------- ### Instantiate SimpleMetadata with Existing Metadata Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Wrap an existing ISO 19139 metadata object with the SimpleMetadata class for easier access to its properties. Ensure the provided metadata object is not null. ```csharp public SimpleMetadata(MD_Metadata_Type md) ``` ```csharp MD_Metadata_Type isoMetadata = api.GetRecordByUuid("some-uuid"); SimpleMetadata simple = new SimpleMetadata(isoMetadata); Console.WriteLine(simple.Title); ``` -------------------------------- ### Execute Default CSW GetRecords Request Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestrunner-httpexecutor.md Executes a CSW GetRecords request using default parameters, typically via an HTTP GET method. This is a simpler way to fetch records when specific search criteria are not required. ```csharp public GetRecordsResponseType RunGetRecordsRequest() ``` -------------------------------- ### CrossReference Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets cross-references to related resources. ```APIDOC ## CrossReference Property ### Description Gets or sets cross-references to related resources. ### Type List ``` -------------------------------- ### ResourceReference Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets metadata reference information. ```APIDOC ## ResourceReference Property ### Description Gets or sets metadata reference information. ### Type SimpleResourceReference ``` -------------------------------- ### ProductSpecificationOther Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Represents an alternative resource for the product specification. Use this if the primary URL is unavailable or if there's a supplementary document. ```csharp public SimpleOnlineResource ProductSpecificationOther { get; set; } ``` -------------------------------- ### Create GeoNorge API Instance (with Authentication) Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Instantiates the GeoNorge API with provided username and password. This is necessary for operations requiring authentication, such as insert, update, and delete. ```csharp public GeoNorge(string geonetworkUsername, string geonetworkPassword) ``` ```csharp GeoNorge api = new GeoNorge("username", "password"); var transaction = api.MetadataInsert(metadata); ``` -------------------------------- ### ValidTimePeriod Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the valid time range for which the dataset is applicable. ```csharp public SimpleValidTimePeriod ValidTimePeriod { get; set; } ``` -------------------------------- ### QualitySpecification Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets a single quality assessment detail for the dataset. ```csharp public SimpleQualitySpecification QualitySpecification { get; set; } ``` -------------------------------- ### CrossReference Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets cross-references to related resources. This property is a list of strings. ```csharp public List CrossReference { get; set; } ``` -------------------------------- ### Create GeoNorge API Instance (Default) Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Instantiates the GeoNorge API with default settings for public read-only searches. No authentication is required. ```csharp public GeoNorge() ``` ```csharp GeoNorge api = new GeoNorge(); SearchResultsType results = api.Search("water"); ``` -------------------------------- ### Multiple Resource URLs Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Provides URLs for various supporting resources related to the dataset, including product sheets, legend descriptions, coverage maps, and help pages. Ensure all provided URLs are correct and relevant. ```csharp public string ProductSheetUrl { get; set; } public string LegendDescriptionUrl { get; set; } public string ProductPageUrl { get; set; } public string CoverageUrl { get; set; } public string HelpUrl { get; set; } ``` -------------------------------- ### MetadataStandard Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the metadata standard name. Typically 'ISO 19115'. ```csharp public string MetadataStandard { get; set; } ``` -------------------------------- ### Create SimpleReferenceSystem Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/types.md Instantiate a SimpleReferenceSystem object to define a spatial reference system. Use this when setting the metadata's ReferenceSystem property. ```csharp metadata.ReferenceSystem = new SimpleReferenceSystem { EpsgCode = "4258", Url = "http://www.opengis.net/gml/srs/epsg.xml#4258" }; ``` -------------------------------- ### HierarchyLevelName Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the user-friendly name of the hierarchy level. This is a string property. ```APIDOC ## HierarchyLevelName Property ### Description Gets or sets the user-friendly name of the hierarchy level. ### Property Signature ```csharp public string HierarchyLevelName { get; set; } ``` ### Type string ``` -------------------------------- ### ProductSpecificationUrl Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Represents the URL to the official product specification document for the dataset. Ensure this URL is valid and accessible. ```csharp public string ProductSpecificationUrl { get; set; } ``` -------------------------------- ### Set English Supplemental Description Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Use the `EnglishSupplementalDescription` property to set the English translation of the supplemental descriptive information. This allows for providing extra details in English. ```csharp public string EnglishSupplementalDescription { get; set; } ``` -------------------------------- ### MetadataStandardVersion Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the version of the metadata standard (typically `"2003"`). ```APIDOC ## MetadataStandardVersion Property ### Description Gets or sets the version of the metadata standard (typically `"2003"`). ### Type string ``` -------------------------------- ### SimpleMetadata Constructor Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Creates a SimpleMetadata wrapper around an existing ISO 19139 metadata object. This constructor is useful when you already have an MD_Metadata_Type object and want to use the simplified SimpleMetadata interface. ```APIDOC ## SimpleMetadata(MD_Metadata_Type) ### Description Creates a SimpleMetadata wrapper around an existing ISO 19139 metadata object. This constructor is useful when you already have an MD_Metadata_Type object and want to use the simplified SimpleMetadata interface. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Required | Default | Description | |---|---|---|---|---| | md | MD_Metadata_Type | Yes | — | Underlying ISO 19139 metadata object (cannot be null) | ### Throws `ArgumentNullException` if metadata is null. ### Example ```csharp MD_Metadata_Type isoMetadata = api.GetRecordByUuid("some-uuid"); SimpleMetadata simple = new SimpleMetadata(isoMetadata); Console.WriteLine(simple.Title); ``` ``` -------------------------------- ### MetadataStandard Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the metadata standard name (typically `"ISO 19115"`). ```APIDOC ## MetadataStandard Property ### Description Gets or sets the metadata standard name (typically `"ISO 19115"`). ### Type string ``` -------------------------------- ### Status Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the production status of the dataset. Common values are 'completed', 'ongoing', or 'planned'. ```csharp public string Status { get; set; } ``` -------------------------------- ### Uuid Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the unique identifier (file identifier) of the metadata record. This is a string property. ```APIDOC ## Uuid Property ### Description Gets or sets the unique identifier (file identifier) of the metadata record. ### Property Signature ```csharp public string Uuid { get; set; } ``` ### Type string ### Example ```csharp SimpleMetadata simple = SimpleMetadata.CreateDataset(); simple.Uuid = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; Console.WriteLine(simple.Uuid); ``` ``` -------------------------------- ### Create GeoNorge API Instance (with Custom Endpoint and Authentication) Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Instantiates the GeoNorge API with a custom CSW service endpoint URL, along with username and password for authentication. Useful for connecting to non-default GeoNorge instances. ```csharp public GeoNorge(string geonetworkUsername, string geonetworkPassword, string geonetworkEndpoint) ``` ```csharp GeoNorge api = new GeoNorge("user", "pass", "https://custom.example.com/geonetwork/"); ``` -------------------------------- ### Set Uuid Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Sets the unique identifier for the metadata record. Ensure the format is a valid GUID. ```csharp SimpleMetadata simple = SimpleMetadata.CreateDataset(); simple.Uuid = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; Console.WriteLine(simple.Uuid); ``` -------------------------------- ### ResolutionScale Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the scale denominator for resolution. Use this property to define the map scale, such as '1:50000'. ```csharp public string ResolutionScale { get; set; } ``` -------------------------------- ### Add Keywords to Dataset Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Initializes or adds SimpleKeyword objects to a list, each containing a keyword and an optional thesaurus title. This helps in categorizing and searching the dataset. ```csharp simple.Keywords = new List { new SimpleKeyword { Keyword = "water", ThesaurusTitle = "GEMET" }, new SimpleKeyword { Keyword = "mapping", ThesaurusTitle = "INSPIRE" } }; ``` -------------------------------- ### ParentIdentifier Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the identifier of the parent metadata record, used for hierarchical datasets. This is a string property. ```APIDOC ## ParentIdentifier Property ### Description Gets or sets the identifier of the parent metadata record (for hierarchical datasets). ### Property Signature ```csharp public string ParentIdentifier { get; set; } ``` ### Type string ``` -------------------------------- ### GeoNorgeAPI Constructor Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Initializes a new instance of the GeoNorgeAPI class. Requires the base URL of the API. ```csharp public GeoNorgeAPI(string baseUrl) { this.baseUrl = baseUrl; } ``` -------------------------------- ### Create and Insert New Dataset Metadata Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/README.md Creates a new dataset metadata record with basic information and inserts it into the GeoNorge system. Requires authentication credentials. ```csharp GeoNorge api = new GeoNorge("username", "password"); SimpleMetadata metadata = SimpleMetadata.CreateDataset(); metadata.Title = "My Dataset"; metadata.Abstract = "Description of the dataset"; metadata.ContactPublisher = new SimpleContact { Name = "John Doe", Organization = "My Organization", Email = "john@example.com", Role = "publisher" }; var transaction = api.MetadataInsert(metadata.GetMetadata()); Console.WriteLine($"Inserted: {transaction.TotalInserted}"); Console.WriteLine($"New UUID: {transaction.Identifiers[0]}"); ``` -------------------------------- ### MaintenanceFrequency Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the maintenance or update frequency for the dataset. Accepted values include 'daily', 'monthly', or 'asNeeded'. ```csharp public string MaintenanceFrequency { get; set; } ``` -------------------------------- ### Create and Insert Metadata Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/README.md Creates a new dataset metadata record and inserts it into the system. ```APIDOC ## Create and Insert Metadata ### Description Creates a new dataset metadata record with specified details and inserts it into the GeoNorge system. ### Method `MetadataInsert` ### Parameters #### Request Body - **metadata** (SimpleMetadata) - Required - An object containing the metadata details for the new record. ### Request Example ```csharp GeoNorge api = new GeoNorge("username", "password"); SimpleMetadata metadata = SimpleMetadata.CreateDataset(); metadata.Title = "My Dataset"; metadata.Abstract = "Description of the dataset"; metadata.ContactPublisher = new SimpleContact { Name = "John Doe", Organization = "My Organization", Email = "john@example.com", Role = "publisher" }; var transaction = api.MetadataInsert(metadata.GetMetadata()); ``` ### Response #### Success Response - **TotalInserted** (int) - The number of metadata records successfully inserted. - **Identifiers** (array of string) - A list of unique identifiers (UUIDs) for the newly inserted records. ### Response Example ```csharp // Inserted: 1 // New UUID: a1b2c3d4-e5f6-7890-1234-567890abcdef ``` ``` -------------------------------- ### Spatial Representation Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the spatial representation method. Use this property to specify if the data is vector or grid-based. ```csharp public string SpatialRepresentation { get; set; } ``` -------------------------------- ### RequestRunner Constructor Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestrunner-httpexecutor.md Initializes a RequestRunner instance with optional authentication credentials and a specific CSW service endpoint. Use this to configure how the runner connects to the GeoNorge CSW service. ```csharp public RequestRunner( string geonetworkUsername = null, string geonetworkPassword = null, string geonetworkEndpoint = "https://www.geonorge.no/geonetwork/") ``` ```csharp RequestRunner runner = new RequestRunner("user", "password", "https://www.geonorge.no/geonetwork/"); ``` -------------------------------- ### ResolutionDistance Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the spatial resolution in ground distance units, typically meters. This property is of type double and can be null. ```csharp public double? ResolutionDistance { get; set; } ``` -------------------------------- ### FullPostRequest Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestrunner-httpexecutor.md Sends a POST request and returns the complete HttpWebResponse object, allowing access to status codes, headers, and the response stream. It applies default configurations like TLS 1.2 and a 60-second timeout. ```APIDOC ## FullPostRequest ### Description Sends a POST request and returns the full HttpWebResponse object. This method applies default configurations including TLS 1.2, a 60-second timeout, and supports basic authentication, session cookies, and custom headers. ### Method POST ### Endpoint [URL provided in the 'url' parameter] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **postData** (string) - Required - The request body content. #### Headers - **Accept** (string) - Required - Value for the Accept header. - **Content-Type** (string) - Required - Value for the Content-Type header. - **Authorization** (string) - Optional - Basic Auth header if username and password are provided. - **Cookie** (string) - Optional - Session cookie if provided. - **additionalRequestHeaders** (Dictionary) - Optional - Custom HTTP headers. #### Authentication - **username** (string) - Optional - Username for Basic Authentication. - **password** (string) - Optional - Password for Basic Authentication. ### Request Example ```csharp HttpRequestExecutor executor = new HttpRequestExecutor(); HttpWebResponse response = executor.FullPostRequest(url, "application/xml", "application/xml", body); Console.WriteLine($"Status: {response.StatusCode} - {response.StatusDescription}"); StreamReader reader = new StreamReader(response.GetResponseStream()); string content = reader.ReadToEnd(); response.Close(); ``` ### Response #### Success Response (200) - **HttpWebResponse** - The full response object, including status code, headers, and response stream. The caller is responsible for disposing of this object. #### Configuration Applied - TLS 1.2 security protocol - 60-second request timeout - Basic authentication (if credentials provided) - Custom headers added to request - Session cookie added (if provided) ``` -------------------------------- ### Create SimpleBoundingBox Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/types.md Instantiate a SimpleBoundingBox object to define the geographic extent of a dataset. Use this when setting the metadata's BoundingBox property. ```csharp metadata.BoundingBox = new SimpleBoundingBox { EastBoundLongitude = 31.0, WestBoundLongitude = 4.0, NorthBoundLatitude = 71.0, SouthBoundLatitude = 57.0 }; ``` -------------------------------- ### Bounding Box Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the geographic extent of the dataset. Use this property to define the north, south, east, and west boundaries. ```csharp public SimpleBoundingBox BoundingBox { get; set; } ``` -------------------------------- ### GetFromEndpointUrl Method Signature Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Defines the signature for fetching all metadata records from the configured endpoint URL without any additional filters. Returns records in Dublin Core format. ```csharp public SearchResultsType GetFromEndpointUrl() ``` -------------------------------- ### SimpleMetadata Class Factory Methods Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/README.md Factory methods for creating different types of metadata records using the SimpleMetadata class. ```APIDOC ## SimpleMetadata Class Factory Methods ### Description These factory methods are used to initiate the creation of new metadata records for datasets or services. ### Factory Methods - `SimpleMetadata.CreateDataset()`: Creates a new metadata object for a dataset. - `SimpleMetadata.CreateService()`: Creates a new metadata object for a service. ``` -------------------------------- ### HierarchyLevel Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets the scope level of the metadata. Common values include 'dataset', 'service', 'series', and 'application'. This is a string property. ```APIDOC ## HierarchyLevel Property ### Description Gets or sets the scope level of the metadata. Common values: `"dataset"`, `"service"`, `"series"`, `"application"`. ### Property Signature ```csharp public string HierarchyLevel { get; set; } ``` ### Type string ### Example ```csharp simple.HierarchyLevel = "dataset"; ``` ``` -------------------------------- ### Distribution Details Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Gets or sets detailed distribution information, including transfer options. This property provides comprehensive details about data access. ```csharp public SimpleDistributionDetails DistributionDetails { get; set; } ``` -------------------------------- ### Assign Publisher Contact to Metadata Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/types.md Shows how to create and assign a SimpleContact object to the publisher role within a SimpleMetadata object. ```csharp SimpleMetadata metadata = SimpleMetadata.CreateDataset(); metadata.ContactPublisher = new SimpleContact { Name = "John Doe", Email = "john@example.com", Organization = "My Organization", Role = "publisher" }; ``` -------------------------------- ### Handle WebException Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestrunner-httpexecutor.md Provides a basic structure for handling exceptions during HTTP requests. Exceptions are logged and re-thrown, requiring application-level handling. ```csharp try { var response = (HttpWebResponse)request.GetResponse(); } catch (Exception e) { OnLogEventError("Exception while running HTTP request.", e); throw e; } ``` -------------------------------- ### Create HttpRequestExecutor Instance Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/requestrunner-httpexecutor.md Instantiates the HttpRequestExecutor class with default HTTP settings, including TLS 1.2 and a 60-second timeout. ```csharp public HttpRequestExecutor() ``` -------------------------------- ### Set Abstract Property Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Use the `Abstract` property to set the abstract or description of the metadata record. The system automatically uses Norwegian or English based on the `MetadataLanguage` setting. ```csharp public string Abstract { get; set; } ``` ```csharp simple.Abstract = "This dataset contains mapping data for the entire region"; ``` -------------------------------- ### OR Logic Operator for Filters Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/csw-endpoints.md Use the 'OR' operator to combine filter conditions where at least one of the criteria must be met. The example shows an empty OR structure. ```xml ``` -------------------------------- ### Get Feature by ID Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Retrieves a specific feature from a WFS service using its unique ID. Requires valid service URL, layer name, and feature ID. ```csharp public async Task GetFeatureByIdAsync(string serviceUrl, string layerName, string featureId) { var requestUrl = $"{serviceUrl}?service=WFS&version=2.0.0&request=GetFeature&typeName={layerName}&featureID={featureId}"; using (var client = new HttpClient()) { return await client.GetStringAsync(requestUrl); } } ``` -------------------------------- ### Define Dataset Language Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Sets the language code for the dataset's content using the ISO 639-2 format. Examples include 'nor' for Norwegian and 'eng' for English. ```csharp public string Language { get; set; } ``` -------------------------------- ### Create New Dataset Metadata Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/simplemetadata-class.md Use the CreateDataset factory method to initialize a new SimpleMetadata object for dataset records. An optional file identifier can be provided; otherwise, one is auto-generated. This method sets up the object with minimal boilerplate for ISO 19139 compliance. ```csharp public static SimpleMetadata CreateDataset(string fileIdentifier = null) ``` ```csharp SimpleMetadata metadata = SimpleMetadata.CreateDataset(); metadata.Title = "My Dataset"; metadata.Abstract = "This is a description of my dataset"; ``` -------------------------------- ### Perform a Basic Search Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/README.md Searches for records matching a given query string. Displays the number of matched records and iterates through their titles. ```csharp using GeoNorgeAPI; GeoNorge api = new GeoNorge(); SearchResultsType results = api.Search("water maps"); Console.WriteLine($"Found {results.numberOfRecordsMatched} records"); foreach (var record in results.Record ?? Array.Empty()) { Console.WriteLine(record.title); } ``` -------------------------------- ### Search Records by Free Text Source: https://github.com/kartverket/geonorgeapi/blob/master/_autodocs/geonorge-class.md Perform a free text search for records in Dublin Core format. Supports pagination and sorting by title. Use '%' as a wildcard in the search string. ```csharp GeoNorge api = new GeoNorge(); SearchResultsType results = api.Search("water maps"); Console.WriteLine($"Found {results.numberOfRecordsMatched} records"); foreach (var record in results.Record) { Console.WriteLine(record.title); } ```