コード例 #1
0
        /// <summary>
        /// Saves the Category to the DB then closes the window.
        /// </summary>
        /// <param name="window">The window doing the closing.</param>
        private void saveAndClose(Window window)
        {
            //Just always use the defaults in here. Won't matter if they are the same as in the DB anyway.
            Category newCat = new Category(NameText, color: ColorText, priority: PriorityText);

            SQLiteDataAccess.AddNewCategory(newCat);

            CloseHelper.CloseWindow(window);
        }
コード例 #2
0
            /// <summary>
            /// Close the context and free applicable resources.
            /// <para>
            /// If <seealso cref="OwnsAeronClient()"/> is true then the <seealso cref="Aeron()"/> client will be closed.
            /// </para>
            /// </summary>
            public void Dispose()
            {
                CloseHelper.QuietDispose(markFile);

                if (ownsAeronClient)
                {
                    aeron?.Dispose();
                }
            }
コード例 #3
0
        public void OnClose()
        {
            bool isInterrupted = false;

            _clientLock.Lock();
            try
            {
                if (!_isClosed)
                {
                    if (!_aeron.IsClosed)
                    {
                        _aeron.InternalClose();
                    }

                    ForceCloseResources();
                    NotifyCloseHandlers();

                    try
                    {
                        if (_isTerminating)
                        {
                            Thread.Sleep(Aeron.Configuration.IdleSleepMs);
                        }

                        Thread.Sleep((int)TimeUnit.NANOSECONDS.toMillis(_ctx.CloseLingerDurationNs()));
                    }
                    catch (ThreadInterruptedException)
                    {
                        isInterrupted = true;
                    }

                    for (int i = 0, size = _lingeringLogBuffers.Count; i < size; i++)
                    {
                        CloseHelper.Dispose(_ctx.ErrorHandler(), _lingeringLogBuffers[i]);
                    }

                    _driverProxy.ClientClose();
                    _ctx.Dispose();
                }
            }
            finally
            {
                _isClosed = true;

                if (isInterrupted)
                {
                    Thread.CurrentThread.Interrupt();
                }

                _clientLock.Unlock();
            }
        }
コード例 #4
0
        private AeronCluster(Context ctx)
        {
            _ctx = ctx;


            Subscription subscription = null;

            try
            {
                ctx.Conclude();

                _aeron        = ctx.Aeron();
                _idleStrategy = ctx.IdleStrategy();
                _nanoClock    = _aeron.Ctx().NanoClock();
                _isUnicast    = ctx.ClusterMemberEndpoints() != null;
                UpdateMemberEndpoints(ctx.ClusterMemberEndpoints());

                subscription  = _aeron.AddSubscription(ctx.EgressChannel(), ctx.EgressStreamId());
                _subscription = subscription;

                _publication      = ConnectToCluster();
                _clusterSessionId = OpenSession();

                UnsafeBuffer headerBuffer = new UnsafeBuffer(new byte[SessionDecorator.SESSION_HEADER_LENGTH]);
                _sessionHeaderEncoder
                .WrapAndApplyHeader(headerBuffer, 0, _messageHeaderEncoder)
                .ClusterSessionId(_clusterSessionId)
                .Timestamp(Aeron.Aeron.NULL_VALUE);

                _vectors[0] = new DirectBufferVector(headerBuffer, 0, SessionDecorator.SESSION_HEADER_LENGTH);
                _vectors[1] = _messageBuffer;

                _poller            = new Poller(ctx.SessionMessageListener(), _clusterSessionId, this);
                _fragmentAssembler = new FragmentAssembler(_poller);
            }
            catch (Exception)
            {
                if (!ctx.OwnsAeronClient())
                {
                    CloseHelper.QuietDispose(_publication);
                    CloseHelper.QuietDispose(subscription);
                }

                CloseHelper.QuietDispose(ctx);
                throw;
            }
        }
