Ejemplo n.º 1
0
        /// <summary>
        /// Unregisters the given authority.
        /// </summary>
        /// <param name="authority"></param>
        internal static void Unregister(DynamicUriAuthority authority)
        {
            Contract.Requires<ArgumentNullException>(authority != null);

            if (authorities.ContainsKey(authority.Id))
                lock (authorities)
                    if (authorities.ContainsKey(authority.Id))
                        authorities.Remove(authority.Id);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Registers the given authority.
        /// </summary>
        /// <param name="authority"></param>
        internal static void Register(DynamicUriAuthority authority)
        {
            Contract.Requires<ArgumentNullException>(authority != null);

            if (authorities.ContainsKey(authority.Id))
                throw new InvalidOperationException();

            lock (authorities)
                authorities.Add(authority.Id, new WeakReference<DynamicUriAuthority>(authority));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Registers the given authority.
        /// </summary>
        /// <param name="authority"></param>
        internal static void Register(DynamicUriAuthority authority)
        {
            Contract.Requires <ArgumentNullException>(authority != null);

            if (authorities.ContainsKey(authority.Id))
            {
                throw new InvalidOperationException();
            }

            lock (authorities)
                authorities.Add(authority.Id, new WeakReference <DynamicUriAuthority>(authority));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Unregisters the given authority.
        /// </summary>
        /// <param name="authority"></param>
        internal static void Unregister(DynamicUriAuthority authority)
        {
            Contract.Requires <ArgumentNullException>(authority != null);

            if (authorities.ContainsKey(authority.Id))
            {
                lock (authorities)
                    if (authorities.ContainsKey(authority.Id))
                    {
                        authorities.Remove(authority.Id);
                    }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the given authority.
        /// </summary>
        /// <param name="id"></param>
        internal static DynamicUriAuthority Get(Guid id)
        {
            Contract.Requires <ArgumentException>(id != Guid.Empty);

            lock (authorities)
            {
                DynamicUriAuthority a = null;

                var w = authorities.GetOrDefault(id);
                if (w != null)
                {
                    w.TryGetTarget(out a);
                }

                return(a);
            }
        }