ByChance.Core.Context.ClearTarget C# (CSharp) Method

ClearTarget() public method

Breaks the connection between this context and its target, setting Target of both contexts to null.
public ClearTarget ( ) : void
return void
        public void ClearTarget()
        {
            if (this.Target == null)
            {
                return;
            }

            this.Target.Target = null;
            this.Target = null;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Removes passed context from the chunk's list of contexts.
        /// </summary>
        /// <param name="context">Context to be removed.</param>
        /// <exception cref="ArgumentNullException"><paramref name="context"/> is null.</exception>
        /// <returns><c>true</c>, if the context has been removed, and <c>false</c> otherwise.</returns>
        public bool RemoveContext(Context context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (this.ChunkContexts.Remove(context))
            {
                context.ClearTarget();
                return true;
            }

            return false;
        }