Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
weeeBox committed Dec 20, 2016
1 parent cdf8035 commit ff58730
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace LunarEditor
{
class CConsoleFilteredDelegate : ConsoleViewCompositeFilter, ITableViewDataSource, ITableViewDelegate, ICConsoleDelegate
class CConsoleFilteredDelegate : CConsoleViewCompositeFilter, ITableViewDataSource, ITableViewDelegate, ICConsoleDelegate
{
private CConsoleView m_consoleView;

Expand Down Expand Up @@ -201,7 +201,7 @@ public bool SetFilterText(string filterText)
return false;
}

private bool ApplyFilter(IConsoleViewFilter filter)
private bool ApplyFilter(ICConsoleViewFilter filter)
{
int oldIndicesCount = m_filteredIndices.RealLength;
ClearIndices();
Expand All @@ -223,7 +223,7 @@ private bool ApplyFilter(IConsoleViewFilter filter)
m_filteredIndices.RealLength != Entries.RealLength;
}

private bool AppendFilter(IConsoleViewFilter filter)
private bool AppendFilter(ICConsoleViewFilter filter)
{
CConsoleViewCellEntry[] entriesArray = Entries.InternalArray;
int toIndex = m_filteredIndices.HeadIndex;
Expand Down Expand Up @@ -349,7 +349,7 @@ private CCycleArray<CConsoleViewCellEntry> Entries
#endregion
}

class CConsoleViewTextFilter : ConsoleViewFilterBase
class CConsoleViewTextFilter : CConsoleViewFilterBase
{
private string m_text;

Expand Down Expand Up @@ -378,7 +378,7 @@ public string Text
}
}

class CConsoleViewTagFilter : ConsoleViewFilterBase
class CConsoleViewTagFilter : CConsoleViewFilterBase
{
private HashSet<CTag> m_tags;

Expand Down Expand Up @@ -431,7 +431,7 @@ public bool HasTags
}
}

