static public HitFlavor Get(Hit hit)
        {
            if (flavorArray == null)
            {
                flavorArray = new ArrayList();
                ScanAssembly(Assembly.GetExecutingAssembly());
            }

            HitFlavor flavorBest = null;
            int       weightBest = -1;

            foreach (HitFlavor flavor in flavorArray)
            {
                if (flavor.IsMatch(hit))
                {
                    int weight = flavor.Weight;
                    if (weight > weightBest)
                    {
                        flavorBest = flavor;
                        weightBest = weight;
                    }
                    else if (weight == weightBest && flavor.Name != flavorBest.Name)
                    {
                        // This shouldn't happen.
                        Console.WriteLine("HitFlavor Weight tie! {0} and {1}",
                                          flavorBest, flavor);
                    }
                }
            }

            return(flavorBest);
        }
 static private void ScanAssembly(Assembly assembly)
 {
     foreach (Type type in assembly.GetTypes())
     {
         if (type.IsSubclassOf(typeof(Tile)))
         {
             foreach (object obj in Attribute.GetCustomAttributes(type))
             {
                 if (obj is HitFlavor)
                 {
                     HitFlavor flavor = (HitFlavor)obj;
                     flavor.TileType = type;
                     flavorArray.Add(flavor);
                 }
             }
         }
     }
 }
        public void Add(Hit hit)
        {
            HitFlavor flavor = HitToHitFlavor.Get(hit);

            if (flavor == null)
            {
                return;
            }

            object[] args = new object [1];
            args[0] = hit;
            Tile tile = (Tile)Activator.CreateInstance(flavor.TileType, args);

            tile.Hit   = hit;
            tile.Uri   = hit.Uri;
            tile.Query = this.Query;

            if (hit_collection.Add(hit, tile))
            {
                Changed();
            }

            //Console.WriteLine ("+ {0}", hit.Uri);
        }