Beispiel #1
0
            public static IPC Build(eIPC etype, Type type)
            {
                if (type == null)
                {
                    return(null);
                }
                if (type.GetInterface(typeof(IPC).Name) == null)
                {
                    return(null);
                }
                IPC obj = (IPC)AppDomain.CurrentDomain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName, false, BindingFlags.CreateInstance, null,
                                                                               null, null, null);

                obj.Init(etype);
                return(obj);
            }
Beispiel #2
0
            public void Init(eIPC eIPC)
            {
                switch (eIPC)
                {
                case eIPC.Client:
                {
                    bool _cn = false;
                    _mutexc = new Mutex(true, _mcname, out _cn);
                    if (_cn)
                    {
                        npine = new NamedPipeClientStream(MServerName,
                                                          MClientName, PipeDirection.InOut,
                                                          PipeOptions.Asynchronous,
                                                          TokenImpersonationLevel.None);
                        _ready = true;
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                break;

                case eIPC.Server:
                {
                    bool cn = false;
                    _mutexs = new Mutex(true, _msname, out cn);
                    if (cn)
                    {
                        npine = new NamedPipeServerStream(MServerName,
                                                          PipeDirection.InOut, maxNumberOfServerInstances: 1,
                                                          PipeTransmissionMode.Message,
                                                          PipeOptions.Asynchronous);
                        _ready = true;
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                break;

                default:
                    break;
                }
            }
Beispiel #3
0
 public void Init(eIPC eIPC)
 {
     throw new NotImplementedException();
 }
Beispiel #4
0
 public void Init(eIPC eIPC)
 {
 }