コード例 #1
0
 public OperatingSystemDatasourceParser(Stream stream, VocabularyHolder vocabularyHolder)
 {
     Init(stream);
     try
     {
         vocabularyHolder.ExistVocabulary(ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
         this.vocabularyHolder = vocabularyHolder;
     }
     catch (Exception ex)
     {
         this.vocabularyHolder = null;
     }
 }
コード例 #2
0
            public Oddr.Models.OS.OperatingSystem GetOperatingSystem(VocabularyHolder vocabularyHolder)
            {
                Dictionary<string, string> dic = new Dictionary<string, string>();

                if (vocabularyHolder != null)
                {
                    foreach (StringPair sp in properties)
                    {
                        try
                        {
                            //vocabularyHolder.ExistProperty(sp.key, ODDRService.ASPECT_OPERATIVE_SYSTEM, ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
                            if (vocabularyHolder.ExistProperty(sp.key, ODDRService.ASPECT_OPERATIVE_SYSTEM, ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI) != null)
                            {
                                dic.Add(sp.key, sp.value);
                            }
                        }
                        //catch (NameException ex)
                        //{
                        //    //property non loaded
                        //}
                        catch (ArgumentException ae)
                        {
                            //Console.WriteLine(this.GetType().FullName + " " + sp.key + " already present!!!");
                        }
                    }
                }
                else
                {
                    foreach (StringPair sp in properties)
                    {
                        dic.Add(sp.key, sp.value);
                    }
                }

                return new Oddr.Models.OS.OperatingSystem(dic);
            }
コード例 #3
0
        /// <summary>
        /// Initialize method.
        /// </summary>
        /// <param name="defaultVocabularyIRI"></param>
        /// <param name="prprts"></param>
        public void Initialize(string defaultVocabularyIRI, Properties prprts)
        {
            if (defaultVocabularyIRI == null || defaultVocabularyIRI.Trim().Length == 0)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new NullReferenceException("defaultVocabularyIRI can not be null"));
            }

            /*Initializing VocabularyHolder*/
            ODDRVocabularyService oddrVocabularyService = new ODDRVocabularyService();
            oddrVocabularyService.Initialize(prprts);

            vocabularyHolder = oddrVocabularyService.vocabularyHolder;
            vocabularyHolder.ExistVocabulary(defaultVocabularyIRI);

            String oddrUaDeviceBuilderPath = prprts.GetProperty(ODDR_UA_DEVICE_BUILDER_PATH_PROP);
            String oddrUaDeviceDatasourcePath = prprts.GetProperty(ODDR_UA_DEVICE_DATASOURCE_PATH_PROP);
            String oddrUaDeviceBuilderPatchPaths = prprts.GetProperty(ODDR_UA_DEVICE_BUILDER_PATCH_PATHS_PROP);
            String oddrUaDeviceDatasourcePatchPaths = prprts.GetProperty(ODDR_UA_DEVICE_DATASOURCE_PATCH_PATHS_PROP);
            String oddrUaBrowserDatasourcePaths = prprts.GetProperty(ODDR_UA_BROWSER_DATASOURCE_PATH_PROP);
            String oddrUaOperatingSystemDatasourcePaths = prprts.GetProperty(ODDR_UA_OPERATINGSYSTEM_DATASOURCE_PATH_PROP);

            Stream oddrUaDeviceBuilderStream = null;
            Stream oddrUaDeviceDatasourceStream = null;
            Stream[] oddrUaDeviceBuilderPatchStreams = null;
            Stream[] oddrUaDeviceDatasourcePatchStreams = null;
            Stream oddrUaBrowserDatasourceStream = null;
            Stream oddrUaOperatingSystemDatasourceStream = null;

            try
            {
                oddrUaDeviceBuilderStream = (Stream)prprts.Get(ODDR_UA_DEVICE_BUILDER_STREAM_PROP);
            }
            catch (Exception ex)
            {
                oddrUaDeviceBuilderStream = null;
            }
            try
            {
                oddrUaDeviceDatasourceStream = (Stream)prprts.Get(ODDR_UA_DEVICE_DATASOURCE_STREAM_PROP);
            }
            catch (Exception ex)
            {
                oddrUaDeviceDatasourceStream = null;
            }
            try
            {
                oddrUaDeviceBuilderPatchStreams = (Stream[])prprts.Get(ODDR_UA_DEVICE_BUILDER_PATCH_STREAMS_PROP);
            }
            catch (Exception ex)
            {
                oddrUaDeviceBuilderPatchStreams = null;
            }
            try
            {
                oddrUaDeviceDatasourcePatchStreams = (Stream[])prprts.Get(ODDR_UA_DEVICE_DATASOURCE_PATCH_STREAMS_PROP);
            }
            catch (Exception ex)
            {
                oddrUaDeviceDatasourcePatchStreams = null;
            }
            try
            {
                oddrUaBrowserDatasourceStream = (Stream)prprts.Get(ODDR_UA_BROWSER_DATASOURCE_STREAM_PROP);
            }
            catch (Exception ex)
            {
                oddrUaBrowserDatasourceStream = null;
            }
            try
            {
                oddrUaOperatingSystemDatasourceStream = (Stream)prprts.Get(ODDR_UA_OPERATINGSYSTEM_DATASOURCE_STREAM_PROP);
            }
            catch (Exception ex)
            {
                oddrUaOperatingSystemDatasourceStream = null;
            }

            String oddrThreshold = prprts.GetProperty(ODDR_THRESHOLD_PROP);

            if ((oddrUaDeviceBuilderPath == null || oddrUaDeviceBuilderPath.Trim().Length == 0) && oddrUaDeviceBuilderStream == null)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not find property " + ODDR_UA_DEVICE_BUILDER_PATH_PROP));
            }

            if ((oddrUaDeviceDatasourcePath == null || oddrUaDeviceDatasourcePath.Trim().Length == 0) && oddrUaDeviceDatasourceStream == null)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not find property " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP));
            }

            String[] oddrUaDeviceBuilderPatchPathArray = null;

            if (oddrUaDeviceBuilderPatchPaths != null && oddrUaDeviceBuilderPatchPaths.Trim().Length != 0)
            {
                oddrUaDeviceBuilderPatchPathArray = oddrUaDeviceBuilderPatchPaths.Split(",".ToCharArray());

            }
            else
            {
                oddrUaDeviceBuilderPatchPathArray = new String[0];
            }

            String[] ooddrUaDeviceDatasourcePatchPathArray = null;

            if (oddrUaDeviceDatasourcePatchPaths != null && oddrUaDeviceDatasourcePatchPaths.Trim().Length != 0)
            {
                ooddrUaDeviceDatasourcePatchPathArray = oddrUaDeviceDatasourcePatchPaths.Split(",".ToCharArray());

            }
            else
            {
                ooddrUaDeviceDatasourcePatchPathArray = new String[0];
            }

            if (oddrUaDeviceBuilderPatchStreams == null)
            {
                oddrUaDeviceBuilderPatchStreams = new Stream[0];
            }

            if (oddrUaDeviceDatasourcePatchStreams == null)
            {
                oddrUaDeviceDatasourcePatchStreams = new Stream[0];
            }

            if ((oddrUaBrowserDatasourcePaths == null || oddrUaBrowserDatasourcePaths.Trim().Length == 0) && oddrUaBrowserDatasourceStream == null)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not find property " + ODDR_UA_BROWSER_DATASOURCE_PATH_PROP));
            }

            if ((oddrUaOperatingSystemDatasourcePaths == null || oddrUaOperatingSystemDatasourcePaths.Trim().Length == 0) && oddrUaOperatingSystemDatasourceStream == null)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not find property " + ODDR_UA_OPERATINGSYSTEM_DATASOURCE_PATH_PROP));
            }

            if (oddrThreshold == null || oddrThreshold.Trim().Length == 0)
            {
                this.threshold = ODDR_DEFAULT_THRESHOLD;

            }
            else
            {
                try
                {
                    this.threshold = int.Parse(oddrThreshold);
                    if (this.threshold <= 0)
                    {
                        this.threshold = ODDR_DEFAULT_THRESHOLD;
                    }

                }
                catch (FormatException x)
                {
                    this.threshold = ODDR_DEFAULT_THRESHOLD;
                }
            }

            Dictionary<String, Device> devices = new Dictionary<String, Device>();

            Stream stream = null;

            try
            {
                if (oddrUaDeviceDatasourceStream != null)
                {
                    stream = oddrUaDeviceDatasourceStream;
                }
                else
                {
                    stream = new FileStream(oddrUaDeviceDatasourcePath, FileMode.Open);
                }

            }
            catch (IOException ex)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not open " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " " + oddrUaDeviceDatasourcePath));
            }

            /// TODO: Check stream. If stream is null DeviceDataSourceParser throws ArgumentNullException
            DeviceDatasourceParser deviceDatasourceParser = new DeviceDatasourceParser(stream, devices, vocabularyHolder);

            try
            {
                deviceDatasourceParser.Parse();
            }
            catch (Exception ex)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not parse " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " :" + oddrUaDeviceDatasourcePath));
            }

            try
            {
                stream.Close();
            }
            catch (IOException ex)
            {
                logger.Warn("", ex);
            }

            deviceDatasourceParser.patching = true;

            if (oddrUaDeviceDatasourcePatchStreams != null && oddrUaDeviceDatasourcePatchStreams.Length != 0)
            {
                for (int i = 0; i < oddrUaDeviceDatasourcePatchStreams.Length; i++)
                {
                    stream = oddrUaDeviceDatasourcePatchStreams[i];

                    try
                    {
                        deviceDatasourceParser.SetStream(stream);
                        deviceDatasourceParser.Parse();

                    }
                    catch (ArgumentNullException ane)
                    {
                        throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not open DeviceDatasource input stream " + i));
                    }
                    catch (Exception ex)
                    {
                        throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not parse DeviceDatasource input stream " + i));
                    }

                    try
                    {
                        stream.Close();

                    }
                    catch (IOException ex)
                    {
                        logger.Warn("", ex);
                    }
                }
            }
            else
            {
                for (int i = 0; i < ooddrUaDeviceDatasourcePatchPathArray.Length; i++)
                {
                    try
                    {
                        stream = new FileStream(ooddrUaDeviceDatasourcePatchPathArray[i], FileMode.Open);
                    }
                    catch (IOException ex)
                    {
                        throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not open " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " " + ooddrUaDeviceDatasourcePatchPathArray[i]));
                    }

                    try
                    {
                        deviceDatasourceParser.SetStream(stream);
                        deviceDatasourceParser.Parse();
                    }
                    catch (ArgumentNullException ane)
                    {
                        throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not open " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " :" + ooddrUaDeviceDatasourcePatchPathArray[i]));
                    }
                    catch (Exception ex)
                    {
                        throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not parse document: " + ooddrUaDeviceDatasourcePatchPathArray[i]));
                    }

                    try
                    {
                        stream.Close();
                    }
                    catch (IOException ex)
                    {
                        logger.Warn("", ex);
                    }
                }

            }

            List<IDeviceBuilder> builders = new List<IDeviceBuilder>();

            try
            {
                if (oddrUaDeviceBuilderStream != null)
                {
                    stream = oddrUaDeviceBuilderStream;
                }
                else
                {
                    stream = new FileStream(oddrUaDeviceBuilderPath, FileMode.Open);
                }

            }
            catch (IOException ex)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not open " + ODDR_UA_DEVICE_BUILDER_PATH_PROP + " " + oddrUaDeviceBuilderPath));
            }

            /// TODO: Check stream. If stream is null DeviceBuilderParser throws ArgumentNullException
            DeviceBuilderParser deviceBuilderParser = new DeviceBuilderParser(stream, builders);

            try
            {
                deviceBuilderParser.Parse();
            }
            catch (Exception ex)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not parse " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " :" + oddrUaDeviceBuilderPath));
            }

            try
            {
                stream.Close();

            }
            catch (IOException ex)
            {
                logger.Warn("", ex);
            }

            if (oddrUaDeviceBuilderPatchStreams != null && oddrUaDeviceBuilderPatchStreams.Length != 0)
            {
                for (int i = 0; i < oddrUaDeviceBuilderPatchStreams.Length; i++)
                {
                    stream = oddrUaDeviceBuilderPatchStreams[i];

                    try
                    {
                        deviceBuilderParser.SetStream(stream);
                        deviceBuilderParser.Parse();

                    }
                    catch (ArgumentNullException ane)
                    {
                        throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not open DeviceBuilder input stream " + i));
                    }
                    catch (Exception ex)
                    {
                        throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not parse DeviceBuilder input stream " + i));
                    }

                    try
                    {
                        stream.Close();
                    }
                    catch (IOException ex)
                    {
                        logger.Warn("", ex);
                    }
                }

            }
            else
            {
                for (int i = 0; i < oddrUaDeviceBuilderPatchPathArray.Length; i++)
                {
                    try
                    {
                        stream = new FileStream(oddrUaDeviceBuilderPatchPathArray[i], FileMode.Open);

                    }
                    catch (IOException ex)
                    {
                        throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not open " + ODDR_UA_DEVICE_BUILDER_PATCH_PATHS_PROP + " " + oddrUaDeviceBuilderPatchPathArray[i]));
                    }

                    try
                    {
                        deviceBuilderParser.SetStream(stream);
                        deviceBuilderParser.Parse();
                    }
                    catch (ArgumentNullException ane)
                    {
                        throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not open " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " :" + oddrUaDeviceBuilderPatchPathArray[i]));
                    }
                    catch (Exception ex)
                    {
                        throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not parse document: " + oddrUaDeviceBuilderPatchPathArray[i]));
                    }

                    try
                    {
                        stream.Close();

                    }
                    catch (IOException ex)
                    {
                        logger.Warn("", ex);
                    }
                }
            }

            try
            {
                if (oddrUaBrowserDatasourceStream != null)
                {
                    stream = oddrUaBrowserDatasourceStream;
                }
                else
                {
                    stream = new FileStream(oddrUaBrowserDatasourcePaths, FileMode.Open);
                }

            }
            catch (IOException ex)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not open " + ODDR_UA_BROWSER_DATASOURCE_PATH_PROP + " " + oddrUaBrowserDatasourcePaths));
            }

            /// TODO: Check stream. If stream is null BrowserDatasourceParser throws ArgumentNullException
            BrowserDatasourceParser browserDatasourceParser = new BrowserDatasourceParser(stream, vocabularyHolder);

            try
            {
                browserDatasourceParser.Parse();
            }
            catch (Exception ex)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not parse document: " + oddrUaBrowserDatasourcePaths));
            }

            try
            {
                stream.Close();
            }
            catch (IOException ex)
            {
                logger.Warn("", ex);
            }

            try
            {
                if (oddrUaOperatingSystemDatasourceStream != null)
                {
                    stream = oddrUaOperatingSystemDatasourceStream;
                }
                else
                {
                    stream = new FileStream(oddrUaOperatingSystemDatasourcePaths, FileMode.Open);
                }

            }
            catch (IOException ex)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not open " + ODDR_UA_OPERATINGSYSTEM_DATASOURCE_PATH_PROP + " " + oddrUaOperatingSystemDatasourcePaths));
            }

            /// TODO: Check stream. If stream is null OperatingSystemDatasourceParser throws ArgumentNullException
            OperatingSystemDatasourceParser operatingSystemDatasourceParser = new OperatingSystemDatasourceParser(stream, vocabularyHolder);

            try
            {
                operatingSystemDatasourceParser.Parse();

            }
            catch (Exception ex)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not parse document: " + oddrUaOperatingSystemDatasourcePaths));

            }

            try
            {
                stream.Close();

            }
            catch (IOException ex)
            {
                logger.Warn("", ex);
            }

            deviceIdentificator = new DeviceIdentificator(deviceBuilderParser.DeviceBuilders(), deviceDatasourceParser.devices);
            deviceIdentificator.CompleteInit();

            Dictionary<string, Browser> browsers = new Dictionary<string, Browser>(browserDatasourceParser.browsers);
            browserIdentificator = new BrowserIdentificator(new IBuilder[] { DefaultBrowserBuilder.Instance }, browsers);
            browserIdentificator.CompleteInit();

            Dictionary<string, OSModel.OperatingSystem> operatingSystems = new Dictionary<string, OSModel.OperatingSystem>(operatingSystemDatasourceParser.operatingSystems);
            osIdentificator = new OSIdentificator(new IBuilder[] { DefaultOSBuilder.Instance }, operatingSystems);
            osIdentificator.CompleteInit();

            deviceDatasourceParser = null;
            deviceBuilderParser = null;
            browserDatasourceParser = null;
            operatingSystemDatasourceParser = null;

            this.defaultVocabularyIRI = defaultVocabularyIRI;

            oddrVocabularyService = null;

            return;
        }
