Esempio n. 1
0
        /// <summary>
        /// Creates and initializes a new instance of a NamedPipeConnection.
        /// </summary>
        /// <param name="configurationData">The configuration data for the named pipe.</param>
        /// <returns>A new instance of NamedPipeConnection configured with the supplied <paramref name="configurationData"/>.</returns>
        /// <remarks>The required configuration data is as follows:
        /// PipeName_ConfigDataName - string : The name of the connection, and the base name for the pipes.
        /// PreOpenPort_ConfigDataName - Func&lt;bool&gt; : A non-<c>null</c> value specifies this is a server pipe, otherwise it's a client.
        /// PostOpenPort_ConfigDataName - Action&lt;IStreamConnection&gt;
        /// The input pipe (pipe used to SEND input TO a device) is named [name]Input, and the output pipe
        /// (used to RECEIVE output FROM a device) is named [name]Output</remarks>
        public static NamedPipeConnection Create(IDictionary <string, object> configurationData)
        {
            var namedPipeConnection = new NamedPipeConnection((string)configurationData[PipeNameConfigDataName]);

            namedPipeConnection.Configure(configurationData);
            return(namedPipeConnection);
        }
Esempio n. 2
0
        private static IConnection ConnectionFactory(ConnectionType type, string name, IDictionary <string, object> creationData)
        {
            IConnection connection = null;

            switch (type)
            {
            case ConnectionType.Serial:
                connection = SerialPortConnection.Create(creationData);
                break;

            case ConnectionType.NamedPipe:
                connection = NamedPipeConnection.Create(creationData);
                break;

            default:
                break;
            }
            return(connection);
        }