Inheritance: IPropertyRef
コード例 #1
0
        public IPropertyValues GetPropertyValues(IEvidence evdnc)
        {
            Device deviceFound = null;
            Browser browserFound = null;
            OSModel.OperatingSystem osFound = null;
            bool deviceIdentified = false;
            bool browserIdentified = false;
            bool osIdentified = false;
            UserAgent deviceUA = null;
            UserAgent browserUA = null;

            ODDRPropertyValues ret = new ODDRPropertyValues();
            Dictionary<String, Vocabulary> vocabularies = vocabularyHolder.GetVocabularies();

            foreach (String vocabularyKey in vocabularies.Keys)
            {
                Vocabulary vocabulary = vocabularies[vocabularyKey];
                Dictionary<String, VocabularyProperty> properties = vocabulary.properties;

                foreach (String propertyKey in properties.Keys)
                {
                    IPropertyName propertyName = new ODDRPropertyName(propertyKey, vocabularyKey);

                    VocabularyProperty vocabularyProperty = properties[propertyKey];
                    string[] aspects = vocabularyProperty.aspects;

                    for (int i = 0; i < aspects.Length; i++)
                    {
                        IPropertyRef propertyRef = new ODDRPropertyRef(propertyName, aspects[i]);
                        if (ASPECT_DEVICE.Equals(propertyRef.AspectName()))
                        {
                            if (!deviceIdentified)
                            {
                                if (deviceUA == null)
                                {
                                    deviceUA = UserAgentFactory.newDeviceUserAgent(evdnc);
                                }
                                if (evdnc is BufferedODDRHTTPEvidence)
                                {
                                    deviceFound = ((BufferedODDRHTTPEvidence)evdnc).deviceFound;
                                }
                                if (deviceFound == null)
                                {
                                    deviceFound = deviceIdentificator.Get(deviceUA, this.threshold) as Device;
                                }
                                if (evdnc is BufferedODDRHTTPEvidence)
                                {
                                    ((BufferedODDRHTTPEvidence)evdnc).deviceFound = deviceFound;
                                }
                                deviceIdentified = true;
                            }
                            String property = null;
                            if (deviceFound != null)
                            {
                                property = deviceFound.Get(propertyRef.LocalPropertyName());
                                ret.addProperty(new ODDRPropertyValue(property, vocabularyProperty.type, propertyRef));

                            }
                            else
                            {
                                ret.addProperty(new ODDRPropertyValue(null, vocabularyProperty.type, propertyRef));
                            }
                            continue;

                        }
                        else if (ASPECT_WEB_BROWSER.Equals(propertyRef.AspectName()))
                        {
                            if (!browserIdentified)
                            {
                                if (browserUA == null)
                                {
                                    browserUA = UserAgentFactory.newBrowserUserAgent(evdnc);
                                }
                                if (evdnc is BufferedODDRHTTPEvidence)
                                {
                                    browserFound = ((BufferedODDRHTTPEvidence)evdnc).browserFound;
                                }
                                if (browserFound == null)
                                {
                                    browserFound = browserIdentificator.Get(browserUA, this.threshold) as Browser;
                                }
                                if (evdnc is BufferedODDRHTTPEvidence)
                                {
                                    ((BufferedODDRHTTPEvidence)evdnc).browserFound = browserFound;
                                }

                                browserIdentified = true;
                            }
                            String property = null;
                            if (browserFound != null)
                            {
                                property = browserFound.Get(propertyRef.LocalPropertyName());
                                ret.addProperty(new ODDRPropertyValue(property, vocabularyProperty.type, propertyRef));

                            }
                            else
                            {
                                ret.addProperty(new ODDRPropertyValue(null, vocabularyProperty.type, propertyRef));
                            }
                            continue;

                        }
                        else if (ASPECT_OPERATIVE_SYSTEM.Equals(propertyRef.AspectName()))
                        {
                            if (!osIdentified)
                            {
                                if (deviceUA == null)
                                {
                                    deviceUA = UserAgentFactory.newDeviceUserAgent(evdnc);
                                }
                                if (evdnc is BufferedODDRHTTPEvidence)
                                {
                                    osFound = ((BufferedODDRHTTPEvidence)evdnc).osFound;
                                }
                                if (osFound == null)
                                {
                                    osFound = osIdentificator.Get(deviceUA, this.threshold) as OSModel.OperatingSystem;
                                }
                                if (evdnc is BufferedODDRHTTPEvidence)
                                {
                                    ((BufferedODDRHTTPEvidence)evdnc).osFound = osFound;
                                }

                                osIdentified = true;
                            }
                            String property = null;
                            if (osFound != null)
                            {
                                property = osFound.Get(propertyRef.LocalPropertyName());
                                ret.addProperty(new ODDRPropertyValue(property, vocabularyProperty.type, propertyRef));

                            }
                            else
                            {
                                ret.addProperty(new ODDRPropertyValue(null, vocabularyProperty.type, propertyRef));
                            }
                            continue;

                        }
                    }
                }
            }

            return ret;
        }
コード例 #2
0
        public IPropertyRef[] ListPropertyRefs()
        {
            List<IPropertyRef> propertyRefsList = new List<IPropertyRef>();
            Dictionary<String, Vocabulary> vocabularies = vocabularyHolder.GetVocabularies();

            foreach (String vocabularyKey in vocabularies.Keys)
            {
                Vocabulary vocabulary = vocabularies[vocabularyKey];
                Dictionary<String, VocabularyProperty> properties = vocabulary.properties;

                foreach (String propertyKey in properties.Keys)
                {
                    VocabularyProperty vocabularyProperty = properties[propertyKey];
                    string[] aspects = vocabularyProperty.aspects;
                    IPropertyName propertyName = new ODDRPropertyName(propertyKey, vocabularyKey);
                    for (int i = 0; i < aspects.Length; i++)
                    {
                        IPropertyRef propertyRef = new ODDRPropertyRef(propertyName, aspects[i]);
                        propertyRefsList.Add(propertyRef);
                    }
                }
            }

            IPropertyRef[] propertyRefs = new IPropertyRef[propertyRefsList.Count];
            propertyRefs = propertyRefsList.ToArray();

            return propertyRefs;
        }
コード例 #3
0
        /// <exception cref="W3c.Ddr.Exceptions.NameException">Thrown when...</exception>
        public IPropertyValues GetPropertyValues(IEvidence evdnc, string localAspectName, string vocabularyIRI)
        {
            VocabularyProperty vocabularyProperty = vocabularyHolder.ExistProperty(localAspectName, null, vocabularyIRI, true);

            IPropertyName propertyName = new ODDRPropertyName(localAspectName, vocabularyIRI);
            IPropertyRef propertyRef = new ODDRPropertyRef(propertyName, vocabularyProperty.defaultAspect);

            return GetPropertyValues(evdnc, new IPropertyRef[] { propertyRef });
        }