它已經偉大的,你正在使用tags
分類您的項目。 這可能是非常強大或非常弱,取決於您使用的標籤。
首先:確保您使用的是有意義的標籤名稱。
[壞的:C#1
,C#1.0
,Ruby1
,Ruby-1
等]
[好的:C#1
,C#2
,C#3
,Ruby1
,Ruby2
等]
現在你可以建立GetRelatedItmesList
方法當然是Generic
並做檢查。
例如是這樣的:
List<T> GetRelatedItemsList<T> (T item) where T : IOurMediaItem // I used an interface here because I like them :P - it can also be a class.
{
if (item.TagCount == 1)
{
// Get related items with the same tag and based on some keywords in title
}
else
{
// First: Get all items with exactly the tags
// Second Get all items with relating title and append it to the list
}
}
無論哪種方式,您還可以在item.TagCount
屬性/方法做了switch()
。
使用谷歌應用? – 2010-03-06 07:51:58