本文整理汇总了C#中IConnection类的典型用法代码示例。如果您正苦于以下问题:C# IConnection类的具体用法?C# IConnection怎么用?C# IConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IConnection类属于命名空间,在下文中一共展示了IConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StratumMiner
/// <summary>
/// Creates a new miner instance.
/// </summary>
/// <param name="id"></param>
/// <param name="extraNonce"></param>
/// <param name="connection"></param>
/// <param name="pool"></param>
/// <param name="minerManager"></param>
/// <param name="storageLayer"></param>
public StratumMiner(int id, UInt32 extraNonce, IConnection connection, IPool pool, IMinerManager minerManager, IStorageLayer storageLayer)
{
Id = id; // the id of the miner.
ExtraNonce = extraNonce;
Connection = connection; // the underlying connection.
Pool = pool;
_minerManager = minerManager;
_storageLayer = storageLayer;
Subscribed = false; // miner has to subscribe.
Authenticated = false; // miner has to authenticate.
_logger = Log.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name);
_packetLogger = LogManager.PacketLogger.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name);
_rpcResultHandler = callback =>
{
var asyncData = ((JsonRpcStateAsync)callback); // get the async data.
var result = asyncData.Result + "\n"; // read the result.
var response = Encoding.UTF8.GetBytes(result); // set the response.
Connection.Send(response); // send the response.
_packetLogger.Verbose("tx: {0}", result.PrettifyJson());
};
}
示例2: OrderManager
public OrderManager( string host, int port, IConnection conn )
{
this.Host = host;
this.Port = port;
Connection = conn;
syncReport = new SyncReport( this );
}
示例3: SealedVirtualCluster
public SealedVirtualCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider)
{
this._cluster = cluster;
this._connectionPool = pool;
this._connection = new VirtualClusterConnection(cluster, dateTimeProvider);
this._dateTimeProvider = dateTimeProvider;
}
示例4: PlatronClient
public PlatronClient(IConnection connection)
{
Ensure.ArgumentNotNull(connection, "connection");
_connection = new ApiConnection(connection);
ResultUrl = new ResultUrlClient(_connection);
}
示例5: DeserializeLink
public ILink DeserializeLink(IConnection connection, SerializationInfo info)
{
Link link = new Link();
string sourceEmployeeId = string.Empty;
string targeteEmployeeId = string.Empty;
if (info["SourceEmployeeId"] != null)
sourceEmployeeId = info["SourceEmployeeId"].ToString();
if (info["TargetEmployeeId"] != null)
targeteEmployeeId = info["TargetEmployeeId"].ToString();
if (info["IsVisible"] != null)
link.IsVisible = bool.Parse(info["IsVisible"].ToString());
if (info["Text"] != null)
link.Text = info["Text"].ToString();
if (info["MainColor"] != null)
link.MainColor = info["MainColor"].ToString();
var sourceModel = this.deserializedEmployees.FirstOrDefault(x => x.GetId().Equals(sourceEmployeeId));
if (sourceModel != null)
{
link.Source = sourceModel;
}
var targetModel = this.deserializedEmployees.FirstOrDefault(x => x.GetId().Equals(targeteEmployeeId));
if (targetModel != null)
{
link.Target = targetModel;
}
return link;
}
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:30,代码来源:ObservableGraphSource.Serialization.cs
示例6: NodePingInfo
public NodePingInfo(IConnection con, string nodeName = null)
{
Connection = new Connection(con);
NextPingDate = DateTime.Now;
IsPinged = false;
NodeName = nodeName;
}
示例7: CloseConnection
/// <summary> Close the given NMS Connection and ignore any thrown exception.
/// This is useful for typical <code>finally</code> blocks in manual NMS code.
/// </summary>
/// <param name="con">the NMS Connection to close (may be <code>null</code>)
/// </param>
/// <param name="stop">whether to call <code>stop()</code> before closing
/// </param>
public static void CloseConnection(IConnection con, bool stop)
{
if (con != null)
{
try
{
if (stop)
{
try
{
con.Stop();
}
finally
{
con.Close();
}
}
else
{
con.Close();
}
}
catch (NMSException ex)
{
logger.Debug("Could not close NMS Connection", ex);
}
catch (Exception ex)
{
// We don't trust the NMS provider: It might throw another exception.
logger.Debug("Unexpected exception on closing NMS Connection", ex);
}
}
}
示例8: RouterActor
public RouterActor(bool useDefault = true)
{
ConnectionMode connectionMode = ConnectionMode.ConnectionModeRemoteConnectionless;
IConnectionManager connectionManager = new ConnectionManager();
FalconConnection falconConnection = default(FalconConnection);
if (useDefault)
falconConnection = connectionManager.GetDefaultConnection();
else
falconConnection = connectionManager.GetConnection("", 1);
_connection = ConnectionObjectFactory.CreateUnlicensedConnectionObject(null);
_auto = new AutoDisposeConnectionObject(_connection);
_connection.Mode = connectionMode;
if (falconConnection.guidEdi == Guid.Empty)
throw new Exception("Operation was aborted");
DeviceOpenError err = _connection.Open2("{" + falconConnection.guidEdi.ToString() + "}",
falconConnection.Parameters);
if (err != DeviceOpenError.DeviceOpenErrorNoError)
{
throw new InvalidOperationException(string.Format("Could not open connection: {0}", err.ToString()));
}
beginConfirmedGroupDataChannel();
}
示例9: Process
public override void Process(IConnection connection, string msg)
{
try
{
Campfire campfire = null;
double distance = double.MaxValue;
foreach (var camp in connection.Player.VisibleCampfires)
{
double dist = camp.Position.DistanceTo(connection.Player.Position);
if (dist < distance)
{
campfire = camp;
distance = dist;
}
}
if (campfire == null)
{
new SpChatMessage("Campfire in visible not found!", ChatType.System).Send(connection);
return;
}
new SpChatMessage("Unk1: " + campfire.Type, ChatType.System).Send(connection);
new SpChatMessage("Unk2: " + campfire.Status, ChatType.System).Send(connection);
}
catch (Exception ex)
{
Logger.WriteLine(LogState.Exception,"AdminEngine: CampfireInfo: " + ex);
}
}
示例10: OrderManager
public OrderManager( IConnection conn, string replayFilename )
: this(conn)
{
string path = Game.SupportDir + "Replays" + Path.DirectorySeparatorChar;
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
replaySaveFile = File.Create( path + replayFilename );
}
示例11: GetNegotiationResponse
// virtual to allow mocking
public virtual Task<NegotiationResponse> GetNegotiationResponse(IHttpClient httpClient, IConnection connection, string connectionData)
{
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
if (connection == null)
{
throw new ArgumentNullException("connection");
}
var negotiateUrl = UrlBuilder.BuildNegotiate(connection, connectionData);
httpClient.Initialize(connection);
return httpClient.Get(negotiateUrl, connection.PrepareRequest, isLongRunning: false)
.Then(response => response.ReadAsString())
.Then(raw =>
{
if (String.IsNullOrEmpty(raw))
{
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_ServerNegotiationFailed));
}
return JsonConvert.DeserializeObject<NegotiationResponse>(raw);
});
}
示例12: ProcessRequest
public Func<Task> ProcessRequest(IConnection connection)
{
if (_context.Request.Path.EndsWith("/send"))
{
if (Received != null || Receiving != null)
{
string data = _context.Request.Form["data"];
if (Receiving != null)
{
Receiving(data);
}
if (Received != null)
{
Received(data);
}
}
}
else
{
if (Connected != null)
{
Connected();
}
// Don't timeout and never buffer any output
connection.ReceiveTimeout = TimeSpan.FromTicks(Int32.MaxValue - 1);
_context.Response.BufferOutput = false;
_context.Response.Buffer = false;
return () => ProcessMessages(connection);
}
return null;
}
示例13: ObservableRepositoriesClient
public ObservableRepositoriesClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client.Repository;
_connection = client.Connection;
Status = new ObservableCommitStatusClient(client);
Hooks = new ObservableRepositoryHooksClient(client);
Forks = new ObservableRepositoryForksClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
RepoCollaborators = new ObservableRepoCollaboratorsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
Collaborator = new ObservableRepoCollaboratorsClient(client);
Deployment = new ObservableDeploymentsClient(client);
Statistics = new ObservableStatisticsClient(client);
PullRequest = new ObservablePullRequestsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
RepositoryComments = new ObservableRepositoryCommentsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
Comment = new ObservableRepositoryCommentsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
Commits = new ObservableRepositoryCommitsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
Commit = new ObservableRepositoryCommitsClient(client);
Release = new ObservableReleasesClient(client);
DeployKeys = new ObservableRepositoryDeployKeysClient(client);
Content = new ObservableRepositoryContentsClient(client);
Merging = new ObservableMergingClient(client);
Page = new ObservableRepositoryPagesClient(client);
}
示例14: ObservableRepositoryCommitsClient
public ObservableRepositoryCommitsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_connection = client.Connection;
_commit = client.Repository.Commit;
}
示例15: ObservableIssueCommentsClient
public ObservableIssueCommentsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client.Issue.Comment;
_connection = client.Connection;
}