コード例 #5
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Exit" && hasKey == true)                   // If the player has the key and collides with the exit
     {
         SavePrefs();                                             // save the stats, go to the loading screen, and
         Camera.main.GetComponent <LoadingScreen>().LoadScreen(); // increase the level
         GetComponent <Health>().SetCanBeDamaged(false);
         GameManager.level++;
         PlayerPrefs.SetInt("Level", PlayerPrefs.GetInt("Level") + 1);
         Invoke("Restart", restartLevelDelay);
         enabled = false;
     }
     else if (other.tag == "Feather")   // If the player collides with a feather, increase the feather count
     {
         changeFeathers(1);             // and disable the feather object
         other.gameObject.SetActive(false);
     }
     else if (other.tag == "Key")
     {
         key.color = Color.white;            // If the player colides with the key, set the HUD to display the key
         hasKey    = true;                   // Allow the player to exit the level, play the open door animation
         other.gameObject.SetActive(false);  // and disable the key object
         GameObject.FindGameObjectWithTag("Exit").GetComponent <Animator>().SetTrigger("OpenDoor");
     }
     else if (other.tag == "Speed_PowerUp" && this.moveTime <= 18f)
     {
         this.moveTime++;                        // If the player collides with the speed power up, increase the move
         PlayerPrefs.SetInt("Speed", moveTime);  // time to speed the player up, save the speed in Player Prefs, and
         other.gameObject.SetActive(false);      // disable the orb
         Helper.IncreaseSpeed(this.moveTime);
     }
     else if (other.tag == "Damage_PowerUp") // If the player collides with the damage power up
     {
         CloseHelper closeHelp = GetComponent <PlayerAttackClose>().invisibleProjectile.GetComponent <CloseHelper>();
         closeHelp.increaseDamage(1);       // Increase the damage of the close attack
         Helper rangeHelp = GetComponent <PlayerAttackDistance>().projectile.GetComponent <Helper>();
         rangeHelp.increaseDamage(1);       // Increase the damage of the ranged attack
         other.gameObject.SetActive(false); // Disable the orb
     }
     else if (other.tag == "Health_PowerUp")
     {
         hd.IncreaseMax(2);                 // If the player collides with the health power up, increase the health
         other.gameObject.SetActive(false); // by two and disable the orb
     }
 }
コード例 #6
0
        private int CheckLingeringResources(long nowNs)
        {
            int workCount = 0;

            for (int lastIndex = _lingeringLogBuffers.Count - 1, i = lastIndex; i >= 0; i--)
            {
                LogBuffers logBuffers = _lingeringLogBuffers[i];

                if (logBuffers.LingerDeadlineNs() - nowNs < 0)
                {
                    ListUtil.FastUnorderedRemove(_lingeringLogBuffers, i, lastIndex--);
                    CloseHelper.Dispose(_ctx.ErrorHandler(), logBuffers);
                    workCount += 1;
                }
            }

            return(workCount);
        }
コード例 #7
0
        public void ExecuteBadge(Context context, ComponentName componentName, int badgeCount)
        {
            if (_defaultBadger != null && _defaultBadger.IsSupported(context))
            {
                _defaultBadger.ExecuteBadge(context, componentName, badgeCount);
            }
            else
            {
                var     mUri            = Uri.Parse(ContentUrl);
                var     contentResolver = context.ContentResolver;
                ICursor cursor          = null;
                try
                {
                    cursor = contentResolver.Query(mUri, _contentProjection, "package=?", new[] { componentName.PackageName }, null);
                    if (cursor != null)
                    {
                        var entryActivityName  = componentName.ClassName;
                        var entryActivityExist = false;
                        while (cursor.MoveToNext())
                        {
                            var id            = cursor.GetInt(0);
                            var contentValues = GetContentValues(componentName, badgeCount, false);
                            contentResolver.Update(mUri, contentValues, "_id=?", new[] { id.ToString() });
                            if (entryActivityName.Equals(cursor.GetString(cursor.GetColumnIndex("class"))))
                            {
                                entryActivityExist = true;
                            }
                        }

                        if (!entryActivityExist)
                        {
                            var contentValues = GetContentValues(componentName, badgeCount, true);
                            contentResolver.Insert(mUri, contentValues);
                        }
                    }
                }
                finally
                {
                    CloseHelper.Close(cursor);
                }
            }
        }
コード例 #8
0
        public void OnClose()
        {
            aeron.RemoveCloseHandler(abortHandler);

            if (isAbort)
            {
                ctx.AbortLatch().Signal();
            }
            else
            {
                ErrorHandler errorHandler = ctx.CountedErrorHandler().OnError;

                if (isServiceActive)
                {
                    isServiceActive = false;
                    try
                    {
                        service.OnTerminate(this);
                    }
                    catch (Exception ex)
                    {
                        errorHandler(ex);
                    }
                }

                if (!ctx.OwnsAeronClient() && !aeron.IsClosed)
                {
                    foreach (var session in sessionByIdMap.Values)
                    {
                        session.Disconnect(errorHandler);
                    }


                    CloseHelper.Dispose(errorHandler, logAdapter);
                    CloseHelper.Dispose(errorHandler, _serviceAdapter);
                    CloseHelper.Dispose(errorHandler, _consensusModuleProxy);
                }
            }

            ctx.Dispose();
        }