コード例 #4
0
        /// <summary>
        /// Initialization funcion. It is called by ODDRService at initialization time in order to populate vocabulary holder.
        /// </summary>
        /// <param name="props">Properties object holding the configuration properties.</param>
        /// <exception cref="InitializationException">Throws when...</exception>
        public void Initialize(Properties props)
        {
            Dictionary<String, Vocabulary> vocabularies = new Dictionary<String, Vocabulary>();

            String ddrCoreVocabularyPath = props.GetProperty(DDR_CORE_VOCABULARY_PATH_PROP);
            String oddrVocabularyPath = props.GetProperty(ODDR_VOCABULARY_PATH_PROP);

            Stream ddrCoreVocabulayStream = null;
            Stream[] oddrVocabularyStream = null;
            try {
                ddrCoreVocabulayStream = props.Get(DDR_CORE_VOCABULARY_STREAM_PROP) as Stream;
            } catch (Exception ex) {
                ddrCoreVocabulayStream = null;
            }
            try {
                oddrVocabularyStream = props.Get(ODDR_VOCABULARY_STREAM_PROP) as Stream[];
            } catch (Exception ex) {
                oddrVocabularyStream = null;
            }

            if ((string.IsNullOrEmpty(ddrCoreVocabularyPath)) && ddrCoreVocabulayStream == null) {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not find property " + DDR_CORE_VOCABULARY_PATH_PROP));
            }

            if ((string.IsNullOrEmpty(oddrVocabularyPath)) && oddrVocabularyStream == null) {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not find property " + ODDR_VOCABULARY_PATH_PROP));
            }

            VocabularyParser vocabularyParser = null;
            Vocabulary vocabulary = null;

            if (ddrCoreVocabulayStream != null)
            {
                vocabularyParser = ParseVocabularyFromStream(DDR_CORE_VOCABULARY_STREAM_PROP, ddrCoreVocabulayStream);
            }
            else
            {
                vocabularyParser = ParseVocabularyFromPath(DDR_CORE_VOCABULARY_PATH_PROP, ddrCoreVocabularyPath);
            }
            vocabulary = vocabularyParser.vocabulary;
            vocabularies.Add(vocabulary.vocabularyIRI, vocabulary);

            if (oddrVocabularyStream != null)
            {
                foreach (Stream stream in oddrVocabularyStream)
                {
                    vocabularyParser = ParseVocabularyFromStream(ODDR_VOCABULARY_STREAM_PROP, stream);
                    vocabulary = vocabularyParser.vocabulary;
                    vocabularies.Add(vocabulary.vocabularyIRI, vocabulary);
                }
            }
            else
            {
                String[] oddrVocabularyPaths = oddrVocabularyPath.Split(",".ToCharArray());
                foreach (string p in oddrVocabularyPaths)
                {
                    p.Trim();
                }

                foreach (String oddVocabularyString in oddrVocabularyPaths)
                {
                    vocabularyParser = ParseVocabularyFromPath(ODDR_VOCABULARY_PATH_PROP, oddVocabularyString);
                    vocabulary = vocabularyParser.vocabulary;
                    vocabularies.Add(vocabulary.vocabularyIRI, vocabulary);
                }
            }

            String oddrLimitedVocabularyPath = props.GetProperty(ODDR_LIMITED_VOCABULARY_PATH_PROP);
            Stream oddrLimitedVocabularyStream = props.Get(ODDR_LIMITED_VOCABULARY_STREAM_PROP) as Stream;

            if (oddrLimitedVocabularyStream != null) {
                vocabularyParser = ParseVocabularyFromStream(ODDR_LIMITED_VOCABULARY_STREAM_PROP, oddrLimitedVocabularyStream);
                vocabulary = vocabularyParser.vocabulary;
                vocabularies.Add(ODDR_LIMITED_VOCABULARY_IRI, vocabulary);
            } else {
               if (!string.IsNullOrEmpty(oddrLimitedVocabularyPath)) {
                   vocabularyParser = ParseVocabularyFromPath(ODDR_LIMITED_VOCABULARY_PATH_PROP, oddrLimitedVocabularyPath);
                   vocabulary = vocabularyParser.vocabulary;
                   vocabularies.Add(ODDR_LIMITED_VOCABULARY_IRI, vocabulary);
                }
            }
            //vocabulary = vocabularyParser.vocabulary;
            //vocabularies.Add(ODDR_LIMITED_VOCABULARY_IRI, vocabulary);

            vocabularyHolder = new VocabularyHolder(vocabularies);

            vocabularyParser = null;
            vocabularies = null;
        }
