/**
             * Returns the current maximum Message position within the given Conversation, or
             * Long.MIN_VALUE if no messages are found.
             *
             * @param conversationId Conversation whose maximum Message position to return.
             * @return the current maximum Message position or Long.MIN_VALUE.
             */
            private long GetMaxPosition(Uri conversationId)
            {
                LayerClient layerClient = App.GetLayerClient();

                LayerQuery query = LayerQuery.InvokeBuilder(Java.Lang.Class.FromType(typeof(IMessage)))
                                   .Predicate(new Predicate(MessageProperty.Conversation, Predicate.Operator.EqualTo, conversationId))
                                   .SortDescriptor(new SortDescriptor(MessageProperty.Position, SortDescriptor.Order.Descending))
                                   .Limit(1)
                                   .Build();

                IList <IQueryable> results = layerClient.ExecuteQueryForObjects(query);

                if (results.Count == 0)
                {
                    return(long.MinValue);
                }
                var message = results[0] as IMessage;

                if (message == null)
                {
                    return(long.MinValue);
                }
                return(message.Position);
            }