当前位置: 首页>>代码示例>>C#>>正文


C# PropertyBag.SetProperty方法代码示例

本文整理汇总了C#中PropertyBag.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyBag.SetProperty方法的具体用法?C# PropertyBag.SetProperty怎么用?C# PropertyBag.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PropertyBag的用法示例。


在下文中一共展示了PropertyBag.SetProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnSocketKilled

        protected override void OnSocketKilled(string msg)
        {
            INetworkConnection con = GetOwningServerConnection();

            if (con != null && con.IsAlive && ServerUser.CurrentCharacter != null)
            {
                PropertyBag bag = new PropertyBag();
                bag.SetProperty((int)PropertyID.CharacterId, ServerUser.CurrentCharacter.CharacterInfo.ID);
                if (ServerUser.TransferTarget != null)
                {
                    bag.SetProperty((int)PropertyID.Name, ServerUser.TransferTarget);
                }
                con.SendGenericMessage((int)GenericMessageType.CharacterDisconnected, bag, false);
            }

            if (ServerUser.TransferTarget == null || ServerUser.TransferTarget.Length == 0) // if we're not transferring
            {
                if (ServerUser.Profile != null && !ServerUser.IsAuthorizedClusterServer)
                {
                    ServerUser.Profile.SetLoggedOut();
                    if (ServerBase.UseDatabaseConnectivity && ServerUser.IsAuthenticated)
                    {
                        ServerUser.Profile.Save(MyServer.RequireAuthentication);
                    }
                }
                // kill auth ticket on this server.
                ConnectionManager.UnAuthorizeUser(ServerUser, false);
            }

            base.OnSocketKilled(msg);
        }
开发者ID:kamilion,项目名称:WISP,代码行数:31,代码来源:InboundPlayerConnection.cs

示例2: OnPatchInfoRequest

        private void OnPatchInfoRequest(INetworkConnection con, Packet r)
        {
            PropertyBag bag = new PropertyBag();
            bag.SetProperty("MB", ((PatchServerProcess)MyServer).MBytesPatchDataSent);
            bag.SetProperty("Num", ((PatchServerProcess)MyServer).PatchFileSent);
            bag.SetProperty("Users", ConnectionManager.ConnectionCount);

            PacketGenericMessage msg = r as PacketGenericMessage;
            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms = bag;
        }
开发者ID:kamilion,项目名称:WISP,代码行数:11,代码来源:ZeusInboundZeusConnection.cs

示例3: TSCharacterComponent

        public TSCharacterComponent()
        {
            ComponentName = "TrueSkill Character Rating Component";
            m_Properties = new PropertyBag("True Skill Added Properties");

            GameInfo gameInfo = GameInfo.DefaultGameInfo;
            int gamesPlayed = 0;

            m_Properties.SetProperty("TS Games Played", (int)TSPropertyID.GamesPlayed, gamesPlayed);
            m_Properties.SetProperty("Initial Mean", (int)TSPropertyID.RatingMean, gameInfo.InitialMean);
            m_Properties.SetProperty("Initial Standard Deviation", (int)TSPropertyID.RatingStandardDeviation, gameInfo.InitialStandardDeviation);
        }
开发者ID:kamilion,项目名称:WISP,代码行数:12,代码来源:TSCharacterComponent.cs

示例4: OnConnectionReady

        /// <summary>
        /// Gets called when we are ready to communicate with the player, i.e. we can start sending packets
        /// </summary>
        protected virtual void OnConnectionReady()
        {
            INetworkConnection con = GetOwningServerConnection();

            if (con != null && con.IsAlive && ServerUser.CurrentCharacter != null)
            {
                PropertyBag bag = new PropertyBag();
                bag.SetProperty((int)PropertyID.CharacterInfo, ServerUser.CurrentCharacter as IComponent);
                bag.SetProperty((int)PropertyID.Owner, ServerUser.ID);
                con.SendGenericMessage((int)GenericMessageType.CharacterTransferComplete, bag, false);
            }
        }
