public List <ArtefactInfoSimpleDto> GetFilteredSimple([FromUri] ApiFilter filter, [FromUri] int?artefactId = null) { try { return(new ArtefactInfoHandler(isTest).GetFilteredSimple(filter, artefactId)); } catch (Exception ex) { throw; } }
public async Task <IEnumerable <UserDto> > GetAll(ApiFilter filter) { var result = new List <UserDto>(); try { var query = _context.Users.AsQueryable(); var _filter = new UserListFilter(); if (!string.IsNullOrEmpty(filter.Filter)) { _filter = JsonConvert.DeserializeObject <UserListFilter>(filter.Filter); } // Registros a limitar query.Take(filter.Take); // Condiciones query = query.Where(x => _filter.Name == null || (x.Name + "" + x.Lastname).Contains(_filter.Name)); // Ordenamiento if (!string.IsNullOrEmpty(filter.Sort)) { if (filter.Sort.ToLower().Equals("name")) { if (!filter.Descending) { query = query.OrderBy(x => x.Name); } else { query = query.OrderByDescending(x => x.Name); } } } // Iteramos para mapear el automapper foreach (var user in await query.ToListAsync()) { result.Add( Mapper.Map <UserDto>(user) ); } } catch (Exception e) { // Error logging } return(result); }
public IActionResult Post([FromBody] ApiFilter filter) { //TODO: validators try { _repository.UpdateFilter(filter); return(Created($"api/filters/{1}", filter)); //TODO: not hardcode 1 } catch (Exception) { return(BadRequest("Failed")); } }
public Paginacion <ClienteModel> GetListClientePaginado( ApiFilter <ClienteModel> apiFilter ) { var filtros = apiFilter.Filtros != null; var list = from a in _db.Cliente.Include(x => x.ClasificacionContribuyente) join b in _db.Persona .Include(x => x.TipoDocumento) .Include(x => x.Municipio) .Include(x => x.Municipio.Departamento) on a.PersonaId equals b.PersonaId where filtros && ( apiFilter.Filtros.PersonaId == 0 || b.PersonaId == apiFilter.Filtros.PersonaId ) select new ClienteModel { PersonaId = b.PersonaId, TipoDocumentoId = b.TipoDocumentoId, TipoDocumentoNombre = b.TipoDocumento.Descripcion, NoIdentificacion = b.NoIdentificacion, PrimerNombre = b.PrimerNombre, SegundoNombre = b.SegundoNombre, PrimerApellido = b.PrimerApellido, SegundoApellido = b.SegundoApellido, NombreCompleto = b.NombreCompleto, FotoPerfil = b.FotoPerfil, Correo = b.Correo, Celular = b.Celular, Direccion = b.Direccion, MunicipioId = b.MunicipioId, Municipio = b.Municipio.Descripcion, DepartamentoId = b.Municipio.DepartamentoId, Departamento = b.Municipio.Departamento.Descripcion, Telefono = b.Telefono, ClasificacionContribuyenteId = a.ClasificacionContribuyenteId, ClasificacionContribuyenteNombre = a.ClasificacionContribuyente.Descripcion, // Cliente Nota = a.Nota, NumeroEstablecimientos = a.NumeroEstablecimientos, Estado = a.Estado, }; return(list.OrderBy(apiFilter.OrdenarPor, apiFilter.EsAscendente) .ToPagedList(apiFilter.PaginaNo, apiFilter.PorPagina).Paginar()); }
public void AutoTamperResponseBefore(Session oSession) { if ((ApiAnalyticsRunning) && oSession.fullUrl.StartsWith(ApiFilter.ToLower(), StringComparison.InvariantCultureIgnoreCase)) { var a = DateTime.Now - oSession.Timers.ClientBeginRequest; lock (_lockWriteFile) { File.AppendAllLines(ReportFile, new string[] { $"{oSession.RequestMethod},{oSession.fullUrl},{a},{oSession.requestBodyBytes.Length},{oSession.responseBodyBytes.Length}" }); } } }
public List <ArtefactInfoSimpleDto> GetFilteredSimple(ApiFilter filter, int?artefactId) { IQueryable <ArtefactInfo> infos = Db.ArtefactInfos; if (artefactId.HasValue) { infos = infos.Where(m => m.Artefact.Id == artefactId.Value); } if (filter.isDeleted.HasValue) { infos = infos.Where(m => m.IsDeleted == filter.isDeleted.Value); } return(Mapper.Map <List <ArtefactInfoSimpleDto> >(infos.OrderBy(m => m.ModifiedDate).Skip(filter.pageSize * filter.page).Take(filter.pageSize))); }
private ApiFilter GetInvoiceFilter(dataPack data) { var filter = new ApiFilter(filterType: FilterType.Or); var ids = data.dataPackItem?.Select(s => s.invoice.invoiceHeader.number.numberRequested.ToString()); filter.Filters = new HashSet <FilterItem>(ids.Select(s => { var f = new FilterItem("DocumentNumber"); f.Set(FilterOperator.Eq, s); return(f); })); return(filter.WithPaging(1, int.MaxValue)); }
public async Task <IEnumerable <PhotoListDto> > GetAll(ApiFilter filter) { var result = new List <PhotoListDto>(); try { var _filter = new PhotoListFilter(); if (!string.IsNullOrEmpty(filter.Filter)) { _filter = JsonConvert.DeserializeObject <PhotoListFilter>(filter.Filter); } var query = ( from p in _context.Photos from u in _context.Users.Where(x => x.Id == p.UserId) select new PhotoListDto { PhotoId = p.Id, Comments = _context.CommentsPerPhoto.Count(x => x.PhotoId == p.Id), Likes = _context.LikesPerPhoto.Count(x => x.PhotoId == p.Id), Image = p.Url, CreatedAt = p.CreatedAt, UserId = p.UserId, UserName = u.Name, UserPic = u.Image, UserSeoUrl = u.SeoUrl, ILikedIt = _context.LikesPerPhoto.Any(x => x.UserId == _filter.UserId && x.PhotoId == p.Id ) } ).Take(filter.Take); // Nuestra condicion query = query.Where(x => _filter.SeoUrl == null || x.UserSeoUrl == _filter.SeoUrl); result = await query.ToListAsync(); } catch (Exception e) { // Error logging } return(result); }
public Paginacion <UsuarioModel> GetListUsuarioPaginado( ApiFilter <UsuarioModel> apiFilter ) { var filtros = apiFilter.Filtros != null; var list = from a in _db.Usuario.Include(x => x.Perfil.PerfilMenus) join b in _db.Persona .Include(x => x.TipoDocumento) .Include(x => x.Municipio) .Include(x => x.Municipio.Departamento) on a.PersonaId equals b.PersonaId where filtros && ( apiFilter.Filtros.PersonaId == 0 || b.PersonaId == apiFilter.Filtros.PersonaId ) select new UsuarioModel { PersonaId = b.PersonaId, TipoDocumentoId = b.TipoDocumentoId, TipoDocumentoNombre = b.TipoDocumento.Descripcion, NoIdentificacion = b.NoIdentificacion, PrimerNombre = b.PrimerNombre, SegundoNombre = b.SegundoNombre, PrimerApellido = b.PrimerApellido, SegundoApellido = b.SegundoApellido, NombreCompleto = b.NombreCompleto, FotoPerfil = b.FotoPerfil, Correo = b.Correo, Celular = b.Celular, Direccion = b.Direccion, MunicipioId = b.MunicipioId, Municipio = b.Municipio.Descripcion, DepartamentoId = b.Municipio.DepartamentoId, Departamento = b.Municipio.Departamento.Descripcion, Telefono = b.Telefono, Estado = a.Estado, Login = a.Login }; return(list.OrderBy(apiFilter.OrdenarPor, apiFilter.EsAscendente) .ToPagedList(apiFilter.PaginaNo, apiFilter.PorPagina).Paginar()); }
public async Task <IEnumerable <OriginList> > GetAllAsync(ApiFilter filter) { var result = new List <OriginList>(); try { var _filter = new OriginListFilter(); if (!string.IsNullOrEmpty(filter.Filter)) { _filter = JsonConvert.DeserializeObject <OriginListFilter>(filter.Filter); } var query = ( from u in _context.Origins select new OriginList { Code = u.Code, Name = u.Name, Description = u.Description, Simbol = u.Simbol }).Take(filter.Take); //var query = ( // from c in _context.Origin // // from u in _context.Users.Where(x => x.Id == c.UserId) // select new OriginList // { // Code = c.Code, // Name = c.Name, // Description = c.Description, // Simbol = c.Simbol // } //).Take(filter.Take); //var origin = _context.Origins.whe // Los parámetros del filtro todos deberían ser opcionales query = query.Where(x => _filter.Code == null || x.Code == _filter.Code); result = await query.ToListAsync(); } catch (Exception e) { // Error logging } return(result); }
ArtefactCategoryDto GetArtefactCategory() { ApiFilter filter = new ApiFilter() { isDeleted = false, numPerPage = 1, pageNumber = 0 }; var categories = _controller.GetFiltered(filter); if (categories != null && categories.Any()) { return(categories.First()); } else { //Create a new category for testing return(CreateTestArtefactCategory()); } }
public async Task <IActionResult> Tickets(ApiFilter model) { try { if (ModelState.IsValid) { var result = await _fuseDeskAppService.ObterTickets(model); return(ExportCsvHelper.GetCsv(result, $"tickets-{DateTime.Now.ToString("dd-MM-yyyy-hh:mm")}")); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } return(View(model)); }
ZoneDto GetZone() { ApiFilter filter = new ApiFilter() { isDeleted = false, numPerPage = 1, pageNumber = 0 }; var zones = _controller.GetFiltered(filter); if (zones != null && zones.Any()) { return(zones.First()); } else { //Create a new zone for testing return(CreateTestZone()); } }
StoreItemDto GetStoreItem() { ApiFilter filter = new ApiFilter() { isDeleted = false, numPerPage = 1, pageNumber = 0 }; var storeItems = _controller.GetFiltered(filter); if (storeItems != null && storeItems.Any()) { return(storeItems.First()); } else { //Create a new storeItem for testing return(CreateTestStoreItem()); } }
ExhibitionDto GetExhibition() { ApiFilter filter = new ApiFilter() { isDeleted = false, numPerPage = 1, pageNumber = 0 }; var exhibitions = _controller.GetFiltered(filter); if (exhibitions != null && exhibitions.Any()) { return(exhibitions.First()); } else { //Create a new exhibition for testing return(CreateTestExhibition()); } }
public JsonResult GetListDeclaracionDeudaCuotaPaginado( string sort, int page, int perPage, string filter ) { var apiFilter = new ApiFilter <DeclaracionDeudaCuotaModel>(sort, page, perPage, filter); var filtros = apiFilter.Filtros != null; var list = from a in _db.DeclaracionDeudaCuota.Include(x => x.DeclaracionPrevia) where filtros && ( apiFilter.Filtros.PersonaId == 0 || a.DeclaracionPrevia.PersonaId == apiFilter.Filtros.PersonaId ) select new DeclaracionDeudaCuotaModel { DeclaracionDeudaCuotaId = a.DeclaracionDeudaCuotaId, DeclaracionPreviaId = a.DeclaracionPreviaId, FechaVencimiento = a.FechaVencimiento, PersonaId = a.DeclaracionPrevia.PersonaId, AnioDeclaracion = a.DeclaracionPrevia.Año, TotalImpuestoIndustriaComercio = a.TotalImpuestoIndustriaComercio, ImpuestoAvisosTableros = a.ImpuestoAvisosTableros, PagoUnidadesComerciales = a.PagoUnidadesComerciales, SobretasaBomberil = a.SobretasaBomberil, SobretasaSeguridad = a.SobretasaSeguridad, TotalImpuestoCargo = a.TotalImpuestoCargo, ValorExoneracionImpuesto = a.ValorExoneracionImpuesto, RetencionesDelMunicipio = a.RetencionesDelMunicipio, AutoretencionesDelMunicipio = a.AutoretencionesDelMunicipio, AnticipoAnioAnterior = a.AnticipoAnioAnterior, AnticipoAnioSiguiente = a.AnticipoAnioSiguiente, ValorSancion = a.ValorSancion, SaldoFavorPeriodoAnterior = a.SaldoFavorPeriodoAnterior, TotalSaldoCargo = a.TotalSaldoCargo, TotalSaldoFavor = a.TotalSaldoFavor, InteresesMora = 0, }; return(Json(list.OrderBy(apiFilter.OrdenarPor, apiFilter.EsAscendente) .ToPagedList(apiFilter.PaginaNo, apiFilter.PorPagina).Paginar(), JsonRequestBehavior.AllowGet)); }
//===================================================================== /// <summary> /// Constructor /// </summary> /// <param name="sourceCodeBasePath">An optional base path to the source code. If set, source code /// context information will be included in the reflection data when possible.</param> /// <param name="warnOnMissingContext">True to report missing type source contexts as warnings rather /// than as informational messages.</param> /// <param name="resolver">The assembly resolver to use</param> /// <param name="filter">The API filter to use</param> protected ApiVisitor(string sourceCodeBasePath, bool warnOnMissingContext, AssemblyResolver resolver, ApiFilter filter) { accessoryAssemblies = new List <AssemblyNode>(); assemblies = new List <AssemblyNode>(); catalog = new Dictionary <string, Namespace>(); if (!String.IsNullOrWhiteSpace(sourceCodeBasePath)) { if (sourceCodeBasePath[sourceCodeBasePath.Length - 1] != '\\') { sourceCodeBasePath += "\\"; } this.SourceCodeBasePath = sourceCodeBasePath; this.WarnOnMissingContext = warnOnMissingContext; } this.resolver = resolver; this.filter = filter; }
public async Task <IEnumerable <CommentListDto> > GetAll(ApiFilter filter) { var result = new List <CommentListDto>(); try { var _filter = new CommentListFilter(); if (!string.IsNullOrEmpty(filter.Filter)) { _filter = JsonConvert.DeserializeObject <CommentListFilter>(filter.Filter); } var query = ( from c in _context.CommentsPerPhoto from u in _context.Users.Where(x => x.Id == c.UserId) select new CommentListDto { CommentId = c.Id, Comment = c.Comment, PhotoId = c.PhotoId, User = u.Name, CreatedAt = c.CreatedAt } ).Take(filter.Take); // Los parámetros del filtro todos deberían ser opcionales query = query.Where(x => _filter.PhotoId == null || x.PhotoId == _filter.PhotoId); result = await query.ToListAsync(); } catch (Exception e) { // Error logging } return(result); }
/// <summary> /// GET api/Banks /// Method returns list of banks. /// </summary> public RowsResultWrapper <Bank> Banks(ApiFilter filter = null) { return(Get <RowsResultWrapper <Bank> >(ResourceUrl, filter)); }
/// <summary> /// GET api/Banks/GetChanges /// Method returns list of banks, that were changed. /// </summary> public RowsResultWrapper <Bank> Changes(DateTime lastCheck, ApiFilter filter = null) { return(Get <RowsResultWrapper <Bank> >(ResourceUrl + "/GetChanges" + "?lastCheck=" + lastCheck.ToString(ApiContextConfiguration.DateFormat), filter)); }
/// <summary> /// Apply a member filter to the specified type. /// </summary> /// <param name="apis">The APIs node from which to remove info</param> /// <param name="typeFilter">The type filter to be processed</param> private void ApplyMemberFilter(XmlNode apis, ApiFilter typeFilter) { string id; bool keep; int pos; if (!typeFilter.IsExposed) { // Remove all but the indicated members foreach (XmlNode memberNode in apis.SelectNodes("api[containers/type/@api='T:" + typeFilter.FullName + "']")) { id = memberNode.Attributes["id"].Value.Substring(2); pos = id.IndexOf('('); keep = false; // The API filter ignores parameters on methods if (pos != -1) { id = id.Substring(0, pos); } foreach (ApiFilter memberFilter in typeFilter.Children) { if (memberFilter.FullName == id) { keep = true; break; } } if (!keep) { id = memberNode.Attributes["id"].Value; builder.ReportProgress(" Removing member '{0}'", id); memberNode.ParentNode.RemoveChild(memberNode); // Remove the element nodes too foreach (XmlNode element in apis.SelectNodes("api/elements/element[@api='" + id + "']")) { element.ParentNode.RemoveChild(element); } } } } else { // Remove just the indicated members foreach (ApiFilter memberFilter in typeFilter.Children) { foreach (XmlNode memberNode in apis.SelectNodes("api[starts-with(substring-after(@id,':'),'" + memberFilter.FullName + "')]")) { id = memberNode.Attributes["id"].Value.Substring(2); pos = id.IndexOf('('); // The API filter ignores parameters on methods if (pos != -1) { id = id.Substring(0, pos); } if (id == memberFilter.FullName) { id = memberNode.Attributes["id"].Value; builder.ReportProgress(" Removing member '{0}'", id); memberNode.ParentNode.RemoveChild(memberNode); // Remove the element nodes too foreach (XmlNode element in apis.SelectNodes("api/elements/element[@api='" + id + "']")) { element.ParentNode.RemoveChild(element); } } } } } }
/// <summary> /// GET api/Agendas /// List of agendas. /// </summary> public async Task <RowsResultWrapper <Agenda> > AgendasAsync(ApiFilter filter = null) { return(await GetAsync <RowsResultWrapper <Agenda> >(ResourceUrl, filter)); }
//===================================================================== /// <summary> /// Constructor /// </summary> /// <param name="type">The type for which the dictionary is created</param> /// <param name="filter">The API filter used to exclude unwanted members</param> public MemberDictionary(TypeNode type, ApiFilter filter) { this.type = type; index = new Dictionary <string, List <Member> >(); // !EFW - Track excluded overridden members. These need to be filtered out below or the inherited // base member shows up in the member list. var excludedOverriddenMembers = new List <Member>(); // Add all member of the type except nested types and members that the filter rejects foreach (var member in type.Members) { if (!(member is TypeNode) && filter.IsExposedMember(member)) { this.AddMember(member); } else if (member.OverridesBaseClassMember) { excludedOverriddenMembers.Add(member.OverriddenMember); } } // For enumerations, don't list inherited members if (type is EnumNode) { return; } // For interfaces, list members of inherited interfaces if (type is Interface && filter.IncludeInheritedMembers) { var derivedMembers = new HashSet <string>(); string nameAndParams; int pos; // !EFW - This is a hack to filter out duplicate members by name and parameters for cases where // an interface member in the derived type uses the "new" keyword to re-implement a member using // the same name as in the base type. In such cases, the member is not truly hidden as it is in // a class since it still needs to be explicitly implemented when derived from but we don't want // to see it duplicated below as part of the inherited members. foreach (var m in this) { pos = m.FullName.LastIndexOf('('); if (pos != -1) { pos = m.FullName.LastIndexOf('.', pos, pos); } else { pos = m.FullName.LastIndexOf('.'); } if (pos != -1) { derivedMembers.Add(m.FullName.Substring(pos)); } else { derivedMembers.Add(m.FullName); } } foreach (var contract in type.Interfaces) { // Members of hidden interfaces don't count if (filter.IsExposedType(contract)) { // Otherwise, add inherited interface members except those rejected by the filters. This // is necessary to remove accessor methods. foreach (var contractMember in contract.Members) { pos = contractMember.FullName.LastIndexOf('('); if (pos != -1) { pos = contractMember.FullName.LastIndexOf('.', pos, pos); } else { pos = contractMember.FullName.LastIndexOf('.'); } if (pos != -1) { nameAndParams = contractMember.FullName.Substring(pos); } else { nameAndParams = contractMember.FullName; } if (!filter.IsExcludedFrameworkMember(type, contractMember) && filter.IsExposedMember(contractMember) && !derivedMembers.Contains(nameAndParams)) { this.AddMember(contractMember); derivedMembers.Add(nameAndParams); } } } } return; } // Don't list inherited members for static classes if (type.IsAbstract && type.IsSealed) { return; } // If not including inherited members, don't go any further if (!filter.IncludeInheritedMembers) { return; } // Now iterate up through the type hierarchy for (TypeNode parentType = type.BaseType; parentType != null; parentType = parentType.BaseType) { foreach (var parentMember in parentType.Members) { // Don't add constructors if (parentMember.NodeType == NodeType.InstanceInitializer || parentMember.NodeType == NodeType.StaticInitializer) { continue; } // Don't add inherited static members if (parentMember.IsStatic) { continue; } // Don't add nested types if (parentMember is TypeNode) { continue; } // Don't add protected members if the derived type is sealed and they are not wanted if (!filter.IncludeSealedProtected && type.IsSealed && (parentMember.IsFamily || parentMember.IsFamilyOrAssembly)) { continue; } // Don't add members that the filter rejects if (filter.IsExcludedFrameworkMember(type, parentMember) || !filter.IsExposedMember(parentMember)) { if (parentMember.OverridesBaseClassMember) { excludedOverriddenMembers.Add(parentMember.OverriddenMember); } continue; } // Don't add members we have overridden if (this.Contains(parentMember)) { continue; } // Don't add virtual members that have had their overridden counterparts excluded if (excludedOverriddenMembers.Contains(parentMember)) { if (parentMember.OverridesBaseClassMember) { excludedOverriddenMembers.Add(parentMember.OverriddenMember); } continue; } // Otherwise, add the member this.AddMember(parentMember); } } }
public AssemblyGuardSettings() { _apiFilter = new ApiFilter(ApiPolicy.SafeDefault()); MethodLocalsSizeLimit = IntPtr.Size * 32; MethodStackPushSizeLimit = 64; }
/// <summary> /// GET api/RegisteredSales/Expand /// List of registered sales with related entities. /// </summary> public RowsResultWrapper <RegisteredSaleExpand> RegisteredSalesExpand(ApiFilter filter = null) { return(Get <RowsResultWrapper <RegisteredSaleExpand> >(ResourceUrl + "/Expand", filter)); }
/// <summary> /// GET api/RegisteredSales /// Method returns list of registered sales. /// </summary> public RowsResultWrapper <RegisteredSale> RegisteredSales(ApiFilter filter = null) { return(Get <RowsResultWrapper <RegisteredSale> >(ResourceUrl, filter)); }
/// <summary> /// Apply a member filter to the specified type. /// </summary> /// <param name="apis">The APIs node from which to remove info</param> /// <param name="typeFilter">The type filter to be processed</param> private void ApplyMemberFilter(XmlNode apis, ApiFilter typeFilter) { string id; bool keep; int pos; if(!typeFilter.IsExposed) { // Remove all but the indicated members foreach(XmlNode memberNode in apis.SelectNodes( "api[containers/type/@api='T:" + typeFilter.FullName + "']")) { id = memberNode.Attributes["id"].Value.Substring(2); pos = id.IndexOf('('); keep = false; // The API filter ignores parameters on methods if(pos != -1) id = id.Substring(0, pos); foreach(ApiFilter memberFilter in typeFilter.Children) if(memberFilter.FullName == id) { keep = true; break; } if(!keep) { id = memberNode.Attributes["id"].Value; this.ReportProgress(" Removing member '{0}'", id); memberNode.ParentNode.RemoveChild(memberNode); // Remove the element nodes too foreach(XmlNode element in apis.SelectNodes( "api/elements/element[@api='" + id + "']")) element.ParentNode.RemoveChild(element); } } } else { // Remove just the indicated members foreach(ApiFilter memberFilter in typeFilter.Children) foreach(XmlNode memberNode in apis.SelectNodes( "api[starts-with(substring-after(@id,':'),'" + memberFilter.FullName + "')]")) { id = memberNode.Attributes["id"].Value.Substring(2); pos = id.IndexOf('('); // The API filter ignores parameters on methods if(pos != -1) id = id.Substring(0, pos); if(id == memberFilter.FullName) { id = memberNode.Attributes["id"].Value; this.ReportProgress(" Removing member '{0}'", id); memberNode.ParentNode.RemoveChild(memberNode); // Remove the element nodes too foreach(XmlNode element in apis.SelectNodes( "api/elements/element[@api='" + id + "']")) element.ParentNode.RemoveChild(element); } } } }
/// <summary> /// GET api/RegisteredSales/Expand /// List of registered sales with related entities. /// </summary> public async Task <RowsResultWrapper <RegisteredSaleExpand> > RegisteredSalesExpandAsync(ApiFilter filter = null) { return(await GetAsync <RowsResultWrapper <RegisteredSaleExpand> >(ResourceUrl + "/Expand", filter)); }
//===================================================================== /// <summary> /// This is used to add namespace filters to the API filter /// </summary> /// <param name="root">The tree node from which to start</param> private void AddNamespaceFilter(TreeNode root) { ApiFilter filter; NodeInfo nodeInfo; foreach(TreeNode node in root.Nodes) { if(this.AllChildrenMatchParentCheckState(node.Nodes, node.Checked)) { // We only need to add a filter in this case if the // namespace is being excluded. if(!node.Checked) { nodeInfo = (NodeInfo)node.Tag; apiFilter.Add(new ApiFilter(nodeInfo.EntryType, nodeInfo.Id, false)); } } else { nodeInfo = (NodeInfo)node.Tag; filter = new ApiFilter(nodeInfo.EntryType, nodeInfo.Id, node.Checked); apiFilter.Add(filter); // Add child filters that match the opposite state this.AddChildFilter(filter, node.Nodes, !node.Checked); } } }
/// <summary> /// GET api/SalesOffices /// Method returns list of sales offices. /// </summary> public RowsResultWrapper <SalesOffice> SalesOffices(ApiFilter paging = null) { return(Get <RowsResultWrapper <SalesOffice> >(ResourceUrl, paging)); }
/// <summary> /// GET api/Agendas /// List of agendas. /// </summary> public RowsResultWrapper <Agenda> Agendas(ApiFilter filter = null) { return(Get <RowsResultWrapper <Agenda> >(ResourceUrl, filter)); }
/// <summary> /// This will add child filter entries for each tree node where the /// checked state matches the given state. /// </summary> /// <param name="filter">The filter to which the entries are added</param> /// <param name="nodes">The tree nodes to scan</param> /// <param name="state">The check state to match</param> private void AddChildFilter(ApiFilter filter, TreeNodeCollection nodes, bool state) { ApiFilter childFilter; NodeInfo nodeInfo; string parentId; int idx; foreach(TreeNode node in nodes) { if(this.AllChildrenMatchParentCheckState(node.Nodes, node.Checked)) { // We only need to add a filter in this case if the // node state matches the given state or if it's a nested // class with a state different than the parent class. idx = node.Text.LastIndexOf('.'); if(idx != -1) parentId = node.Text.Substring(0, idx); else parentId = null; if(node.Checked == state || (parentId != null && filter.Children.Any(f => f.FilterName == parentId && f.IsExposed != node.Checked))) { nodeInfo = (NodeInfo)node.Tag; childFilter = new ApiFilter(nodeInfo.EntryType, nodeInfo.Id, node.Checked); // Override the filter name if necessary if(!String.IsNullOrEmpty(nodeInfo.FilterName)) childFilter.FilterName = nodeInfo.FilterName; filter.Children.Add(childFilter); } } else { nodeInfo = (NodeInfo)node.Tag; childFilter = new ApiFilter(nodeInfo.EntryType, nodeInfo.Id, node.Checked); // Override the filter name if necessary if(!String.IsNullOrEmpty(nodeInfo.FilterName)) childFilter.FilterName = nodeInfo.FilterName; filter.Children.Add(childFilter); // Add child filters that match the opposite state of // the parent node. this.AddChildFilter(childFilter, node.Nodes, !node.Checked); } } }
//===================================================================== /// <summary> /// This is used to generate the API filter collection used by MRefBuilder to exclude items from the /// reflection information file. /// </summary> /// <remarks>Namespaces and members with an <c><exclude /></c> tag in their comments are removed /// using the ripping feature as it is more efficient than searching for and removing them from the /// reflection file after it has been generated especially on large projects.</remarks> private void GenerateApiFilter() { XmlNodeList excludes; XmlNode docMember; List <string> ripList; string nameSpace, memberName, typeName, fullName; int pos; this.ReportProgress(BuildStep.GenerateApiFilter, "Generating API filter for MRefBuilder..."); if (this.ExecutePlugIns(ExecutionBehaviors.InsteadOf)) { return; } this.ExecutePlugIns(ExecutionBehaviors.Before); ripList = new List <string>(); // Add excluded namespaces foreach (NamespaceSummaryItem ns in project.NamespaceSummaries) { if (!ns.IsDocumented && !ns.IsGroup) { memberName = ns.Name; if (memberName[0] == '(') { memberName = "N:"; // Global namespace } else { memberName = "N:" + memberName; } ripList.Add(memberName); } } // If the namespace summaries don't contain an explicit entry for the global namespace, exclude it // by default. if (project.NamespaceSummaries[null] == null) { ripList.Add("N:"); } // Add members excluded via comments foreach (XmlCommentsFile comments in commentsFiles) { excludes = comments.Members.SelectNodes("//exclude/.."); foreach (XmlNode member in excludes) { // It should appear at the same level as <summary> so that we can find the member name in the // parent node. if (member.Attributes["name"] == null) { this.ReportProgress(" Incorrect placement of <exclude/> tag. Unable to locate " + "member name."); continue; } memberName = member.Attributes["name"].Value; if (!ripList.Contains(memberName)) { ripList.Add(memberName); } } } // Sort by entry type and name so that we create the collection from the namespace down to the // members. ripList.Sort((x, y) => { ApiEntryType xType = ApiFilter.ApiEntryTypeFromLetter(x[0]), yType = ApiFilter.ApiEntryTypeFromLetter(y[0]); if (xType == yType) { return(String.Compare(x, y, StringComparison.Ordinal)); } return((int)xType - (int)yType); }); // Get the project's API filter and merge the members from the rip list var apiFilter = project.ApiFilter; // For the API filter to work, we have to nest the entries by namespace, type, and member. As such, // we have to break apart what we've got in the list and merge it with the stuff the user may have // specified using the project's API filter property. foreach (string member in ripList) { // Namespaces are easy if (member[0] == 'N') { if (!apiFilter.MergeExclusionEntry(ApiEntryType.Namespace, member.Substring(2))) { this.ReportWarning("BE0008", "Namespace '{0}' excluded via namespace comments " + "conflicted with API filter setting. Exclusion ignored.", member); } continue; } // Types and members are a bit tricky. Since we don't have any real context, we have to assume // that we can remove the last part and look it up. If a type entry isn't found, we can assume // it's the namespace. Where this can fail is on a nested class where the parent class is // lacking XML comments. Not much we can do about it in that case. if (member[0] == 'T') { fullName = nameSpace = member; typeName = member.Substring(2); memberName = null; } else { // Strip parameters. The ripping feature only goes to the name level. If one overload is // ripped, they are all ripped. pos = member.IndexOf('('); if (pos != -1) { fullName = memberName = member.Substring(0, pos); } else { fullName = memberName = member; } // Generic method pos = memberName.IndexOf("``", StringComparison.Ordinal); if (pos != -1) { memberName = memberName.Substring(0, pos); } pos = memberName.LastIndexOf('.'); memberName = memberName.Substring(pos + 1); typeName = fullName.Substring(2, pos - 2); nameSpace = "T:" + typeName; } for (int idx = 0; idx < commentsFiles.Count; idx++) { docMember = commentsFiles[idx].Members.SelectSingleNode("member[@name='" + nameSpace + "']"); if (docMember != null) { pos = nameSpace.LastIndexOf('.'); if (pos == -1) { nameSpace = "N:"; break; } else { nameSpace = nameSpace.Substring(0, pos); } idx = -1; } } nameSpace = nameSpace.Substring(2); // If the names still match, we probably didn't find comments for the type so assume the // namespace is the part up to the last period. if (nameSpace == typeName) { pos = nameSpace.LastIndexOf('.'); if (pos != -1) { nameSpace = nameSpace.Substring(0, pos); } else { nameSpace = "N:"; // Global namespace } } if (apiFilter.AddNamespaceChild(fullName, nameSpace, typeName, memberName)) { if (fullName.Length > 2) { // If it's a nested class, adjust the filter name fullName = typeName; typeName = typeName.Substring(nameSpace.Length + 1); if (typeName.IndexOf('.') != -1) { foreach (ApiFilter ns in apiFilter) { if (ns.FullName == nameSpace) { foreach (ApiFilter t in ns.Children) { if (t.FullName == fullName) { t.FilterName = typeName; break; } } break; } } } } } else { this.ReportWarning("BE0009", "'{0}' is marked with <exclude /> but conflicted with the " + "API filter setting. Exclusion ignored.", member); } } this.ExecutePlugIns(ExecutionBehaviors.After); }