class CConsoleViewLogLevelFilter : ConsoleViewFilterBase
class CConsoleViewLogLevelFilter : CConsoleViewFilterBase
{
private CLogLevel m_level;

Expand Down
20 changes: 10 additions & 10 deletions Project/Assets/LunarPlugin/Editor/Console/ICConsoleViewFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@

namespace LunarEditor
{
interface IConsoleViewFilter
interface ICConsoleViewFilter
{
bool Apply(ref CConsoleViewCellEntry entry);
}

abstract class ConsoleViewFilterBase : IConsoleViewFilter
abstract class CConsoleViewFilterBase : ICConsoleViewFilter
{
private int m_priority;

public ConsoleViewFilterBase(int priority = int.MinValue)
public CConsoleViewFilterBase(int priority = int.MinValue)
{
m_priority = priority;
}
Expand All @@ -47,13 +47,13 @@ public int Priority
}
}

class ConsoleViewCompositeFilter : IConsoleViewFilter
class CConsoleViewCompositeFilter : ICConsoleViewFilter
{
private List<ConsoleViewFilterBase> m_filters;
private List<CConsoleViewFilterBase> m_filters;

public ConsoleViewCompositeFilter()
public CConsoleViewCompositeFilter()
{
m_filters = new List<ConsoleViewFilterBase>();
m_filters = new List<CConsoleViewFilterBase>();
}

#region IConsoleViewFilter implementation
Expand All @@ -75,7 +75,7 @@ public bool Apply(ref CConsoleViewCellEntry entry)

#region Filters

public void AddFilter(ConsoleViewFilterBase filter)
public void AddFilter(CConsoleViewFilterBase filter)
{
if (filter == null)
{
Expand All @@ -84,7 +84,7 @@ public void AddFilter(ConsoleViewFilterBase filter)

for (int i = 0; i < m_filters.Count; ++i)
{
ConsoleViewFilterBase f = m_filters[i];
CConsoleViewFilterBase f = m_filters[i];
if (f.Priority < filter.Priority)
{
m_filters.Insert(i, filter);
Expand All @@ -100,7 +100,7 @@ public void AddFilter(ConsoleViewFilterBase filter)
m_filters.Add(filter);
}

public void RemoveFilter(ConsoleViewFilterBase filter)
public void RemoveFilter(CConsoleViewFilterBase filter)
{
m_filters.Remove(filter);
}
Expand Down
26 changes: 13 additions & 13 deletions Test/Test/ConsoleViewTests/ConsoleViewTest.Filtering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ public void TestFilterPriority()
{
List<int> priorities = new List<int>();

ConsoleViewFilterBase filter1 = new TestFilter(1, delegate(ref CConsoleViewCellEntry e)
CConsoleViewFilterBase filter1 = new TestFilter(1, delegate(ref CConsoleViewCellEntry e)
{
priorities.Add(1);
return true;
});

ConsoleViewFilterBase filter2 = new TestFilter(2, delegate(ref CConsoleViewCellEntry e)
CConsoleViewFilterBase filter2 = new TestFilter(2, delegate(ref CConsoleViewCellEntry e)
{
priorities.Add(2);
return true;
});

ConsoleViewFilterBase filter3 = new TestFilter(3, delegate(ref CConsoleViewCellEntry e)
CConsoleViewFilterBase filter3 = new TestFilter(3, delegate(ref CConsoleViewCellEntry e)
{
priorities.Add(3);
return true;
});

ConsoleViewCompositeFilter compositeFilter = new ConsoleViewCompositeFilter();
CConsoleViewCompositeFilter compositeFilter = new CConsoleViewCompositeFilter();
compositeFilter.AddFilter(filter2);
compositeFilter.AddFilter(filter1);
compositeFilter.AddFilter(filter3);
Expand All @@ -59,25 +59,25 @@ public void TestCompositeFilterApply()
{
List<int> priorities = new List<int>();

ConsoleViewFilterBase filter1 = new TestFilter(1, delegate(ref CConsoleViewCellEntry e)
CConsoleViewFilterBase filter1 = new TestFilter(1, delegate(ref CConsoleViewCellEntry e)
{
priorities.Add(1);
return true;
});

ConsoleViewFilterBase filter2 = new TestFilter(2, delegate(ref CConsoleViewCellEntry e)
CConsoleViewFilterBase filter2 = new TestFilter(2, delegate(ref CConsoleViewCellEntry e)
{
priorities.Add(2);
return false;
});

ConsoleViewFilterBase filter3 = new TestFilter(3, delegate(ref CConsoleViewCellEntry e)
CConsoleViewFilterBase filter3 = new TestFilter(3, delegate(ref CConsoleViewCellEntry e)
{
priorities.Add(3);
return true;
});

ConsoleViewCompositeFilter compositeFilter = new ConsoleViewCompositeFilter();
CConsoleViewCompositeFilter compositeFilter = new CConsoleViewCompositeFilter();
compositeFilter.AddFilter(filter2);
compositeFilter.AddFilter(filter1);
compositeFilter.AddFilter(filter3);
Expand All @@ -96,25 +96,25 @@ public void TestCompositeFilterRemove()
{
List<int> priorities = new List<int>();

ConsoleViewFilterBase filter1 = new TestFilter(1, delegate(ref CConsoleViewCellEntry e)
CConsoleViewFilterBase filter1 = new TestFilter(1, delegate(ref CConsoleViewCellEntry e)
{
priorities.Add(1);
return true;
});

ConsoleViewFilterBase filter2 = new TestFilter(2, delegate(ref CConsoleViewCellEntry e)
CConsoleViewFilterBase filter2 = new TestFilter(2, delegate(ref CConsoleViewCellEntry e)
{
priorities.Add(2);
return true;
});

ConsoleViewFilterBase filter3 = new TestFilter(3, delegate(ref CConsoleViewCellEntry e)
CConsoleViewFilterBase filter3 = new TestFilter(3, delegate(ref CConsoleViewCellEntry e)
{
priorities.Add(3);
return true;
});

ConsoleViewCompositeFilter compositeFilter = new ConsoleViewCompositeFilter();
CConsoleViewCompositeFilter compositeFilter = new CConsoleViewCompositeFilter();
compositeFilter.AddFilter(filter1);
compositeFilter.AddFilter(filter2);
compositeFilter.AddFilter(filter3);
Expand Down Expand Up @@ -905,7 +905,7 @@ public void TestMixedFiltersTagLevelText()

delegate bool TestFilterDelegate(ref CConsoleViewCellEntry entry);

class TestFilter : ConsoleViewFilterBase
class TestFilter : CConsoleViewFilterBase
{
private TestFilterDelegate m_delegate;

Expand Down

0 comments on commit ff58730

Please sign in to comment.