Esempio n. 1
0
                                      protected SectionWithNamedAppConfigs(Catalog catalog, string name, string path, FileSystemSession session) : base(catalog, name, path, session)
                                      {
                                          m_AppConfigs =
                                              Metabank.fsAccess("SectionWithAppConfig.ctor", path,
                                                                (fss, dir) =>
                {
                    var result = new Dictionary <string, IConfigSectionNode>(StringComparer.InvariantCultureIgnoreCase);
                    foreach (var fn in dir.FileNames.Where(fn => fn.StartsWith(Metabank.CONFIG_SECTION_LEVEL_APP_FILE_PREFIX)))
                    {
                        var ipr  = fn.IndexOf(Metabank.CONFIG_SECTION_LEVEL_APP_FILE_PREFIX);
                        var si   = ipr + Metabank.CONFIG_SECTION_LEVEL_APP_FILE_PREFIX.Length;
                        var isfx = fn.IndexOf(Metabank.CONFIG_SECTION_LEVEL_APP_FILE_SUFFIX);

                        if (ipr != 0 || isfx <= si)
                        {
                            continue;
                        }
                        var appName = fn.Substring(si, isfx - si);

                        var app = this.Metabank.CatalogApp.Applications[appName];
                        if (app == null)
                        {
                            throw new MetabaseException(StringConsts.METABASE_APP_CONFIG_APP_DOESNT_EXIST_ERROR.Args(path, fn, appName));
                        }

                        var config = Metabank.getConfigFromExistingFile(session, Metabank.JoinPaths(dir.Path, fn)).Root;
                        result.Add(appName, config);
                    }
                    return(result);
                }
                                                                );
                                      }
Esempio n. 2
0
                                      protected Section(Catalog catalog, string name, string path, FileSystemSession session)
                                      {
                                          if (name.IsNullOrWhiteSpace() || catalog == null || path.IsNullOrWhiteSpace())
                                          {
                                              throw new MetabaseException(StringConsts.ARGUMENT_ERROR + GetType().Name + ".ctor(catalog|name|path==null|empty");
                                          }
                                          Catalog  = catalog;
                                          Metabank = catalog.Metabank;
                                          m_Name   = name;
                                          Path     = Metabank.JoinPaths("", path);//ensure root path symbol i.e.

                                          m_LevelConfig = Metabank.getConfigFromFile(session, Metabank.JoinPaths(path, Metabank.CONFIG_SECTION_LEVEL_FILE)).Root;

                                          if (!m_LevelConfig.IsSameName(RootNodeName))
                                          {
                                              throw new MetabaseException(StringConsts.METABASE_METADATA_CTOR_1_ERROR.Args(GetType().Name, RootNodeName, m_LevelConfig.Name));
                                          }

                                          var cn = m_LevelConfig.AttrByName(Metabank.CONFIG_NAME_ATTR);

                                          if (!cn.Exists || !m_LevelConfig.IsSameNameAttr(name))
                                          {
                                              throw new MetabaseException(StringConsts.METABASE_METADATA_CTOR_2_ERROR.Args(GetType().Name, name, cn.ValueAsString(SysConsts.UNKNOWN_ENTITY)));
                                          }

                                          if (!name.IsValidName())
                                          {
                                              throw new MetabaseException(StringConsts.METABASE_METADATA_CTOR_3_ERROR.Args(GetType().Name, name, path));
                                          }

                                          Metabank.includeCommonConfig(m_LevelConfig);
                                          m_LevelConfig.ResetModified();
                                      }
Esempio n. 3
0
                                      /// <summary>
                                      /// Gets host by name
                                      /// </summary>
                                      public SectionHost GetHost(string name)
                                      {
                                          string CACHE_KEY = ("ZN.h" + Path + name).ToLowerInvariant();
                                          //1. Try to get from cache
                                          var result = Metabank.cacheGet(REG_CATALOG, CACHE_KEY) as SectionHost;

                                          if (result != null)
                                          {
                                              return(result);
                                          }

                                          var rdir  = "{0}{1}".Args(name, RegCatalog.HST_EXT);
                                          var rpath = Metabank.JoinPaths(Path, rdir);

                                          result =
                                              Metabank.fsAccess("Zone[{0}].GetHost({1})".Args(m_Name, name), rpath,
                                                                (session, dir) => new SectionHost(this, name, rpath, session)
                                                                );


                                          Metabank.cachePut(REG_CATALOG, CACHE_KEY, result);
                                          return(result);
                                      }
Esempio n. 4
0
 protected SectionWithAnyAppConfig(Catalog catalog, string name, string path, FileSystemSession session) : base(catalog, name, path, session)
 {
     m_AnyAppConfig = Metabank.getConfigFromFile(session, Metabank.JoinPaths(path, Metabank.CONFIG_SECTION_LEVEL_ANY_APP_FILE), require: false).Root;
 }