Browse Source

Removed INameScope.

No point having it in there if it's not used.
pull/63/head
Steven Kirk 11 years ago
parent
commit
92c4f502a2
  1. 57
      Perspex.Controls/Control.cs
  2. 40
      Perspex.Controls/INameScope.cs
  3. 1
      Perspex.Controls/Perspex.Controls.csproj

57
Perspex.Controls/Control.cs

@ -321,39 +321,6 @@ namespace Perspex.Controls
}
this.SetValue(ParentProperty, parent);
if (parent != null)
{
var nameScope = parent.GetSelfAndLogicalAncestors()
.OfType<INameScope>()
.FirstOrDefault();
if (nameScope != null)
{
this.RegisterName(nameScope);
foreach (var descendent in this.GetLogicalDescendents().OfType<Control>())
{
descendent.RegisterName(nameScope);
}
}
}
else if (old != null)
{
var nameScope = old.GetSelfAndLogicalAncestors()
.OfType<INameScope>()
.FirstOrDefault();
if (nameScope != null)
{
this.UnregisterName(nameScope);
foreach (var descendent in this.GetLogicalDescendents().OfType<Control>())
{
descendent.UnregisterName(nameScope);
}
}
}
}
[Obsolete("Obsolete this: use properties instead")]
@ -443,29 +410,5 @@ namespace Perspex.Controls
IStyler styler = Locator.Current.GetService<IStyler>();
styler.ApplyStyles(this);
}
/// <summary>
/// Registers the control with the specified name scope.
/// </summary>
/// <param name="nameScope">The name scope.</param>
private void RegisterName(INameScope nameScope)
{
if (!string.IsNullOrWhiteSpace(this.Name))
{
nameScope.RegisterName(this.Name, this);
}
}
/// <summary>
/// Unregisters the control with the specified name scope.
/// </summary>
/// <param name="nameScope">The name scope.</param>
private void UnregisterName(INameScope nameScope)
{
if (!string.IsNullOrWhiteSpace(this.Name))
{
nameScope.UnregisterName(this.Name);
}
}
}
}

40
Perspex.Controls/INameScope.cs

@ -1,40 +0,0 @@
// -----------------------------------------------------------------------
// <copyright file="INameScope.cs" company="Steven Kirk">
// Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Controls
{
/// <summary>
/// Defines the interface for object which define a name scope.
/// </summary>
public interface INameScope
{
/// <summary>
/// Returns an object tha thas the requested name.
/// </summary>
/// <param name="name">The name of the object.</param>
/// <returns>The named object or null if the named object was not found.</returns>
object FindName(string name);
/// <summary>
/// Registers an object with the specified name in the name scope.
/// </summary>
/// <param name="name">The name of the object.</param>
/// <param name="o">The object.</param>
/// <exception cref="ArgumentException">
/// An object with the same name has already been registered.
/// </exception>
void RegisterName(string name, object o);
/// <summary>
/// Unregisters the specified name in the name scope.
/// </summary>
/// <param name="name">The name of the object.</param>
/// <exception cref="ArgumentException">
/// The name does not exist in the name scope.
/// </exception>
void UnregisterName(string name);
}
}

1
Perspex.Controls/Perspex.Controls.csproj

@ -37,7 +37,6 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="IControl.cs" />
<Compile Include="INameScope.cs" />
<Compile Include="ISetLogicalParent.cs" />
<Compile Include="MenuItemAccessKeyHandler.cs" />
<Compile Include="Parsers\GridLengthsParser.cs" />

Loading…
Cancel
Save