Esempio n. 1
0
        public CollectionOfCollections <Plan> GetPlansInterface(Type t)
        {
            if (!t.IsInterface)
            {
                throw new ArgumentException("must be an interface.");
            }

            CollectionOfCollections <Plan> retval = new CollectionOfCollections <Plan>();

            foreach (Type dbType in plansByType.Keys)
            {
                if (dbType.Equals(t))
                {
                    retval.Add(plansByType[dbType]);
                }
                else
                {
                    foreach (Type interfaceType in dbType.GetInterfaces())
                    {
                        if (t.Equals(interfaceType))
                        {
                            retval.Add(plansByType[dbType]);
                            break;
                        }
                    }
                }
            }
            return(retval);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a list of plans of type t in the database.
        /// New: The list returned can be empty if its a valuetype and a default value can't be created
        /// </summary>
        /// <param name="t">The type of plan desired.</param>
        /// <returns></returns>
        private CollectionOfCollections <Plan> GetPlans(Type t)
        {
            if (!plansByType.ContainsKey(t))
            {
                bool success;
                Plan pl = DefaultPlan(t, out success);
                if (success)
                {
                    AddPlan(pl);
                }
                else
                {
                    return(null);
                }
            }

            Util.Assert(plansByType[t] != null);

            if (t.IsInterface)
            {
                return(GetPlansInterface(t));
            }

            CollectionOfCollections <Plan> retval = new CollectionOfCollections <Plan>();

            retval.Add(plansByType[t]);

            if (typeMatchingMode == TypeMatchingMode.SubTypes)
            {
                foreach (Type dbType in typeMap.TypesWithPlans(t).Keys)
                {
                    Util.Assert(ReflectionUtils.IsSubclassOrEqual(dbType, t));
                    retval.Add(plansByType[dbType]);
                }
            }

            return(retval);
        }
Esempio n. 3
0
        public CollectionOfCollections<Plan> GetPlansInterface(Type t)
        {
            if (!t.IsInterface)
                throw new ArgumentException("must be an interface.");

            CollectionOfCollections<Plan> retval = new CollectionOfCollections<Plan>();
            foreach (Type dbType in plansByType.Keys)
            {
                if (dbType.Equals(t))
                    retval.Add(plansByType[dbType]);
                else
                {
                    foreach (Type interfaceType in dbType.GetInterfaces())
                        if (t.Equals(interfaceType))
                        {
                            retval.Add(plansByType[dbType]);
                            break;
                        }
                }
            }
            return retval;
        }
Esempio n. 4
0
        /// <summary>
        /// Returns a list of plans of type t in the database.
        /// New: The list returned can be empty if its a valuetype and a default value can't be created
        /// </summary>
        /// <param name="t">The type of plan desired.</param>
        /// <returns></returns>
        private CollectionOfCollections<Plan> GetPlans(Type t)
        {
            if (!plansByType.ContainsKey(t))
            {
                bool success;
                Plan pl = DefaultPlan(t, out success);
                if (success)
                {
                    AddPlan(pl);
                }
                else
                    return null;
            }

            Util.Assert(plansByType[t] != null);

            if (t.IsInterface)
                return GetPlansInterface(t);

            CollectionOfCollections<Plan> retval = new CollectionOfCollections<Plan>();
            retval.Add(plansByType[t]);

            if (typeMatchingMode == TypeMatchingMode.SubTypes)
            {
                foreach (Type dbType in typeMap.TypesWithPlans(t).Keys)
                {
                    Util.Assert(ReflectionUtils.IsSubclassOrEqual(dbType, t));
                    retval.Add(plansByType[dbType]);
                }
            }

            return retval;
        }