コード例 #9
0
        private string GetSystemProperty(string propName)
        {
            string         line;
            BufferedReader input = null;

            try
            {
                var p = Runtime.GetRuntime().Exec("getprop " + propName);
                input = new BufferedReader(new InputStreamReader(p.InputStream), 1024);
                line  = input.ReadLine();
                input.Close();
            }
            catch (IOException)
            {
                return(null);
            }
            finally
            {
                CloseHelper.CloseQuietly(input);
            }
            return(line);
        }
コード例 #10
0
ファイル: AeronCluster.cs プロジェクト: G-Research/Aeron.NET
        private AeronCluster(Context ctx)
        {
            _ctx = ctx;

            Subscription subscription = null;
            Publication  publication  = null;

            try
            {
                ctx.Conclude();

                _aeron        = ctx.Aeron();
                _lock         = ctx.Lock();
                _idleStrategy = ctx.IdleStrategy();
                _nanoClock    = _aeron.Ctx().NanoClock();
                _isUnicast    = ctx.ClusterMemberEndpoints() != null;

                subscription  = _aeron.AddSubscription(ctx.EgressChannel(), ctx.EgressStreamId());
                _subscription = subscription;

                publication  = ConnectToCluster();
                _publication = publication;

                _clusterSessionId = OpenSession();
            }
            catch (Exception)
            {
                if (!ctx.OwnsAeronClient())
                {
                    CloseHelper.QuietDispose(publication);
                    CloseHelper.QuietDispose(subscription);
                }

                CloseHelper.QuietDispose(ctx);
                throw;
            }
        }
コード例 #11
0
        private SMB2Command ProcessSMB2Command(SMB2Command command, SMB2ConnectionState state)
        {
            if (command is SessionSetupRequest)
            {
                return(SessionSetupHelper.GetSessionSetupResponse((SessionSetupRequest)command, m_securityProvider, state));
            }
            else if (command is EchoRequest)
            {
                return(new EchoResponse());
            }
            else
            {
                SMB2Session session = state.GetSession(command.Header.SessionID);
                if (session == null)
                {
                    return(new ErrorResponse(command.CommandName, NTStatus.STATUS_USER_SESSION_DELETED));
                }

                if (command is TreeConnectRequest)
                {
                    return(TreeConnectHelper.GetTreeConnectResponse((TreeConnectRequest)command, state, m_services, m_shares));
                }
                else if (command is LogoffRequest)
                {
                    state.LogToServer(Severity.Information, "Logoff: User '{0}' logged off. (SessionID: {1})", session.UserName, command.Header.SessionID);
                    m_securityProvider.DeleteSecurityContext(ref session.SecurityContext.AuthenticationContext);
                    state.RemoveSession(command.Header.SessionID);
                    return(new LogoffResponse());
                }
                else if (command.Header.IsAsync)
                {
                    // TreeID will not be present in an ASYNC header
                    if (command is CancelRequest)
                    {
                        return(CancelHelper.GetCancelResponse((CancelRequest)command, state));
                    }
                }
                else
                {
                    ISMBShare share = session.GetConnectedTree(command.Header.TreeID);
                    if (share == null)
                    {
                        state.LogToServer(Severity.Verbose, "{0} failed. Invalid TreeID (SessionID: {1}, TreeID: {2}).", command.CommandName, command.Header.SessionID, command.Header.TreeID);
                        return(new ErrorResponse(command.CommandName, NTStatus.STATUS_NETWORK_NAME_DELETED));
                    }

                    if (command is TreeDisconnectRequest)
                    {
                        return(TreeConnectHelper.GetTreeDisconnectResponse((TreeDisconnectRequest)command, share, state));
                    }
                    else if (command is CreateRequest)
                    {
                        return(CreateHelper.GetCreateResponse((CreateRequest)command, share, state));
                    }
                    else if (command is QueryInfoRequest)
                    {
                        return(QueryInfoHelper.GetQueryInfoResponse((QueryInfoRequest)command, share, state));
                    }
                    else if (command is SetInfoRequest)
                    {
                        return(SetInfoHelper.GetSetInfoResponse((SetInfoRequest)command, share, state));
                    }
                    else if (command is QueryDirectoryRequest)
                    {
                        return(QueryDirectoryHelper.GetQueryDirectoryResponse((QueryDirectoryRequest)command, share, state));
                    }
                    else if (command is ReadRequest)
                    {
                        return(ReadWriteResponseHelper.GetReadResponse((ReadRequest)command, share, state));
                    }
                    else if (command is WriteRequest)
                    {
                        return(ReadWriteResponseHelper.GetWriteResponse((WriteRequest)command, share, state));
                    }
                    else if (command is LockRequest)
                    {
                        return(LockHelper.GetLockResponse((LockRequest)command, share, state));
                    }
                    else if (command is FlushRequest)
                    {
                        return(ReadWriteResponseHelper.GetFlushResponse((FlushRequest)command, share, state));
                    }
                    else if (command is CloseRequest)
                    {
                        return(CloseHelper.GetCloseResponse((CloseRequest)command, share, state));
                    }
                    else if (command is IOCtlRequest)
                    {
                        return(IOCtlHelper.GetIOCtlResponse((IOCtlRequest)command, share, state));
                    }
                    else if (command is CancelRequest)
                    {
                        return(CancelHelper.GetCancelResponse((CancelRequest)command, state));
                    }
                    else if (command is ChangeNotifyRequest)
                    {
                        return(ChangeNotifyHelper.GetChangeNotifyInterimResponse((ChangeNotifyRequest)command, share, state));
                    }
                }
            }

            return(new ErrorResponse(command.CommandName, NTStatus.STATUS_NOT_SUPPORTED));
        }
