Solvberget.Domain.DTO.Document.FillPropertiesLight C# (CSharp) Method

FillPropertiesLight() protected method

protected FillPropertiesLight ( string xml ) : void
xml string
return void
        protected virtual void FillPropertiesLight(string xml)
        {
            var xmlDoc = XDocument.Parse(xml);
            if (xmlDoc.Root != null)
            {
                DocumentNumber = xmlDoc.Root.Descendants("doc_number").Select(x => x.Value).FirstOrDefault();

                var nodes = xmlDoc.Root.Descendants("oai_marc");
                var language = GetFixfield(nodes, "008", 35, 37);

                string languageLookupValue = null;
                if (language != null)
                    LanguageDictionary.TryGetValue(language, out languageLookupValue);

                Language = languageLookupValue ?? "Språk er ikke registrert";

                var docTypeString = GetVarfield(nodes, "019", "b");
                if (docTypeString != null)
                    DocumentType = docTypeString.Split(';');

                Title = GetVarfield(nodes, "245", "a");
                SubTitle = GetVarfield(nodes, "245", "b");

                var publishedYearString = GetVarfield(nodes, "260", "c");
                if (publishedYearString != null)
                {
                    //Format may be "[2009]" or "2009.", trim if so
                    var regExp = new Regex(@"[a-zA-Z.\[\]]*(\d+)[a-zA-Z.\[\]]*");
                    var foundValue = regExp.Match(publishedYearString).Groups[1].ToString();
                    if (!string.IsNullOrEmpty(foundValue))
                        PublishedYear = int.Parse(foundValue);
                }

            }
        }

Usage Example

Exemplo n.º 1
0
 public static Document GetObjectFromFindDocXmlBsMarcLight(string xml)
 {
     var document = new Document();
     document.FillPropertiesLight(xml);
     return document;
 }