Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Delete unnecessary abstraction from stubbed out SecurityElement (#27474)
Browse files Browse the repository at this point in the history
The stubbed out SecurityElement implementation does not support extensibility that ISecurityElementFactory was designed for.
  • Loading branch information
jkotas authored Oct 27, 2019
1 parent 34c5c62 commit b64c201
Showing 1 changed file with 1 addition and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@

namespace System.Security
{
internal interface ISecurityElementFactory
{
SecurityElement CreateSecurityElement();

object Copy();

string GetTag();

string? Attribute(string attributeName);
}

public sealed class SecurityElement : ISecurityElementFactory
public sealed class SecurityElement
{
internal string _tag = null!;
internal string? _text;
Expand Down Expand Up @@ -171,7 +160,6 @@ public ArrayList? Children
{
get
{
ConvertSecurityElementFactories();
return _children;
}

Expand All @@ -185,18 +173,6 @@ public ArrayList? Children
}
}

internal void ConvertSecurityElementFactories()
{
if (_children == null)
return;

for (int i = 0; i < _children.Count; ++i)
{
if (_children[i] is ISecurityElementFactory iseFactory && !(_children[i] is SecurityElement))
_children[i] = iseFactory.CreateSecurityElement();
}
}

//-------------------------- Public Methods -----------------------------

internal void AddAttributeSafe(string name, string value)
Expand Down Expand Up @@ -302,9 +278,6 @@ public bool Equal(SecurityElement? other)
if (_children.Count != other._children.Count)
return false;

ConvertSecurityElementFactories();
other.ConvertSecurityElementFactories();

IEnumerator lhs = _children.GetEnumerator();
IEnumerator rhs = other._children.GetEnumerator();

Expand Down Expand Up @@ -532,8 +505,6 @@ private void ToString(object obj, Action<object, string?> write)
// Output any children.
if (_children != null)
{
ConvertSecurityElementFactories();

write(obj, Environment.NewLineConst);

for (int i = 0; i < _children.Count; ++i)
Expand Down Expand Up @@ -631,27 +602,5 @@ private void ToString(object obj, Action<object, string?> write)

return default;
}

//--------------- ISecurityElementFactory implementation -----------------

SecurityElement ISecurityElementFactory.CreateSecurityElement()
{
return this;
}

string ISecurityElementFactory.GetTag()
{
return ((SecurityElement)this).Tag;
}

object ISecurityElementFactory.Copy()
{
return ((SecurityElement)this).Copy();
}

string? ISecurityElementFactory.Attribute(string attributeName)
{
return ((SecurityElement)this).Attribute(attributeName);
}
}
}

0 comments on commit b64c201

Please sign in to comment.