开发者ID:kamilion,项目名称:WISP,代码行数:15,代码来源:InboundPlayerConnection.cs

示例5: PropertyBagRepresentsPropertiesCorrectly

        public void PropertyBagRepresentsPropertiesCorrectly()
        {
            var propertyBag = new PropertyBag();

            Assert.False(propertyBag.HasProperty("Test"));
            Assert.Null(propertyBag.GetProperty("Test"));
            Assert.Null(propertyBag.GetProperty<string>("Test"));
            Assert.Equal(default(int), propertyBag.GetProperty<int>("Test"));

            propertyBag.SetProperty("Test", "Test");
            Assert.True(propertyBag.HasProperty("Test"));
            Assert.Equal("Test", propertyBag.GetProperty("Test"));
            Assert.Equal("Test", propertyBag.GetProperty<string>("Test"));

            propertyBag.ClearProperty("Test");
            Assert.False(propertyBag.HasProperty("Test"));
            Assert.Null(propertyBag.GetProperty("Test"));
            Assert.Null(propertyBag.GetProperty<string>("Test"));
            Assert.Equal(default(int), propertyBag.GetProperty<int>("Test"));
        }
开发者ID:adestis-mh,项目名称:RESTier,代码行数:20,代码来源:PropertyBag.Tests.cs

示例6: SaveComics

        private void SaveComics( ArrayList aComics, string fileName )
        {
            PropertyBag bags;

            bags = new PropertyBag();

            foreach( ComicInfo ci in aComics )
            {
                PropertyBag comicBag;

                comicBag = new PropertyBag();
                comicBag.Name = ci.DisplayName;
                comicBag.SetProperty( "Website", ci.Website );
                comicBag.SetProperty( "FolderName", ci.FolderName );
                comicBag.SetProperty( "DisplayName", ci.DisplayName );
                comicBag.SetProperty( "ImageSuffix", ci.ImageSuffix );
                comicBag.SetProperty( "ImageFilename", ci.ImageFilename );
                comicBag.SetProperty( "ImagePath", ci.ImagePath );
                comicBag.SetProperty( "Subscribed", ci.Subscribed.ToString() );

                bags.AddBag( comicBag );
            }

            bags.Save( fileName );
            return;
        }
开发者ID:tmar89,项目名称:tmar89snapstreamdev,代码行数:26,代码来源:ComicsUpdater.cs

示例7: SelectCharacter

 /// <summary>
 /// Selects a character to play with.  
 /// </summary>
 /// <param name="characterId"></param>
 /// <returns></returns>
 public bool SelectCharacter(int characterId)
 {
     PropertyBag bag = new PropertyBag();
     bag.SetProperty((int)PropertyID.CharacterId, characterId);
     SendGenericMessage((int)GenericMessageType.RequestSelectCharacter, bag, false);
     return true;
 }
开发者ID:kamilion,项目名称:WISP,代码行数:12,代码来源:ClientCentralServerOutboundConnection.cs

示例8: NotifyPercentLevelLoaded

        /// <summary>
        /// Notifies the server of far along we are in loading the level after the game has started.
        /// No one can take any moves until all clients are loaded in.
        /// </summary>
        /// <param name="percent">the percentage between 0.0f and 100.0f</param>
        public void NotifyPercentLevelLoaded(float percent)
        {
            if (!Client.GameServerReadyForPlay)
            {
                Log.LogMsg("Tried to send PacketGameMessage type [ ClientLevelLoaded ], but game server not ready.");
                return;
            }

            PropertyBag p = new PropertyBag();
            p.SetProperty("PercentLoaded", Math.Max(0f, percent));
            SendGameMessage((int)LobbyGameMessageSubType.ClientLevelLoaded, p);
        }
开发者ID:kamilion,项目名称:WISP,代码行数:17,代码来源:ClientGame.cs

