public static List <byte[]> GetDataArrayValueFromPList(PNode rootNode, string key)
 {
     if (rootNode is DictionaryNode)
     {
         PNode value;
         if (((DictionaryNode)rootNode).TryGetValue(key, out value))
         {
             if (value is ArrayNode)
             {
                 ArrayNode     array  = (ArrayNode)value;
                 List <byte[]> result = new List <byte[]>();
                 foreach (PNode node in array)
                 {
                     DataNode dataNode = node as DataNode;
                     if (dataNode != null)
                     {
                         result.Add(dataNode.Value);
                     }
                 }
                 return(result);
             }
         }
     }
     return(null);
 }
Exemple #2
0
        //ARRAYS//
        public string Visit(ArrayNode node)
        {
            int       counterone = 0;
            var       sb         = new StringBuilder();
            ArrayList theInts    = new ArrayList();

            foreach (var n in node)
            {
                theInts.Add(Visit((dynamic)n));
            }

            foreach (var x in theInts)
            {
                counterone++;
            }

            sb.Append("\t\tldc.i4 " + 0 + "\n");
            sb.Append(String.Format("\t\tcall int32 class ['deeplingolib']'DeepLingo'.'Utils'::'New'(int32)\n\n"));
            for (int i = 0; i < counterone; i++)
            {
                sb.Append("\t\tdup\n");
            }
            foreach (var x in theInts)
            {
                sb.Append(x);
                sb.Append(String.Format("\t\tcall int32 class ['deeplingolib']'DeepLingo'.'Utils'::'Add'(int32,int32)\n\n"));
                sb.Append("\t\tpop\n");
            }

            return(sb.ToString());
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHavePredefinedRoles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHavePredefinedRoles()
        {
            // Given
            StartServerWithConfiguredUser();

            // When
            string method = "POST";
            string path   = "db/data/transaction/commit";

            HTTP.RawPayload payload  = HTTP.RawPayload.quotedJson("{'statements':[{'statement':'CALL dbms.security.listRoles()'}]}");
            HTTP.Response   response = HTTP.withBasicAuth("neo4j", "secret").request(method, Server.baseUri().resolve(path).ToString(), payload);

            // Then
            assertThat(response.Status(), equalTo(200));
            ArrayNode errors = ( ArrayNode )response.Get("errors");

            assertThat("Should have no errors", errors.size(), equalTo(0));
            ArrayNode results = ( ArrayNode )response.Get("results");
            ArrayNode data    = ( ArrayNode )results.get(0).get("data");

            assertThat("Should have 5 predefined roles", data.size(), equalTo(5));
            Stream <string> values = data.findValues("row").Select(row => row.get(0).asText());

            assertThat("Expected specific roles", values.collect(Collectors.toList()), hasItems("admin", "architect", "publisher", "editor", "reader"));
        }
Exemple #4
0
        public override void VisitArrayNode(ArrayNode node)
        {
            node.Type.Visit(this);

            var initializer = InitializerExpression(SyntaxKind.ArrayInitializerExpression);

            foreach (var element in node.Elements)
            {
                element.Expression.Visit(this);
                initializer = initializer.AddExpressions(expressions.Pop());
            }

            var arrayType     = ArrayType(expressions.Pop() as TypeSyntax);
            var rankSpecifier = ArrayRankSpecifier().AddSizes(OmittedArraySizeExpression());
            var array         = ArrayCreationExpression(arrayType)
                                .AddTypeRankSpecifiers(rankSpecifier)
                                .WithInitializer(initializer);

            var libraryArray = ObjectCreationExpression(
                GenericName("Array").AddTypeArgumentListArguments(arrayType)
                ).AddArgumentListArguments(Argument(array));


            libraryArray = GetNodeWithAnnotation(libraryArray, node.Location) as ObjectCreationExpressionSyntax;
            expressions.Push(libraryArray);
        }
        //check if it is array type
        public override void Visit(ArrayNode node)
        {
            base.Visit(node);
            var typeOfArray = node.VariableType;

            if (typeOfArray == null)
            {
                throw new TypeCheckException("No set Type for Array.");
            }
            if (!(typeOfArray is ArrayTypeNode))
            {
                throw new TypeCheckException("Array doesn't have array type");
            }
            var typeOfElementInArray = ((ArrayTypeNode)typeOfArray).ElementType;

            if (typeOfElementInArray == null)
            {
                throw new TypeCheckException("Type of element in array is not set.");
            }
            foreach (var expression in node.Elements)
            {
                if (expression.ExpressionType == null)
                {
                    throw new TypeCheckException("Array contains value with not specified type.");
                }
                if (!typeOfElementInArray.Equals(expression.ExpressionType))
                {
                    throw new TypeCheckException("Improper Type of element in array.");
                }
            }
            node.ExpressionType = node.VariableType;
        }
        public void Equals_returns_true_for_instances_with_null_and_empty_children()
        {
            var sets1 = new ArrayNode("Name", null);
            var sets2 = new ArrayNode("Name", new ISettingsNode[0]);

            Equals(sets1, sets2).Should().BeTrue();
        }
Exemple #7
0
            internal UnboundedBufferManager(int capacityHint)
            {
                var n = new ArrayNode(capacityHint);

                this.tail = n;
                this.head = n;
            }
Exemple #8
0
        public static TSource SingleOrDefault <TSource>(this TSource[] source, Func <TSource, bool> predicate)
        {
            var aggregate = new SingleOrDefaultPredicate <TSource>(predicate);

            ArrayNode.ProcessArray(source, ref aggregate);
            return(aggregate.GetResult());
        }
Exemple #9
0
        public static System.Linq.ILookup <TKey, TElement> ToLookup <TSource, TKey, TElement>(this TSource[] source, Func <TSource, TKey> keySelector, Func <TSource, TElement> elementSelector, IEqualityComparer <TKey> comparer = null)
        {
            var aggregate = new ToLookup <TSource, TKey, TElement>(comparer, keySelector, elementSelector);

            ArrayNode.ProcessArray(source, ref aggregate);
            return(aggregate.GetResult());
        }
Exemple #10
0
        public static bool Contains <TSource>(this TSource[] source, TSource value, IEqualityComparer <TSource> comparer)
        {
            var aggregate = new ContainsByComparer <TSource>(comparer, value);

            ArrayNode.ProcessArray(source, ref aggregate);
            return(aggregate.GetResult());
        }
Exemple #11
0
        public static TSource Single <TSource>(this TSource[] source)
        {
            var aggregate = new Single <TSource>();

            ArrayNode.ProcessArray(source, ref aggregate);
            return(aggregate.GetResult());
        }
Exemple #12
0
        public static int Count <TSource>(this TSource[] source, Func <TSource, bool> predicate)
        {
            var aggregate = new CountIf <TSource>(predicate);

            ArrayNode.ProcessArray(source, ref aggregate);
            return(aggregate.GetResult());
        }
Exemple #13
0
        public static bool All <TSource>(this TSource[] source, Func <TSource, bool> predicate)
        {
            var aggregate = new All <TSource, FuncToIFunc <TSource, bool> >(new FuncToIFunc <TSource, bool>(predicate));

            ArrayNode.ProcessArray(source, ref aggregate);
            return(aggregate.GetResult());
        }
Exemple #14
0
        public static TResult Aggregate <TSource, TAccumulate, TResult>(this TSource[] source, TAccumulate seed, Func <TAccumulate, TSource, TAccumulate> func, Func <TAccumulate, TResult> resultSelector)
        {
            var aggregate = new FoldForward <TSource, TAccumulate>(func, seed);

            ArrayNode.ProcessArray(source, ref aggregate);
            return(resultSelector(aggregate.GetResult()));
        }
Exemple #15
0
 public static List <string> GetStringArrayValueFromPList(PNode rootNode, string key)
 {
     if (rootNode is DictionaryNode)
     {
         PNode value;
         if (((DictionaryNode)rootNode).TryGetValue(key, out value))
         {
             if (value is ArrayNode)
             {
                 ArrayNode     array  = (ArrayNode)value;
                 List <string> result = new List <string>();
                 foreach (PNode node in array)
                 {
                     StringNode stringNode = node as StringNode;
                     if (stringNode != null)
                     {
                         result.Add(stringNode.Value);
                     }
                 }
                 return(result);
             }
         }
     }
     return(null);
 }
Exemple #16
0
        public static Dictionary <TKey, TSource> ToDictionary <TSource, TKey>(this TSource[] source, Func <TSource, TKey> keySelector, IEqualityComparer <TKey> comparer = null)
        {
            var aggregate = new ToDictionary <TSource, TKey>(keySelector, comparer);

            ArrayNode.ProcessArray(source, ref aggregate);
            return(aggregate.GetResult());
        }
Exemple #17
0
        public static TSource Aggregate <TSource>(this TSource[] source, Func <TSource, TSource, TSource> func)
        {
            var aggregate = new ReduceForward <TSource>(func);

            ArrayNode.ProcessArray(source, ref aggregate);
            return(aggregate.GetResult());
        }
Exemple #18
0
        protected override PropertyEditor AutoCreateMemberEditor(MemberInfo info)
        {
            if (ReflectionHelper.MemberInfoEquals(info, typeof(ArrayNode).GetProperty("PrimitiveData")))
            {
                ArrayNode arrayNode  = this.GetValue().NotNull().FirstOrDefault() as ArrayNode;
                Type      actualType = ReflectionHelper.ResolveType(arrayNode.TypeString);
                if (actualType == null || !actualType.IsArray || actualType.GetElementType() == null)
                {
                    actualType = (info as PropertyInfo).PropertyType;
                }

                bool primitiveDataEditable = actualType != null && actualType.IsArray && (actualType.GetElementType().IsPrimitive || actualType.GetElementType() == typeof(string));

                this.editorPrimitiveData = this.ParentGrid.CreateEditor(actualType, this);
                if (!primitiveDataEditable)
                {
                    this.editorPrimitiveData.Setter = null;
                }
                return(this.editorPrimitiveData);
            }
            else
            {
                return(base.AutoCreateMemberEditor(info));
            }
        }
Exemple #19
0
        public override String ToString()
        {
            StringBuilder str = new StringBuilder().Append('{');
            int           size = list.Size(), i = 0;

            ArrayNode <Object> o = this.list.Node().next;

            for (; o != this.list.Node();)
            {
                if (o.data is String)
                {
                    str.Append('"').Append(o.data).Append('"');
                }
                else
                {
                    str.Append(o.data);
                }
                if (++i < size)
                {
                    str.Append(',');
                }
                o = o.next;
            }
            str.Append('}');

            return(str.ToString());
        }
Exemple #20
0
            /// <inheritdoc/>
            public override (Node Head, Node Tail) Insert(Int32 index, Char[] element)
            {
                Node head;
                Node tail;

                if (index == 0)
                {
                    tail          = this;
                    head          = new ArrayNode(element, previous: null, next: tail);
                    tail.Previous = head;
                }
                else if (index == Count)
                {
                    head      = this;
                    tail      = new ArrayNode(element, previous: head, next: null);
                    head.Next = tail;
                }
                else
                {
                    head = Slice(0, index);
                    tail = Slice(index, Count - index);
                    Node mid = new ArrayNode(element, previous: head, next: tail);
                    head.Next     = mid;
                    tail.Previous = mid;
                }
                return(head, tail);
            }
Exemple #21
0
        public static HashSet <TSource> ToHashSet <TSource>(this TSource[] source, IEqualityComparer <TSource> comparer = null)
        {
            var aggregate = new ToHashSet <TSource>(comparer);

            ArrayNode.ProcessArray(source, ref aggregate);
            return(aggregate.GetResult());
        }
        public ArrayList GetArrayList(ArrayNode arrayNode)
        {
            ArrayList arrayList = new ArrayList();

            foreach (var item in arrayNode.Values)
            {
                if (item is ListKeyValueNode)
                {
                    // has key, value
                    var listKeyvalueNodeParser = new ListKeyValueNodeParser();
                    var listKeyvalueNode       = listKeyvalueNodeParser.GetDictionary(item as ListKeyValueNode);
                    arrayList.Add(listKeyvalueNode);
                }
                else if (item is ArrayNode)
                {
                    var arrayNodeParser = new ArrayNodeParser();
                    var innerArrayList  = arrayNodeParser.GetArrayList(item as ArrayNode);
                    arrayList.Add(innerArrayList);
                }
                else if (item is ValueNode)
                {
                    var ValueNodeParser = new ValueNodeParser();
                    var value           = ValueNodeParser.GetDictionaryValue(item as ValueNode);
                    arrayList.Add(value);
                }
                else
                {
                    throw new Exception();
                }
            }
            return(arrayList);
        }
Exemple #23
0
        private ArrayNode ParseArray()
        {
            Expect(TokenType.LBRACK);
            Next();

            var array = new ArrayNode(Position(-1));

            while (More() && !Accept(TokenType.RBRACK))
            {
                array.AddDefaultElement(ParseExpression());

                if (Accept(TokenType.COMMA))
                {
                    Next();
                    ExpectNot(TokenType.RBRACK);
                }
                else
                {
                    Expect(TokenType.RBRACK);
                }
            }

            Expect(TokenType.RBRACK);
            Next();

            return(array);
        }
Exemple #24
0
        // Token: 0x06000033 RID: 51 RVA: 0x00002D68 File Offset: 0x00000F68
        private static int GetNodeCount(PNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            ArrayNode arrayNode = node as ArrayNode;

            if (arrayNode != null)
            {
                int num = 1;
                foreach (PNode node2 in arrayNode)
                {
                    num += BinaryFormatWriter.GetNodeCount(node2);
                }
                return(num);
            }
            DictionaryNode dictionaryNode = node as DictionaryNode;

            if (dictionaryNode != null)
            {
                int num2 = 1;
                foreach (PNode node3 in dictionaryNode.Values)
                {
                    num2 += BinaryFormatWriter.GetNodeCount(node3);
                }
                num2 += dictionaryNode.Keys.Count;
                return(num2);
            }
            return(1);
        }
Exemple #25
0
        /// <summary>
        /// Transforms the given node into some other node if necessary.
        /// </summary>
        /// <param name="node">The node to transform.</param>
        /// <returns>The transformed node.</returns>
        private static BaseNode TransformNode(BaseNode node)
        {
            var custom = GetCustomCodeGeneratorForNode(node);

            if (custom != null)
            {
                return(custom.TransformNode(node));
            }

            BaseNode GetCharacterNodeForEncoding(Encoding encoding)
            {
                if (encoding.IsSameCodePage(Encoding.Unicode))
                {
                    return(new Utf16CharacterNode());
                }
                if (encoding.IsSameCodePage(Encoding.UTF32))
                {
                    return(new Utf32CharacterNode());
                }
                return(new Utf8CharacterNode());
            }

            if (node is BaseTextNode textNode)
            {
                var arrayNode = new ArrayNode {
                    Count = textNode.Length
                };
                arrayNode.CopyFromNode(node);
                arrayNode.ChangeInnerNode(GetCharacterNodeForEncoding(textNode.Encoding));
                return(arrayNode);
            }

            if (node is BaseTextPtrNode textPtrNode)
            {
                var pointerNode = new PointerNode();
                pointerNode.CopyFromNode(node);
                pointerNode.ChangeInnerNode(GetCharacterNodeForEncoding(textPtrNode.Encoding));
                return(pointerNode);
            }

            if (node is BitFieldNode bitFieldNode)
            {
                var underlayingNode = bitFieldNode.GetUnderlayingNode();
                underlayingNode.CopyFromNode(node);
                return(underlayingNode);
            }

            if (node is BaseHexNode hexNode)
            {
                var arrayNode = new ArrayNode {
                    Count = hexNode.MemorySize
                };
                arrayNode.CopyFromNode(node);
                arrayNode.ChangeInnerNode(new Utf8CharacterNode());
                return(arrayNode);
            }

            return(node);
        }
Exemple #26
0
        public void LoadArrayNode(ArrayNode node, NewNode currentNode, int counter)
        {
            var key = node.Index;

            if (currentNode == null)
            {
                currentNode = new NewNode();
                FlattenedNodes.Add(currentNode);
            }
            currentNode.AddKeyNode(node, "[" + key + "]");

            foreach (var nodeValue in node.Values)
            {
                if (currentNode.HasValueNode)
                {
                    var nodes        = currentNode.GetNodes();
                    var currentNode2 = new NewNode();
                    foreach (var n in nodes.Take(counter))
                    {
                        currentNode2.AddKeyNode(n.Key, n.Value);
                    }
                    currentNode2.AddKeyNode(node, "[" + key + "]");
                    FlattenedNodes.Add(currentNode2);
                    currentNode = currentNode2;
                }

                if (nodeValue is ArrayNode)
                {
                    var arrayNode = nodeValue as ArrayNode;
                    LoadArrayNode(arrayNode, currentNode, counter + 1);
                }
                else if (nodeValue is KeyArrayNode)
                {
                    var keyArrayNode = nodeValue as KeyArrayNode;
                    LoadKeyArrayNode(keyArrayNode, currentNode, counter + 1);
                }
                else if (nodeValue is KeyValueNode)
                {
                    var keyValueNode = nodeValue as KeyValueNode;
                    LoadKeyValueNode(keyValueNode, currentNode, counter + 1);
                }
                else if (nodeValue is ListKeyValueNode)
                {
                    var listKeyValueNode = nodeValue as ListKeyValueNode;
                    LoadListKeyValueNode(listKeyValueNode, currentNode, counter + 1);
                }
                else if (nodeValue is ValueNode)
                {
                    var valueNode = nodeValue as ValueNode;
                    LoadValueNode(valueNode, currentNode);
                }
                else if (nodeValue == null)
                {
                    var valueNode = new ValueNode();
                    valueNode.Value = "";
                    currentNode.SetValueNode(valueNode);
                }
            }
        }
Exemple #27
0
        public void ForeachForEmptyElemsTest()
        {
            var n = new ArrayNode();

            foreach (var e in n)
            {
            }
        }
Exemple #28
0
        public void DeletionForEmptyElemsTest()
        {
            var n = new ArrayNode();

            n.RemoveElementAt(0);

            Assert.AreEqual(null, n.Elems);
        }
Exemple #29
0
        /// <summary>
        /// 构造一个数组节点。
        /// </summary>
        /// <param name="nodes">所有数组中的项。</param>
        /// <returns></returns>
        public IArray Array(IEnumerable <IQueryNode> nodes)
        {
            IArray array = new ArrayNode();

            array.Items = new List <IQueryNode>(nodes);

            return(array);
        }
Exemple #30
0
        private IReq <ArrayNode> Array(Token lbrac)
        {
            var value = this.ArrayValue(out var emptyArrayComments);

            return(this.input.Expect(t => t.Type == TokenType.RBrac)
                   .CreateNode(
                       onSuccess: rbrac => ArrayNode.Create(lbrac, value, rbrac, emptyArrayComments, this.AppComment()).Req(),
                       onError: ue => SyntaxErrorNode.Unexpected("Expected array close tag ']'", ue)));
        }
Exemple #31
0
 public ArrayNameNode()
 {
     ArrayDimensions = null;
 }
Exemple #32
0
        public ArrayNode(ArrayNode rhs)
            : base(rhs)
        {
            Expr = null;
            Type = null;
            if (null != rhs)
            {
                if (null != rhs.Expr)
                {
                    Expr = ProtoCore.Utils.NodeUtils.Clone(rhs.Expr);
                }

                if (null != rhs.Type)
                {
                    Type = ProtoCore.Utils.NodeUtils.Clone(rhs.Type);
                }
            }
        }
Exemple #33
0
 public ArrayNameNode(ArrayNameNode rhs) : base(rhs)
 {
     ArrayDimensions = null;
     if (null != rhs.ArrayDimensions)
     {
         ArrayDimensions = new ArrayNode(rhs.ArrayDimensions);
     }
 }
Exemple #34
0
        private static void GenerateArray(ArrayNode node, DataContext data)
        {
            Append(data, "new dynamic[{0}] {{ ", node.ValueExpressions.Count);

            for (int i = 0; i < node.ValueExpressions.Count; i++)
            {
                if (i != 0)
                    Append(data, ", ");

                GenerateExpression(node.ValueExpressions[i], data);
            }

            Append(data, " }}");
        }