public void GetNamedPropertiesTest()
        {
            parser  = new MsgParser(@"TestFiles\TestMessage-default.msg");
            msgFile = parser.Parse();
            var namedProperties = msgFile.NamedProperties;

            Assert.That(namedProperties.Count, Is.EqualTo(1));
            Assert.That(namedProperties[0].GUID, Is.EqualTo(new Guid("{86030200-0000-0000-c000-000000000046}")));
            Assert.That(namedProperties[0].ID, Is.EqualTo(32772));
            Assert.That((namedProperties[0].Entry as VariableLengthPropertyEntry).VariableLengthData, Is.EqualTo("en-US").IgnoreCase);
        }
        public void ReadPropertyStreamDefaultTest()
        {
            parser  = new MsgParser(@"TestFiles\TestMessage-default.msg");
            msgFile = parser.Parse();
            PropertyStream ps = msgFile.PropertyStream;

            Assert.That(ps.Header, Is.Not.Null);
            Assert.That(ps.Header.NextRecipientId, Is.EqualTo(3));
            Assert.That(ps.Header.NextAttachmentId, Is.EqualTo(1));
            Assert.That(ps.Header.RecipientCount, Is.EqualTo(3));
            Assert.That(ps.Header.AttachmentCount, Is.EqualTo(1));
            Assert.That(ps.NumberOfProperties, Is.EqualTo(24));
        }
예제 #3
0
        private static void RankUp(TSPlayer player, Rank rank, bool silent = false)
        {
            try
            {
                if (player == null)
                {
                    throw new NullReferenceException("TSPlayer object cannot be null.");
                }
                if (rank == null)
                {
                    throw new NullReferenceException("Rank object cannot be null.");
                }
                if (rank.Group() == null)
                {
                    throw new NullReferenceException("Group object cannot be null.");
                }

                rank.PerformCommands(player);
                if (!silent)
                {
                    TShock.Users.SetUserGroup(TShock.Users.GetUserByID(player.User.ID), rank.Group().Name);
                    if (!String.IsNullOrWhiteSpace(AutoRank.Config.RankUpMessage))
                    {
                        player.SendSuccessMessage(MsgParser.Parse(AutoRank.Config.RankUpMessage, player, rank));
                    }
                    if (!String.IsNullOrWhiteSpace(rank.message))
                    {
                        player.SendSuccessMessage(MsgParser.Parse(rank.message, player, rank));
                    }
                }

                                #if DEBUG
                TShock.Log.ConsoleInfo($"[AutoRank] Ranked '{player.Name}' to '{rank.name}' (silent: {silent}).");
                                #else
                TShock.Log.ConsoleInfo($"[AutoRank] Ranked '{player.Name}' to {rank.name}.");
                                #endif
            }
            catch (Exception ex)
            {
                TShock.Log.ConsoleError("[SBPlanet Package] Exception at 'RankUp': {0}\nCheck logs for details.",
                                        ex.Message);
                TShock.Log.Error(ex.ToString());
            }
        }
예제 #4
0
        /// <summary>
        /// Loads a .MSG file
        /// </summary>
        /// <param name="filePath">The path to the .MSG file</param>
        public void Load(string filePath)
        {
            var msgParser = new MsgParser(filePath);

            _message = msgParser.Parse();
        }