Ejemplo n.º 1
0
        //-------------------------------------------------------------------------

        public static bool GetIsDependencyAllowed(Type dependant, Type dependency)
        {
            if (AllowedDependencies.ContainsKey(dependant))
            {
                return(AllowedDependencies[dependant].Contains(dependency));
            }

            return(false);
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------

        public static void AddAllowedDependency(Type dependant, Type dependency)
        {
            // Types must extend Entity class.
            if (dependant.IsSubclassOf(typeof(Entity)) == false ||
                dependency.IsSubclassOf(typeof(Entity)) == false)
            {
                throw new Exception("Dependant and dependency types must extend Entity.");
            }

            // First time a dependant of this type is used?
            if (AllowedDependencies.ContainsKey(dependant) == false)
            {
                AllowedDependencies.Add(
                    dependant,
                    new List <Type>());
            }

            // Add the dependency for the dependant.
            if (AllowedDependencies[dependant].Contains(dependency) == false)
            {
                AllowedDependencies[dependant].Add(dependency);
            }
        }