using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
namespace ScrewTurn.Wiki.PluginFramework {
///
/// Represents a Page Category. A page can be binded with one or more categories (within the same Provider); this class manages this binding.
///
public class CategoryInfo {
///
/// The namespace of the Category.
///
protected string nspace;
///
/// The Name of the Category.
///
protected string name;
///
/// The Provider that handles the Category.
///
protected IPagesStorageProviderV30 provider;
///
/// The Pages of the Category.
///
protected string[] pages = new string[0];
///
/// Initializes a new instance of the class.
///
/// The Full Name of the Category.
/// The Storage that manages the category.
public CategoryInfo(string fullName, IPagesStorageProviderV30 provider) {
NameTools.ExpandFullName(fullName, out nspace, out name);
this.provider = provider;
}
///
/// Gets or sets the full name of the Category, such as 'Namespace.Category' or 'Category'.
///
public string FullName {
get { return NameTools.GetFullName(nspace, name); }
set { NameTools.ExpandFullName(value, out nspace, out name); }
}
///
/// Gets or sets the Provider that manages the Category.
///
public IPagesStorageProviderV30 Provider {
get { return provider; }
set { provider = value; }
}
///
/// Gets or sets the Page array, containing their names.
///
public string[] Pages {
get { return pages; }
set { pages = value; }
}
///
/// Gets a string representation of the current object.
///
/// The string representation.
public override string ToString() {
return NameTools.GetFullName(nspace, name);
}
}
///
/// Compares two CategoryInfo objects, using the FullName as parameter.
///
/// The comparison is case insensitive.
public class CategoryNameComparer : IComparer {
///
/// Compares two objects, using the FullName as parameter.
///
/// The first object.
/// The second object.
/// The comparison result (-1, 0 or 1).
public int Compare(CategoryInfo x, CategoryInfo y) {
return StringComparer.OrdinalIgnoreCase.Compare(x.FullName, y.FullName);
}
}
}