コード例 #12
0
 /// <summary>
 /// Saves the Files to the DB then closes the window.
 /// </summary>
 /// <param name="window">The window doing the closing.</param>
 private void saveAndClose(Window window)
 {
     SQLiteDataAccess.AddNewTag(NewTag);
     CloseHelper.CloseWindow(window);
 }
コード例 #13
0
ファイル: HandleHolder.cs プロジェクト: chinaboard/CuratorNet
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public UnsyncHelper(CloseHelper helper)
 {
     _helper = helper;
 }
コード例 #14
0
ファイル: HandleHolder.cs プロジェクト: Lagrang/CuratorNet
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public UnsyncHelper(CloseHelper helper)
 {
     _helper = helper;
 }
コード例 #15
0
 internal void Disconnect(ErrorHandler errorHandler)
 {
     CloseHelper.Dispose(errorHandler, _responsePublication);
     _responsePublication = null;
 }
コード例 #16
0
 /// <summary>
 /// Saves the Files to the DB then closes the window.
 /// </summary>
 /// <param name="window">The window doing the closing.</param>
 private void saveAndClose(Window window)
 {
     addFilesToDB();
     //TODO: Open a new tab with all of the added files as the search to make it easy to tag the new stuff.
     CloseHelper.CloseWindow(window);
 }
コード例 #17
0
        private Publication ConnectToCluster()
        {
            Publication publication     = null;
            string      ingressChannel  = _ctx.IngressChannel();
            int         ingressStreamId = _ctx.IngressStreamId();
            long        deadlineNs      = _nanoClock.NanoTime() + _ctx.MessageTimeoutNs();

            if (_isUnicast)
            {
                ChannelUri    channelUri   = ChannelUri.Parse(ingressChannel);
                int           memberCount  = _endpointByMemberIdMap.Count;
                Publication[] publications = new Publication[memberCount];

                foreach (var entry in _endpointByMemberIdMap)
                {
                    channelUri.Put(Aeron.Aeron.Context.ENDPOINT_PARAM_NAME, entry.Value);
                    string channel = channelUri.ToString();
                    publications[entry.Key] = AddIngressPublication(channel, ingressStreamId);
                }

                int connectedIndex = -1;
                while (true)
                {
                    for (int i = 0; i < memberCount; i++)
                    {
                        if (publications[i].IsConnected)
                        {
                            connectedIndex = i;
                            break;
                        }
                    }

                    if (-1 != connectedIndex)
                    {
                        for (int i = 0; i < memberCount; i++)
                        {
                            if (i == connectedIndex)
                            {
                                publication = publications[i];
                            }
                            else
                            {
                                publications[i]?.Dispose();
                            }
                        }

                        break;
                    }

                    if (_nanoClock.NanoTime() > deadlineNs)
                    {
                        for (int i = 0; i < memberCount; i++)
                        {
                            CloseHelper.QuietDispose(publications[i]);
                        }

                        throw new TimeoutException("awaiting connection to cluster");
                    }

                    _idleStrategy.Idle();
                }
            }
            else
            {
                publication = AddIngressPublication(ingressChannel, ingressStreamId);

                _idleStrategy.Reset();
                while (!publication.IsConnected)
                {
                    if (_nanoClock.NanoTime() > deadlineNs)
                    {
                        CloseHelper.QuietDispose(publication);

                        throw new TimeoutException("awaiting connection to cluster");
                    }

                    _idleStrategy.Idle();
                }
            }

            return(publication);
        }
