private T CreateApp(IQueryWeb web, bool shouldDispose) { // check that all public properties are virtual var appType = typeof(T); var props = appType.GetProperties(); foreach (var propertyInfo in props) { // skip props with [NotMapped] attribute var hasNomapAttrs = propertyInfo.GetCustomAttributes(typeof(NotMappedAttribute), false).Length != 0; if (hasNomapAttrs) { continue; } // not check properties of not IQueryList<> var isQueryList = CommonHelper.ImplementsOpenGenericInterface(propertyInfo.PropertyType, typeof(IQueryList <>)); if (!isQueryList) { continue; } Assert.IsPropertyVirtual(propertyInfo); } // create 'Application' proxy and init var app = _proxyGenerator.CreateClassProxy <T>(new AppBaseAccessInterceptor(web)); app.QueryWeb = web; app.ShouldDispose = shouldDispose; app.Init(); return(app); }
public void Start() { _queryWeb = WebFactory.Open(_webUrl); if (_queryWeb.ExistsByName(ListForLookup)) { _listForLookup = _queryWeb.GetByName <Item>(ListForLookup); } else { _listForLookup = _queryWeb.Create <Item>(ListForLookup); } var users = _queryWeb.Web.SiteUsers.Cast <SPUser>().ToList(); var uu = users.Where(u => u.IsDomainGroup == false).ToList(); _domainGroup = users.FirstOrDefault(u => u.IsDomainGroup); if (_domainGroup == null) { throw new Exception("No domain groups in site users!"); } _spGroup = _queryWeb.Web.SiteGroups[0]; _firstUser = uu[0]; _secondUser = uu[1]; }
public void Start() { _queryWeb = WebFactory.Open(_webUrl); if (_queryWeb.ExistsByName(ListForLookup)) { _listForLookup = _queryWeb.GetByName <Item>(ListForLookup); } else { _listForLookup = _queryWeb.Create <Item>(ListForLookup); } }
public void Moq_QueryWeb_Test() { var moqQueryWeb = new Mock <IQueryWeb>(); var moqQueryList = new Mock <IQueryList <Item> >(MockBehavior.Strict); moqQueryWeb.Setup(m => m.GetByName <Item>(It.IsAny <string>())) .Returns(moqQueryList.Object); moqQueryList.Setup(m => m.Add(It.IsAny <Item>())); IQueryWeb queryWeb = moqQueryWeb.Object; IQueryList <Item> list = queryWeb.GetByName <Item>("Test"); list.Add(new Item()); }
internal ListBase(SPList list, IQueryWeb parentWeb) { List = list; ParentWeb = parentWeb; }
public T ExistingWeb(IQueryWeb queryWeb) { return(CreateApp(queryWeb, false)); }
public AppBaseAccessInterceptor(IQueryWeb queryWeb) { _queryWeb = queryWeb; }
internal static object MakeParentList(Type entityType, IQueryWeb queryWeb, Guid listId) { var method = typeof(QueryWeb).GetMethod("GetById").MakeGenericMethod(entityType); return(method.Invoke(queryWeb, new object[] { listId })); }