Beispiel #1
0
        public void Init()
        {
            OaiConfigurationTest.Init();
            IOaiConfiguration configuration = OaiConfiguration.Instance;
            var metadataFormatRepository    = SampleMetadataFormatRepositoryTest.Create();
            var recordRepository            = SampleRecordRepositoryTest.Create();
            var setRepository = SampleSetRepositoryTest.Create();

            _baseUrl      = configuration.BaseUrl();
            _dataProvider = new DataProvider(configuration, metadataFormatRepository, recordRepository, setRepository);
        }
Beispiel #2
0
        private XElement CreateRequest(OaiVerb verb, ArgumentContainer arguments)
        {
            IList <object> attributes = new List <object>();

            switch (verb)
            {
            case OaiVerb.None:
                // don't add any attributes
                break;

            default:
                attributes.Add(new XAttribute("verb", verb.ToString()));
                if (!string.IsNullOrWhiteSpace(arguments.Identifier))
                {
                    attributes.Add(new XAttribute("identifier", arguments.Identifier));
                }
                if (!string.IsNullOrWhiteSpace(arguments.MetadataPrefix))
                {
                    attributes.Add(new XAttribute("metadataPrefix", arguments.MetadataPrefix));
                }
                if (!string.IsNullOrWhiteSpace(arguments.ResumptionToken))
                {
                    attributes.Add(new XAttribute("resumptionToken", arguments.ResumptionToken));
                }
                if (!string.IsNullOrWhiteSpace(arguments.From) && _dateConverter.TryDecode(arguments.From, out DateTime fromDateTime))
                {
                    attributes.Add(new XAttribute("from", arguments.From));
                }
                if (!string.IsNullOrWhiteSpace(arguments.Until) && _dateConverter.TryDecode(arguments.Until, out DateTime untilDateTime))
                {
                    attributes.Add(new XAttribute("until", arguments.Until));
                }
                if (!string.IsNullOrWhiteSpace(arguments.Set))
                {
                    attributes.Add(new XAttribute("set", arguments.Set));
                }
                break;
            }

            return(new XElement("request", _configuration.BaseUrl(), attributes));
        }