コード例 #18
0
        private SMB2Command ProcessSMB2Command(SMB2Command command, SMB2ConnectionState state)
        {
            if (command is SessionSetupRequest)
            {
                return(SessionSetupHelper.GetSessionSetupResponse((SessionSetupRequest)command, m_securityProvider, state));
            }
            else if (command is EchoRequest)
            {
                return(new EchoResponse());
            }
            else
            {
                SMB2Session session = state.GetSession(command.Header.SessionID);
                if (session == null)
                {
                    return(new ErrorResponse(command.CommandName, NTStatus.STATUS_USER_SESSION_DELETED));
                }

                if (command is TreeConnectRequest)
                {
                    return(TreeConnectHelper.GetTreeConnectResponse((TreeConnectRequest)command, state, m_services, m_shares));
                }
                else if (command is LogoffRequest)
                {
                    state.LogToServer(Severity.Information, "Logoff: User '{0}' logged off.", session.UserName);
                    m_securityProvider.DeleteSecurityContext(ref session.SecurityContext.AuthenticationContext);
                    state.RemoveSession(command.Header.SessionID);
                    return(new LogoffResponse());
                }
                else
                {
                    // Cancel requests can have an ASYNC header (TreeID will not be present)
                    if (command is CancelRequest)
                    {
                        if (command.Header.IsAsync && command.Header.AsyncID == 0)
                        {
                            ErrorResponse response = new ErrorResponse(command.CommandName, NTStatus.STATUS_CANCELLED);
                            response.Header.IsAsync = true;
                            return(response);
                        }

                        // [MS-SMB2] If a request is not found, the server MUST stop processing for this cancel request. No response is sent.
                        return(null);
                    }

                    ISMBShare share = session.GetConnectedTree(command.Header.TreeID);
                    if (share == null)
                    {
                        return(new ErrorResponse(command.CommandName, NTStatus.STATUS_NETWORK_NAME_DELETED));
                    }

                    if (command is TreeDisconnectRequest)
                    {
                        return(TreeConnectHelper.GetTreeDisconnectResponse((TreeDisconnectRequest)command, share, state));
                    }
                    else if (command is CreateRequest)
                    {
                        return(CreateHelper.GetCreateResponse((CreateRequest)command, share, state));
                    }
                    else if (command is QueryInfoRequest)
                    {
                        return(QueryInfoHelper.GetQueryInfoResponse((QueryInfoRequest)command, share, state));
                    }
                    else if (command is SetInfoRequest)
                    {
                        return(SetInfoHelper.GetSetInfoResponse((SetInfoRequest)command, share, state));
                    }
                    else if (command is QueryDirectoryRequest)
                    {
                        return(QueryDirectoryHelper.GetQueryDirectoryResponse((QueryDirectoryRequest)command, share, state));
                    }
                    else if (command is ReadRequest)
                    {
                        return(ReadWriteResponseHelper.GetReadResponse((ReadRequest)command, share, state));
                    }
                    else if (command is WriteRequest)
                    {
                        return(ReadWriteResponseHelper.GetWriteResponse((WriteRequest)command, share, state));
                    }
                    else if (command is FlushRequest)
                    {
                        FlushRequest   request  = (FlushRequest)command;
                        OpenFileObject openFile = session.GetOpenFileObject(request.FileId);
                        if (openFile == null)
                        {
                            return(new ErrorResponse(request.CommandName, NTStatus.STATUS_FILE_CLOSED));
                        }
                        NTStatus status = share.FileStore.FlushFileBuffers(openFile.Handle);
                        if (status != NTStatus.STATUS_SUCCESS)
                        {
                            return(new ErrorResponse(request.CommandName, status));
                        }
                        return(new FlushResponse());
                    }
                    else if (command is CloseRequest)
                    {
                        return(CloseHelper.GetCloseResponse((CloseRequest)command, share, state));
                    }
                    else if (command is IOCtlRequest)
                    {
                        return(IOCtlHelper.GetIOCtlResponse((IOCtlRequest)command, share, state));
                    }
                    else if (command is ChangeNotifyRequest)
                    {
                        // [MS-SMB2] If the underlying object store does not support change notifications, the server MUST fail this request with STATUS_NOT_SUPPORTED
                        ErrorResponse response = new ErrorResponse(command.CommandName, NTStatus.STATUS_NOT_SUPPORTED);
                        // Windows 7 / 8 / 10 will infinitely retry sending ChangeNotify requests if the response does not have SMB2_FLAGS_ASYNC_COMMAND set.
                        // Note: NoRemoteChangeNotify can be set in the registry to prevent the client from sending ChangeNotify requests altogether.
                        response.Header.IsAsync = true;
                        return(response);
                    }
                }
            }

            return(new ErrorResponse(command.CommandName, NTStatus.STATUS_NOT_SUPPORTED));
        }
