public
override
IEnumerable GetItemsByTaxon(Guid taxonId,
bool
isSingleTaxon,
string
propertyName, Type itemType,
string
filterExpression,
string
orderExpression,
int
skip,
int
take,
ref
int
? totalCount)
{
if
(itemType ==
typeof
(LocationItem))
{
this
.CurrentTaxonomyProperty = propertyName;
int
? internalTotCount =
null
;
IQueryable<LocationItem> query =
(IQueryable<LocationItem>)
this
.GetItems(itemType, filterExpression, orderExpression, 0, 0,
ref
internalTotCount);
if
(isSingleTaxon)
{
var query0 = from i
in
query
where i.GetValue<Guid>(
this
.CurrentTaxonomyProperty) == taxonId
select i;
query = query0;
}
else
{
var query1 = from i
in
query
where (i.GetValue<IList<Guid>>(
this
.CurrentTaxonomyProperty)).Any(t => t == taxonId)
select i;
query = query1;
}
if
(totalCount.HasValue)
{
totalCount = query.Count();
}
if
(skip > 0)
query = query.Skip(skip);
if
(take > 0)
query = query.Take(take);
return
query;
}
throw
GetInvalidItemTypeException(itemType,
this
.GetKnownTypes());
}
public
override
IDataItem GetItemFromUrl(Type itemType,
string
url,
bool
published,
out
string
redirectUrl)
{
if
(itemType ==
null
)
throw
new
ArgumentNullException(
"itemType"
);
if
(String.IsNullOrEmpty(url))
throw
new
ArgumentNullException(
"Url"
);
var urlType =
this
.GetUrlTypeFor(itemType);
var urlData =
this
.GetUrls(urlType).Where(u => u.Url == url).FirstOrDefault();
if
(urlData !=
null
)
{
var item = urlData.Parent;
if
(urlData.RedirectToDefault)
redirectUrl =
this
.GetItemUrl((ILocatable)item, CultureInfo.GetCultureInfo(urlData.Culture));
else
redirectUrl =
null
;
if
(item !=
null
)
item.Provider =
this
;
return
item;
}
redirectUrl =
null
;
return
null
;
}
public
override
Type GetParentTypeFor(Type contentType)
{
return
null
;
}
public
override
Type GetUrlTypeFor(Type itemType)
{
if
(itemType ==
typeof
(LocationItem))
return
typeof
(LocationItemUrlData);
throw
GetInvalidItemTypeException(itemType,
this
.GetKnownTypes());
}
public
override
string
GetUrlFormat(ILocatable item)
{
if
(item.GetType() ==
typeof
(LocationItem))
{
return
"/[UrlName]"
;
}
return
base
.GetUrlFormat(item);
}
public
override
Type[] GetKnownTypes()
{
return
new
[] {
typeof
(LocationItem) };
}
public
override
string
RootKey
{
get
{
return
"LocationsDataProvider"
; }
}