Add example code to use beagle as a service provider.
[beagle.git] / search / Tiles / HitFlavor.cs
blob2b132377f04a5300882bc7da2a886ee5c7c2c537
1 using System;
3 using Beagle;
4 using Beagle.Util;
6 namespace Search.Tiles {
8 public class HitFlavor {
10 private string uri;
11 private string type;
12 private string mimetype;
14 public HitFlavor (string uri)
16 this.uri = uri;
19 public HitFlavor (string uri, string type, string mimetype)
21 this.uri = uri;
22 this.type = type;
23 this.mimetype = mimetype;
26 public string Uri {
27 get { return uri; }
30 public string Type {
31 get { return type; }
34 public string MimeType {
35 get { return mimetype; }
38 public bool IsMatch (Hit hit)
40 return (uri == null || StringFu.GlobMatch (uri, hit.EscapedUri))
41 && (type == null || StringFu.GlobMatch (type, hit.Type))
42 && (mimetype == null || StringFu.GlobMatch (mimetype, hit.MimeType));
45 public int Weight {
46 get {
47 int weight = 0;
49 if (mimetype != null)
50 weight += 4;
51 if (type != null)
52 weight += 2;
53 if (uri != null)
54 weight += 1;
56 return weight;