コード例 #1
0
        /// <summary>
        ///     Clears the binding.
        /// </summary>
        /// <param name="target">
        ///     The target.
        /// </param>
        public void ClearBinding(object target)
        {
            WeakTarget weakTarget = this.GetWeakTarget(target);

            weakTarget.ClearBindings();

            this.weakTargets.Remove(weakTarget.GetHashCode());
        }
コード例 #2
0
        /// <summary>
        ///     Gets the <see cref="WeakTarget"/>.
        /// </summary>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <returns>
        ///     The <see cref="WeakTarget"/>.
        /// </returns>
        private WeakTarget GetWeakTarget(object target)
        {
            if (this.weakTargets.ContainsKey(target))
            {
                return(this.weakTargets[target]);
            }

            var weakTarget = new WeakTarget(target);

            this.weakTargets.Add(target, weakTarget);
            return(weakTarget);
        }
コード例 #3
0
        /// <summary>
        ///     Sets the binding.
        /// </summary>
        /// <typeparam name="T">
        ///     The concrete <see cref="WeakBinding"/> to return.
        /// </typeparam>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="targetProperty">
        ///     The target property.
        /// </param>
        /// <param name="source">
        ///     The source.
        /// </param>
        /// <param name="sourceProperty">
        ///     The source property.
        /// </param>
        /// <param name="activate">
        ///     if set to <c>true</c> activate.
        /// </param>
        /// <returns>
        ///     The <see cref="T"/>.
        /// </returns>
        public T SetBinding <T>(object target, string targetProperty, object source, string sourceProperty, bool activate = true) where T : WeakBinding
        {
            WeakTarget weakTarget = this.GetWeakTarget(target);

            return(weakTarget.SetBinding <T>(targetProperty, source, sourceProperty, activate));
        }
コード例 #4
0
        /// <summary>
        ///     Sets the property binding.
        /// </summary>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="targetProperty">
        ///     The target property.
        /// </param>
        /// <param name="source">
        ///     The source.
        /// </param>
        /// <param name="sourceProperty">
        ///     The source property.
        /// </param>
        /// <param name="activate">
        ///     The activate.
        /// </param>
        /// <returns>
        ///     The <see cref="WeakPropertyBinding"/>.
        /// </returns>
        public WeakPropertyBinding SetPropertyBinding(object target, string targetProperty, object source, string sourceProperty, bool activate = true)
        {
            WeakTarget weakTarget = this.GetWeakTarget(target);

            return(weakTarget.SetBinding <WeakPropertyBinding>(targetProperty, source, sourceProperty, activate));
        }
コード例 #5
0
        /// <summary>
        ///     Clears the binding.
        /// </summary>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="targetProperty">
        ///     The target property.
        /// </param>
        /// <param name="source">
        ///     The source.
        /// </param>
        /// <param name="sourceProperty">
        ///     The source property.
        /// </param>
        public void ClearBinding(object target, string targetProperty, object source, string sourceProperty)
        {
            WeakTarget weakTarget = this.GetWeakTarget(target);

            weakTarget.ClearBinding(targetProperty, source, sourceProperty);
        }