Skip to content

Commit

Permalink
cleanup I
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornhoof committed Sep 24, 2017
1 parent ad783b8 commit 7662417
Show file tree
Hide file tree
Showing 32 changed files with 1,672 additions and 1,391 deletions.
18 changes: 12 additions & 6 deletions Benchmark/ExtensionMethods.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -96,16 +97,21 @@ public static bool TrueEqualsListDynamic<T>(this IEnumerable<T> a, IEnumerable<d
return false;
}

if (a.Count() != b.Count())
{
return false;
}

using (var e1 = a.GetEnumerator())
using (var e2 = b.GetEnumerator())
{
while (e1.MoveNext() && e2.MoveNext())
while (true)
{
var e1Next = e1.MoveNext();
var e2Next = e2.MoveNext();
if (e1Next != e2Next)
{
return false;
}
if (!e1Next && !e2Next)
{
break;
}
var c1 = e1.Current;
var c2 = e2.Current;

Expand Down
22 changes: 11 additions & 11 deletions Benchmark/Models/AccessToken.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
using ProtoBuf;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProtoBuf;

namespace Benchmark.Models
{
[ProtoContract]
class AccessToken : IGenericEquality<AccessToken>
internal class AccessToken : IGenericEquality<AccessToken>
{
[ProtoMember(1)]
public string access_token { get; set; }

[ProtoMember(2)]
public DateTime? expires_on_date { get; set; }

[ProtoMember(3)]
public int? account_id { get; set; }

[ProtoMember(4)]
public List<string> scope { get; set; }

Expand All @@ -31,10 +31,10 @@ public bool Equals(AccessToken obj)
public bool EqualsDynamic(dynamic obj)
{
return
access_token.TrueEqualsString((string)obj.access_token) ||
expires_on_date.TrueEquals((DateTime?)obj.expires_on_date) ||
account_id.TrueEquals((int?)obj.account_id) ||
scope.TrueEqualsString((IEnumerable<string>)obj.scope);
access_token.TrueEqualsString((string) obj.access_token) ||
expires_on_date.TrueEquals((DateTime?) obj.expires_on_date) ||
account_id.TrueEquals((int?) obj.account_id) ||
scope.TrueEqualsString((IEnumerable<string>) obj.scope);
}
}
}
}
20 changes: 9 additions & 11 deletions Benchmark/Models/AccountMerge.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
using ProtoBuf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using ProtoBuf;

namespace Benchmark.Models
{
[ProtoContract]
class AccountMerge : IGenericEquality<AccountMerge>
internal class AccountMerge : IGenericEquality<AccountMerge>
{
[ProtoMember(1)]
public int? old_account_id { get; set; }

[ProtoMember(2)]
public int? new_account_id { get; set; }

[ProtoMember(3)]
public DateTime? merge_date { get; set; }

Expand All @@ -28,9 +26,9 @@ public bool Equals(AccountMerge obj)
public bool EqualsDynamic(dynamic obj)
{
return
old_account_id.TrueEquals((int?)obj.old_account_id) &&
new_account_id.TrueEquals((int?)obj.new_account_id) &&
merge_date.TrueEquals((DateTime?)obj.merge_date);
old_account_id.TrueEquals((int?) obj.old_account_id) &&
new_account_id.TrueEquals((int?) obj.new_account_id) &&
merge_date.TrueEquals((DateTime?) obj.merge_date);
}
}
}
}
128 changes: 74 additions & 54 deletions Benchmark/Models/Answer.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using ProtoBuf;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProtoBuf;

