本文整理汇总了C#中SearchClient类的典型用法代码示例。如果您正苦于以下问题:C# SearchClient类的具体用法?C# SearchClient怎么用?C# SearchClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchClient类属于命名空间,在下文中一共展示了SearchClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestsTheCorrectUrl
public void RequestsTheCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
client.SearchUsers(new SearchUsersRequest("something"));
connection.Received().Get<SearchUsersResult>(Arg.Is<Uri>(u => u.ToString() == "search/users"), Arg.Any<Dictionary<string, string>>());
}
示例2: RequestsTheCorrectUrl
public void RequestsTheCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
client.SearchRepo(new SearchRepositoriesRequest("something"));
connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"), Arg.Any<Dictionary<string, string>>());
}
示例3: BuildClient
/// <summary>
/// Build and initialize an IdmNet Client object ready for use
/// </summary>
/// <returns>Newly initialized IdmNet Client</returns>
public static IdmNetClient BuildClient()
{
var soapBinding = new IdmSoapBinding();
string fqdn = GetEnvironmentSetting("MIM_fqdn");
var endpointIdentity = EndpointIdentity.CreateSpnIdentity("FIMSERVICE/" + fqdn);
var enumerationPath = "http://" + fqdn + SoapConstants.EnumeratePortAndPath;
var factoryPath = "http://" + fqdn + SoapConstants.FactoryPortAndPath;
var resourcePath = "http://" + fqdn + SoapConstants.ResourcePortAndPath;
var enumerationEndpoint = new EndpointAddress(new Uri(enumerationPath), endpointIdentity);
var factoryEndpoint = new EndpointAddress(new Uri(factoryPath), endpointIdentity);
var resourceEndpoint = new EndpointAddress(new Uri(resourcePath), endpointIdentity);
var searchClient = new SearchClient(soapBinding, enumerationEndpoint);
var factoryClient = new ResourceFactoryClient(soapBinding, factoryEndpoint);
var resourceClient = new ResourceClient(soapBinding, resourceEndpoint);
var credentials = new NetworkCredential(
GetEnvironmentSetting("MIM_username"),
GetEnvironmentSetting("MIM_pwd"),
GetEnvironmentSetting("MIM_domain"));
searchClient.ClientCredentials.Windows.ClientCredential = credentials;
factoryClient.ClientCredentials.Windows.ClientCredential = credentials;
resourceClient.ClientCredentials.Windows.ClientCredential = credentials;
var it = new IdmNetClient(searchClient, factoryClient, resourceClient);
return it;
}
示例4: TestingTheTermParameter
public void TestingTheTermParameter()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
var request = new SearchUsersRequest("github");
client.SearchUsers(request);
connection.Received().Get<SearchUsersResult>(
Arg.Is<Uri>(u => u.ToString() == "search/users"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github"));
}
示例5: TestingTheAccountTypeQualifier_Org
public void TestingTheAccountTypeQualifier_Org()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
var request = new SearchUsersRequest("github");
request.AccountType = AccountType.Org;
client.SearchUsers(request);
connection.Received().Get<SearchUsersResult>(
Arg.Is<Uri>(u => u.ToString() == "search/users"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+type:Org"));
}
示例6: RefreshFromConnection
public override ElasticResponse RefreshFromConnection(SearchClient cli)
{
var rawAliases = cli.GetAliases();
if (rawAliases.HasData)
{
var result = rawAliases.Data.Where(a => a.Value?.Aliases != null && a.Value.Aliases.Count > 0).ToDictionary(a => a.Key, a => a.Value.Aliases.Keys.ToList());
Aliases = result;
}
return rawAliases;
}
示例7: TestingTheStarsQualifier
public void TestingTheStarsQualifier()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
//get repos whos stargazers are greater than 500
var request = new SearchRepositoriesRequest("github");
request.Stars = Range.GreaterThan(500);
client.SearchRepo(request);
connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"), Arg.Any<Dictionary<string, string>>());
}
示例8: TestingTheInQualifier
public void TestingTheInQualifier()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
//get users where the fullname contains 'github'
var request = new SearchUsersRequest("github");
request.In = new[] { UserInQualifier.Fullname };
client.SearchUsers(request);
connection.Received().Get<SearchUsersResult>(
Arg.Is<Uri>(u => u.ToString() == "search/users"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+in:Fullname"));
}
示例9: RefreshFromConnection
public override ElasticResponse RefreshFromConnection(SearchClient cli)
{
var rawHealth = cli.GetClusterHealth();
if (rawHealth.HasData)
{
var health = rawHealth.Data;
Name = health.ClusterName;
TotalNodeCount = health.NumberOfNodes;
DataNodeCount = health.NumberOfDataNodes;
ActiveShards = health.ActiveShards;
ActivePrimaryShards = health.ActivePrimaryShards;
InitializingShards = health.InitializingShards;
RelocatingShards = health.RelocatingShards;
UnassignedShards = health.UnassignedShards;
StringStatus = health.Status;
Indices = health.Indices.Select(i => new NodeIndexInfo
{
Name = i.Key,
StringStatus = i.Value.Status,
NumberOfShards = i.Value.NumberOfShards,
NumberOfReplicas = i.Value.NumberOfReplicas,
ActiveShards = i.Value.ActiveShards,
ActivePrimaryShards = i.Value.ActivePrimaryShards,
InitializingShards = i.Value.InitializingShards,
RelocatingShards = i.Value.RelocatingShards,
UnassignedShards = i.Value.UnassignedShards,
Shards = i.Value.Shards.Select(s => new NodeIndexShardInfo
{
Name = s.Key,
StringStatus = s.Value.Status,
PrimaryActive = s.Value.PrimaryActive,
ActiveShards = s.Value.ActiveShards,
InitializingShards = s.Value.InitializingShards,
RelocatingShards = s.Value.RelocatingShards,
UnassignedShards = s.Value.UnassignedShards
}).ToList()
}).OrderBy(i =>
{
int j;
return int.TryParse(i.Name, out j) ? j : 0;
}).ToList();
}
else
{
Indices = new List<NodeIndexInfo>();
}
return rawHealth;
}
示例10: RefreshFromConnection
public override ElasticResponse RefreshFromConnection(SearchClient cli)
{
var infos = cli.GetClusterNodeInfo().Data;
Name = infos.ClusterName;
if (infos.Nodes != null)
{
Nodes = infos.Nodes.Select(node => new NodeInfoWrap
{
GUID = node.Key,
Name = node.Value.Name,
Hostname = node.Value.Hostname,
VersionString = node.Value.Version,
BuildString = node.Value.Build,
Attributes = node.Value.Attributes,
Info = node.Value,
}).OrderBy(node => node.Name).ToList();
}
var rawStats = cli.GetClusterNodeStats();
var stats = rawStats.Data;
if (stats != null)
{
Name = stats.ClusterName;
if (stats.Nodes != null)
{
foreach (var ns in stats.Nodes)
{
var ni = Nodes.FirstOrDefault(n => n.GUID == ns.Key);
if (ni != null)
{
ni.Stats = ns.Value;
}
else
{
Nodes.Add(new NodeInfoWrap
{
GUID = ns.Key,
Name = ns.Value.Name,
Hostname = ns.Value.Hostname,
Stats = ns.Value
});
}
}
Nodes = Nodes.OrderBy(n => n.Name).ToList();
}
}
return rawStats;
}
示例11: RefreshFromConnection
public override ElasticResponse RefreshFromConnection(SearchClient cli)
{
var rawAliases = cli.GetAliases();
if (rawAliases.HasData)
{
var result = new Dictionary<string, List<string>>();
foreach (var a in rawAliases.Data)
{
if (a.Value != null && a.Value.Aliases != null && a.Value.Aliases.Count > 0)
result.Add(a.Key, a.Value.Aliases.Keys.ToList());
}
Aliases = result;
}
return rawAliases;
}
示例12: RefreshFromConnection
public override ElasticResponse RefreshFromConnection(SearchClient cli)
{
var rawState = cli.GetClusterState();
if (rawState.HasData)
{
var state = rawState.Data;
ClusterName = state.ClusterName;
MasterNode = state.MasterNode;
Nodes = state.Nodes;
RoutingNodes = state.RoutingNodes;
if (state.RoutingTable != null)
RoutingIndices = state.RoutingTable.Indices;
}
return rawState;
}
示例13: PopulateFromConnections
public void PopulateFromConnections(SearchClient client)
{
var response = RefreshFromConnection(client);
// Some implementations are raw
if (response?.Exception == null) return;
string lastErrorMessage = response.Exception.Message;
Exception lastException = response.Exception;
// Failed to poll all nodes
if (lastErrorMessage.HasValue())
{
throw new Exception($"Failed to poll all elastic nodes for {GetType().Name}: {lastErrorMessage}", lastException);
}
throw new Exception($"Failed to poll all elastic nodes for {GetType().Name}");
}
示例14: RefreshFromConnection
public override ElasticResponse RefreshFromConnection(SearchClient cli)
{
var health = cli.GetIndexStats();
if (health.HasData)
{
GlobalStats = health.Data.All;
Shards = health.Data.Shards;
Indices = health.Data.Indices;
}
else
{
GlobalStats = new IndexStats();
Shards = new ShardCountStats();
Indices = new Dictionary<string, IndexStats>();
}
return health;
}
示例15: TestingTheCommentsQualifier_Range
public void TestingTheCommentsQualifier_Range()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
var request = new SearchIssuesRequest("something");
request.Comments = new Range(10, 20);
client.SearchIssues(request);
connection.Received().Get<SearchIssuesResult>(
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+comments:10..20"));
}