Core.Xml - import NavigableNavigator initial version

This commit is contained in:
Stephan
2013-06-11 01:36:06 +02:00
parent 9d243c6c46
commit 1ddf2fa365
8 changed files with 2313 additions and 0 deletions

View File

@@ -805,6 +805,11 @@
<Compile Include="WriteLock.cs" />
<Compile Include="XmlExtensions.cs" />
<Compile Include="XmlHelper.cs" />
<Compile Include="Xml\XPath\INavigableContentType.cs" />
<Compile Include="Xml\XPath\NavigableNavigator.cs" />
<Compile Include="Xml\XPath\INavigableContent.cs" />
<Compile Include="Xml\XPath\INavigableFieldType.cs" />
<Compile Include="Xml\XPath\INavigableSource.cs" />
<Compile Include="Xml\DynamicContext.cs" />
<Compile Include="Xml\XmlNamespaces.cs" />
<Compile Include="Xml\XmlNodeListFactory.cs" />

View File

@@ -0,0 +1,59 @@
using System.Collections.Generic;
namespace Umbraco.Core.Xml.XPath
{
/// <summary>
/// Represents a content that can be navigated via XPath.
/// </summary>
interface INavigableContent
{
/// <summary>
/// Gets the unique identifier of the navigable content.
/// </summary>
/// <remarks>The root node identifier should be <c>-1</c>.</remarks>
int Id { get; }
/// <summary>
/// Gets the unique identifier of parent of the navigable content.
/// </summary>
/// <remarks>The top-level content parent identifiers should be <c>-1</c> ie the identifier
/// of the root node, whose parent identifier should in turn be <c>-1</c>.</remarks>
int ParentId { get; }
/// <summary>
/// Gets the type of the navigable content.
/// </summary>
INavigableContentType Type { get; }
/// <summary>
/// Gets the unique identifiers of the children of the navigable content.
/// </summary>
IList<int> ChildIds { get; }
/// <summary>
/// Gets the value of a field of the navigable content for XPath navigation use.
/// </summary>
/// <param name="index">The field index.</param>
/// <returns>The value of the field for XPath navigation use.</returns>
/// <remarks>
/// <para>Fields are attributes or elements depending on their relative index value compared
/// to source.LastAttributeIndex.</para>
/// <para>For attributes, the value must be a string.</para>
/// <para>For elements, the value should an <c>XPathNavigator</c> instance if the field is xml
/// and has content (is not empty), <c>null</c> to indicate that the element is empty, or a string
/// which can be empty, whitespace... depending on what the data type wants to expose.</para>
/// </remarks>
object Value(int index);
// TODO implement the following one
///// <summary>
///// Gets the value of a field of the navigable content, for a specified language.
///// </summary>
///// <param name="index">The field index.</param>
///// <param name="languageKey">The language key.</param>
///// <returns>The value of the field for the specified language.</returns>
///// <remarks>...</remarks>
//object Value(int index, string languageKey);
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Umbraco.Core.Xml.XPath
{
/// <summary>
/// Represents the type of a content that can be navigated via XPath.
/// </summary>
interface INavigableContentType
{
/// <summary>
/// Gets the name of the content type.
/// </summary>
string Name { get; }
/// <summary>
/// Gets the field types of the content type.
/// </summary>
/// <remarks>This includes the attributes and the properties.</remarks>
INavigableFieldType[] FieldTypes { get; }
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Umbraco.Core.Xml.XPath
{
/// <summary>
/// Represents the type of a field of a content that can be navigated via XPath.
/// </summary>
/// <remarks>A field can be an attribute or a property.</remarks>
interface INavigableFieldType
{
/// <summary>
/// Gets the name of the field type.
/// </summary>
string Name { get; }
/// <summary>
/// Gets a method to convert the field value to a string.
/// </summary>
/// <remarks>This is for built-in properties, ie attributes. User-defined properties have their
/// own way to convert their value for XPath.</remarks>
Func<object, string> XmlStringConverter { get; }
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Umbraco.Core.Xml.XPath
{
/// <summary>
/// Represents a source of content that can be navigated via XPath.
/// </summary>
interface INavigableSource
{
/// <summary>
/// Gets a content identified by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier.</param>
/// <returns>The content identified by the unique identifier, or null.</returns>
/// <remarks>When <c>id</c> is <c>-1</c> (root content) implementations should return <c>null</c>.</remarks>
INavigableContent Get(int id);
/// <summary>
/// Gets the index of the last attribute in the fields collections.
/// </summary>
int LastAttributeIndex { get; }
/// <summary>
/// Gets the content at the root of the source.
/// </summary>
/// <remarks>That content should have unique identifier <c>-1</c> and should not be gettable,
/// ie Get(-1) should return null. Its <c>ParentId</c> should be <c>-1</c>. It should provide
/// values for the attribute fields.</remarks>
INavigableContent Root { get; }
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -206,6 +206,7 @@
<Compile Include="Services\UserServiceTests.cs" />
<Compile Include="TestHelpers\BaseSeleniumTest.cs" />
<Compile Include="Integration\InstallPackage.cs" />
<Compile Include="CoreXml\NavigableNavigatorTests.cs" />
<Compile Include="PublishedCache\PublishedMediaCacheTests.cs" />
<Compile Include="CoreStrings\CmsHelperCasingTests.cs" />
<Compile Include="CoreStrings\ShortStringHelperResolverTest.cs" />