IQueryCast
IQueryCast indicates that query is a type-cast of an underlying query.
/// <summary>Indicates that the query is a type-casts decoration, and decorates no other aspect of the source.</summary>
public interface IQueryCast : IQueryDecoration { }
.Cast<Request, Response>() type-casts query to other parameters.
// Type-cast generic type parameters
IQuery<object, object> queryOO = query.Cast<object, object>();
.Cast(type) type-casts query to other parameters with run-time type.
// Type-cast generic type parameters
IQuery<object, object> query2 = (IQuery<object, object>)query.Cast(typeof(object), typeof(object));
Full Example
Full example
using System.Collections.Generic;
using Avalanche.Service;
public class query_cast
{
public static void Run()
{
{
// Create service
IService service = Services.Create(ServiceHandlers.Instance);
// Create request
string request = "Request";
// Create response
IEntry<string> entry = new Entry<string>();
// Create query
IQuery<string, string> query = new Query<string, string>(
service: service,
context: new Dictionary<string, object>(),
cancelToken: default,
request: request,
response: entry);
// <01>
// Type-cast generic type parameters
IQuery<object, object> queryOO = query.Cast<object, object>();
// </01>
// <02>
// Type-cast generic type parameters
IQuery<object, object> query2 = (IQuery<object, object>)query.Cast(typeof(object), typeof(object));
// </02>
}
}
}