public void Assert(IQueryResults queryResult) { var matchingCallsInOrder = queryResult .MatchingCallsInOrder() .Where(x => IsNotPropertyGetterCall(x.GetMethodInfo())) .ToArray(); var querySpec = queryResult .QuerySpecification() .Where(x => IsNotPropertyGetterCall(x.CallSpecification.GetMethodInfo())) .ToArray(); if (matchingCallsInOrder.Length != querySpec.Length) { throw new CallSequenceNotFoundException(GetExceptionMessage(querySpec, matchingCallsInOrder)); } var callsAndSpecs = matchingCallsInOrder .Zip(querySpec, (call, specAndTarget) => new { Call = call, Spec = specAndTarget.CallSpecification, IsMatch = Matches(call, specAndTarget) } ); if (callsAndSpecs.Any(x => !x.IsMatch)) { throw new CallSequenceNotFoundException(GetExceptionMessage(querySpec, matchingCallsInOrder)); } }
private CallSpecAndTarget[] QuerySpecificationFrom(IQueryResults queryResult) { return (queryResult.QuerySpecification() .Where(x => this.IsNotPropertyGetterCall(x.CallSpecification.GetMethodInfo())) .ToArray()); }
///<summary>Sets the Query results handler for this context and object type</summary> ///<param name="qr"></param> ///<param name="objectType"></param> ///<param name="options"></param> public void setQueryResults( IQueryResults qr, IElementDef objectType, QueryResultsOptions options) { SetHandler(fQueryResults, qr, objectType, options); }
private CallSpecAndTarget[] QuerySpecificationFrom(IQueryResults queryResult) { return (queryResult.QuerySpecification() .Where(x => _queryFilter.ShouldVerify(x.CallSpecification.GetMethodInfo())) .ToArray()); }
public void SetQueryResults(IQueryResults queryResults, IElementDef objectType, QueryResultsOptions options) { if (options == null) { options = new QueryResultsOptions(); } foreach (SifContext context in options.SupportedContexts) { GetOrCreateContextMatrix(context).setQueryResults(queryResults, objectType, options); } }
/// <summary> /// Gets the global QueryResults message handler registered with the Agent for the specified SIF object type. /// </summary> /// <param name="context">The SIF context to look up the QueryResults handler for. /// The default implementation of Agent only returns handlers for /// SIFContext.DEFAULT</param> /// <param name="objectType">The QueryResults object registered for this object type by the /// agent when it called the <code>setQueryResults</code> method, or /// <code>null</code> if no QueryResults object has been registered /// for the specified object type.</param> /// <returns></returns> public virtual IQueryResults GetQueryResults(SifContext context, IElementDef objectType) { IQueryResults q = null; if (SifContext.DEFAULT.Equals(context)) { q = (IQueryResults)fQueryResults[objectType]; if (q == null) { q = (IQueryResults)fQueryResults[SifDtd.SIF_MESSAGE]; } } return(q); }
public void Assert(IQueryResults queryResult) { var querySpec = QuerySpecificationFrom(queryResult); var allReceivedCalls = AllCallsExceptPropertyGettersReceivedByTargetsOf(querySpec); var callsSpecifiedButNotReceived = GetCallsExpectedButNoReceived(querySpec, allReceivedCalls); var callsReceivedButNotSpecified = GetCallsReceivedButNotExpected(querySpec, allReceivedCalls); if (callsSpecifiedButNotReceived.Any() || callsReceivedButNotSpecified.Any()) { throw new CallSequenceNotFoundException(ExceptionMessage.For(querySpec, allReceivedCalls, callsSpecifiedButNotReceived, callsReceivedButNotSpecified, _queryFilter)); } }
private static void LogQuery(string query, TwitterAPIEndpoint endpoint, IQueryResults results) { QueryHistory.Get[endpoint].LastQuery = query; if (QueryInfo.UsesMaxID(endpoint)) { TweetSearchResults statusResults = results as TweetSearchResults; // Exclude lowest ID to prevent duplicate results string nextMaxID = (long.TryParse(statusResults.MinStatusID, out long result)) ? (result - 1).ToString() : ""; QueryHistory.Get[endpoint].NextMaxID = nextMaxID; } if (QueryInfo.UsesCursor(endpoint)) { UserIdsResults idResults = results as UserIdsResults; QueryHistory.Get[endpoint].NextCursor = idResults.NextCursorStr; } }
public void SetQueryResults(IQueryResults results, QueryResultsOptions flags) { assertProvisioningOptions(flags); if (results == null) { fQueryResults = null; fQueryResultsOptions = null; } else { fQueryResults = results; if (flags == null) { flags = new QueryResultsOptions(); } fQueryResultsOptions = flags; } }
/// <summary> Register a global IQueryResults message handler object with this /// agent for the specified SIF object type in the default SIF Context /// /// Note agents typically register message handlers with Topics or with /// Zones instead of with the Agent. The message fDispatcher first /// delivers messages to Topics, then to Zones, and finally to the Agent /// itself. /// /// </summary> /// <param name="queryResults">An object that implements the <c>IQueryResults</c> /// interface to respond to SIF_Response query results received by the agent, /// where the SIF object type referenced by the request matches the /// specified objectType. This IQueryResults object will be called whenever /// a SIF_Response is received and no other object in the message /// dispatching chain has processed the message. /// /// </param> /// <param name="objectType">A constant from the SifDtd class that identifies the /// type of SIF Data Object this IQueryResults message handler will /// respond to. /// </param> public virtual void SetQueryResults(IQueryResults queryResults, IElementDef objectType) { if (queryResults == null) { AdkUtils._throw (new ArgumentException("IQueryResults object cannot be null"), GetLog()); } if (objectType == null) { fQueryResults[SifDtd.SIF_MESSAGE] = queryResults; } else { fQueryResults[objectType] = queryResults; } }
public void Assert(IQueryResults queryResult) { var array1 = queryResult.MatchingCallsInOrder().Where(x => _queryFilter.ShouldVerify(x.GetMethodInfo())).ToArray(); var array2 = queryResult.QuerySpecification().Where(x => _queryFilter.ShouldVerify(x.CallSpecification.GetMethodInfo())).ToArray(); if (array1.Length != array2.Length) { throw new CallSequenceNotFoundException(GetExceptionMessage(array2, array1)); } if (array1.Zip(array2, (call, specAndTarget) => new { Call = call, Spec = specAndTarget.CallSpecification, IsMatch = Matches(call, specAndTarget) }).Any(x => !x.IsMatch)) { throw new CallSequenceNotFoundException(GetExceptionMessage(array2, array1)); } }
public void Assert(IQueryResults queryResult) { var matchingCallsInOrder = queryResult.MatchingCallsInOrder().ToArray(); var querySpec = queryResult.QuerySpecification().ToArray(); if (matchingCallsInOrder.Length != querySpec.Length) { throw new CallSequenceNotFoundException(); } var callsAndSpecs = matchingCallsInOrder .Zip(querySpec, (call, specAndTarget) => new { Call = call, Spec = specAndTarget.CallSpecification, IsMatch = Matches(call, specAndTarget) } ); if (callsAndSpecs.Any(x => !x.IsMatch)) { throw new CallSequenceNotFoundException(); } }
private async Task AddContentItemsAsync(NavigationBuilder listTypeMenu, IQueryResults queryResults, Enums.LinkMode nodeLinkMode) { foreach (var ci in queryResults.Items)// first level children await getContentItemsAsync()) { if (ci is ContentItem contentItem) { var cim = await _contentManager.PopulateAspectAsync <ContentItemMetadata>(contentItem); switch (nodeLinkMode) { case Enums.LinkMode.Admin: if (cim.AdminRouteValues.Any() && contentItem.DisplayText != null) { listTypeMenu.Add(new LocalizedString(contentItem.DisplayText, contentItem.DisplayText), m => { m.Action(cim.AdminRouteValues["Action"] as string, cim.AdminRouteValues["Controller"] as string, cim.AdminRouteValues); m.Resource(ci); m.Priority(_node.Priority); m.Position(_node.Position); m.LocalNav(); AddPrefixToClasses(_node.IconForContentItems).ToList().ForEach(c => m.AddClass(c)); //todo // m.Permission(ContentTypePermissions.CreateDynamicPermission( // ContentTypePermissions.PermissionTemplates[Contents.Permissions.EditContent.Name], _contentType)); m.AdminNodeProvider(nameof(QueryAdminNode)); }); } break; case Enums.LinkMode.Display: if (cim.DisplayRouteValues.Any() && contentItem.DisplayText != null) { listTypeMenu.Add(new LocalizedString(contentItem.DisplayText, contentItem.DisplayText), m => { m.Action(cim.DisplayRouteValues["Action"] as string, cim.DisplayRouteValues["Controller"] as string, cim.DisplayRouteValues); m.Resource(ci); m.Priority(_node.Priority); m.Position(_node.Position); m.LocalNav(); AddPrefixToClasses(_node.IconForContentItems).ToList().ForEach(c => m.AddClass(c)); //todo // m.Permission(ContentTypePermissions.CreateDynamicPermission( // ContentTypePermissions.PermissionTemplates[Contents.Permissions.EditContent.Name], _contentType)); }); } break; case Enums.LinkMode.Edit: if (cim.EditorRouteValues.Any() && contentItem.DisplayText != null) { listTypeMenu.Add(new LocalizedString(contentItem.DisplayText, contentItem.DisplayText), m => { m.Action(cim.EditorRouteValues["Action"] as string, cim.EditorRouteValues["Controller"] as string, cim.EditorRouteValues); m.Resource(ci); m.Priority(_node.Priority); m.Position(_node.Position); m.LocalNav(); AddPrefixToClasses(_node.IconForContentItems).ToList().ForEach(c => m.AddClass(c)); //todo // m.Permission(ContentTypePermissions.CreateDynamicPermission( // ContentTypePermissions.PermissionTemplates[Contents.Permissions.EditContent.Name], _contentType)); }); } break; case Enums.LinkMode.Create: if (cim.CreateRouteValues.Any() && contentItem.DisplayText != null) { listTypeMenu.Add(new LocalizedString(contentItem.DisplayText, contentItem.DisplayText), m => { m.Action(cim.CreateRouteValues["Action"] as string, cim.CreateRouteValues["Controller"] as string, cim.CreateRouteValues); m.Resource(ci); m.Priority(_node.Priority); m.Position(_node.Position); m.LocalNav(); AddPrefixToClasses(_node.IconForContentItems).ToList().ForEach(c => m.AddClass(c)); //todo // m.Permission(ContentTypePermissions.CreateDynamicPermission( // ContentTypePermissions.PermissionTemplates[Contents.Permissions.EditContent.Name], _contentType)); }); } break; default: throw new ArgumentOutOfRangeException(nameof(nodeLinkMode), nodeLinkMode, null); } } } }
/// <summary> Register a global IQueryResults message handler object with this /// agent for the specified SIF object type in the default SIF Context /// /// Note agents typically register message handlers with Topics or with /// Zones instead of with the Agent. The message fDispatcher first /// delivers messages to Topics, then to Zones, and finally to the Agent /// itself. /// /// </summary> /// <param name="queryResults">An object that implements the <c>IQueryResults</c> /// interface to respond to SIF_Response query results received by the agent, /// where the SIF object type referenced by the request matches the /// specified objectType. This IQueryResults object will be called whenever /// a SIF_Response is received and no other object in the message /// dispatching chain has processed the message. /// /// </param> /// <param name="objectType">A constant from the SifDtd class that identifies the /// type of SIF Data Object this IQueryResults message handler will /// respond to. /// </param> public virtual void SetQueryResults( IQueryResults queryResults, IElementDef objectType ) { if ( queryResults == null ) { AdkUtils._throw ( new ArgumentException( "IQueryResults object cannot be null" ), GetLog() ); } if ( objectType == null ) { fQueryResults[SifDtd.SIF_MESSAGE] = queryResults; } else { fQueryResults[objectType] = queryResults; } }
/// <summary> /// Register a QueryResults object with this zone for the specified SIF object type. /// </summary> /// <param name="queryResults"> /// An object that implements the <code>QueryResults</code> /// interface to respond to SIF_Response query results received by the agent, /// where the SIF object type referenced by the request matches the /// specified objectType. This QueryResults object will be called whenever /// a SIF_Response is received on this zone and no other object in the /// message dispatching chain has processed the message. ///</param> ///<param name="objectType"> /// A constant from the SIFDTD class that identifies a /// SIF Data Object type. /// </param> public void SetQueryResults(IQueryResults queryResults, IElementDef objectType) { throw new NotImplementedException(); }
void IProvisioner.SetQueryResults(IQueryResults queryResults, IElementDef objectType, QueryResultsOptions flags) { // TODO: Add TestZone.SetQueryResults implementation }
void IProvisioner.SetQueryResults(IQueryResults queryResults) { // TODO: Add TestZone.OpenADK.Library.IZone.SetQueryResults implementation }
public void SetQueryResults(IQueryResults queryResults, IElementDef objectType) { SetQueryResults(queryResults, objectType, null); }
///<summary> /// <see cref="OpenADK.Library.IProvisioner.SetQueryResults(IQueryResults)"/> ///</summary> public void SetQueryResults(IQueryResults queryResults) { SetQueryResults(queryResults, null); }
public void SetQueryResults(IQueryResults results ) { SetQueryResults( results, null ); }
public void SetQueryResults(IQueryResults results) { SetQueryResults(results, null); }
public void SetQueryResults(IQueryResults results, QueryResultsOptions flags) { assertProvisioningOptions(flags); if (results == null) { fQueryResults = null; fQueryResultsOptions = null; } else { fQueryResults = results; if (flags == null){ flags = new QueryResultsOptions(); } fQueryResultsOptions = flags; } }
/// <summary> Register a global IQueryResults message handler with this agent for all SIF object types. /// /// Note agents typically register message handlers with Topics or with /// Zones instead of with the Agent. The message fDispatcher first /// delivers messages to Topics, then to Zones, and finally to the Agent /// itself. /// /// </summary> /// <param name="IQueryResults">An object that implements the <c>IQueryResults</c> /// interface to respond to SIF_Response query results received by the /// agent. This object will be called whenever a SIF_Response is received /// and no other object in the message dispatching chain has processed /// the message. /// </param> public virtual void SetQueryResults(IQueryResults IQueryResults) { SetQueryResults(IQueryResults, null); }
/// <summary> Register a global IQueryResults message handler with this agent for all SIF object types. /// /// Note agents typically register message handlers with Topics or with /// Zones instead of with the Agent. The message fDispatcher first /// delivers messages to Topics, then to Zones, and finally to the Agent /// itself. /// /// </summary> /// <param name="IQueryResults">An object that implements the <c>IQueryResults</c> /// interface to respond to SIF_Response query results received by the /// agent. This object will be called whenever a SIF_Response is received /// and no other object in the message dispatching chain has processed /// the message. /// </param> public virtual void SetQueryResults( IQueryResults IQueryResults ) { SetQueryResults( IQueryResults, null ); }