Skip to content

Commit

Permalink
Better filtering options.
Browse files Browse the repository at this point in the history
  • Loading branch information
janno-p committed Feb 15, 2018
1 parent 061c6c9 commit a2a3e22
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#### 1.1.2 - 15.02.2018

* Allow operation filter to override visibility of operations hidden by schema exporter.

#### 1.1.1 - 15.02.2018

* `MergeContentAttribute` should be usable on fields, parameters and return values.
Expand Down
4 changes: 2 additions & 2 deletions src/XRoadLib/IServiceManager.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Web.Services.Description;
using System.Xml;
using System.Xml.Linq;
using XRoadLib.Headers;
using XRoadLib.Schema;
using XRoadLib.Serialization;
using XRoadLib.Styles;

Expand Down Expand Up @@ -57,6 +57,6 @@ public interface IServiceManager
/// <param name="operationFilter">Allows to filter out unwanted operations which should not appear in service description.</param>
/// <param name="version">Global DTO version of wanted service description.</param>
/// <returns>Service description instance of current schema definition.</returns>
ServiceDescription CreateServiceDescription(Func<XName, bool> operationFilter = null, uint? version = null);
ServiceDescription CreateServiceDescription(Func<OperationDefinition, bool> operationFilter = null, uint? version = null);
}
}
9 changes: 4 additions & 5 deletions src/XRoadLib/ServiceDescriptionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public sealed class ServiceDescriptionBuilder
{
private readonly SchemaDefinitionProvider schemaDefinitionProvider;
private readonly uint? version;
private readonly Func<XName, bool> operationFilter;
private readonly Func<OperationDefinition, bool> operationFilter;

private readonly Binding binding;
private readonly PortType portType;
Expand Down Expand Up @@ -60,10 +60,10 @@ public sealed class ServiceDescriptionBuilder
/// <param name="operationFilter">Allows to filter operations which are presented in service description.</param>
/// <param name="version">Global version for service description (when versioning entire schema and operations using same version number).</param>
/// </summary>
public ServiceDescriptionBuilder(SchemaDefinitionProvider schemaDefinitionProvider, Func<XName, bool> operationFilter = null, uint? version = null)
public ServiceDescriptionBuilder(SchemaDefinitionProvider schemaDefinitionProvider, Func<OperationDefinition, bool> operationFilter = null, uint? version = null)
{
this.schemaDefinitionProvider = schemaDefinitionProvider ?? throw new ArgumentNullException(nameof(schemaDefinitionProvider));
this.operationFilter = operationFilter ?? (name => true);
this.operationFilter = operationFilter;
this.version = version;

portType = new PortType { Name = "PortTypeName" };
Expand Down Expand Up @@ -191,8 +191,7 @@ private IEnumerable<OperationDefinition> GetOperationDefinitions(string targetNa
.SelectMany(x => x.Value
.Where(op => !version.HasValue || op.ExistsInVersion(version.Value))
.Select(op => schemaDefinitionProvider.GetOperationDefinition(x.Key, XName.Get(op.Name, targetNamespace), version)))
.Where(def => operationFilter(def.Name))
.Where(def => def.State == DefinitionState.Default)
.Where(operationFilter ?? (def => def.State == DefinitionState.Default))
.OrderBy(def => def.Name.LocalName.ToLower())
.ToList();
}
Expand Down
2 changes: 1 addition & 1 deletion src/XRoadLib/ServiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public virtual TResult Execute<TResult>(WebRequest webRequest, object body, THea
}

/// <inheritdoc />
public virtual ServiceDescription CreateServiceDescription(Func<XName, bool> operationFilter = null, uint? version = null)
public virtual ServiceDescription CreateServiceDescription(Func<OperationDefinition, bool> operationFilter = null, uint? version = null)
{
if (!version.HasValue && ProtocolDefinition.SupportedVersions.Any())
throw new ArgumentNullException(nameof(version), "Version value is required to generate service description.");
Expand Down

0 comments on commit a2a3e22

Please sign in to comment.