当前位置: 首页>>代码示例>>C#>>正文


C# PropertyBag.AddBag方法代码示例

本文整理汇总了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;
        }
开发者ID:tmar89,项目名称:tmar89snapstreamdev,代码行数:26,代码来源:ComicsUpdater.cs

示例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);
        }
开发者ID:michyer,项目名称:canape,代码行数:54,代码来源:SslNetworkLayer.cs

示例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);
                    }
//.........这里部分代码省略.........
开发者ID:michyer,项目名称:canape,代码行数:101,代码来源:ProxyNetworkService.cs

示例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);
        }
开发者ID:michyer,项目名称:canape,代码行数:57,代码来源:SslNetworkLayer.cs


注:本文中的PropertyBag.AddBag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。