本文整理汇总了C#中Exchange类的典型用法代码示例。如果您正苦于以下问题:C# Exchange类的具体用法?C# Exchange怎么用?C# Exchange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Exchange类属于命名空间,在下文中一共展示了Exchange类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: createListener
protected RabbitListener createListener(IRegistration registration, Exchange exchange)
{
// create a channel
var connection = _connFactory.ConnectTo(exchange);
// create a listener
RabbitListener listener = new RabbitListener(registration, exchange, connection);
listener.OnEnvelopeReceived += dispatcher =>
{
Log.Debug("Got an envelope from the RabbitListener: dispatching.");
// the dispatcher encapsulates the logic of giving the envelope to handlers
dispatcher.Dispatch();
};
listener.OnClose += _listeners.Remove;
//TODO: Resolve that RabbitListener does not implement OnConnectionError
//listener.OnConnectionError(new ReconnectOnConnectionErrorCallback(_channelFactory));
// store the listener
_listeners.Add(registration, listener);
// put it on another thread so as not to block this one
// don't continue on this thread until we've started listening
ManualResetEvent startEvent = new ManualResetEvent(false);
Thread listenerThread = new Thread(listener.Start);
listenerThread.Name = string.Format("{0} on {1}:{2}{3}", exchange.QueueName, exchange.HostName, exchange.Port, exchange.VirtualHost);
listenerThread.Start(startEvent);
return listener;
}
开发者ID:Berico-Technologies,项目名称:AMP,代码行数:30,代码来源:RabbitEnvelopeReceiver.cs
示例2: ConfigureConnectionFactory
public override void ConfigureConnectionFactory(ConnectionFactory factory, Exchange exchange)
{
base.ConfigureConnectionFactory(factory, exchange);
factory.UserName = _username;
factory.Password = _password;
}
开发者ID:jar349,项目名称:AMP,代码行数:7,代码来源:BasicConnectionFactory.cs
示例3: PublishJob
protected PublishJob(IBroker broker, Exchange exchange, String routingKey)
{
Broker = broker;
_exchange = exchange;
_routingKey = routingKey;
_stopwatch = new Stopwatch();
}
开发者ID:pichierri,项目名称:Carrot,代码行数:7,代码来源:PublishJob.cs
示例4: ConnectTo
public IConnection ConnectTo(Exchange exchange)
{
_log.Debug("Getting connection for exchange: " + exchange.ToString());
IConnection connection = null;
// first, see if we have a cached connection
if (_connections.ContainsKey(exchange))
{
connection = _connections[exchange];
if (!connection.IsOpen)
{
_log.Info("Cached connection to RabbitMQ was closed: reconnecting");
connection = this.CreateConnection(exchange);
}
}
else
{
_log.Debug("No connection to the exchange was cached: creating");
connection = this.CreateConnection(exchange);
// add the new connection to the cache
_connections[exchange] = connection;
}
return connection;
}
开发者ID:Berico-Technologies,项目名称:AMP,代码行数:27,代码来源:BaseConnectionFactory.cs
示例5: ConfigureConnectionFactory
public override void ConfigureConnectionFactory(ConnectionFactory factory, Exchange exchange)
{
// try to get a certificate
X509Certificate2 cert = _certProvider.GetCertificate();
if (null != cert)
{
_log.Info("A certificate was located with subject: " + cert.Subject);
}
else
{
throw new RabbitException("Cannot connect to an exchange because no certificate was found");
}
base.ConfigureConnectionFactory(factory, exchange);
// let's set the connection factory's ssl-specific settings
// NOTE: it's absolutely required that what you set as Ssl.ServerName be
// what's on your rabbitmq server's certificate (its CN - common name)
factory.AuthMechanisms = new AuthMechanismFactory[] { new ExternalMechanismFactory() };
factory.Ssl.Certs = new X509CertificateCollection(new X509Certificate[] { cert });
factory.Ssl.ServerName = exchange.HostName;
factory.Ssl.Enabled = true;
// TLS will enable more secure cipher suites to use in the exchange, encryption, and HMAC algorithms
// used on a secure connection. Also, if the Windows OS the client runs on has the FIPS Mode security
// policy enabled (Windows STIG), this will ensure successful connections to the Message Broker.
factory.Ssl.Version = System.Security.Authentication.SslProtocols.Tls;
}
开发者ID:Berico-Technologies,项目名称:AMP,代码行数:27,代码来源:CertificateConnectionFactory.cs
示例6: Start
/**
* The Start method is called automatically by Monobehaviors,
* essentially becoming the constructor of the class.
* <p>
* See <a href="http://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html">docs.unity3d.com</a> for more information.
*/
private void Start() {
exchange = this.transform.parent.parent.GetComponentInParent<Exchange>();
tooltip = this.transform.FindChild("Item Tooltip").gameObject;
tooltip.SetActive(false);
BuildTooltipText();
clickDelta = 0.0f;
}
开发者ID:Icohedron,项目名称:Tremaze,代码行数:13,代码来源:ShopItem.cs
示例7: BetfairClientSync
public BetfairClientSync(Exchange exchange,
string appKey,
Action preNetworkRequest = null,
WebProxy proxy = null)
{
client = new BetfairClient(exchange, appKey, preNetworkRequest, proxy);
}
开发者ID:hugocorreia77,项目名称:betfairng,代码行数:7,代码来源:BetfairClientSync.cs
示例8: testWriting
public void testWriting()
{
string path = @"C:\Users\Phil\Desktop\out.txt";
Exchange ex = new Exchange();
string response = WebInterface.queryAPI("JPM");
Utilities.arrayify("JPM", response, ex);
FileInterface.writeExchangeToFile(path, gl);
}
开发者ID:pratstercs,项目名称:StockSimulator,代码行数:8,代码来源:Program.cs
示例9: GetExchangeBindings
public static IEnumerable<ExchangeBindingSettings> GetExchangeBindings(this ReceiveSettings settings, string exchangeName)
{
var exchange = new Exchange(exchangeName, settings.Durable, settings.AutoDelete, settings.ExchangeType);
var binding = new ExchangeBinding(exchange);
yield return binding;
}
开发者ID:phatboyg,项目名称:MassTransit,代码行数:8,代码来源:RabbitMqExchangeBindingExtensions.cs
示例10: SendResponse
/// <inheritdoc/>
public override void SendResponse(INextLayer nextLayer, Exchange exchange, Response response)
{
// A response must have the same token as the request it belongs to. If
// the token is empty, we must use a byte array of length 0.
if (response.Token == null)
response.Token = exchange.CurrentRequest.Token;
base.SendResponse(nextLayer, exchange, response);
}
开发者ID:rlusian1,项目名称:CoAP.NET,代码行数:9,代码来源:TokenLayer.cs
示例11: RabbitListener
public RabbitListener(IRegistration registration, Exchange exchange, IConnection connection)
{
_registration = registration;
_exchange = exchange;
_connection = connection;
_log = LogManager.GetLogger(this.GetType());
}
开发者ID:berico-tpinney,项目名称:AMP,代码行数:8,代码来源:RabbitListener.cs
示例12: GetExchangeBinding
public static ExchangeBindingSettings GetExchangeBinding(this SendSettings settings, string exchangeName)
{
var exchange = new Exchange(exchangeName, settings.Durable, settings.AutoDelete);
var binding = new ExchangeBinding(exchange);
return binding;
}
开发者ID:phatboyg,项目名称:MassTransit,代码行数:8,代码来源:RabbitMqExchangeBindingExtensions.cs
示例13: GetErrorExchangeBinding
public static ExchangeBindingSettings GetErrorExchangeBinding(this SendSettings settings)
{
var exchange = new Exchange(settings.ExchangeName, true, false);
var binding = new ExchangeBinding(exchange);
return binding;
}
开发者ID:nicklv,项目名称:MassTransit,代码行数:8,代码来源:RabbitMqExchangeBindingExtensions.cs
示例14: StartDataGeneration
public void StartDataGeneration(int refreshInterval, Exchange exchange)
{
_refreshInterval = refreshInterval;
this._exchange = exchange;
//Start data fetch in another thread
Task tskPollData = new Task(new Action(UpdateData));
tskPollData.Start();
}
开发者ID:togglebrain,项目名称:stock-analytics,代码行数:9,代码来源:YahooDataGenerator.cs
示例15: DeliverResponse
/// <inheritdoc/>
public void DeliverResponse(Exchange exchange, Response response)
{
if (exchange == null)
throw ThrowHelper.ArgumentNull("exchange");
if (response == null)
throw ThrowHelper.ArgumentNull("response");
if (exchange.Request == null)
throw new ArgumentException("Request should not be empty.", "exchange");
exchange.Request.Response = response;
}
开发者ID:rlusian1,项目名称:CoAP.NET,代码行数:11,代码来源:ClientMessageDeliverer.cs
示例16: GetExchangeBinding
public static ExchangeBindingSettings GetExchangeBinding(this Type messageType, IMessageNameFormatter messageNameFormatter)
{
bool temporary = IsTemporaryMessageType(messageType);
var exchange = new Exchange(messageNameFormatter.GetMessageName(messageType).ToString(), !temporary, temporary);
var binding = new ExchangeBinding(exchange);
return binding;
}
开发者ID:nicklv,项目名称:MassTransit,代码行数:10,代码来源:RabbitMqExchangeBindingExtensions.cs
示例17: FindPrevious
/// <inheritdoc/>
public Exchange FindPrevious(Exchange.KeyID key, Exchange exchange)
{
Exchange prev = null;
_incommingMessages.AddOrUpdate(key, exchange, (k, v) =>
{
prev = v;
return exchange;
});
return prev;
}
开发者ID:rlusian1,项目名称:CoAP.NET,代码行数:11,代码来源:SweepDeduplicator.cs
示例18: Contract
public Contract(HtmlNode link, Exchange exchange)
{
ContractId = Regex.Match(link.ChildNodes[3].InnerHtml,"conid=(.*?)'").Groups[1].Value;
Description = link.ChildNodes[3].InnerText.Replace("&","&");
IbSymbol = link.ChildNodes[1].InnerText;
Symbol = link.ChildNodes[5].InnerText;
Currency = link.ChildNodes[7].InnerText;
Category = exchange.Category;
ExchangeCode = exchange.Code;
}
开发者ID:BMcDonie,项目名称:IbContractExtractor,代码行数:10,代码来源:Contract.cs
示例19: Main
/// <summary>
/// Application arguments:
/// arg0: Selected Exchange. Has to be enum StockModel.Master.Exchange
/// arg1: Data generator to use. Has to be IDataPublisher.
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
//Loading system startup data for all the exchanges
List<Exchange> exchanges = new List<Exchange>();
//defaults selected...
selectedExchange = Exchange.FAKE_NASDAQ;
dataGenerator = YahooDataGenerator.Instance;
ResolveAppArgs(args);
exchanges = Enum.GetValues(typeof(Exchange)).OfType<Exchange>().ToList();
InMemoryObjects.LoadInMemoryObjects(exchanges);
TimeSpan updateDuration = TimeSpan.FromMilliseconds(Constants.FAKE_DATA_GENERATE_PERIOD);
//Start data generation - this will start fetching data for all symbols of current exchange
//Later, need to change this to only subscribe to the specific symbol(s) selected.
dataGenerator.StartDataGeneration(300, selectedExchange);
sender = SenderFactory.GetSender(FeederQueueSystem.REDIS_CACHE);
List<StockModel.Symbol> symbols = InMemoryObjects.ExchangeSymbolList.SingleOrDefault(x => x.Exchange == selectedExchange).Symbols;
List<SymbolFeeds> generatedData = new List<SymbolFeeds>();
List<StockModel.Symbol> symbolList = new List<StockModel.Symbol>();
Action<double, string> addMovingAverage = new Action<double, string>((val,MVA_id) => {
sender.SendMVA(val, MVA_id);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Sent value {0} to redis", val);
Console.ResetColor();
});
Parallel.ForEach(symbols, (symbol) =>
{
//subscribe
dataGenerator.SubscribeFeed(symbol.Id, (Feed fd) =>
{
sender.SendFeed(fd, selectedExchange.ToString());
Console.WriteLine(fd.ToString());
});
//add subscription for each aggregator configured
//RXProcessing.AddAggregator(dataGenerator, new MovingAverage(),
// addMovingAverage
// , symbol.Id);
});
Console.Read();
}
开发者ID:togglebrain,项目名称:stock-analytics,代码行数:61,代码来源:Program.cs
示例20: Process
public override Exchange Process(Exchange exchange, UriDescriptor uriDescriptor)
{
try
{
var showOut = uriDescriptor.GetUriProperty("show-out", false);
var filePathToLogTo = uriDescriptor.GetUriProperty("file");
var additionalMessage = uriDescriptor.GetUriProperty("message", "");
//in data
var inHeaderBuilder = new StringBuilder();
exchange.InMessage.HeaderCollection.ToList().ForEach(c => inHeaderBuilder.AppendFormat("{0}='{1}', ", c.Key, c.Value.ToString()));
var propertyBuilder = new StringBuilder();
exchange.PropertyCollection.ToList().ForEach(c => propertyBuilder.AppendFormat("{0}='{1}',", c.Key, c.Value.ToString()));
var inBody = exchange.InMessage.Body.ToString();
var msg = string.Format("Exchange: Id: {0}, MEP={5}. >> Route: ID({1}), Properties [{3}], In Message: [Headers: {2} Body: {4}]",
exchange.ExchangeId, exchange.Route.RouteId, inHeaderBuilder, propertyBuilder, inBody, exchange.MepPattern);
//out data
if (exchange.MepPattern == Exchange.Mep.InOut)
{
var outHeaderBuilder = new StringBuilder();
exchange.OutMessage.HeaderCollection.ToList().ForEach(c => outHeaderBuilder.AppendFormat("{0}='{1}', ", c.Key, c.Value.ToString()));
var outBody = exchange.OutMessage.Body.ToString();
msg = string.Format("{0}, Out Message: [Headers: {1} Body: {2}]", msg, outHeaderBuilder, outBody);
}
var errors = exchange.DequeueAllErrors;
if (errors.Count > 0)
{
var errorListing = new StringBuilder();
errors.ForEach(c => errorListing.AppendFormat("[ error-message?: {0}, any-stack-trace?: {1} ]", c.Message, c.StackTrace));
msg = string.Format("{0}, {1}", msg, errorListing);
}
var starTime = DateTime.Now;
if (!string.IsNullOrEmpty(filePathToLogTo))
Log(filePathToLogTo, msg, uriDescriptor);
var interval = DateTime.Now - starTime;
return exchange;
}
catch (AggregateException exception)
{
}
catch (Exception exception)
{
}
return exchange;
}
开发者ID:ojoadeolagabriel,项目名称:TqWorkflow-beta,代码行数:54,代码来源:LogProducer.cs
注:本文中的Exchange类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论