示例9: RequestVersionUpdate

 /// <summary>
 /// Sends the patch server the version we currently think we are, based on what's in the ver.txt file.
 /// Patch server will send us the next patch in the sequence.
 /// </summary>
 private static void RequestVersionUpdate()
 {
     Log.LogMsg("Requesting version update.");
     AddMsg("Requesting version update.");
     PropertyBag parms = new PropertyBag();
     parms.SetProperty("CurrentVersion", 1, GetCurrentVersion());
     m_PatchCon.SendGenericMessage((byte)GenericMessageType.GetLatestVersion, parms, false);
 }
开发者ID:kamilion,项目名称:WISP,代码行数:12,代码来源:Patcher.cs

示例10: Character_GetPropertyTypesFromTemplate

        /// <summary>
        /// Reads the character.xml file and returns a list of properties that that character should have
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool Character_GetPropertyTypesFromTemplate(string filePath, ref PropertyBag props, ref StatBag stats)
        {
            XPathDocument doc = LoadDocument(filePath, true);
            XPathNavigator nav = null;

            string[] sections = new string[] { "StringProperties", "IntProperties", "LongProperties", "FloatProperties" };
            try
            {
                if (doc == null)
                {
                    return false;
                }

                nav = doc.CreateNavigator();
                for (int i = 0; i < sections.Length; i++)
                {
                    XPathNodeIterator iter = nav.Select(@"./Template/Character/PropertyBag/" + sections[i] + "/Property");
                    while (iter.MoveNext())
                    {
                        string id = iter.Current.GetAttribute("ID", "");
                        if (id == null || id.Length < 1)
                        {
                            Log.LogMsg("Error reading ID attribute in node " + iter.Current.InnerXml);
                            continue;
                        }

                        string name = iter.Current.GetAttribute("Name", "");
                        if (name == null)
                        {
                            name = "";
                        }

                        int propertyTypeID = int.Parse(id);

                        if (sections[i] == "IntProperties")
                        {
                            int value = int.Parse(iter.Current.Value);
                            props.SetProperty(name, propertyTypeID, value);
                        }
                        else if (sections[i] == "StringProperties")
                        {
                            props.SetProperty(name, propertyTypeID, iter.Current.Value);
                        }
                        else if (sections[i] == "FloatProperties")
                        {
                            float value = float.Parse(iter.Current.Value);
                            props.SetProperty(name, propertyTypeID, value);
                        }
                        else if (sections[i] == "LongProperties")
                        {
                            long value = long.Parse(iter.Current.Value);
                            props.SetProperty(name, propertyTypeID, value);
                        }
                    }
                }

                // Stats
                XPathNodeIterator statIter = nav.Select(@"./Template/Character/StatBag/Stat");
                while (statIter.MoveNext())
                {
                    int id = int.Parse(statIter.Current.GetAttribute("StatID", ""));

                    Stat proto = StatManager.Instance[id];
                    if (proto == null)
                    {
                        Log.LogMsg("Error reading character template. Stat id [" + id + "] was specified but was not loaded from the Stats.xml configuration file. Stat not added to character.");
                        continue;
                    }

                    float currentValue = float.Parse(statIter.Current.Value);
                    Stat s = new Stat(id, proto.DisplayName, proto.Description, proto.Group, currentValue,proto.MinValue, proto.MaxValue);
                    stats.AddStat(s);
                }
            }
            catch (Exception e)
            {
                Log.LogMsg("Failed to load character properties from template.");
                //Log.LogMsg("Exception thrown reading Character template. " + e.Message);
                return false;
            }

            return true;
        }
开发者ID:kamilion,项目名称:WISP,代码行数:88,代码来源:XMLHelper.cs

