当前位置: 首页>>代码示例>>C#>>正文


C# Registry.FirstOrDefault方法代码示例

本文整理汇总了C#中Registry.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# Registry.FirstOrDefault方法的具体用法?C# Registry.FirstOrDefault怎么用?C# Registry.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Registry的用法示例。


在下文中一共展示了Registry.FirstOrDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Portal

    /// <summary>
    /// Makes portal from config.
    /// Due to the nature of Portal object there is no need to create other parametrized ctors
    /// </summary>
    protected Portal(IConfigSectionNode conf)
    {
      const string PORTAL = "portal";

      m_Name = conf.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
      if (m_Name.IsNullOrWhiteSpace())
      {
        m_Name = this.GetType().Name;
        if (m_Name.EndsWith(PORTAL, StringComparison.OrdinalIgnoreCase) && m_Name.Length>PORTAL.Length)
         m_Name = m_Name.Substring(0, m_Name.Length-PORTAL.Length);
      }

      m_Description = conf.AttrByName(CONFIG_DESCR_ATTR).ValueAsString(m_Name);
      m_Offline = conf.AttrByName(CONFIG_OFFLINE_ATTR).ValueAsBool(false);
      m_Default = conf.AttrByName(CONFIG_DEFAULT_ATTR).ValueAsBool(false);

      var puri = conf.AttrByName(CONFIG_PRIMARY_ROOT_URI_ATTR).Value;

      try{ m_PrimaryRootUri = new Uri(puri, UriKind.Absolute); }
      catch(Exception error)
      {
        throw new WaveException(StringConsts.CONFIG_PORTAL_ROOT_URI_ERROR.Args(m_Name, error.ToMessageWithType()), error);
      }

      m_Themes = new Registry<Theme>();
      var nthemes = conf.Children.Where(c => c.IsSameName(CONFIG_THEME_SECTION));
      foreach(var ntheme in nthemes)
      {
        var theme = FactoryUtils.Make<Theme>(ntheme, args: new object[]{this, ntheme});
        if(!m_Themes.Register(theme))
          throw new WaveException(StringConsts.CONFIG_PORTAL_DUPLICATE_THEME_NAME_ERROR.Args(theme.Name, m_Name)); 
      }

      if (m_Themes.Count==0)
        throw new WaveException(StringConsts.CONFIG_PORTAL_NO_THEMES_ERROR.Args(m_Name)); 

      m_DefaultTheme = m_Themes.FirstOrDefault(t => t.Default);
      if (m_DefaultTheme==null)
        throw new WaveException(StringConsts.CONFIG_PORTAL_NO_DEFAULT_THEME_ERROR.Args(m_Name)); 

      ConfigAttribute.Apply(this, conf);
    }//.ctor
开发者ID:keck,项目名称:nfx,代码行数:46,代码来源:Portal.cs

示例2: Portal

        /// <summary>
        /// Makes portal from config.
        /// Due to the nature of Portal object there is no need to create other parametrized ctors
        /// </summary>
        protected Portal(IConfigSectionNode conf)
            : base(PortalHub.Instance)
        {
            const string PORTAL = "portal";

            m_Name = conf.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
            if (m_Name.IsNullOrWhiteSpace())
            {
              m_Name = this.GetType().Name;
              if (m_Name.EndsWith(PORTAL, StringComparison.OrdinalIgnoreCase) && m_Name.Length>PORTAL.Length)
               m_Name = m_Name.Substring(0, m_Name.Length-PORTAL.Length);
            }

            //Register with the Hub
            if (!PortalHub.Instance.m_Portals.Register( this ))
              throw new WaveException(StringConsts.PORTAL_HUB_INSTANCE_ALREADY_CONTAINS_PORTAL_ERROR.Args(m_Name));

            m_Description = conf.AttrByName(CONFIG_DESCR_ATTR).ValueAsString(m_Name);
            m_Offline = conf.AttrByName(CONFIG_OFFLINE_ATTR).ValueAsBool(false);
            m_Default = conf.AttrByName(CONFIG_DEFAULT_ATTR).ValueAsBool(false);

            var puri = conf.AttrByName(CONFIG_PRIMARY_ROOT_URI_ATTR).Value;

            try{ m_PrimaryRootUri = new Uri(puri, UriKind.Absolute); }
            catch(Exception error)
            {
              throw new WaveException(StringConsts.CONFIG_PORTAL_ROOT_URI_ERROR.Args(m_Name, error.ToMessageWithType()), error);
            }

            m_DisplayName = conf.AttrByName(CONFIG_DISPLAY_NAME_ATTR).Value;

            if (m_DisplayName.IsNullOrWhiteSpace())
              m_DisplayName = m_PrimaryRootUri.ToString();

            m_Themes = new Registry<Theme>();
            var nthemes = conf.Children.Where(c => c.IsSameName(CONFIG_THEME_SECTION));
            foreach(var ntheme in nthemes)
            {
              var theme = FactoryUtils.Make<Theme>(ntheme, args: new object[]{this, ntheme});
              if(!m_Themes.Register(theme))
            throw new WaveException(StringConsts.CONFIG_PORTAL_DUPLICATE_THEME_NAME_ERROR.Args(theme.Name, m_Name));
            }

            if (m_Themes.Count==0)
              throw new WaveException(StringConsts.CONFIG_PORTAL_NO_THEMES_ERROR.Args(m_Name));

            m_DefaultTheme = m_Themes.FirstOrDefault(t => t.Default);
            if (m_DefaultTheme==null)
              throw new WaveException(StringConsts.CONFIG_PORTAL_NO_DEFAULT_THEME_ERROR.Args(m_Name));

            m_ParentName = conf.AttrByName(CONFIG_PARENT_NAME_ATTR).Value;

            ConfigAttribute.Apply(this, conf);

            m_LocalizableContent = new Dictionary<string,string>(GetLocalizableContent(), StringComparer.InvariantCultureIgnoreCase);
            foreach(var atr in conf[CONFIG_LOCALIZATION_SECTION][CONFIG_CONTENT_SECTION].Attributes)
             m_LocalizableContent[atr.Name] = atr.Value;

            var gen = conf[CONFIG_RECORD_MODEL_SECTION];
            m_RecordModelGenerator = FactoryUtils.Make<Client.RecordModelGenerator>(gen,
                                                                                typeof(Client.RecordModelGenerator),
                                                                                new object[]{gen});

            m_RecordModelGenerator.ModelLocalization += recGeneratorLocalization;

            m_LocalizationData = conf[CONFIG_LOCALIZATION_SECTION];
            var msgFile = m_LocalizationData.AttrByName(CONFIG_MSG_FILE_ATTR).Value;
            if (msgFile.IsNotNullOrWhiteSpace())
            try
            {
               m_LocalizationData = Configuration.ProviderLoadFromFile(msgFile).Root;
            }
            catch(Exception fileError)
            {
               throw new WaveException(StringConsts.CONFIG_PORTAL_LOCALIZATION_FILE_ERROR.Args(m_Name, msgFile, fileError.ToMessageWithType()), fileError);
            }
        }
开发者ID:yhhno,项目名称:nfx,代码行数:81,代码来源:Portal.cs


注:本文中的Registry.FirstOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。