Exemple #1
0
 public virtual Net.Vpc.Upa.Section AddSection(string name, string parentPath, int index) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (name == null)
     {
         throw new System.NullReferenceException();
     }
     if (name.Contains("/"))
     {
         throw new System.ArgumentException("Name cannot contain '/'");
     }
     string[]            canonicalPathArray = Net.Vpc.Upa.Impl.Util.UPAUtils.GetCanonicalPathArray(parentPath);
     Net.Vpc.Upa.Section parentModule       = null;
     foreach (string n in canonicalPathArray)
     {
         Net.Vpc.Upa.Section next = null;
         if (parentModule == null)
         {
             next = GetSection(n);
         }
         else
         {
             next = parentModule.GetSection(n);
         }
         parentModule = next;
     }
     Net.Vpc.Upa.Section currentModule          = GetPersistenceUnit().GetFactory().CreateObject <Net.Vpc.Upa.Section>(typeof(Net.Vpc.Upa.Section));
     Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter a = Net.Vpc.Upa.Impl.Util.UPAUtils.Prepare(GetPersistenceUnit(), currentModule, name);
     if (parentModule == null)
     {
         AddPart(currentModule, index);
     }
     else
     {
         parentModule.AddPart(currentModule, index);
     }
     //invalidateStructureCache();
     return(currentModule);
 }
Exemple #2
0
        public virtual Net.Vpc.Upa.Section GetSection(string path, Net.Vpc.Upa.MissingStrategy missingStrategy) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            if (path == null)
            {
                throw new System.NullReferenceException();
            }
            string[] canonicalPathArray = Net.Vpc.Upa.Impl.Util.UPAUtils.GetCanonicalPathArray(path);
            if (canonicalPathArray.Length == 0)
            {
                throw new System.ArgumentException("invalid module path " + path);
            }
            Net.Vpc.Upa.Section module = null;
            foreach (string n in canonicalPathArray)
            {
                Net.Vpc.Upa.Section next = null;
                if (module == null)
                {
                    foreach (Net.Vpc.Upa.EntityPart schemaItem in parts)
                    {
                        if (schemaItem is Net.Vpc.Upa.Section)
                        {
                            if (schemaItem.GetName().Equals(n))
                            {
                                next = (Net.Vpc.Upa.Section)schemaItem;
                                break;
                            }
                        }
                    }
                    if (next == null)
                    {
                        switch (missingStrategy)
                        {
                        case Net.Vpc.Upa.MissingStrategy.ERROR:
                        {
                            throw new Net.Vpc.Upa.Exceptions.NoSuchSectionException(path);
                        }

                        case Net.Vpc.Upa.MissingStrategy.CREATE:
                        {
                            next = AddSection(n, null);
                            break;
                        }

                        case Net.Vpc.Upa.MissingStrategy.NULL:
                        {
                            return(null);
                        }

                        default:
                        {
                            throw new System.Exception();
                        }
                        }
                    }
                }
                else
                {
                    try {
                        next = module.GetSection(n);
                    } catch (Net.Vpc.Upa.Exceptions.NoSuchSectionException e) {
                        switch (missingStrategy)
                        {
                        case Net.Vpc.Upa.MissingStrategy.ERROR:
                        {
                            throw new Net.Vpc.Upa.Exceptions.NoSuchSectionException(path);
                        }

                        case Net.Vpc.Upa.MissingStrategy.CREATE:
                        {
                            next = AddSection(n, module.GetPath());
                            break;
                        }

                        case Net.Vpc.Upa.MissingStrategy.NULL:
                        {
                            return(null);
                        }

                        default:
                        {
                            throw new System.Exception();
                        }
                        }
                    }
                }
                module = next;
            }
            return(module);
        }