Пример #1
0
        private bool MemberNameEqual(string memberName, IBindingSourceAccessor accessor)
        {
            if (string.IsNullOrEmpty(memberName))
            {
                return(true);
            }
            var  paths    = ErrorPaths;
            bool hasPaths = paths != null && paths.Length != 0;

            if (hasPaths)
            {
                for (int i = 0; i < paths.Length; i++)
                {
                    if (ToolkitExtensions.PropertyNameEqual(memberName, paths[i], true))
                    {
                        return(true);
                    }
                }
            }
            var    singleAccessor = accessor as ISingleBindingSourceAccessor;
            string path;

            if (singleAccessor != null)
            {
                path = singleAccessor.Source.Path.Parts.LastOrDefault();
                if (hasPaths && string.IsNullOrEmpty(path))
                {
                    return(false);
                }
                return(ToolkitExtensions.PropertyNameEqual(memberName, path, true));
            }
            for (int i = 0; i < accessor.Sources.Count; i++)
            {
                path = accessor.Sources[i].Path.Parts.LastOrDefault();
                if (hasPaths && string.IsNullOrEmpty(path))
                {
                    continue;
                }
                if (ToolkitExtensions.PropertyNameEqual(memberName, path, true))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
            public void Handle(object sender, PropertyChangedEventArgs args)
            {
                bool hasDeadRef = false;
                var  listeners  = _listeners;

                for (int i = 0; i < listeners.Length; i++)
                {
                    var pair = listeners[i];
                    if (ToolkitExtensions.PropertyNameEqual(args.PropertyName, pair.Value, true))
                    {
                        if (!pair.Key.EventListener.TryHandle(sender, args))
                        {
                            hasDeadRef = true;
                        }
                    }
                }
                if (hasDeadRef)
                {
                    lock (_propertyChanged)
                        Update(WeakEventListenerWrapper.Empty, null);
                }
            }