示例11: RequestJoinGame

        /// <summary>
        /// Request the joining of an existing game instance on the game server.  
        /// This is a non-blocking call.  Once the game join request has been resolved
        /// the LobbyClient.GameJoinRequestResolved event will fire.
        /// </summary>
        /// <param name="gameId">the ID of the game we wish to join</param>
        /// <param name="msg">a string which will hold player facing text message if the call fails (returns false)</param>
        /// <returns>true if IsGameServerConnected and was ReadyForPlay and the request was thus sent</returns>
        public bool RequestJoinGame(Guid gameId, ref string msg, PropertyBag parms)
        {
            msg = "";
            if (!IsCentralServerConnected || !CentralReadyForCommunication)
            {
                msg = "Not ready to communicate with game server.";
                return false;
            }

            PropertyBag options = new PropertyBag();
            options.SetProperty("IsNewGame", false);
            options.SetProperty((int)PropertyID.GameId, gameId);
            if (parms != null)
            {
                options.UpdateWithValues(parms);
            }
            TargetGameOptions = options;
            Log.LogMsg("Requesting to join game " + gameId.ToString());
            m_CentralServer.SendGenericMessage((int)GenericLobbyMessageType.JoinGame, options, false);
            return true;
        }
开发者ID:kamilion,项目名称:WISP,代码行数:29,代码来源:LobbyClient.cs

示例12: RequestGameListing

        /// <summary>
        /// Request a list of all games that the server knows about. This is a non-blocking call. Once the game data arrives, LobbyClient.Games 
        /// will have the latest data in it and LobbyClient.CompleteMatchListingArrived event will fire.
        /// </summary>
        /// <param name="msg">a string which will hold player facing text message if the call fails (returns false)</param>
        /// <returns>true if IsGameServerConnected and was ReadyForPlay and the request was thus sent</returns>
        public bool RequestGameListing(ref string msg, int page, int numPerPage, bool includeInProgress, int minPlayersAllowed, PropertyBag parms)
        {
            msg = "";
            if (!IsCentralServerConnected || !CentralReadyForCommunication)
            {
                msg = "Not ready to communicate with game server.";
                return false;
            }

            Log.LogMsg("Requesting content listing from game server.");
            PropertyBag bag = new PropertyBag();
            bag.SetProperty("Page", page);
            bag.SetProperty("NumPerPage", numPerPage);
            bag.SetProperty("IncludeInProgress", includeInProgress);
            bag.SetProperty("MinPlayersAllowed", minPlayersAllowed);

            // ad-hoc parms
            bag.UpdateWithValues(parms);

            if (GameRequestSearchInvoker != null)
            {
                PropertyBag add = FireGameRequestSearch();
                if (add != null)
                {
                    bag.UpdateWithValues(add);
                }
            }

            m_CentralServer.SendGenericMessage((int)GenericLobbyMessageType.RequestGameListing, bag, false);
            return true;
        }
开发者ID:kamilion,项目名称:WISP,代码行数:37,代码来源:LobbyClient.cs

示例13: RequestCreateNewGame

        /// <summary>
        /// Request the creation of a new game instance on the game server.  Any pertinent options should be
        /// included in the parameter.  This is a non-blocking call.  Once the game creation request has been resolved
        /// the LobbyClient.GameCreationRequestResolved event will fire.
        /// </summary>
        /// <param name="options">any options required by the server for game creation</param>
        /// <param name="msg">a string which will hold player facing text message if the call fails (returns false)</param>
        /// <returns>true if IsGameServerConnected and was ReadyForPlay and the request was thus sent</returns>
        public bool RequestCreateNewGame(PropertyBag options, ref string msg)
        {
            msg = "";
            if (!IsCentralServerConnected || !CentralReadyForCommunication)
            {
                msg = "Not ready to communicate with game server.";
                return false;
            }

            Log.LogMsg("Requesting game [" + options.GetStringProperty((int)PropertyID.Name) + "] creation from Central server.");
            options.SetProperty("IsNewGame", true);
            TargetGameOptions = options;
            m_CentralServer.SendGenericMessage((int)GenericLobbyMessageType.CreateGame, options, true); // encrypt it, beccause it could contain a password
            return true;
        }
