using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace Csla.Security
{
///
/// Maintains a list of all the per-type
/// objects
/// loaded in memory.
///
internal static class SharedAuthorizationRules
{
private static Dictionary _managers =
new Dictionary();
///
/// Gets the for the
/// specified object type, optionally creating a new instance
/// of the object if necessary.
///
///
/// Type of business object for which the rules apply.
///
/// Indicates whether to create
/// a new instance of the object if one doesn't exist.
internal static AuthorizationRulesManager GetManager(Type objectType, bool create)
{
AuthorizationRulesManager result = null;
if (!_managers.TryGetValue(objectType, out result) && create)
{
lock (_managers)
{
result = new AuthorizationRulesManager();
_managers.Add(objectType, result);
}
}
return result;
}
///
/// Gets a value indicating whether a set of rules
/// have been created for a given .
///
///
/// Type of business object for which the rules apply.
///
/// if rules exist for the type.
public static bool RulesExistFor(Type objectType)
{
return _managers.ContainsKey(objectType);
}
}
}