本文整理汇总了C#中PropertyBag.AddBag方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyBag.AddBag方法的具体用法?C# PropertyBag.AddBag怎么用?C# PropertyBag.AddBag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyBag
的用法示例。
在下文中一共展示了PropertyBag.AddBag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveComics
private void SaveComics( ArrayList aComics, string fileName )
{
PropertyBag bags;
bags = new PropertyBag();
foreach( ComicInfo ci in aComics )
{
PropertyBag comicBag;
comicBag = new PropertyBag();
comicBag.Name = ci.DisplayName;
comicBag.SetProperty( "Website", ci.Website );
comicBag.SetProperty( "FolderName", ci.FolderName );
comicBag.SetProperty( "DisplayName", ci.DisplayName );
comicBag.SetProperty( "ImageSuffix", ci.ImageSuffix );
comicBag.SetProperty( "ImageFilename", ci.ImageFilename );
comicBag.SetProperty( "ImagePath", ci.ImagePath );
comicBag.SetProperty( "Subscribed", ci.Subscribed.ToString() );
bags.AddBag( comicBag );
}
bags.Save( fileName );
return;
}
示例2: ConnectServer
private IDataAdapter ConnectServer(IDataAdapter adapter, Logger logger, PropertyBag properties)
{
X509Certificate2 cert = null;
// If server certificate not specified try and auto generate one
if (!_config.SpecifyServerCert)
{
if (_remoteCert != null)
{
cert = CertManager.GetCertificate(_remoteCert);
}
else
{
cert = CertManager.GetCertificate("CN=localhost");
}
}
else if (_config.ServerCertificate != null)
{
cert = _config.ServerCertificate.Certificate;
}
else
{
// Ideally shouldn't get here, but not necessarily consistent :)
cert = CertManager.GetCertificate("CN=localhost");
}
SslStream sslStream = new SslStream(new DataAdapterToStream(adapter), false, ValidateRemoteServerConnection);
bool setReadTimeout = false;
int oldTimeout = -1;
try
{
oldTimeout = sslStream.ReadTimeout;
sslStream.ReadTimeout = _config.Timeout;
setReadTimeout = true;
}
catch (InvalidOperationException)
{
}
sslStream.AuthenticateAsServer(cert, _config.RequireClientCertificate, _config.ServerProtocol, false);
if (setReadTimeout)
{
sslStream.ReadTimeout = oldTimeout;
}
logger.LogVerbose(CANAPE.Net.Properties.Resources.SslNetworkLayer_ClientLogString,
sslStream.SslProtocol, sslStream.IsSigned, sslStream.IsMutuallyAuthenticated, sslStream.IsEncrypted);
PopulateSslMeta(properties.AddBag("SslServer"), sslStream);
return new StreamDataAdapter(sslStream, adapter.Description);
}
示例3: ConnectClient
/// <summary>
/// Connect client
/// </summary>
/// <param name="baseAdapter"></param>
/// <param name="connProperties"></param>
/// <returns></returns>
public NetGraph ConnectClient(IDataAdapter baseAdapter, PropertyBag connProperties)
{
IDataAdapter server = null;
IDataAdapter client = null;
ProxyToken token = null;
NetGraph graph = null;
NetGraph retGraph = null;
MetaDictionary meta = new MetaDictionary();
PropertyBag properties = new PropertyBag("Properties");
try
{
properties.AddBag(connProperties);
token = _proxyServer.Accept(baseAdapter, meta, _globalMeta, this);
if (token != null)
{
token = FilterToken(token);
if (token.Status == NetStatusCodes.Success)
{
ProxyClient proxyClient = token.Client ?? _proxyClient;
if (token.Bind)
{
client = proxyClient.Bind(token, _logger, meta, _globalMeta, properties.AddBag("Client"), _credentialManager);
}
else
{
client = proxyClient.Connect(token, _logger, meta, _globalMeta, properties.AddBag("Client"), _credentialManager);
}
server = _proxyServer.Complete(token, meta, _globalMeta, this, client);
if ((token.Status == NetStatusCodes.Success) && (client != null))
{
NetGraphFactory factory = token.Graph != null ? token.Graph : _factory;
token.PopulateBag(properties.AddBag("Token"));
// Negotiate SSL or other bespoke encryption mechanisms
if (token.Layers != null)
{
foreach (INetworkLayer layer in token.Layers)
{
layer.Negotiate(ref server, ref client, token, _logger, meta,
_globalMeta, properties, DefaultBinding);
}
}
var clients = factory.GetNodes<ClientEndpointFactory>();
var servers = factory.GetNodes<ServerEndpointFactory>();
if ((clients.Length > 0) && (servers.Length > 0))
{
graph = CreateNetGraph(factory, meta, properties);
graph.BindEndpoint(clients[0].Id, client);
graph.BindEndpoint(servers[0].Id, server);
if (token.NetworkDescription != null)
{
graph.NetworkDescription = token.NetworkDescription;
}
else
{
graph.NetworkDescription = String.Format("{0} <=> {1}",
server.Description, client.Description);
}
PropertyBag networkService = properties.AddBag("NetworkService");
networkService.AddValue("ClientId", clients[0].Id);
networkService.AddValue("ServerId", servers[0].Id);
networkService.AddValue("ClientAdapter", client);
networkService.AddValue("ServerAdapter", server);
networkService.AddValue("Token", token);
graph.Start();
OnNewConnection(graph);
retGraph = graph;
}
else
{
_logger.LogError(CANAPE.Net.Properties.Resources.ProxyNetworkService_InvalidGraph);
}
}
}
else
{
_logger.LogVerbose(CANAPE.Net.Properties.Resources.ProxyNetworkService_ConnectionFiltered);
server = _proxyServer.Complete(token, meta, _globalMeta, this, client);
}
//.........这里部分代码省略.........
示例4: ConnectClient
private IDataAdapter ConnectClient(IDataAdapter adapter, Logger logger, PropertyBag properties, string serverName)
{
SslStream sslStream = new SslStream(new DataAdapterToStream(adapter), false, ValidateRemoteClientConnection);
if (serverName == null)
{
// Just generate something
serverName = Interlocked.Increment(ref nameCounter).ToString();
}
X509Certificate2Collection clientCerts = new X509Certificate2Collection();
bool setReadTimeout = false;
int oldTimeout = -1;
foreach(X509CertificateContainer clientCert in _config.ClientCertificates)
{
clientCerts.Add(clientCert.Certificate);
}
try
{
oldTimeout = sslStream.ReadTimeout;
sslStream.ReadTimeout = _config.Timeout;
setReadTimeout = true;
}
catch (InvalidOperationException)
{
}
sslStream.AuthenticateAsClient(serverName, clientCerts, _config.ClientProtocol, false);
if (setReadTimeout)
{
sslStream.ReadTimeout = oldTimeout;
}
_remoteCert = sslStream.RemoteCertificate;
if (_remoteCert == null)
{
if (!_certCache.TryGetValue(serverName, out _remoteCert))
{
throw new InvalidOperationException(CANAPE.Net.Properties.Resources.SslNetworkLayer_CannotGetServerCertificate);
}
}
else
{
_certCache.TryAdd(serverName, _remoteCert);
}
logger.LogVerbose(CANAPE.Net.Properties.Resources.SslNetworkLayer_ClientConnectLog,
sslStream.SslProtocol, _remoteCert.Subject,
sslStream.IsSigned, sslStream.IsMutuallyAuthenticated, sslStream.IsEncrypted);
PopulateSslMeta(properties.AddBag("SslClient"), sslStream);
return new StreamDataAdapter(sslStream, adapter.Description);
}