??????????????????????????
???????????? ???????[ 2015/7/23 13:42:43 ] ???????????????????
??????????1?д???????????????????????????縴???Щ????????к??LINQ???????ж?????????????????????????mock???????????????????
??????????仯?????????????????????????仯??????????????——???????????????????????????????????????????????????
??????????????????? ????????????????????????????????????????????????????????????????????y????????????????????е????????????????????????????д????????????????????
???????????????.Where(x => x.Id == Id).FirstOrDefault(); ??????????? _refreshTokens ?? context.Set<RefreshToken>()???????????? List<RefreshToken>????????????? System.Data.Entity.DbSet ????2??????????????????
??????Visual Studio?а?F12?????????????????????1??????????????IQueryable——DbSet?????IQueryable????List????????IQueryable?????AsQueryable??????????????????????????????????????????????????2??RefreshTokenRepository???1??RefreshTokenRepository??
public class RefreshTokenRepository : IRefreshTokenRepository
{
private IQueryable<RefreshToken> _refreshTokens;
public RefreshTokenRepository()
{
}
public async Task<RefreshToken> FindById(string Id)
{
return _refreshTokens.Where(x => x.Id == Id).FirstOrDefault();
}
}
????????????????????——??2????????????????????????δ???????????θ???????????洢?????????????е?_refreshTokens??????????????????????_refreshTokens?????????????
??????????????????????????????????????????????——????Interface????
?????????????????????????_refreshTokens?????????????????????IUnitOfWork?ɡ?IUnitOfWork????????£?
????public interface IUnitOfWork : IDisposable
????{
????IQueryable<TEntity> Set<TEntity>() where TEntity : class;
????}
????????RefreshTokenRepository???????IUnitOfWork????_refreshTokens?????
public class RefreshTokenRepository : IRefreshTokenRepository
{
private IQueryable<RefreshToken> _refreshTokens;
public RefreshTokenRepository(IUnitOfWork unitOfWork)
{
_refreshTokens = unitOfWork.Set<RefreshToken>();
}
public async Task<RefreshToken> FindById(string Id)
{
return await _refreshTokens.Where(x => x.Id == Id).FirstOrDefaultAsync();
}
}
???????????????????洢????????????????FileStorageUnitOfWork??
publicclassFileStorageUnitOfWork:IUnitOfWork
{
publicIQueryable<TEntity>Set<TEntity>()whereTEntity:class
{
returnReadFromFile<TEntity>().AsQueryable<TEntity>();
}
privateIList<TEntity>ReadFromFile<TEntity>()
{
IList<TEntity>entities=null;
varjsonFilePath=HostingEnvironment.MapPath(string.Format("~/App_Data/{0}.json"??typeof(TEntity)));
if(File.Exists(jsonFilePath))
{
varjson=File.ReadAllText(jsonFilePath);
entities=JsonConvert.DeserializeObject<List<TEntity>>(json);
}
if(entities==null)entities=newList<TEntity>();
returnentities;
}
}
?????????????????洢??????????????Entity Framework??????EfUnitOfWork??EF???????????????
????public class EfUnitOfWork : DbContext?? IUnitOfWork
????{
????public new IQueryable<TEntity> Set<TEntity>() where TEntity : class
????{
????return base.Set<TEntity>();
????}
????}
???????????????????????IOC??????????Unity?????????UnitOfWork??
???????????洢?????FileStorageUnitOfWork??
????container.RegisterType<IUnitOfWork?? FileStorageUnitOfWork>(new HttpContextLifetimeManager<IUnitOfWork>());
????????????洢?????EfUnitOfWork??
????container.RegisterType<IUnitOfWork?? EfUnitOfWork>(new HttpContextLifetimeManager<IUnitOfWork>());
???????????????????????oauth refresh token??????????????洢?????????洢?????????洢????????洢???????????????????NoSQL?????????????????
????д??????????????????????????????ī???——IUnitOfWork??????????????仯??????£?????Repository????????????????IUnitOfWork??????Repositroy????IUnitOfWork????????????????IUnitOfWork??????У??????????????????????????????????????????????С????????????
??????????
?????仯?????????£?
????Presentation??-WebAPI??CNBlogsRefreshTokenProvider
????Application??-????IRefreshTokenService
????Application??-????RefreshTokenService
????Domain??-??壺RefreshToken
????Repository??-????IRefreshTokenRepository
????Repository??-????RefreshTokenRepository
????UnitOfWork??-????IUnitOfWork
????UnitOfWork??-????FileStorageUnitOfWork??EfUnitOfWork
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
?????????????????????????Щ????????????????????TC???????????????Щ???????????????????????????????????????????????(java .net ?????)???mysql???????????????????ж????д???Python???????????????(DB2)??????BufferPool????????????????????????????????6??????????????????滮???????????????-????????SQL Server???????????????????λ?????PHP??SQL????????????????????Pythonд???NoSQL????????? SQL ?е????????????? SQL ?е?????????Java???????:?????MySQL???????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????