Beispiel #1
0
		/// <summary>Associate ClassCache object with the given top-level scope.</summary>
		/// <remarks>
		/// Associate ClassCache object with the given top-level scope.
		/// The ClassCache object can only be associated with the given scope once.
		/// </remarks>
		/// <param name="topScope">scope to associate this ClassCache object with.</param>
		/// <returns>
		/// true if no previous ClassCache objects were embedded into
		/// the scope and this ClassCache were successfully associated
		/// or false otherwise.
		/// </returns>
		/// <seealso cref="Get(Scriptable)">Get(Scriptable)</seealso>
		public virtual bool Associate(ScriptableObject topScope)
		{
			if (topScope.GetParentScope() != null)
			{
				// Can only associate cache with top level scope
				throw new ArgumentException();
			}
			if (this == topScope.AssociateValue(AKEY, this))
			{
				associatedScope = topScope;
				return true;
			}
			return false;
		}