コード例 #1
0
 private SwitchCase GetKnownTypeSwitchCaseForRecursion(DeserializerTypeContext ctx, RecursionNode node)
 {
     //var
       return null;
 }
コード例 #2
0
        private SwitchCase ProcessNode(DeserializerTypeContext ctx, RecursionNode node)
        {
            var accessFunction = Expression.MakeMemberAccess(null, typeof(DeserializerStore<>)
            .MakeGenericType(node.Type).GetField("Function"));

              var invokeReturnValue = Expression.Invoke(accessFunction, ctx.IteratorVar, ctx.StringParam);

              var accessMember = Expression.MakeMemberAccess(ctx.InstanceVar, node.Member);

              var assignMember = Expression.Assign(accessMember, invokeReturnValue);
              var bodyExpressions = new List<Expression>();

              bodyExpressions.Add(assignMember);
              bodyExpressions.Add(Expression.Empty());

              var body = Expression.Block(bodyExpressions);

              var @case = Expression.SwitchCase(body, GetSwitchConstant(ctx, node));

              return @case;
        }
コード例 #3
0
ファイル: TreeBuilder.cs プロジェクト: JulianR/Marlee
        private Node GetDeserializationNode(PropertyOrFieldInfo member)
        {
            Func<PropertyOrFieldInfo, Node> nodeFunc;

              if (!_deserializers.TryGetValue(member.PropertyOrFieldType, out nodeFunc))
              {
            var key = _deserializers.Keys.FirstOrDefault(k => k.IsAssignableFrom(member.PropertyOrFieldType));

            if (key != null)
            {
              nodeFunc = _deserializers[key];
            }
            else
            {
              key = _deserializers.Keys.FirstOrDefault(k => member.PropertyOrFieldType.IsAssignableFrom(k));

              if (key != null)
              {
            nodeFunc = _deserializers[key];
              }

            }

              }

              Node node;

              if (nodeFunc != null)
              {
            node = nodeFunc(member);
              }
              else if (_recursionStack.Contains(member.PropertyOrFieldType))
              {
            node = new RecursionNode
            {
              Type = member.PropertyOrFieldType,
              Member = member
            };
              }
              else
              {
            var customNode = new UnknownTypeNode
            {
              Type = member.PropertyOrFieldType,
              Member = member,
              Children = new List<Node>()
            };

            var members = GetMembers(member.PropertyOrFieldType);

            foreach (var childMember in members)
            {
              var childNode = GetDeserializationNode(childMember);
              customNode.Children.Add(childNode);
            }

            node = customNode;

              }

              return node;
        }