Ejemplo n.º 1
0
        public static TTerm AddTerm <TTerm>(BaseTaxonomy taxonomy, Session session, string termPath, string termName) where TTerm : BaseTerm
        {
            var term = GetTerm <TTerm>(session, StructurePath(taxonomy.Key, termPath));

            if (term == null)
            {
                string[] pathSegments = GetPathSegments(taxonomy.Key, termPath);

                if (pathSegments.Length == 0)
                {
                    throw new UserFriendlyException(new ArgumentException(String.Format("Invalid path: {0}", termPath)));
                }

                term      = (TTerm)Activator.CreateInstance(typeof(TTerm), session);
                term.Key  = pathSegments.Last();
                term.Name = String.IsNullOrEmpty(termName) ? pathSegments.Last() : termName;
                string parentPath = termPath.Substring(0, termPath.LastIndexOf("/"));
                if (!string.IsNullOrEmpty(parentPath) && parentPath != taxonomy.Key)
                {
                    term.ParentTerm = AddTerm <TTerm>(taxonomy, session, parentPath, String.Empty);
                }
                else if (session != taxonomy.Session)
                {
                    term.BaseTaxonomy = (IBaseTaxonomy)session.GetObject(taxonomy);
                }
                else
                {
                    term.BaseTaxonomy = taxonomy;
                }
                term.EvaluateTermPropertyValues(false);
            }
            return(term);
        }
Ejemplo n.º 2
0
        public static TTerm AddStructuralTerm <TTerm>(BaseTaxonomy taxonomy, Session session, string termPath, string termName, Type[] types) where TTerm : BaseTerm, IStructuralTerm
        {
            var term = AddTerm <TTerm>(taxonomy, session, termPath, termName);

            term.UpdateTypes(types);
            return(term);
        }
Ejemplo n.º 3
0
        public static TTerm AddValueTerm <TTerm>(BaseTaxonomy taxonomy, Session session, string termPath, string termName, IStructuralTerm structuralTerm) where TTerm : BaseTerm, IValueTerm
        {
            var term = AddValueTerm <TTerm>(taxonomy, session, termPath, termName);

            term.StructuralTerm = structuralTerm;
            return(term);
        }
Ejemplo n.º 4
0
 public TaxonomyManager(Session session, BaseTaxonomy taxonomy)
 {
     _session  = session;
     _taxonomy = taxonomy;
 }
Ejemplo n.º 5
0
 public TaxonomyManager(BaseTaxonomy taxonomy) : this(taxonomy.Session, taxonomy)
 {
 }
Ejemplo n.º 6
0
 public static TTerm AddValueTerm <TTerm>(BaseTaxonomy taxonomy, Session session, string termPath, string termName) where TTerm : BaseTerm, IValueTerm
 {
     return(AddTerm <TTerm>(taxonomy, session, termPath, termName));
 }