last works on Event Service ...
This commit is contained in:
@@ -71,7 +71,7 @@ namespace xEventService.Extensions
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.Exchange.IsNullOrEmpty() &&
|
||||
!source.ExchangeType.IsValid();
|
||||
source.ExchangeType.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -110,7 +110,37 @@ namespace xEventService.Extensions
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Validate ZeroMQ Pattern ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this XZeroMQPattern source)
|
||||
{
|
||||
//
|
||||
var result = source != XZeroMQPattern.None;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate ZeroMQ Options ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this XZeroMQOptions source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
source.Pattern.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate an Array is Wildcard passed or not ...
|
||||
/// </summary>
|
||||
@@ -122,9 +152,9 @@ namespace xEventService.Extensions
|
||||
var result =
|
||||
source is not null &&
|
||||
source.Length == 1 &&
|
||||
source.Any(s =>
|
||||
source.Any(s =>
|
||||
s == XEventServiceConstants.XWildcard);
|
||||
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -145,6 +175,101 @@ namespace xEventService.Extensions
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Sender ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="allowedSenders"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValidSender(
|
||||
this XEventMessage source,
|
||||
string[] allowedSenders
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Source and Collection ...
|
||||
var result =
|
||||
source.IsValid() &&
|
||||
allowedSenders
|
||||
.IsAllowedCollection();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Sender ...
|
||||
result =
|
||||
allowedSenders.IsAllowedWildcard() ||
|
||||
allowedSenders.Any(x =>
|
||||
x.Equals(
|
||||
source.Sender,
|
||||
System.StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Action ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="allowedActions"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValidAction(
|
||||
this XEventMessage source,
|
||||
string[] allowedActions
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Source and Collection ...
|
||||
var result =
|
||||
source.IsValid() &&
|
||||
allowedActions
|
||||
.IsAllowedCollection();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Action ...
|
||||
result =
|
||||
allowedActions.IsAllowedWildcard() ||
|
||||
allowedActions.Any(x =>
|
||||
x.Equals(
|
||||
source.Action,
|
||||
System.StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Completely Validate a Message, based on providing:
|
||||
/// - Allowed Actions
|
||||
/// - Allowed Senders
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="allowedSenders"></param>
|
||||
/// <param name="allowedActions"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(
|
||||
this XEventMessage source,
|
||||
string[] allowedSenders,
|
||||
string[] allowedActions
|
||||
)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
source.IsValid() &&
|
||||
source.IsValidAction(allowedActions) &&
|
||||
source.IsValidSender(allowedSenders);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse Url and Extract Host address ...
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user