Removes ITree!

This commit is contained in:
Shannon
2016-03-17 15:48:43 +01:00
parent 1a880f6b68
commit c0f8532350
7 changed files with 14 additions and 92 deletions

View File

@@ -8,6 +8,7 @@ using Umbraco.Web.Routing;
using Umbraco.Web.Trees;
using Umbraco.Web.WebApi;
using umbraco;
using umbraco.cms.presentation.Trees;
using umbraco.interfaces;
using Umbraco.Web.Models.Trees;
using Umbraco.Web._Legacy.Actions;
@@ -54,7 +55,7 @@ namespace Umbraco.Web
/// <returns></returns>
internal static IEnumerable<Type> ResolveTrees(this PluginManager resolver)
{
return resolver.ResolveTypes<ITree>();
return resolver.ResolveTypes<BaseTree>();
}

View File

@@ -19,7 +19,7 @@ namespace umbraco.cms.presentation.Trees
/// <summary>
/// All ITree's should inherit from BaseTree.
/// </summary>
public abstract class BaseTree : ITree, ITreeService //, IApplicationEventHandler
public abstract class BaseTree : ITreeService //, IApplicationEventHandler
{
public BaseTree(string application)
@@ -417,50 +417,7 @@ namespace umbraco.cms.presentation.Trees
this.Render(ref xTree);
return xTree.ToString();
}
/// <summary>
/// Returns a boolean value indicating if the ITree passed in is an extension of BaseTree.
/// This is used to preserve backwards compatibility previous to version 5.
/// </summary>
/// <param name="tree"></param>
/// <returns></returns>
public static bool IsBaseTree(ITree tree)
{
return tree is BaseTree;
}
/// <summary>
/// Converts an ITree into a BaseTree. This is used for Legacy trees that don't inherit from BaseTree already.
/// </summary>
/// <param name="tree"></param>
/// <param name="alias"></param>
/// <param name="appAlias"></param>
/// <param name="iconClosed"></param>
/// <param name="iconOpened"></param>
/// <param name="action"></param>
/// <returns></returns>
public static BaseTree FromITree(ITree tree, string alias, string appAlias, string iconClosed, string iconOpened, string action)
{
TreeService treeSvc = new TreeService(null, alias, null, null, TreeDialogModes.none, appAlias);
//create the generic XmlTreeNode and fill it with the properties from the db
NullTree nullTree = new NullTree(appAlias);
XmlTreeNode node = XmlTreeNode.CreateRoot(nullTree);
node.Text = BaseTree.GetTreeHeader(alias);;
node.Action = action;
node.Source = treeSvc.GetServiceUrl();
node.Icon = iconClosed;
node.OpenIcon = iconOpened;
node.NodeType = "init" + alias;
node.NodeType = alias;
node.NodeID = "init";
node.Menu = BaseTree.GetDefaultRootNodeActions();
//convert the tree to a LegacyTree
LegacyTree bTree = new LegacyTree(tree, appAlias, node);
return bTree;
}
}
/// <summary>
/// Returns the default actions for a root node

View File

@@ -11,7 +11,7 @@ namespace umbraco.cms.presentation.Trees
public class LegacyTree : BaseTree
{
public LegacyTree(ITree tree, string application, XmlTreeNode rootNode)
public LegacyTree(BaseTree tree, string application, XmlTreeNode rootNode)
: base(application)
{
_tree = tree;
@@ -21,7 +21,7 @@ namespace umbraco.cms.presentation.Trees
Initialize();
}
private ITree _tree;
private BaseTree _tree;
private XmlTreeNode _rootNode;
public void SetRootNode(XmlTreeNode rootNode)

View File

@@ -49,7 +49,7 @@ namespace umbraco.cms.presentation.Trees
if (typeInstance != null)
{
//convert to BaseTree
return (BaseTree.IsBaseTree(typeInstance) ? typeInstance as BaseTree : BaseTree.FromITree(typeInstance, m_tree.Alias, m_app.Alias, m_tree.IconClosed, m_tree.IconOpened, null));
return typeInstance;
}
return null;
}
@@ -90,20 +90,20 @@ namespace umbraco.cms.presentation.Trees
/// <param name="tree">The tree.</param>
/// <param name="appAlias">The app alias.</param>
/// <returns></returns>
public static ITree CreateTreeInstance(Type tree, string appAlias)
public static BaseTree CreateTreeInstance(Type tree, string appAlias)
{
ITree typeInstance;
BaseTree typeInstance;
//call the correct constructor
if (typeof(BaseTree).IsAssignableFrom(tree))
typeInstance = Activator.CreateInstance(tree, new object[] { appAlias }) as ITree; //the BaseTree constructor
typeInstance = Activator.CreateInstance(tree, new object[] { appAlias }) as BaseTree; //the BaseTree constructor
else
typeInstance = CreateTreeInstance(tree);
return typeInstance;
}
private static ITree CreateTreeInstance(Type tree)
private static BaseTree CreateTreeInstance(Type tree)
{
ITree typeInstance = Activator.CreateInstance(tree) as ITree; //an empty constructor (ITree)
BaseTree typeInstance = Activator.CreateInstance(tree) as BaseTree; //an empty constructor (ITree)
return typeInstance;
}

View File

@@ -33,7 +33,7 @@ namespace umbraco.cms.presentation.Trees
/// </summary>
/// <param name="tree"></param>
/// <returns></returns>
public TreeDefinition FindTree(ITree tree)
public TreeDefinition FindTree(BaseTree tree)
{
EnsureTreesRegistered();
@@ -51,7 +51,7 @@ namespace umbraco.cms.presentation.Trees
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public TreeDefinition FindTree<T>() where T : ITree
public TreeDefinition FindTree<T>() where T : BaseTree
{
EnsureTreesRegistered();

View File

@@ -1,33 +0,0 @@
using System;
using System.Xml;
namespace umbraco.interfaces
{
/// <summary>
/// Interface for created application trees in the umbraco backoffice
/// </summary>
[Obsolete("Get rid of this!!")]
public interface ITree
{
/// <summary>
/// Sets the tree id.
/// </summary>
/// <value>The id.</value>
int id{set;}
/// <summary>
/// Sets the applicatin alias.
/// </summary>
/// <value>The app.</value>
String app {set;}
/// <summary>
/// Renders the specified tree.
/// </summary>
/// <param name="Tree">The tree.</param>
void Render(ref XmlDocument Tree);
/// <summary>
/// Renders the client side script associatied with the tree.
/// </summary>
/// <param name="Javascript">The javascript.</param>
void RenderJS(ref System.Text.StringBuilder Javascript);
}
}

View File

@@ -131,9 +131,6 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="IPackageAction.cs" />
<Compile Include="ITree.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">