/// <summary>
        /// Resolves address and reads the <see cref="DomainModel"/> record as an asynchronous operation.
        /// </summary>
        /// <param name="modelUri">The model URI.</param>
        /// <param name="rootZoneUrl">The root zone URL where the resolving process shall start.</param>
        /// <param name="log"><see cref="Action{T1, T2, T3}"/> encapsulating tracing functionality .</param>
        /// <returns>Task{DomainModel}.</returns>
        /// <exception cref="InvalidOperationException">Too many iteration in the resolving process.</exception>
        public async Task <DomainModel> ResolveDomainModelAsync(Uri modelUri, Uri rootZoneUrl, Action <string, TraceEventType, Priority> log)
        {
            log($"Starting resolving address of the domain model descriptor for the model Uri {modelUri}", TraceEventType.Verbose, Priority.Low);
            DomainDescriptor _lastDomainDescriptor = new DomainDescriptor()
            {
                NextStepRecordType = RecordType.DomainDescriptor
            };
            Uri _nextUri   = rootZoneUrl;
            int _iteration = 0;

            do
            {
                _iteration++;
                log($"Resolving address iteration {_iteration} address: {_nextUri}", TraceEventType.Verbose, Priority.Low);
                if (_iteration > 16)
                {
                    throw new InvalidOperationException("Too many iteration in the resolving process.");
                }
                _lastDomainDescriptor = await GetHTTPResponseAsync <DomainDescriptor>(_nextUri, log);

                _nextUri = _lastDomainDescriptor.ResolveUri(modelUri);
            } while (_lastDomainDescriptor.NextStepRecordType == RecordType.DomainDescriptor);
            log($"Reading DomainModel at: {_nextUri}", TraceEventType.Verbose, Priority.Low);
            Task <DomainModel> _DomainModelTask = GetHTTPResponseAsync <DomainModel>(_nextUri, log);
            DomainModel        _model           = await _DomainModelTask;

            _model.UniversalDiscoveryServiceLocator = _nextUri.ToString();
            log($"Successfuly received and decoded the requested DomainModel record: {_nextUri}", TraceEventType.Verbose, Priority.Low);
            return(_model);
        }
Exemplo n.º 2
0
        public void GetRootDomainDescriptorTest()
        {
            DomainDescriptor _rootDomainDescriptor = DomainDescriptorFactory.GetRootDomainDescriptor();
            Uri    _resolution            = _rootDomainDescriptor.ResolveUri(m_ModelUri);
            string m_ExpectedFirsRoundUrl = "https://raw.githubusercontent.com/mpostol/OPC-UA-OOI/master/DataDiscovery/Tests/DiscoveryServices.UnitTest/TestData/root.zone/commsvr.com/DomainDescriptor.xml";

            Assert.AreEqual <string>(m_ExpectedFirsRoundUrl, _resolution.ToString());
            string   _fn = "RootDomainDescriptor.xml";
            FileInfo _fi = new FileInfo($@"TestData\{_fn}");

            using (Stream _outputStream = _fi.Create())
            {
                XmlSerializer _serializer = new XmlSerializer(typeof(DomainDescriptor));
                _serializer.Serialize(_outputStream, _rootDomainDescriptor);
            }
            _fi.Refresh();
            Assert.IsTrue(_fi.Exists);
            Assert.IsTrue(_fi.Length > 0);
            DomainDescriptor _tc;

            using (Stream _descriptionStream = _fi.OpenRead())
            {
                XmlSerializer _serializer = new XmlSerializer(typeof(DomainDescriptor));
                _tc = (DomainDescriptor)_serializer.Deserialize(_descriptionStream);
                Assert.IsNotNull(_tc);
            }
            Assert.IsTrue(_tc.Description.Contains("Starting point"));
            Assert.AreEqual <RecordType>(RecordType.DomainDescriptor, _tc.NextStepRecordType);
            Assert.AreEqual <string>(@"https://raw.githubusercontent.com/mpostol/OPC-UA-OOI/master/DataDiscovery/Tests/DiscoveryServices.UnitTest/TestData/root.zone/#authority#/DomainDescriptor.xml", _tc.UrlPattern);
            _resolution = _tc.ResolveUri(m_ModelUri);
            Assert.AreEqual <string>(m_ExpectedFirsRoundUrl, _resolution.ToString());
        }
