本文整理汇总了C#中Plug类的典型用法代码示例。如果您正苦于以下问题:C# Plug类的具体用法?C# Plug怎么用?C# Plug使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Plug类属于命名空间,在下文中一共展示了Plug类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatedPlugCanBeDisconnected
public void CreatedPlugCanBeDisconnected()
{
var stream = Substitute.For<IAudioStream>();
var plug = new Plug<IAudioStream>(stream);
plug.Disconnect();
plug.IsConnected.Should().Be.False();
}
示例2: CreateConnectorCollection
public ConnectorCollection CreateConnectorCollection()
{
var plug = new Plug();
var connectorCollection = new ConnectorCollection();
connectorCollection.Connectors.Add(plug);
return connectorCollection;
}
示例3: RemoveHalfPlug
public void RemoveHalfPlug(Plug plug) {
try {
plugs.Remove(plug);
Plugs_ListBox.ItemsSource = plugs;
} catch (Exception) {
}
}
示例4: CanConnectPlugToSocket
public void CanConnectPlugToSocket()
{
var stream = Substitute.For<IAudioStream>();
var plug = new Plug<IAudioStream>(stream);
var socket = new Socket<IAudioStream>();
plug.ConnectTo(socket).Should().Be.True();
}
示例5: CanConnectSocketToPlug
public void CanConnectSocketToPlug()
{
var stream = Substitute.For<IAudioStream>();
var plug = new Plug<IAudioStream>(stream);
var socket = new Socket<IAudioStream>();
socket.ConnectTo(plug).Should().Be.True();
}
示例6: ConnectingSetsSocketChannel
public void ConnectingSetsSocketChannel()
{
var stream = Substitute.For<IAudioStream>();
var plug = new Plug<IAudioStream>(stream);
var socket = new Socket<IAudioStream>();
plug.ConnectTo(socket);
Assert.Same(stream, socket.Channel);
}
示例7: ConnectedSocketIsConnected
public void ConnectedSocketIsConnected()
{
var stream = Substitute.For<IAudioStream>();
var plug = new Plug<IAudioStream>(stream);
var socket = new Socket<IAudioStream>();
plug.ConnectTo(socket);
socket.IsConnected.Should().Be.True();
}
示例8: Start
//--- Methods ---
protected override Yield Start(XDoc config, Result result)
{
yield return Coroutine.Invoke(base.Start, config, new Result());
_redirect = Plug.New(config["proxy"].AsUri ?? config["redirect"].AsUri, TimeSpan.FromSeconds(config["timeout"].AsInt ?? (int)Plug.DEFAULT_TIMEOUT.TotalSeconds));
if(_redirect == null) {
throw new ArgumentException("redirect URI missing or invalid");
}
result.Return();
}
示例9: AmazonS3Client
//--- Constructors ---
/// <summary>
/// Create new client instance
/// </summary>
/// <param name="config">Client configuration.</param>
/// <param name="timerFactory">Timer factory.</param>
public AmazonS3Client(AmazonS3ClientConfig config, TaskTimerFactory timerFactory)
{
_config = config;
_bucketPlug = Plug.New(_config.S3BaseUri)
.WithS3Authentication(_config.PrivateKey, _config.PublicKey)
.WithTimeout(_config.Timeout)
.At(_config.Bucket);
_rootPlug = _bucketPlug;
if(!string.IsNullOrEmpty(_config.RootPath)) {
_keyRootParts = _config.RootPath.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
if(_keyRootParts != null && _keyRootParts.Any()) {
_rootPlug = _rootPlug.At(_keyRootParts);
}
}
_expirationEntries = new ExpiringHashSet<string>(timerFactory);
_expirationEntries.EntryExpired += OnDelete;
}
示例10: Main
public static void Main(string[] args)
{
if (args.Length != 2) {
Console.WriteLine("Need socket id and file-name as an argument.");
return;
}
uint socket_id = UInt32.Parse(args[0]);
string filename=args[1];
Console.WriteLine("filename="+filename);
Console.WriteLine("using socket "+socket_id);
// Glib.Thread.Init();
Gdk.Threads.Init();
Application.Init();
Gdk.Threads.Enter();
try {
Plug plug= new Plug(socket_id);
Fixed fixed1 = new Fixed();
fixed1.Put(new Label("File: \""+filename+"\""), 10, 10);
fixed1.Put(new Entry("HELLO"), 10, 50);
fixed1.Put(new Entry("World"), 10, 100);
fixed1.ShowAll();
plug.Add(fixed1);
plug.ShowAll();
Console.WriteLine("app is running..");
Application.Run();
} finally {
Gdk.Threads.Leave();
}
Console.WriteLine("Done!");
}
示例11: WaitFor
private bool WaitFor(Plug plug, Func<DreamMessage, bool> func, TimeSpan timeout)
{
var expire = DateTime.Now.Add(timeout);
while(expire > DateTime.Now) {
var r = plug.GetAsync().Wait();
if(func(r)) {
return true;
}
Thread.Sleep(100);
}
return false;
}
示例12: Init
public void Init()
{
_hostInfo = DreamTestHelper.CreateRandomPortHost();
_hostInfo.Host.Self.At("load").With("name", "test.mindtouch.dream").Post(DreamMessage.Ok());
var config = new XDoc("config")
.Elem("path", "test")
.Elem("sid", "sid://mindtouch.com/DreamContextTestService");
DreamMessage result = _hostInfo.LocalHost.At("host", "services").With("apikey", _hostInfo.ApiKey).PostAsync(config).Wait();
Assert.IsTrue(result.IsSuccessful, result.ToText());
_plug = Plug.New(_hostInfo.LocalHost.Uri.WithoutQuery()).At("test");
DreamContextTestService.ContextVar = null;
}
示例13: CreateBadStartChild
public Yield CreateBadStartChild(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
yield return CreateService(
"badchild",
"sid://mindtouch.com/TestBadStartService",
new XDoc("config").Elem("throw", context.GetParam("throw", "false")),
new Result<Plug>()).Set(v => _badChild = v);
response.Return(DreamMessage.Ok());
yield break;
}
示例14:
Yield IPlugEndpoint.Invoke(Plug plug, string verb, XUri uri, DreamMessage request, Result<DreamMessage> response)
{
_env.UpdateInfoMessage(_sourceInternal, null);
Result<DreamMessage> res = new Result<DreamMessage>(response.Timeout);
_env.SubmitRequestAsync(verb, uri, null, request, res);
yield return res;
response.Return(res);
}
示例15: CreateSecondPrivateStorageServiceProxy
private void CreateSecondPrivateStorageServiceProxy()
{
_hostInfo.Host.Self.At("services").Post(
new XDoc("config")
.Elem("class", typeof(TestServiceWithPrivateStorage).FullName)
.Elem("path", TEST_PATH + "2"));
_log.Debug("created second storage service");
testService = Plug.New(_hostInfo.Host.LocalMachineUri).At(TEST_PATH + "2");
}