コード例 #19
0
ファイル: SMBServer.SMB1.cs プロジェクト: Ozytis/SMBLibrary
        private List <SMB1Command> ProcessSMB1Command(SMB1Header header, SMB1Command command, SMB1ConnectionState state)
        {
            if (command is SessionSetupAndXRequest)
            {
                SessionSetupAndXRequest request = (SessionSetupAndXRequest)command;
                state.MaxBufferSize = request.MaxBufferSize;
                return(SessionSetupHelper.GetSessionSetupResponse(header, request, m_securityProvider, state));
            }
            else if (command is SessionSetupAndXRequestExtended)
            {
                SessionSetupAndXRequestExtended request = (SessionSetupAndXRequestExtended)command;
                state.MaxBufferSize = request.MaxBufferSize;
                return(SessionSetupHelper.GetSessionSetupResponseExtended(header, request, m_securityProvider, state));
            }
            else if (command is EchoRequest)
            {
                return(EchoHelper.GetEchoResponse((EchoRequest)command));
            }
            else
            {
                SMB1Session session = state.GetSession(header.UID);
                if (session == null)
                {
                    header.Status = NTStatus.STATUS_USER_SESSION_DELETED;
                    return(new ErrorResponse(command.CommandName));
                }

                if (command is TreeConnectAndXRequest)
                {
                    return(TreeConnectHelper.GetTreeConnectResponse(header, (TreeConnectAndXRequest)command, state, m_services, m_shares));
                }
                else if (command is LogoffAndXRequest)
                {
                    state.LogToServer(Severity.Information, "Logoff: User '{0}' logged off. (UID: {1})", session.UserName, header.UID);
                    m_securityProvider.DeleteSecurityContext(ref session.SecurityContext.AuthenticationContext);
                    state.RemoveSession(header.UID);
                    return(new LogoffAndXResponse());
                }
                else
                {
                    ISMBShare share = session.GetConnectedTree(header.TID);
                    if (share == null)
                    {
                        state.LogToServer(Severity.Verbose, "{0} failed. Invalid TID (UID: {1}, TID: {2}).", command.CommandName, header.UID, header.TID);
                        header.Status = NTStatus.STATUS_SMB_BAD_TID;
                        return(new ErrorResponse(command.CommandName));
                    }

                    if (command is CreateDirectoryRequest)
                    {
                        return(FileStoreResponseHelper.GetCreateDirectoryResponse(header, (CreateDirectoryRequest)command, share, state));
                    }
                    else if (command is DeleteDirectoryRequest)
                    {
                        return(FileStoreResponseHelper.GetDeleteDirectoryResponse(header, (DeleteDirectoryRequest)command, share, state));
                    }
                    else if (command is CloseRequest)
                    {
                        return(CloseHelper.GetCloseResponse(header, (CloseRequest)command, share, state));
                    }
                    else if (command is FlushRequest)
                    {
                        return(ReadWriteResponseHelper.GetFlushResponse(header, (FlushRequest)command, share, state));
                    }
                    else if (command is DeleteRequest)
                    {
                        return(FileStoreResponseHelper.GetDeleteResponse(header, (DeleteRequest)command, share, state));
                    }
                    else if (command is RenameRequest)
                    {
                        return(FileStoreResponseHelper.GetRenameResponse(header, (RenameRequest)command, share, state));
                    }
                    else if (command is QueryInformationRequest)
                    {
                        return(FileStoreResponseHelper.GetQueryInformationResponse(header, (QueryInformationRequest)command, share, state));
                    }
                    else if (command is SetInformationRequest)
                    {
                        return(FileStoreResponseHelper.GetSetInformationResponse(header, (SetInformationRequest)command, share, state));
                    }
                    else if (command is ReadRequest)
                    {
                        return(ReadWriteResponseHelper.GetReadResponse(header, (ReadRequest)command, share, state));
                    }
                    else if (command is WriteRequest)
                    {
                        return(ReadWriteResponseHelper.GetWriteResponse(header, (WriteRequest)command, share, state));
                    }
                    else if (command is CheckDirectoryRequest)
                    {
                        return(FileStoreResponseHelper.GetCheckDirectoryResponse(header, (CheckDirectoryRequest)command, share, state));
                    }
                    else if (command is WriteRawRequest)
                    {
                        // [MS-CIFS] 3.3.5.26 - Receiving an SMB_COM_WRITE_RAW Request:
                        // the server MUST verify that the Server.Capabilities include CAP_RAW_MODE,
                        // If an error is detected [..] the Write Raw operation MUST fail and
                        // the server MUST return a Final Server Response [..] with the Count field set to zero.
                        return(new WriteRawFinalResponse());
                    }
                    else if (command is SetInformation2Request)
                    {
                        return(FileStoreResponseHelper.GetSetInformation2Response(header, (SetInformation2Request)command, share, state));
                    }
                    else if (command is LockingAndXRequest)
                    {
                        return(LockingHelper.GetLockingAndXResponse(header, (LockingAndXRequest)command, share, state));
                    }
                    else if (command is OpenAndXRequest)
                    {
                        return(OpenAndXHelper.GetOpenAndXResponse(header, (OpenAndXRequest)command, share, state));
                    }
                    else if (command is ReadAndXRequest)
                    {
                        return(ReadWriteResponseHelper.GetReadResponse(header, (ReadAndXRequest)command, share, state));
                    }
                    else if (command is WriteAndXRequest)
                    {
                        return(ReadWriteResponseHelper.GetWriteResponse(header, (WriteAndXRequest)command, share, state));
                    }
                    else if (command is FindClose2Request)
                    {
                        return(CloseHelper.GetFindClose2Response(header, (FindClose2Request)command, state));
                    }
                    else if (command is TreeDisconnectRequest)
                    {
                        return(TreeConnectHelper.GetTreeDisconnectResponse(header, (TreeDisconnectRequest)command, share, state));
                    }
                    else if (command is TransactionRequest) // Both TransactionRequest and Transaction2Request
                    {
                        return(TransactionHelper.GetTransactionResponse(header, (TransactionRequest)command, share, state));
                    }
                    else if (command is TransactionSecondaryRequest) // Both TransactionSecondaryRequest and Transaction2SecondaryRequest
                    {
                        return(TransactionHelper.GetTransactionResponse(header, (TransactionSecondaryRequest)command, share, state));
                    }
                    else if (command is NTTransactRequest)
                    {
                        return(NTTransactHelper.GetNTTransactResponse(header, (NTTransactRequest)command, share, state));
                    }
                    else if (command is NTTransactSecondaryRequest)
                    {
                        return(NTTransactHelper.GetNTTransactResponse(header, (NTTransactSecondaryRequest)command, share, state));
                    }
                    else if (command is NTCreateAndXRequest)
                    {
                        return(NTCreateHelper.GetNTCreateResponse(header, (NTCreateAndXRequest)command, share, state));
                    }
                    else if (command is NTCancelRequest)
                    {
                        CancelHelper.ProcessNTCancelRequest(header, (NTCancelRequest)command, share, state);
                        // [MS-CIFS] The SMB_COM_NT_CANCEL command MUST NOT send a response.
                        return(new List <SMB1Command>());
                    }
                }
            }

            header.Status = NTStatus.STATUS_SMB_BAD_COMMAND;
            return(new ErrorResponse(command.CommandName));
        }