コード例 #5
0
 /// <exception cref="System.ArgumentNullException">Thrown when stream is null</exception>
 public DeviceDatasourceParser(Stream stream, Dictionary<string, Device> devices, VocabularyHolder vocabularyHolder)
 {
     try
     {
         Init(stream);
     }
     catch (ArgumentNullException ex)
     {
         throw new ArgumentNullException(ex.Message, ex);
     }
     this.devices = devices;
     try
     {
         vocabularyHolder.ExistVocabulary(ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
         this.vocabularyHolder = vocabularyHolder;
     }
     catch (Exception ex)
     {
         this.vocabularyHolder = null;
     }
 }
コード例 #6
0
            public Device GetDevice(VocabularyHolder vocabularyHolder)
            {
                Dictionary<string, string> dic = new Dictionary<string, string>();

                if (vocabularyHolder != null)
                {
                    foreach (StringPair sp in properties)
                    {
                        try
                        {
                            //vocabularyHolder.ExistProperty(sp.key, ODDRService.ASPECT_DEVICE, ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
                            if (vocabularyHolder.ExistProperty(sp.key, ODDRService.ASPECT_DEVICE, ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI) != null)
                            {
                                //dic.Add(sp.key, sp.value);
                                dic[sp.key] = sp.value;
                            }
                        }
                        //catch (NameException ex)
                        //{
                        //    Console.WriteLine(ex.Message);
                        //    //property non loaded
                        //}
                        catch (ArgumentException ae)
                        {
                            //Console.WriteLine(this.GetType().FullName + " " + sp.key + " already present in device " + id);
                        }
                    }
                }
                else
                {
                    foreach (StringPair sp in properties)
                    {
                        //dic.Add(sp.key, sp.value);
                        dic[sp.key] = sp.value;
                    }
                }

                Device d = new Device();
                d.id = this.id;
                d.parentId = this.parentId;
                d.PutPropertiesMap(dic);

                return d;
            }
コード例 #7
0
            public Browser GetBrowser(VocabularyHolder vocabularyHolder)
            {
                Dictionary<string, string> dic = new Dictionary<string, string>();

                if (vocabularyHolder != null)
                {
                    foreach (StringPair sp in properties)
                    {
                        try
                        {
                            //vocabularyHolder.ExistProperty(sp.key, ODDRService.ASPECT_WEB_BROWSER, ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
                            if (vocabularyHolder.ExistProperty(sp.key, ODDRService.ASPECT_WEB_BROWSER, ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI) != null)
                            {
                                dic.Add(sp.key, sp.value);
                            }
                        }
                        //catch (NameException ex)
                        //{
                        //    //property non loaded
                        //}
                        catch (ArgumentException ae)
                        {
                            //Console.WriteLine(this.GetType().FullName + " " + sp.key + " already present in device " + id);
                        }
                    }
                }
                else
                {
                    foreach (StringPair sp in properties)
                    {
                        dic.Add(sp.key, sp.value);
                    }
                }

                Browser b;
                b = new Browser(dic);

                return b;
            }