开发者ID:kamilion,项目名称:WISP,代码行数:23,代码来源:LobbyClient.cs

示例14: OnGetLatestVersion

        public void OnGetLatestVersion(INetworkConnection con, Packet nmsg)
        {
            PacketGenericMessage packet = nmsg as PacketGenericMessage;
            string version = packet.Parms.GetStringProperty("CurrentVersion");

            try
            {
                double curVersion = double.Parse(version);
                int idx = PatchServerProcess.Patches.IndexOfKey(curVersion);
                if (idx == -1)
                {
                    Log1.Logger("Server").Info("User reported being at version number [" + version + "]. Version not known as per Versions.txt. Dropping user connection.");
                    KillConnection("Unknown current version.");
                    return;
                }

                if (!m_SentPatchNotes)
                {
                    PropertyBag bag = new PropertyBag();
                    bag.SetProperty("notes", 1, PatchServerProcess.PatchNotes);
                    PacketGenericMessage p = (PacketGenericMessage)CreatePacket((int)PacketType.PacketGenericMessage, (int)GenericMessageType.Notes, false, false);
                    p.Parms = bag;
                    p.NeedsDeliveryAck = true;
                    Send(p);
                    m_SentPatchNotes = true;
                }

                if (idx == (PatchServerProcess.Patches.Count - 1))
                {
                    // if the server is configured to collect client spec data, then we do it right before we tell the client they're current.
                    // if not, just send the iscurrent message now.
                    if (ShouldCollectClientSpecs())
                    {
                        RequestClientSpec();
                    }
                    else
                    {
                        SendVersionIsCurrent();
                    }
                    return;
                }

                // get next patch in line
                idx++;
                FileInfo fi = PatchServerProcess.Patches.Values[idx];
                try
                {
                    double newVersion = PatchServerProcess.Patches.Keys[idx];
                    SendFileStream(fi, newVersion.ToString());
                }
                catch(Exception se)
                {
                    Log1.Logger("Patcher").Error("Error sending patch to " + RemoteEndPoint.ToString(), se);
                }
            }
            catch(Exception e)
            {
                KillConnection("Malformed patch request. " + e.Message);
                return;
            }

            // we only send one patch file.  let client process that file, then call us back for next file.
            if (Transit.NumAcksWaitingFor < 1)
            {
                KillConnection("Patch sent.");
            }
            else
            {
                SetTimer(500);
            }
        }
开发者ID:kamilion,项目名称:WISP,代码行数:71,代码来源:UserConnection.cs

示例15: RequestClientSpec

        private void RequestClientSpec()
        {
            PropertyBag bag = new PropertyBag();
            PacketGenericMessage p = (PacketGenericMessage)CreatePacket((int)PacketType.PacketGenericMessage, 878787, false, false);
            p.Parms = bag;
            p.NeedsDeliveryAck = false;

            if (PatchServerProcess.Instance.CaptureCPU)
            {
                bag.SetProperty("cpu", true);
            }

            if (PatchServerProcess.Instance.CaptureDrives)
            {
                bag.SetProperty("drives", true);
            }

            if (PatchServerProcess.Instance.CaptureGPU)
            {
                bag.SetProperty("gpu", true);
            }

            if (PatchServerProcess.Instance.CaptureMainboard)
            {
                bag.SetProperty("mainboard", true);
            }

            if (PatchServerProcess.Instance.CaptureOS)
            {
                bag.SetProperty("os", true);
            }

            if (PatchServerProcess.Instance.CaptureRAM)
            {
                bag.SetProperty("ram", true);
            }

            Send(p);
        }
开发者ID:kamilion,项目名称:WISP,代码行数:39,代码来源:UserConnection.cs


注:本文中的PropertyBag.SetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。