Esempio n. 1
0
        /// <summary>
        /// Sets an association between an object and a symbol.
        /// </summary>
        /// <param name="associatable">The associated object; or <see langword="null"/>.</param>
        /// <param name="symbol">The associated symbol; or <see langword="null"/>.</param>
        public static void SetAssociation(IAssociatable associatable, Symbol symbol)
        {
            if (symbol != null && associatable != null)
            {
                // Remove the associations between the specified symbol and its associatable,
                // and the specified associatable and its symbol.
                SetAssociation(symbol.association, null);
                SetAssociation(associatable, null);

                symbol.association = associatable;
                associatable.SetAssociatedSymbol(symbol);
            }
            else if (symbol != null)
            {
                if (symbol.association != null)
                {
                    symbol.association.SetAssociatedSymbol(null);
                }
                symbol.association = null;
            }
            else if (associatable != null)
            {
                if (associatable.AssociatedSymbol != null)
                {
                    associatable.AssociatedSymbol.association = null;
                }
                associatable.SetAssociatedSymbol(null);
            }
            // Else: both are null. We don't have to associate a null object with a null Symbol.
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Reference"/> class that references an associatable object.
        /// </summary>
        /// <param name="associatable">The <see cref="IAssociatable"/> being referenced.</param>
        /// <remarks>
        /// When the <see cref="IAssociatable"/> changes its <see cref="IAssociatable.AssociatedSymbol"/>,
        /// this reference is <em>not</em> updated or changed to reflect that, and will still be pointing at the
        /// previous, obsolete symbol.
        /// </remarks>
        public Reference(IAssociatable associatable)
        {
            #region Contract
            Contract.Requires<ArgumentNullException>(associatable != null);
            #endregion

            this.symbol = associatable.AssociatedSymbol;
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Reference"/> class that references an associatable object.
        /// </summary>
        /// <param name="associatable">The <see cref="IAssociatable"/> being referenced.</param>
        /// <remarks>
        /// When the <see cref="IAssociatable"/> changes its <see cref="IAssociatable.AssociatedSymbol"/>,
        /// this reference is <em>not</em> updated or changed to reflect that, and will still be pointing at the
        /// previous, obsolete symbol.
        /// </remarks>
        public Reference(IAssociatable associatable)
        {
            #region Contract
            Contract.Requires <ArgumentNullException>(associatable != null);
            #endregion

            this.symbol = associatable.AssociatedSymbol;
        }
Esempio n. 4
0
 /// <summary>
 /// Sets an association between an object and a symbol.
 /// </summary>
 /// <param name="symbol">The associated symbol; or <see langword="null"/>.</param>
 /// <param name="associatable">The associated object; or <see langword="null"/>.</param>
 public static void SetAssociation(Symbol symbol, IAssociatable associatable)
 {
     SetAssociation(associatable, symbol);
 }
Esempio n. 5
0
        /// <summary>
        /// Sets an association between an object and a symbol.
        /// </summary>
        /// <param name="associatable">The associated object; or <see langword="null"/>.</param>
        /// <param name="symbol">The associated symbol; or <see langword="null"/>.</param>
        public static void SetAssociation(IAssociatable associatable, Symbol symbol)
        {
            if (symbol != null && associatable != null)
            {
                // Remove the associations between the specified symbol and its associatable,
                // and the specified associatable and its symbol.
                SetAssociation(symbol.association, null);
                SetAssociation(associatable, null);

                symbol.association = associatable;
                associatable.SetAssociatedSymbol(symbol);
            }
            else if (symbol != null)
            {
                if (symbol.association != null)
                    symbol.association.SetAssociatedSymbol(null);
                symbol.association = null;
            }
            else if (associatable != null)
            {
                if (associatable.AssociatedSymbol != null)
                    associatable.AssociatedSymbol.association = null;
                associatable.SetAssociatedSymbol(null);
            }
            // Else: both are null. We don't have to associate a null object with a null Symbol.
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Reference"/> class that references an associatable object.
 /// </summary>
 /// <param name="associatable">The <see cref="IAssociatable"/> being referenced.</param>
 /// <remarks>
 /// When the <see cref="IAssociatable"/> changes its <see cref="IAssociatable.AssociatedSymbol"/>,
 /// this reference is <em>not</em> updated or changed to reflect that, and will still be pointing at the
 /// previous, obsolete symbol.
 /// </remarks>
 public Reference(IAssociatable associatable)
 {
     Symbol = associatable.AssociatedSymbol;
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Reference"/> class that references an associatable object.
 /// </summary>
 /// <param name="associatable">The <see cref="IAssociatable"/> being referenced.</param>
 /// <remarks>
 /// When the <see cref="IAssociatable"/> changes its <see cref="IAssociatable.AssociatedSymbol"/>,
 /// this reference is <em>not</em> updated or changed to reflect that, and will still be pointing at the
 /// previous, obsolete symbol.
 /// </remarks>
 public Reference(IAssociatable associatable)
 {
     Symbol = associatable.AssociatedSymbol;
 }
Esempio n. 8
0
 /// <summary>
 /// Sets an association between an object and a symbol.
 /// </summary>
 /// <param name="symbol">The associated symbol; or <see langword="null"/>.</param>
 /// <param name="associatable">The associated object; or <see langword="null"/>.</param>
 public static void SetAssociation(Symbol symbol, IAssociatable associatable)
 {
     SetAssociation(associatable, symbol);
 }