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

Commit

Permalink
Change code styles
Browse files Browse the repository at this point in the history
  • Loading branch information
yck1509 committed Dec 23, 2014
1 parent e0d6051 commit 24a7fd8
Show file tree
Hide file tree
Showing 230 changed files with 858 additions and 1,720 deletions.
32 changes: 16 additions & 16 deletions Confuser.CLI/ObfAttrParser.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Confuser.Core;

namespace Confuser.CLI {
internal struct ObfAttrParser {
private System.Collections.IDictionary items;
IDictionary items;

private string str;
private int index;
string str;
int index;

public ObfAttrParser(System.Collections.IDictionary items) {
public ObfAttrParser(IDictionary items) {
this.items = items;
this.str = null;
this.index = -1;
str = null;
index = -1;
}

private enum ParseState {
enum ParseState {
Init,
ReadPreset,
ReadItemName,
Expand All @@ -27,7 +28,7 @@ private enum ParseState {
End
}

private bool ReadId(StringBuilder sb) {
bool ReadId(StringBuilder sb) {
while (index < str.Length) {
switch (str[index]) {
case '(':
Expand All @@ -46,21 +47,21 @@ private bool ReadId(StringBuilder sb) {
return false;
}

private void Expect(char chr) {
void Expect(char chr) {
if (str[index] != chr)
throw new ArgumentException("Expect '" + chr + "' at position " + (index + 1) + ".");
index++;
}

private char Peek() {
char Peek() {
return str[index];
}

private void Next() {
void Next() {
index++;
}

private bool IsEnd() {
bool IsEnd() {
return index == str.Length;
}

Expand All @@ -69,7 +70,7 @@ public void ParseProtectionString(ProtectionSettings settings, string str) {
return;

this.str = str;
this.index = 0;
index = 0;

var state = ParseState.Init;
var buffer = new StringBuilder();
Expand All @@ -80,7 +81,6 @@ public void ParseProtectionString(ProtectionSettings settings, string str) {

while (state != ParseState.End) {
switch (state) {

case ParseState.Init:
ReadId(buffer);
if (buffer.ToString().Equals("preset", StringComparison.OrdinalIgnoreCase)) {
Expand Down Expand Up @@ -211,7 +211,7 @@ public void ParsePackerString(string str, out Packer packer, out Dictionary<stri
return;

this.str = str;
this.index = 0;
index = 0;

var state = ParseState.ReadItemName;
var buffer = new StringBuilder();
Expand Down Expand Up @@ -278,4 +278,4 @@ public void ParsePackerString(string str, out Packer packer, out Dictionary<stri
}
}
}
}
}
37 changes: 18 additions & 19 deletions Confuser.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@

namespace Confuser.CLI {
internal class Program {

private static int Main(string[] args) {
static int Main(string[] args) {
ConsoleColor original = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.White;
string originalTitle = Console.Title;
Console.Title = "ConfuserEx";

bool noPause = false;
string outDir = null;
var p = new OptionSet() {
{ "n|nopause", "no pause after finishing protection.",
value => { noPause = (value != null); } },
{ "o|out=", "specifies output directory.",
value => { outDir = value; } },
var p = new OptionSet {
{
"n|nopause", "no pause after finishing protection.",
value => { noPause = (value != null); }
}, {
"o|out=", "specifies output directory.",
value => { outDir = value; }
}
};

List<string> files;
Expand Down Expand Up @@ -62,7 +64,7 @@ private static int Main(string[] args) {
// Assuming first file = main module
var proj = new ConfuserProject();
foreach (var input in files)
proj.Add(new ProjectModule() { Path = input });
proj.Add(new ProjectModule { Path = input });
proj.BaseDirectory = Path.GetDirectoryName(files[0]);
proj.OutputDirectory = outDir;
parameters.Project = proj;
Expand All @@ -84,7 +86,7 @@ private static int Main(string[] args) {
}
}

private static int RunProject(ConfuserParameters parameters) {
static int RunProject(ConfuserParameters parameters) {
var logger = new ConsoleLogger();
parameters.Logger = new ConsoleLogger();

Expand All @@ -94,36 +96,35 @@ private static int RunProject(ConfuserParameters parameters) {
return logger.ReturnValue;
}

private static bool NeedPause() {
static bool NeedPause() {
return Debugger.IsAttached || string.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROMPT"));
}

private static void PrintUsage() {
static void PrintUsage() {
WriteLine("Usage:");
WriteLine("Confuser.CLI -n|noPause <project configuration>");
WriteLine("Confuser.CLI -n|noPause -o|out=<output directory> <modules>");
WriteLine(" -n|noPause : no pause after finishing protection.");
WriteLine(" -o|out : specifies output directory.");
}

private static void WriteLineWithColor(ConsoleColor color, string txt) {
static void WriteLineWithColor(ConsoleColor color, string txt) {
ConsoleColor original = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(txt);
Console.ForegroundColor = original;
}

private static void WriteLine(string txt) {
static void WriteLine(string txt) {
Console.WriteLine(txt);
}

private static void WriteLine() {
static void WriteLine() {
Console.WriteLine();
}

private class ConsoleLogger : ILogger {

private readonly DateTime begin;
class ConsoleLogger : ILogger {
readonly DateTime begin;

public ConsoleLogger() {
begin = DateTime.Now;
Expand Down Expand Up @@ -195,8 +196,6 @@ public void Finish(bool successful) {
ReturnValue = 1;
}
}

}

}
}
14 changes: 4 additions & 10 deletions Confuser.Core/Annotations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace Confuser.Core {
/// The annotations are stored using <see cref="WeakReference" />
/// </remarks>
public class Annotations {

private readonly Dictionary<object, ListDictionary> annotations = new Dictionary<object, ListDictionary>(WeakReferenceComparer.Instance);
readonly Dictionary<object, ListDictionary> annotations = new Dictionary<object, ListDictionary>(WeakReferenceComparer.Instance);

/// <summary>
/// Retrieves the annotation on the specified object associated with the specified key.
Expand Down Expand Up @@ -136,8 +135,7 @@ public void Trim() {
/// <summary>
/// Equality comparer of weak references.
/// </summary>
private class WeakReferenceComparer : IEqualityComparer<object> {

class WeakReferenceComparer : IEqualityComparer<object> {
/// <summary>
/// The singleton instance of this comparer.
/// </summary>
Expand All @@ -146,7 +144,7 @@ private class WeakReferenceComparer : IEqualityComparer<object> {
/// <summary>
/// Prevents a default instance of the <see cref="WeakReferenceComparer" /> class from being created.
/// </summary>
private WeakReferenceComparer() { }
WeakReferenceComparer() { }

/// <inheritdoc />
public new bool Equals(object x, object y) {
Expand All @@ -172,14 +170,12 @@ public int GetHashCode(object obj) {
return ((WeakReferenceKey)obj).HashCode;
return obj.GetHashCode();
}

}

/// <summary>
/// Represent a key using <see cref="WeakReference" />.
/// </summary>
private class WeakReferenceKey : WeakReference {

class WeakReferenceKey : WeakReference {
/// <inheritdoc />
public WeakReferenceKey(object target)
: base(target) {
Expand All @@ -191,8 +187,6 @@ public WeakReferenceKey(object target)
/// </summary>
/// <value>The hash code.</value>
public int HashCode { get; private set; }

}

}
}
2 changes: 0 additions & 2 deletions Confuser.Core/ConfuserComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace Confuser.Core {
/// Represent a component in Confuser
/// </summary>
public abstract class ConfuserComponent {

/// <summary>
/// Gets the name of component.
/// </summary>
Expand Down Expand Up @@ -41,6 +40,5 @@ public abstract class ConfuserComponent {
/// </summary>
/// <param name="pipeline">The processing pipeline.</param>
protected internal abstract void PopulatePipeline(ProtectionPipeline pipeline);

}
}
6 changes: 2 additions & 4 deletions Confuser.Core/ConfuserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ namespace Confuser.Core {
/// Context providing information on the current protection process.
/// </summary>
public class ConfuserContext {

private readonly Annotations annotations = new Annotations();
private readonly ServiceRegistry registry = new ServiceRegistry();
readonly Annotations annotations = new Annotations();
readonly ServiceRegistry registry = new ServiceRegistry();
internal CancellationToken token;

/// <summary>
Expand Down Expand Up @@ -181,6 +180,5 @@ public NativeModuleWriterOptions RequestNative() {
CurrentModuleWriterOptions = newOptions;
return newOptions;
}

}
}
Loading

0 comments on commit 24a7fd8

Please sign in to comment.