Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using FiftyOne.Foundation.Mobile.Detection;
- using FiftyOne.Foundation.Mobile.Detection.Entities;
- using FiftyOne.Foundation.Mobile.Detection.Factories;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Provider provider = new Provider(MemoryFactory.Create("path\\to\\51Degrees\\file.dat"));
- string requiredProperty = "HardwareVendor";
- string requiredValue = "Samsung";
- Property property = provider.DataSet.GetProperty(requiredProperty);
- if (property == null)
- {
- //Property not found.
- return;
- }
- List<Signature> signatures = new List<Signature>();
- //For each signature.
- foreach (Signature sig in provider.DataSet.Signatures)
- {
- // Each signature has 4 components associated with it.
- // Find the component the property belongs to.
- foreach (Profile profile in sig.Profiles)
- {
- if (profile.Component == property.Component)
- {
- foreach (Value val in profile.Values) {
- // Verify the current value is related to the property that we are interested in.
- // If not - move on to the next value.
- if (val.Property.Index != property.Index) {
- continue;
- }
- // Otherwise compare current value to the one we are interested in.
- if (val.Name.Equals(requiredValue)) {
- // Add signature to the list.
- signatures.Add(sig);
- //Console.Write("Componenet: " + profile.Component)
- //Console.WriteLine(" Profile: "+profile.ProfileId+" - "+val.Property.Name+": "+val.Name);
- }
- }
- }
- }
- }
- //At this point we have a list of Signatures where HardwareProfile component's HardwareVendor
- //value is 'Samsung'
- Console.WriteLine("There are: " + signatures.Count+" signatures in the list");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement