Пример #1
0
        static void Main(string[] args)
        {
            const string categoryName = "Likes";

            var methods = new[]
            {
                "likes.getList",
                "likes.add",
                "likes.delete",
                "likes.isLiked"
            };

            var parser    = new VkApiParser();
            var generator = new VkApiGenerator();
            var source    = InitializeSource(categoryName);

            foreach (string methodName in methods)
            {
                System.Console.WriteLine("*** {0} ***", methodName);
                VkMethodInfo methodInfo;
                try
                {
                    methodInfo = parser.Parse(methodName);
                }
                catch (WebException ex)
                {
                    System.Console.WriteLine(ex.Message);
                    continue;
                }
                System.Console.WriteLine("DESCRIPTION: {0}", methodInfo.Description);
                System.Console.WriteLine("RETURN TEXT: {0}", methodInfo.ReturnText);
                System.Console.WriteLine("RETURN TYPE: {0}", methodInfo.ReturnType);

                System.Console.WriteLine("PAPAMETERS:");
                foreach (var p in methodInfo.Params)
                {
                    System.Console.WriteLine("    {0} - {1}", p.Name, p.Description);
                }

                source.Append(generator.GenerateMethod(methodInfo))
                .AppendLine()
                .AppendLine();

                System.Console.WriteLine("\n========================================\n");
                //System.Console.ReadLine();
            }

            source.Append("}}");

            System.Console.WriteLine("Saving to disk");

            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            path = Path.Combine(path, @"..\VkNet\Categories\");
            path = string.Format("{0}\\{1}Category_Generated.cs", path, categoryName);

            File.WriteAllText(path, source.ToString());

            System.Console.WriteLine("done.");
        }
Пример #2
0
        public void GenerateUnitTest_NormalCase()
        {
            var gen = new VkApiGenerator();
            gen.GenerateUnitTest("Photos", "asjkfjklsjflksjflksjkgjdltioewurwejirwkrjkm");

            Assert.Fail();
        }
Пример #3
0
        static void Main(string[] args)
        {
            const string categoryName = "Likes";

            var methods = new[]
            {
                "likes.getList",
                "likes.add",
                "likes.delete",
                "likes.isLiked"
            };

            var parser = new VkApiParser();
            var generator = new VkApiGenerator();
            var source = InitializeSource(categoryName);
            
            foreach (string methodName in methods)
            {
                System.Console.WriteLine("*** {0} ***", methodName);
                VkMethodInfo methodInfo;
                try
                {
                    methodInfo = parser.Parse(methodName);
                }
                catch (WebException ex)
                {
                    System.Console.WriteLine(ex.Message);
                    continue;
                }
                System.Console.WriteLine("DESCRIPTION: {0}", methodInfo.Description);
                System.Console.WriteLine("RETURN TEXT: {0}", methodInfo.ReturnText);
                System.Console.WriteLine("RETURN TYPE: {0}", methodInfo.ReturnType);

                System.Console.WriteLine("PAPAMETERS:");
                foreach (var p in methodInfo.Params)
                {
                    System.Console.WriteLine("    {0} - {1}", p.Name, p.Description);
                }

                source.Append(generator.GenerateMethod(methodInfo))
                    .AppendLine()
                    .AppendLine();

                System.Console.WriteLine("\n========================================\n");
                //System.Console.ReadLine();
            }

            source.Append("}}");

            System.Console.WriteLine("Saving to disk");

            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            path = Path.Combine(path, @"..\VkNet\Categories\");
            path = string.Format("{0}\\{1}Category_Generated.cs", path, categoryName);

            File.WriteAllText(path, source.ToString());

            System.Console.WriteLine("done.");
        }
Пример #4
0
        public void GenerateUnitTest_NormalCase()
        {
            var gen = new VkApiGenerator();

            gen.GenerateUnitTest("Photos", "asjkfjklsjflksjflksjkgjdltioewurwejirwkrjkm");

            Assert.Fail();
        }
Пример #5
0
        public void GenerateMethod_Fave_GetUsers()
        {
            var method = new VkMethodInfo
            {
                Name = "fave.getUsers",
                Description = "Возвращает список пользователей",
                ReturnType = ReturnType.Collection,
                ReturnText = "После успешного выполнения возвращает список объектов пользователей."
            };

            method.Params.Add(new VkMethodParam
            {
                Name = "count",
                Description = "Количество пользователей, информацию о которых необходимо вернуть",
                Restrictions = VkParamRestrictions.PositiveDigit
            });
            method.Params.Add(new VkMethodParam
            {
                Name = "offset",
                Description = "Смещение",
                Restrictions = VkParamRestrictions.PositiveDigit
            });

            var gen = new VkApiGenerator();
            string result = gen.GenerateMethod(method);

            result.ShouldEqual(@"/// <summary>
/// Возвращает список пользователей
/// </summary>
/// <param name=""count"">Количество пользователей, информацию о которых необходимо вернуть</param>
/// <param name=""offset"">Смещение</param>
/// <returns>После успешного выполнения возвращает список объектов пользователей.</returns>
/// <remarks>
/// Страница документации ВКонтакте <see href=""http://vk.com/dev/fave.getUsers""/>.
/// </remarks>
public ReadOnlyCollection<> GetUsers(int? count = null, int? offset = null)
{
    VkErrors.ThrowIfNumberIsNegative(() => count);
    VkErrors.ThrowIfNumberIsNegative(() => offset);

    var parameters = new VkParameters
        {
            {""count"", count},
            {""offset"", offset}
        };

    VkResponseArray response = _vk.Call(""fave.getUsers"", parameters);

    return response.ToReadOnlyCollectionOf<>(x => x);
}");
        }
Пример #6
0
        public void GenerateMethod_Fave_GetUsers()
        {
            var method = new VkMethodInfo
            {
                Name        = "fave.getUsers",
                Description = "Возвращает список пользователей",
                ReturnType  = ReturnType.Collection,
                ReturnText  = "После успешного выполнения возвращает список объектов пользователей."
            };

            method.Params.Add(new VkMethodParam
            {
                Name         = "count",
                Description  = "Количество пользователей, информацию о которых необходимо вернуть",
                Restrictions = VkParamRestrictions.PositiveDigit
            });
            method.Params.Add(new VkMethodParam
            {
                Name         = "offset",
                Description  = "Смещение",
                Restrictions = VkParamRestrictions.PositiveDigit
            });

            var    gen    = new VkApiGenerator();
            string result = gen.GenerateMethod(method);

            result.ShouldEqual(@"/// <summary>
/// Возвращает список пользователей
/// </summary>
/// <param name=""count"">Количество пользователей, информацию о которых необходимо вернуть</param>
/// <param name=""offset"">Смещение</param>
/// <returns>После успешного выполнения возвращает список объектов пользователей.</returns>
/// <remarks>
/// Страница документации ВКонтакте <see href=""http://vk.com/dev/fave.getUsers""/>.
/// </remarks>
public ReadOnlyCollection<> GetUsers(int? count = null, int? offset = null)
{
    VkErrors.ThrowIfNumberIsNegative(() => count);
    VkErrors.ThrowIfNumberIsNegative(() => offset);

    var parameters = new VkParameters
        {
            {""count"", count},
            {""offset"", offset}
        };

    VkResponseArray response = _vk.Call(""fave.getUsers"", parameters);

    return response.ToReadOnlyCollectionOf<>(x => x);
}");
        }
Пример #7
0
        static void Main(string[] args)
        {
            const string categoryName = "Photos";

            var methods = new[]
            {
//                "notes.get",
//                "notes.getById",
//                "notes.getFriendsNotes",
//                "notes.add",
//                "notes.edit",
//                "notes.delete",
//                "notes.getComments",
//                "notes.createComment",
//                "notes.editComment",
//                "notes.deleteComment",
//                "notes.restoreComment"

                "photos.createAlbum",
                "photos.editAlbum",
                "photos.getAlbums",
                "photos.get",
                "photos.getAlbumsCount",
                "photos.getProfile",
                "photos.getById",
                "photos.getUploadServer",
                "photos.getProfileUploadServer",
                "photos.getChatUploadServer",
                "photos.saveProfilePhoto",
                "photos.saveWallPhoto",
                "photos.getWallUploadServer",
                "photos.getMessagesUploadServer",
                "photos.saveMessagesPhoto",
                "photos.report",
                "photos.reportComment",
                "photos.search",
                "photos.save",
                "photos.copy",
                "photos.edit",
                "photos.move",
                "photos.makeCover",
                "photos.reorderAlbums",
                "photos.reorderPhotos",
                "photos.getAll",
                "photos.getUserPhotos",
                "photos.deleteAlbum",
                "photos.delete",
                "photos.confirmTag",
                "photos.getComments",
                "photos.getAllComments",
                "photos.createComment",
                "photos.deleteComment",
                "photos.restoreComment",
                "photos.editComment",
                "photos.getTags",
                "photos.putTag",
                "photos.removeTag",
                "photos.getNewTags"
            };
            var parser    = new VkApiParser();
            var generator = new VkApiGenerator();
            var source    = InitializeSource(categoryName);

            foreach (string methodName in methods)
            {
                System.Console.WriteLine("*** {0} ***", methodName);
                VkMethodInfo methodInfo;
                try
                {
                    methodInfo = parser.Parse(methodName);
                }
                catch (WebException ex)
                {
                    System.Console.WriteLine(ex.Message);
                    continue;
                }
                System.Console.WriteLine("DESCRIPTION: {0}", methodInfo.Description);
                System.Console.WriteLine("RETURN TEXT: {0}", methodInfo.ReturnText);
                System.Console.WriteLine("RETURN TYPE: {0}", methodInfo.ReturnType);

                System.Console.WriteLine("PAPAMETERS:");
                foreach (var p in methodInfo.Params)
                {
                    System.Console.WriteLine("    {0} - {1}", p.Name, p.Description);
                }

                source.Append(generator.GenerateMethod(methodInfo))
                .AppendLine()
                .AppendLine();

                System.Console.WriteLine("\n========================================\n");
                //System.Console.ReadLine();
            }

            source.Append("}}");

            System.Console.WriteLine("Saving to disk");

            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            path = Path.Combine(path, @"..\VkNet\Categories\");
            path = string.Format("{0}\\{1}Category_Generated.cs", path, categoryName);

            File.WriteAllText(path, source.ToString());

            System.Console.WriteLine("done.");
        }