namespace Benchmark.Models
{
Expand All @@ -12,109 +9,132 @@ public class Answer : IGenericEquality<Answer>
{
[ProtoMember(1)]
public int? question_id { get; set; }

[ProtoMember(2)]
public int? answer_id { get; set; }

[ProtoMember(3)]
public DateTime? locked_date { get; set; }

[ProtoMember(4)]
public DateTime? creation_date { get; set; }

[ProtoMember(5)]
public DateTime? last_edit_date { get; set; }

[ProtoMember(6)]
public DateTime? last_activity_date { get; set; }

[ProtoMember(7)]
public int? score { get; set; }

[ProtoMember(8)]
public DateTime? community_owned_date { get; set; }

[ProtoMember(9)]
public bool? is_accepted { get; set; }

[ProtoMember(10)]
public string body { get; set; }

[ProtoMember(11)]
public ShallowUser owner { get; set; }

[ProtoMember(12)]
public string title { get; set; }

[ProtoMember(13)]
public int? up_vote_count { get; set; }

[ProtoMember(14)]
public int? down_vote_count { get; set; }

[ProtoMember(15)]
public List<Comment> comments { get; set; }

[ProtoMember(16)]
public string link { get; set; }

[ProtoMember(17)]
public List<string> tags { get; set; }

[ProtoMember(18)]
public bool? upvoted { get; set; }

[ProtoMember(19)]
public bool? downvoted { get; set; }

[ProtoMember(20)]
public bool? accepted { get; set; }

[ProtoMember(21)]
public ShallowUser last_editor { get; set; }

[ProtoMember(22)]
public int? comment_count { get; set; }

[ProtoMember(23)]
public string body_markdown { get; set; }

[ProtoMember(24)]
public string share_link { get; set; }

public bool Equals(Answer obj)
{
return
this.accepted.TrueEquals(obj.accepted) &&
this.answer_id.TrueEquals(obj.answer_id) &&
this.body.TrueEqualsString(obj.body) &&
this.body_markdown.TrueEqualsString(obj.body_markdown) &&
this.comment_count.TrueEquals(obj.comment_count) &&
this.comments.TrueEqualsList(obj.comments) &&
this.community_owned_date.TrueEquals(obj.community_owned_date) &&
this.creation_date.TrueEquals(obj.creation_date) &&
this.down_vote_count.TrueEquals(obj.down_vote_count) &&
this.downvoted.TrueEquals(obj.downvoted) &&
this.is_accepted.TrueEquals(obj.is_accepted) &&
this.last_activity_date.TrueEquals(obj.last_activity_date) &&
this.last_edit_date.TrueEquals(obj.last_edit_date) &&
this.last_editor.TrueEquals(obj.last_editor) &&
this.link.TrueEqualsString(obj.link) &&
this.locked_date.TrueEquals(obj.locked_date) &&
this.owner.TrueEquals(obj.owner) &&
this.question_id.TrueEquals(obj.question_id) &&
this.score.TrueEquals(obj.score) &&
this.share_link.TrueEqualsString(obj.share_link) &&
this.tags.TrueEqualsString(obj.tags) &&
this.title.TrueEqualsString(obj.title) &&
this.up_vote_count.TrueEquals(obj.up_vote_count) &&
this.upvoted.TrueEquals(obj.upvoted);
accepted.TrueEquals(obj.accepted) &&
answer_id.TrueEquals(obj.answer_id) &&
body.TrueEqualsString(obj.body) &&
body_markdown.TrueEqualsString(obj.body_markdown) &&
comment_count.TrueEquals(obj.comment_count) &&
comments.TrueEqualsList(obj.comments) &&
community_owned_date.TrueEquals(obj.community_owned_date) &&
creation_date.TrueEquals(obj.creation_date) &&
down_vote_count.TrueEquals(obj.down_vote_count) &&
downvoted.TrueEquals(obj.downvoted) &&
is_accepted.TrueEquals(obj.is_accepted) &&
last_activity_date.TrueEquals(obj.last_activity_date) &&
last_edit_date.TrueEquals(obj.last_edit_date) &&
last_editor.TrueEquals(obj.last_editor) &&
link.TrueEqualsString(obj.link) &&
locked_date.TrueEquals(obj.locked_date) &&
owner.TrueEquals(obj.owner) &&
question_id.TrueEquals(obj.question_id) &&
score.TrueEquals(obj.score) &&
share_link.TrueEqualsString(obj.share_link) &&
tags.TrueEqualsString(obj.tags) &&
title.TrueEqualsString(obj.title) &&
up_vote_count.TrueEquals(obj.up_vote_count) &&
upvoted.TrueEquals(obj.upvoted);
}

public bool EqualsDynamic(dynamic obj)
{
return
this.accepted.TrueEquals((bool?)obj.accepted) &&
this.answer_id.TrueEquals((int?)obj.answer_id) &&
this.body.TrueEqualsString((string)obj.body) &&
this.body_markdown.TrueEqualsString((string)obj.body_markdown) &&
this.comment_count.TrueEquals((int?)obj.comment_count) &&
this.comments.TrueEqualsListDynamic((IEnumerable<dynamic>)obj.comments) &&
this.community_owned_date.TrueEquals((DateTime?)obj.community_owned_date) &&
this.creation_date.TrueEquals((DateTime?)obj.creation_date) &&
this.down_vote_count.TrueEquals((int?)obj.down_vote_count) &&
this.downvoted.TrueEquals((bool?)obj.downvoted) &&
this.is_accepted.TrueEquals((bool?)obj.is_accepted) &&
this.last_activity_date.TrueEquals((DateTime?)obj.last_activity_date) &&
this.last_edit_date.TrueEquals((DateTime?)obj.last_edit_date) &&
(this.last_editor == null && obj.last_editor == null || this.last_editor.EqualsDynamic(obj.last_editor)) &&
this.link.TrueEqualsString((string)obj.link) &&
this.locked_date.TrueEquals((DateTime?)obj.locked_date) &&
(this.owner == null && obj.owner == null || this.owner.EqualsDynamic(obj.owner)) &&
this.question_id.TrueEquals((int?)obj.question_id) &&
this.score.TrueEquals((int?)obj.score) &&
this.share_link.TrueEqualsString((string)obj.share_link) &&
this.tags.TrueEqualsString((IEnumerable<string>)obj.tags) &&
this.title.TrueEqualsString((string)obj.title) &&
this.up_vote_count.TrueEquals((int?)obj.up_vote_count) &&
this.upvoted.TrueEquals((bool?)obj.upvoted);
accepted.TrueEquals((bool?) obj.accepted) &&
answer_id.TrueEquals((int?) obj.answer_id) &&
body.TrueEqualsString((string) obj.body) &&
body_markdown.TrueEqualsString((string) obj.body_markdown) &&
comment_count.TrueEquals((int?) obj.comment_count) &&
comments.TrueEqualsListDynamic((IEnumerable<dynamic>) obj.comments) &&
community_owned_date.TrueEquals((DateTime?) obj.community_owned_date) &&
creation_date.TrueEquals((DateTime?) obj.creation_date) &&
down_vote_count.TrueEquals((int?) obj.down_vote_count) &&
downvoted.TrueEquals((bool?) obj.downvoted) &&
is_accepted.TrueEquals((bool?) obj.is_accepted) &&
last_activity_date.TrueEquals((DateTime?) obj.last_activity_date) &&
last_edit_date.TrueEquals((DateTime?) obj.last_edit_date) &&
(last_editor == null && obj.last_editor == null || last_editor.EqualsDynamic(obj.last_editor)) &&
link.TrueEqualsString((string) obj.link) &&
locked_date.TrueEquals((DateTime?) obj.locked_date) &&
(owner == null && obj.owner == null || owner.EqualsDynamic(obj.owner)) &&
question_id.TrueEquals((int?) obj.question_id) &&
score.TrueEquals((int?) obj.score) &&
share_link.TrueEqualsString((string) obj.share_link) &&
tags.TrueEqualsString((IEnumerable<string>) obj.tags) &&
title.TrueEqualsString((string) obj.title) &&
up_vote_count.TrueEquals((int?) obj.up_vote_count) &&
upvoted.TrueEquals((bool?) obj.upvoted);
}
}
}
}
Loading

0 comments on commit 7662417

Please sign in to comment.