Exemplo n.º 3
0
 public void GetHTTPResponseAsyncRetryCountErrorTestMethod()
 {
     using (LocalDataDiscoveryServices _service = new LocalDataDiscoveryServices())
     {
         DomainDescriptor _tc = null;
         _service.GetHTTPResponse <DomainDescriptor>(new Uri("http://localhost/alfa.bravo.xml"), DebugLog, x => _tc = x);
     }
 }
Exemplo n.º 4
0
            internal void AreEqualsDomainDescriptors(DomainDescriptor _rootDomainDescriptor, Uri address, Action <string, TraceEventType, Priority> debugLog)
            {
                DomainDescriptor _tc = null;

                GetHTTPResponse <DomainDescriptor>(address, DebugLog, x => _tc = x);
                Assert.IsNotNull(_tc);
                Assert.AreEqual <string>(_rootDomainDescriptor.Description, _tc.Description);
                Assert.AreEqual <RecordType>(_rootDomainDescriptor.NextStepRecordType, _tc.NextStepRecordType);
                Assert.AreEqual <String>(_rootDomainDescriptor.UrlPattern, _tc.UrlPattern);
                debugLog($"Finished {nameof(AreEqualsDomainDescriptors)} succesfully", TraceEventType.Verbose, Priority.None);
            }
Exemplo n.º 5
0
        public void RootZoneDomainDescriptorTest()
        {
            DomainDescriptor _referenceDomainDescriptor = DomainDescriptorFactory.GetRootDomainDescriptor();

            AreEqualsDomainDescriptors(_referenceDomainDescriptor, @"root.zone\DomainDescriptor.xml");

            _referenceDomainDescriptor = DomainDescriptorFactory.Iteration1DomainDescriptor();
            AreEqualsDomainDescriptors(_referenceDomainDescriptor, @"root.zone\commsvr.com\DomainDescriptor.xml");

            _referenceDomainDescriptor = DomainDescriptorFactory.Iteration2DomainDescriptor();
            AreEqualsDomainDescriptors(_referenceDomainDescriptor, @"root.zone\commsvr.com\UA\Examples\BoilersSet\DomainDescriptor.xml");
        }
Exemplo n.º 6
0
        public void DomainDescriptorAutogeneratedFileTest()
        {
            FileInfo _fi = new FileInfo(@"TestData\DomainDescriptor.xml");

            Assert.IsTrue(_fi.Exists);
            DomainDescriptor _newDescription = null;

            using (Stream _descriptionStream = _fi.OpenRead())
            {
                XmlSerializer _serializer = new XmlSerializer(typeof(DomainDescriptor));
                _newDescription = (DomainDescriptor)_serializer.Deserialize(_descriptionStream);
            }
            Assert.IsNotNull(_newDescription);
            Assert.IsFalse(string.IsNullOrEmpty(_newDescription.Description));
            Assert.IsFalse(string.IsNullOrEmpty(_newDescription.UrlPattern));
        }
Exemplo n.º 7
0
        private static void AreEqualsDomainDescriptors(DomainDescriptor _rootDomainDescriptor, string fileName)
        {
            FileInfo _fi = new FileInfo($@"TestData\{fileName}");

            Assert.IsTrue(_fi.Exists);
            DomainDescriptor _tc;

            using (Stream _descriptionStream = _fi.OpenRead())
            {
                XmlSerializer _serializer = new XmlSerializer(typeof(DomainDescriptor));
                _tc = (DomainDescriptor)_serializer.Deserialize(_descriptionStream);
                Assert.IsNotNull(_tc);
            }
            Assert.AreEqual <string>(_rootDomainDescriptor.Description, _tc.Description);
            Assert.AreEqual <RecordType>(_rootDomainDescriptor.NextStepRecordType, _tc.NextStepRecordType);
            Assert.AreEqual <String>(_rootDomainDescriptor.UrlPattern, _tc.UrlPattern);
        }
Exemplo n.º 8
0
 internal DomainTreeViewItemViewModel(Authentication authentication, DomainDescriptor descriptor, object selector)
     : base(authentication, descriptor, selector)
 {
 }
 protected override DomainTreeItemBase CreateInstance(Authentication authentication, DomainDescriptor descriptor, object owner)
 {
     return(new DomainTreeViewItemViewModel(authentication, descriptor, owner));
 }