private static long IncrementIdentity(NodeReference node)
        {
            var identityValue = node.GetObject(IdentityValueSubscriptName);

            var identitySeed = identityValue == null ? 0 : Convert.ToInt64(identityValue);

            node.Set(++identitySeed, IdentityValueSubscriptName);

            return(identitySeed);
        }
        private static object ReadComplexNode(NodeReference node, Type objectType)
        {
            var isNullable = EntityTypeDescriptor.IsNullableType(objectType);

            if (isNullable && IsNullableComplexColumnEmpty(node))
            {
                return(null);
            }

            var underlyingType = !isNullable
                ? objectType
                : Nullable.GetUnderlyingType(objectType);

            var typeDescription = EntityTypeDescriptor.GetTypeDescription(underlyingType);

            var instance = InstanceCreator.CreateInstance(underlyingType);

            foreach (var column in typeDescription.Columns)
            {
                var subscript = column.ColumnAttribute.Name ?? column.ColumnInfo.Name;

                if (column.IsSimpleColumn)
                {
                    node.AppendSubscript(subscript);
                    var nodeValue = node.GetObject();
                    column.ColumnInfo.SetValue(instance, ConvertValue(nodeValue, column.ColumnInfo.PropertyType), null);
                }
                else if (column.IsArrayColumn)
                {
                    node.AppendSubscript(subscript);
                    column.ColumnInfo.SetValue(instance, ReadArray(node, column.ColumnInfo.PropertyType), null);
                }
                else if (column.IsEnumerableColumn)
                {
                    node.AppendSubscript(subscript);
                    column.ColumnInfo.SetValue(instance, ReadEnumerable(node, column.ColumnInfo.PropertyType), null);
                }
                else if (column.IsComplexColumn)
                {
                    node.AppendSubscript(subscript);
                    column.ColumnInfo.SetValue(instance,
                                               ReadComplexNode(node, column.ColumnInfo.PropertyType), null);
                }

                node.SetSubscriptCount(node.GetSubscriptCount() - 1);
            }

            return(instance);
        }
        static void GetData(NodeReference node)
        {
            Object value = node.GetObject();

            if (value is string)
            {
                if ((node.GetSubscriptCount() == 1) || (node.GetSubscriptCount() == 2))
                {
                    Console.WriteLine(value.ToString());
                }
                else if (node.GetSubscriptCount() == 5)
                {
                    ValueList outList = node.GetList();
                    outList.ResetToFirst();

                    for (int i = 0; i < outList.Length - 1; i++)
                    {
                        Console.Write(outList.GetNextObject() + ", ");
                    }
                    Console.WriteLine(outList.GetNextObject());
                    outList.Close();
                }
                else if (node.GetSubscriptCount() == 4)
                {
                    string tempString = Encoding.GetEncoding(1251).GetString(node.GetBytes());
                    Console.WriteLine(tempString);
                }
            }
            else if (value is double)
            {
                Console.WriteLine(value.ToString());
            }
            else if (value is int)
            {
                Console.WriteLine(value.ToString());
            }
        }
        internal static object ReadNode(NodeReference node, Type elementType)
        {
            object instance;

            if (EntityTypeDescriptor.IsSimpleType(elementType) || EntityTypeDescriptor.IsSimpleNullableType(elementType))
            {
                var nodeValue = node.GetObject();
                instance = ConvertValue(nodeValue, elementType);
            }
            else if (EntityTypeDescriptor.IsArrayType(elementType))
            {
                instance = ReadArray(node, elementType);
            }
            else if (EntityTypeDescriptor.IsSupportedEnumerable(elementType))
            {
                instance = ReadEnumerable(node, elementType);
            }
            else
            {
                instance = ReadComplexNode(node, elementType);
            }

            return(instance);
        }