, bool (, Predicate<CategoryFeatureType>). GetParentCategoryType true false, , . :
private static CategoryFeatureType GetParentCategoryType(
DMS.ProductLocation productLocation,
DMS.ProductLocation[] productLocations,
Dictionary<string, CategoryFeatureType> categoryFeatureTypes,
int level,
Predicate<CategoryFeatureType> shouldBreak)
{
CategoryFeatureType categoryFeatureType = null;
categoryFeatureTypes.TryGetValue(productLocation.ExternalChannelCode, out categoryFeatureType);
if (shouldBreak(categoryFeatureType))
return categoryFeatureType;
if (conditionTypeCollection == null && productLocation.ProductLocationIdForParent.HasValue)
{
DMS.ProductLocation parentLocation = productLocations.FirstOrDefault(p => p.Id == productLocation.ProductLocationIdForParent);
if (parentLocation != null)
{
conditionTypeCollection = GetParentCategoryTypeCollection(
parentLocation,
productLocations,
categoryFeatureTypes,
level + 1,
shouldBreak);
}
}
}
, :
private static CategoryFeatureType GetParentCategoryTypeWhereTypeIsAwesome(
DMS.ProductLocation productLocation,
DMS.ProductLocation[] productLocations,
Dictionary<string, CategoryFeatureType> categoryFeatureTypes,
int level)
{
Predicate<CategoryFeatureType> returnCheck = categoryFeatureType =>
{
return categoryFeatureType.Coolness == "Awesome";
};
return GetParentCategoryType(
productLocation,
productLocations,
categoryFeatureTypes,
level,
returnCheck);
}
, , , false:
if (shouldBreak != null && shouldBreak(categoryFeatureType))
return categoryFeatureType;
:
private static CategoryFeatureType GetParentCategoryTypeNeverExit(
DMS.ProductLocation productLocation,
DMS.ProductLocation[] productLocations,
Dictionary<string, CategoryFeatureType> categoryFeatureTypes,
int level)
{
Predicate<CategoryFeatureType> returnCheck = categoryFeatureType =>
{
return false;
};
return GetParentCategoryType(
productLocation,
productLocations,
categoryFeatureTypes,
level,
returnCheck);
}