/// <summary> /// it is expected the Account Xml node be formated as such: /// <Account accountId="" fbAccountid="" piAccountId="" nickname=""> /// <AccountData> /// <UserProperties> /// <UserProperty Name="" Value=""/> /// <UserProperty Name="" Value=""/> /// <UserProperty Name="" Value=""/> /// ... /// </UserProperties> /// </AccountData> /// </Account> /// </summary> /// <param name="xmlNode"></param> public static ServerAccount GetAccountFromXml(XmlNode xmlNode) { string accountIdString = string.Empty; string fbAccountIdString = string.Empty; string piAccountIdString = string.Empty; string piSecureKeyString = string.Empty; string nickNameString = string.Empty; string firstNameString = string.Empty; string lastNameString = string.Empty; if (!(XmlUtil.TryGetAttributeFromXml(ConstStrings.kAccountId, xmlNode, out accountIdString) && //uint XmlUtil.TryGetAttributeFromXml(ConstStrings.kFbAccountId, xmlNode, out fbAccountIdString) && //long XmlUtil.TryGetAttributeFromXml(ConstStrings.kPiAccountId, xmlNode, out piAccountIdString) && // XmlUtil.TryGetAttributeFromXml(ConstStrings.kPiSecureKey, xmlNode, out piSecureKeyString) && // XmlUtil.TryGetAttributeFromXml(ConstStrings.kNickName, xmlNode, out nickNameString) && XmlUtil.TryGetAttributeFromXml(ConstStrings.kFirstName, xmlNode, out firstNameString) && XmlUtil.TryGetAttributeFromXml(ConstStrings.kLastName, xmlNode, out lastNameString))) // { StateServerAssert.Assert(new Exception("An account parameter is missing when creating a new account.")); return(null); } AccountId accountId = null; long fbAccountId = 0; try { uint accountIdUInt = Convert.ToUInt32(accountIdString); accountId = new AccountId(accountIdUInt); fbAccountId = Convert.ToInt64(fbAccountIdString); } catch (System.Exception ex) { StateServerAssert.Assert(new Exception("Error converting string to accountId type: " + ex.Data, ex)); return(null); } XmlNode accountDataNode = xmlNode.SelectSingleNode(ConstStrings.kAccountData); UserProperties userProperties = new UserProperties(); if (accountDataNode != null) { XmlNode userPropertiesXmlNode = accountDataNode.SelectSingleNode(ConstStrings.kUserProperties); //if we can't find a UserProperties node, we can just set some default values if (userPropertiesXmlNode != null) { if (!UserProperties.UserPropertiesFromXml(userPropertiesXmlNode, out userProperties)) { StateServerAssert.Assert(new Exception("Error parsing user properties from xml: " + xmlNode.OuterXml)); return(null); } } } SetDefaultUserProperties(ref userProperties); return(new ServerAccount(accountId, fbAccountId, piAccountIdString, piSecureKeyString, nickNameString, firstNameString, lastNameString, userProperties)); }