Esempio n. 1
0
        // classMap can have more than one templateMaps of the same templateIds
        public void AddTemplateMap(ClassMap classMap, TemplateMap templateMap)
        {
            AddClassMap(null, classMap);
            KeyValuePair <ClassMap, List <TemplateMap> > pair = classTemplateListMaps.Where(c => c.Key.classId == classMap.classId).FirstOrDefault();

            if (pair.Key != null)
            {
                pair.Value.Add(templateMap);
            }
        }
Esempio n. 2
0
        public TemplateMap(TemplateMap templateMap)
            : this()
        {
            templateId = templateMap.templateId;
            name       = templateMap.name;

            foreach (RoleMap roleMap in templateMap.roleMaps)
            {
                roleMaps.Add(new RoleMap(roleMap));
            }
        }
Esempio n. 3
0
        public void DeleteRoleMap(TemplateMap templateMap, string roleId)
        {
            RoleMap roleMap = templateMap.roleMaps.Where(c => c.roleId == roleId).FirstOrDefault();

            if (roleMap != null)
            {
                if (roleMap.classMap != null)
                {
                    DeleteClassMap(roleMap.classMap.classId);
                    roleMap.classMap = null;
                }
            }
        }
Esempio n. 4
0
        public void DeleteTemplateMap(string classId, TemplateMap templateMap)
        {
            KeyValuePair <ClassMap, List <TemplateMap> > classTemplateListMap = GetClassTemplateListMap(classId);

            if (classTemplateListMap.Key != null)
            {
                List <TemplateMap> templateMaps = classTemplateListMap.Value;

                foreach (TemplateMap tplMap in templateMaps)
                {
                    if (tplMap.templateId == templateMap.templateId)
                    {
                        bool templateMatched = true;

                        // a template is matched when its id and all the roles are matched
                        foreach (RoleMap roleMap in templateMap.roleMaps)
                        {
                            foreach (RoleMap rlMap in tplMap.roleMaps)
                            {
                                if (rlMap.roleId == roleMap.roleId && rlMap.value != rlMap.value)
                                {
                                    templateMatched = false;
                                    break;
                                }
                            }

                            if (!templateMatched)
                            {
                                break;
                            }
                        }

                        if (templateMatched)
                        {
                            List <RoleMap> classRoles = templateMap.roleMaps.Where(c => c.classMap != null).ToList <RoleMap>();

                            if (classRoles != null)
                            {
                                foreach (RoleMap classRole in classRoles)
                                {
                                    DeleteClassMap(classRole.classMap.classId);
                                }
                            }

                            templateMaps.Remove(templateMap);
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 5
0
 public TemplateMap(TemplateMap templateMap, RoleMap roleMap)
     : this(templateMap)
 {
     AddRoleMap(roleMap);
 }