protected override async Task <RefreshToken> Convert(RefreshTokenDocument document) { if (document == null) { return(null); } return(new RefreshToken() { AccessToken = await _propertySerializer.Deserialize <Token>(document.AccessTokenJson), Version = document.Version, CreationTime = document.CreationTimeSecondsSinceEpoch.FromEpoch(), LifeTime = document.LifeTime, Subject = await _propertySerializer.Deserialize <ClaimsPrincipal>(document.SubjectJson), }); }
protected override async Task <AuthorizationCode> Convert(AuthorizationCodeTokenDocument document) { if (document == null) { return(null); } return(new AuthorizationCode() { Client = (await _clientRepository.GetByClientId(document.ClientId)).ToModel(), CreationTime = document.CreationTimeSecondsSinceEpoch.FromEpoch(), IsOpenId = document.IsOpenId, Nonce = document.Nonce, RedirectUri = document.RedirectUri, RequestedScopes = await _propertySerializer.Deserialize <IEnumerable <Scope> >(document.RequestScopesJson), SessionId = document.SessionId, WasConsentShown = document.WasConsentShown, Subject = await _propertySerializer.Deserialize <ClaimsPrincipal>(document.SubjectJson), }); }
protected T GetProperty <T>(XElement xParent, string name) { var xProperty = xParent.Elements() .FirstOrDefault(p => p.Name == name); if (xProperty == null) { return(default(T)); } var value = _propertySerializer.Deserialize <T>(xProperty); return(value); }
private static void ReadGenericObjectProperty(GenericObject target, IFileStream stream, string type, uint size, string name) { IPropertySerializer serializer = GetSerializer(type); if (serializer != null) { target.SetProperty(name, type, serializer.Deserialize(stream)); } else { uint valueSize = size - 4; byte[] value = new byte[valueSize]; stream.SerializeValue(ref value, valueSize); target.SetProperty(name, type, value); } }
protected override async Task <Token> Convert(TokenHandleDocument document) { if (document == null) { return(null); } var client = await _clientRepository.GetByClientId(document.ClientId); var result = new Token() { Audience = document.Audience, Claims = await _propertySerializer.Deserialize <List <Claim> >(document.ClaimsListJson), Client = client.ToModel(), CreationTime = document.CreationTimeSecondsSinceEpoch.FromEpoch(), Issuer = document.Issuer, Lifetime = document.Lifetime, Type = document.Type, Version = document.Version, }; return(result); }
public BaseItem[] GetAllItems(string player_uuid = "") { List <BaseItem> items = new List <BaseItem>(); string conn = GetDBPath(); IDbConnection dbconn = (IDbConnection) new SqliteConnection(conn); dbconn.Open(); #region DB Structure //CREATE TABLE `items` ( // `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, // `object_id` TEXT DEFAULT '00000000-0000-0000-0000-000000000000', // `owner_id` INTEGER NOT NULL, // `object_owner_id` TEXT, // `type` TEXT NOT NULL, // `data` BLOB NOT NULL, // `position` BLOB NOT NULL, // `rotation` BLOB NOT NULL //); #endregion DB Structure IDbCommand dbcmd = dbconn.CreateCommand(); string sql = ""; if (string.IsNullOrEmpty(player_uuid)) { sql = "SELECT id, item_uuid, type, data, properties " + "FROM items;"; } else { sql = "SELECT id, item_uuid, type, data, properties " + "FROM items WHERE owner_uuid=\"" + player_uuid + "\";"; } dbcmd.CommandText = sql; IDataReader reader = dbcmd.ExecuteReader(); while (reader.Read()) { //int id = reader.GetInt32(0); //string item_uuid = reader.GetString(1); //string type = reader.GetString(2); string data = reader.GetString(3); string propertiesData = reader.GetString(4); var newData = Helper.FactoreData <SData>(data); BaseItem extItemDB = null; if (newData != null) { ISerializeData iSerializeInterface = newData as ISerializeData; if (iSerializeInterface != null) { extItemDB = iSerializeInterface.FactoryCloneItemFromData(); } else { Debug.Log("The external DB item data does not implement the ISerializable interface"); } IPropertySerializer propertySerializerInterface = extItemDB.BaseData.Properties as IPropertySerializer; if (propertySerializerInterface != null) { propertySerializerInterface.Deserialize <List <Property> >(propertiesData); } else { Debug.Log("The external DB item data property does not implement the interface IPropertySerializer"); } } if (items.Contains(extItemDB) == false && extItemDB != null) { items.Add(extItemDB); } else { Debug.LogError("Trying to add a duplicated external DB item skipping."); } } reader.Close(); reader = null; dbcmd.Dispose(); dbcmd = null; dbconn.Close(); dbconn = null; return(items.ToArray()); }