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


C# UserProfile.GetType方法代码示例

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


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

示例1: CompileData


//.........这里部分代码省略.........

					var userGames = new List<UserGame>();
					int orderPlayed = 1;
					// Get game data and add to games plus create trophies- file.
					foreach (var apiGame in apiGames)
					{
						var hasTrophyDetails = File.Exists(Path.Combine(this.TrophyDetailsPath, string.Format("{0}.xml", apiGame.Id)));
						var hasEarnedDetails = File.Exists(Path.Combine(this.RawDataPath, string.Format("game-{0}.xml", apiGame.Id)));
						if (hasTrophyDetails && hasEarnedDetails)
						{
							var trophyDetailsXml = XDocument.Load(Path.Combine(this.TrophyDetailsPath, string.Format("{0}.xml", apiGame.Id))).Root;
							var earnedDetailsXml = XDocument.Load(Path.Combine(this.RawDataPath, string.Format("game-{0}.xml", apiGame.Id))).Root;

							var gameDetails = trophyDetailsXml.Descendants("Game").FirstOrDefault();

							var userGame = new UserGame();
							userGame.Id = apiGame.Id;
							userGame.IdEurope = gameDetails.Element("IdEurope").Value;
							userGame.Title = gameDetails.Element("Title").Value;
							userGame.ImageUrl = gameDetails.Element("Image").Value;
							userGame.BronzeEarned = apiGame.Bronze;
							userGame.SilverEarned = apiGame.Silver;
							userGame.GoldEarned = apiGame.Gold;
							userGame.PlatinumEarned = apiGame.Platinum;
							userGame.TotalEarned = apiGame.Bronze + apiGame.Silver + apiGame.Gold + apiGame.Platinum;
							userGame.OrderPlayed = orderPlayed++;
							userGame.LastUpdated = apiGame.Updated;
							userGame.TotalPoints = int.Parse(gameDetails.Element("TotalPoints").Value);
							// It appears that PS4 games now include platinums in the total points count. Should probably just overwrite this for all platforms.
							userGame.EarnedPoints = userGame.CalculateEarnedPoints(apiGame.Platform.ToLower() == "ps4");
							userGame.Progress = userGame.CalculateProgress().ToString();
							userGame.Platform = apiGame.Platform;

							var trophyDetails = trophyDetailsXml.Descendants("Trophy");
							userGame.PossibleTrophies = trophyDetails.Count();

							userGames.Add(userGame);

							// Compile trophy data.
							var userTrophies = new List<UserTrophy>();
							foreach (var trophyDetail in trophyDetails)
							{
								var userTrophy = new UserTrophy();
								userTrophy.Id = trophyDetail.Element("Id").Value;
								userTrophy.GameId = apiGame.Id;
								userTrophy.Title = trophyDetail.Element("Title").Value;
								userTrophy.ImageUrl = trophyDetail.Element("Image").Value;
								userTrophy.Description = trophyDetail.Element("Description").Value;
								userTrophy.Type = ParseTrophyType(trophyDetail.Element("Type").Value);
								// Trophy data can now have null values for this. If that's the case, assume it's hidden to be on the safe side.
								userTrophy.Hidden = !string.IsNullOrWhiteSpace(trophyDetail.Element("Hidden").Value) ? bool.Parse(trophyDetail.Element("Hidden").Value) : true;
								userTrophy.Platform = apiGame.Platform;

								foreach (var earnedDetail in earnedDetailsXml.Descendants("trophy"))
								{
									if (earnedDetail.Attribute("id").Value == userTrophy.Id)
									{
										userTrophy.Earned = DateTime.Parse(earnedDetail.Value).ToUniversalTime().ToLocalTime();
										break;
									}
								}
								userTrophies.Add(userTrophy);
							}

							PerformBackup("trophies-" + apiGame.Id, "__{0}-" + currentTime);
							savePath = string.Format(filePath, "trophies-" + apiGame.Id);
							SaveTrophyXml(savePath, userTrophies);
						}
						else
						{
							DebugInfo.Add(apiGame.Id);
							DebugInfo.Add(hasTrophyDetails);
							DebugInfo.Add(hasEarnedDetails);
						}
					}

					#region Save data
					// Profile
					PerformBackup("profile", "__{0}-" + currentTime);
					savePath = string.Format(filePath, "profile");
					var psnProfile = new XmlSerializer(userProfile.GetType());
					using (StreamWriter writer = new StreamWriter(savePath))
					{
						psnProfile.Serialize(writer, userProfile);
					}
					// Games
					PerformBackup("games", "__{0}-" + currentTime);
					savePath = string.Format(filePath, "games");
					var psnGames = new XmlSerializer(userGames.GetType());
					using (StreamWriter writer = new StreamWriter(savePath))
					{
						psnGames.Serialize(writer, userGames);
					}
					// Trophies
					// done above
					#endregion
					return true;
				}
				return false;
			}
开发者ID:jimyong1988,项目名称:PsnWrapper,代码行数:101,代码来源:UserDataCompiler.cs

示例2: getUserProfile

        /*
         * Get user profile
         */
        public static GetProfileResultType getUserProfile(paymentServer_dataBase DBHandler, int userNo)
        {
            GetProfileResultType reply = new GetProfileResultType();
            reply.status = ResultCodeType.ERROR_UNKNOWN;

            List<string>[] list = DBHandler.Select("userProfile", "userNo", ""+userNo);
            if (list.Length == 1)
            {
                if (list[0].Count() == (int)UserProfileEnum.NUM_PROFILE_DATA_ITEMS)
                {
                    string String = "";
                    int Int = 1;
                    bool Bool = false;
                    double Double = 0.1;

                    object Profile = new UserProfile();
                    PropertyInfo[] properties = Profile.GetType().GetProperties();
                    int i;
                    for (i = 0; i < properties.Length; i++)
                    {
                        Console.WriteLine(properties[i].GetValue(Profile, null).ToString());
                        if (properties[i].GetType() == String.GetType())
                        {
                            properties[i].SetValue(Profile, (string)list[0][i], null);

                        }
                        else if (properties[i].GetType() == Double.GetType())
                        {
                            properties[i].SetValue(Profile, Convert.ToDouble(list[0][i]), null);
                        }
                        else if (properties[i].GetType() == Int.GetType())
                        {
                            properties[i].SetValue(Profile, Convert.ToInt32(list[0][i]), null);

                        }
                        else if (properties[i].GetType() == Bool.GetType())
                        {
                            properties[i].SetValue(Profile, Convert.ToBoolean(list[0][i]), null);
                        }
                        reply.status = ResultCodeType.UPDATE_USER_PROFILE_SUCCESS;
                        reply.profile = (UserProfile)Profile;
                    }
                }
                else
                {
                    Console.WriteLine("ServerWorker::getUserProfile - Error: Did not receive extpected number of data items from server. Received: {}, Expected: {}", list[0].Count(), (int)UserProfileEnum.NUM_PROFILE_DATA_ITEMS);
                }

            }

            else
            {
                Console.WriteLine("ServerWorker::getUserProfile - Error: Database query returned more than one record. Number Received: {}", list.Length);
            }
            return reply;
        }
开发者ID:quattrozhou,项目名称:paymentServer,代码行数:59,代码来源:paymentServer_requestWorker.cs


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