summaryrefslogtreecommitdiff
path: root/FireBase/Offline/Internals/MemberAccessVisitor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'FireBase/Offline/Internals/MemberAccessVisitor.cs')
-rw-r--r--FireBase/Offline/Internals/MemberAccessVisitor.cs46
1 files changed, 0 insertions, 46 deletions
diff --git a/FireBase/Offline/Internals/MemberAccessVisitor.cs b/FireBase/Offline/Internals/MemberAccessVisitor.cs
deleted file mode 100644
index 89a77da..0000000
--- a/FireBase/Offline/Internals/MemberAccessVisitor.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System.Collections.Generic;
-using System.Linq.Expressions;
-using System.Reflection;
-using Newtonsoft.Json;
-
-namespace Firebase.Database.Offline.Internals
-{
- public class MemberAccessVisitor : ExpressionVisitor
- {
- private readonly IList<string> propertyNames = new List<string>();
-
- private bool wasDictionaryAccess;
-
- public IEnumerable<string> PropertyNames => propertyNames;
-
- public override Expression Visit(Expression expr)
- {
- if (expr?.NodeType == ExpressionType.MemberAccess)
- {
- if (wasDictionaryAccess)
- {
- wasDictionaryAccess = false;
- }
- else
- {
- var memberExpr = (MemberExpression) expr;
- var jsonAttr = memberExpr.Member.GetCustomAttribute<JsonPropertyAttribute>();
-
- propertyNames.Add(jsonAttr?.PropertyName ?? memberExpr.Member.Name);
- }
- }
- else if (expr?.NodeType == ExpressionType.Call)
- {
- var callExpr = (MethodCallExpression) expr;
- if (callExpr.Method.Name == "get_Item" && callExpr.Arguments.Count == 1)
- {
- var e = Expression.Lambda(callExpr.Arguments[0]).Compile();
- propertyNames.Add(e.DynamicInvoke().ToString());
- wasDictionaryAccess = callExpr.Arguments[0].NodeType == ExpressionType.MemberAccess;
- }
- }
-
- return base.Visit(expr);
- }
- }
-} \ No newline at end of file