internal override void ProcessReply(CallbackMessage message, bool moreComing)
 {
     if (message is BrowseCallbackMessage brm)
     {
         BrowseEvent?.Invoke(Token, new BrowseEventArgs(brm.Payload.Flags.HasFlag(ServiceFlags.Add) ? BrowseEventType.Added : BrowseEventType.Removed,
                                                        new ServiceDescriptor(brm.Payload.InstanceName, brm.Payload.ServiceType, brm.Payload.Domain, brm.Payload.InterfaceIndex), moreComing));
     }
 }
        public async Task <IOperationToken> BrowseAsync(string serviceType, string domain = "", uint interfaceIndex = 0, object context = null)
        {
            await CheckConnectionAsync();

            var op = new BrowseOperation(serviceType, domain, interfaceIndex, context);

            op.BrowseEvent += (s, e) => BrowseEvent?.Invoke(s, e);

            await _connection.AddAndExecuteSubordinate(op);

            return(op.Token);
        }
示例#3
0
        /// <summary>
        /// Fills the CurrentItems property for display in ItemsControl
        /// based view (ListBox, ListView etc.).
        ///
        /// This method wraps a parameterized version of the same method
        /// with a call that contains the standard data field.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="browseEvent">Defines whether a request should result
        /// in an explicit event relayed to a controller or not.</param>
        protected FinalBrowseResult PopulateView(BrowseRequest request,
                                                 bool browseEvent)
        {
            //Logger.DebugFormat("PopulateView method");
            //Logger.DebugFormat("Populating view for request id: {0} - '{1}'", request.RequestId, request.NewLocation.Path);

            // This can happen when the viewmodel is configured at start-up
            // but the current folder is not configured, yet
            if (request == null)
            {
                return(FinalBrowseResult.FromRequest(request, BrowseResult.InComplete));
            }

            IPathModel newPathToNavigateTo = request.NewLocation;

            bool result = false;

            IsBrowsing = true;
            try
            {
                if (newPathToNavigateTo != null && browseEvent == true)
                {
                    BrowseEvent?.Invoke(this,
                                        new BrowsingEventArgs(newPathToNavigateTo, true));
                }

                DirectoryInfo cur = new DirectoryInfo(newPathToNavigateTo.Path);

                if (cur.Exists == false)
                {
                    return(FinalBrowseResult.FromRequest(request, BrowseResult.InComplete));
                }

                CurrentItemClear();

                result = InternalPopulateView(_ParsedFilter, cur, ShowIcons);

                if (result == true)
                {
                    SetCurrentLocation(newPathToNavigateTo);
                    return(FinalBrowseResult.FromRequest(request, BrowseResult.Complete));
                }

                return(FinalBrowseResult.FromRequest(request, BrowseResult.InComplete));
            }
            catch (Exception exp)
            {
                var bresult = FinalBrowseResult.FromRequest(request, BrowseResult.InComplete);
                bresult.UnexpectedError = exp;
                return(bresult);
            }
            finally
            {
                if (newPathToNavigateTo != null && browseEvent == true)
                {
                    BrowseEvent?.Invoke(this, new BrowsingEventArgs(
                                            newPathToNavigateTo, false,
                                            result == true ? BrowseResult.Complete : BrowseResult.InComplete));
                }

                IsBrowsing = false;
            }
        }