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;
}