Esempio n. 1
0
 public WallGetObject GetWallInfo(ParserParams @params)
 {
     try
     {
         long groupId;
         var  w_pars = new WallGetParams();
         if (long.TryParse(@params.Domain, out groupId))
         {
             w_pars.OwnerId = groupId;
         }
         else
         {
             w_pars.Domain = @params.Domain;
         }
         WallGetObject wall = api.Wall.Get(
             new WallGetParams
         {
             OwnerId = groupId,
             Count   = 0
         });
         return(wall);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     return(null);
 }
    public void ParseConstant()
    {
        var value = Encoding.Default.GetBytes("1.5");
        var param = (PartSysParamConstant)
                    ParserParams.Parse(PartSysParamId.emit_accel_X, value, 0, 0, out var success);

        Assert.NotNull(param);
        Assert.True(success);
        Assert.AreEqual(PartSysParamType.PSPT_CONSTANT, param.Type);
        Assert.AreEqual(1.5f, param.GetValue());
    }
Esempio n. 3
0
        public List <Post> GetPostsBeforeDT(ParserParams @params, DateTime time, ulong offset = 0)
        {
            List <Post> posts = new List <Post>();

            try
            {
                long          groupId;
                WallGetObject wall;
                var           w_pars = new WallGetParams();
                if (long.TryParse(@params.Domain, out groupId))
                {
                    w_pars.OwnerId = groupId;
                }
                else
                {
                    w_pars.Domain = @params.Domain;
                }
                w_pars.Count = 100;

                for (ulong i = 0;; i += 100)
                {
                    w_pars.Offset = offset + i;
                    wall          = api.Wall.Get(w_pars);

                    if (wall.WallPosts.Count == 0)
                    {
                        return(posts);
                    }
                    foreach (var p in wall.WallPosts)
                    {
                        if (p.Date <= time)
                        {
                            return(posts);
                        }
                        posts.Add(
                            new Post(
                                p.Reposts == null ? 0 : p.Reposts.Count,
                                p.Likes == null ? 0 : p.Likes.Count,
                                p.Views == null ? 0 : p.Views.Count,
                                p.Comments == null ? 0 : p.Comments.Count,
                                p.Date.Value
                                ));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(posts);
        }
    public void ParseConstantDefault()
    {
        var value = Encoding.Default.GetBytes("0");
        var param = ParserParams.Parse(PartSysParamId.emit_accel_X, value, 0, 0, out var success);

        Assert.True(param == null, "No parameter should have been returned for a default value.");
        Assert.True(success, "The parser should still indicate success, however.");

        // Try it for a param with another default value than 1

        value = Encoding.Default.GetBytes("255");
        param = ParserParams.Parse(PartSysParamId.emit_init_alpha, value, 0, 0, out success);

        Assert.True(param == null, "No parameter should have been returned for a default value.");
        Assert.True(success, "The parser should still indicate success, however.");
    }
Esempio n. 5
0
        public List <Post> GetPosts(ParserParams @params, ulong offset = 0)
        {
            List <Post> posts = new List <Post>();

            try
            {
                long          groupId;
                WallGetObject wall;
                var           w_pars = new WallGetParams();
                if (long.TryParse(@params.Domain, out groupId))
                {
                    w_pars.OwnerId = groupId;
                }
                else
                {
                    w_pars.Domain = @params.Domain;
                }

                for (ulong i = 0; i < @params.Count; i += 100)
                {
                    w_pars.Count  = Math.Min(@params.Count - i, 100);
                    w_pars.Offset = offset + i;
                    wall          = api.Wall.Get(w_pars);
                    try
                    {
                        posts.AddRange(wall.WallPosts.Select(x =>
                                                             new Post(
                                                                 x.Reposts.Count,
                                                                 x.Likes.Count,
                                                                 // x.Views.Count,
                                                                 x.Comments.Count,
                                                                 x.Date.Value
                                                                 )));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(posts);
        }
Esempio n. 6
0
 private void UpdateProps()
 {
     ParserParams.EmitEvent("update-props");
 }