本文整理汇总了C#中IConfigSectionNode.AttrByName方法的典型用法代码示例。如果您正苦于以下问题:C# IConfigSectionNode.AttrByName方法的具体用法?C# IConfigSectionNode.AttrByName怎么用?C# IConfigSectionNode.AttrByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConfigSectionNode
的用法示例。
在下文中一共展示了IConfigSectionNode.AttrByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ctor
private void ctor(IConfigSectionNode confNode)
{
m_UseThemeCookie = confNode.AttrByName(CONF_USE_THEME_COOKIE_ATTR).ValueAsBool(true);
m_ThemeCookieName = confNode.AttrByName(CONF_THEME_COOKIE_NAME_ATTR).ValueAsString(DEFAULT_THEME_COOKIE_NAME);
//read matches
foreach(var cn in confNode.Children.Where(cn=>cn.IsSameName(WorkMatch.CONFIG_MATCH_SECTION)))
if(!m_PortalMatches.Register( FactoryUtils.Make<WorkMatch>(cn, typeof(WorkMatch), args: new object[]{ cn })) )
throw new WaveException(StringConsts.CONFIG_OTHER_DUPLICATE_MATCH_NAME_ERROR.Args(cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value, "{0}".Args(GetType().FullName)));
}
示例2: Configure
public override void Configure(IConfigSectionNode node)
{
base.Configure(node);
var email = node.AttrByName(CONFIG_EMAIL_ATTR).Value;
var apiKey = node.AttrByName(CONFIG_APIKEY_ATTR).Value;
var cred = new TaxJarCredentials(email, apiKey);
var at = new AuthenticationToken(TAXJAR_REALM, email);
User = new User(cred, at, UserStatus.User, email, email, Rights.None);
}
示例3: Configure
public override void Configure(IConfigSectionNode node)
{
base.Configure(node);
var email = node.AttrByName(CFG_EMAIL).Value;
var clientID = node.AttrByName(CFG_CLIENT_ID).Value;
var clientSecret = node.AttrByName(CFG_CLIENT_SECRET).Value;
var credentials = new PayPalCredentials(email, clientID, clientSecret);
var token = new AuthenticationToken(PayPalSystem.PAYPAL_REALM, null); // OAuth token is empty at start
User = new User(credentials, token, email, Rights.None);
}
示例4: Theme
protected Theme(Portal portal, IConfigSectionNode conf)
{
m_Portal = portal;
m_Name = conf.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
if (m_Name.IsNullOrWhiteSpace())
throw new WaveException(StringConsts.CONFIG_PORTAL_THEME_NO_NAME_ERROR.Args(portal.Name));
m_Description = conf.AttrByName(Portal.CONFIG_DESCR_ATTR).ValueAsString(m_Name);
m_Default = conf.AttrByName(Portal.CONFIG_DEFAULT_ATTR).ValueAsBool(false);
ConfigAttribute.Apply(this, conf);
}
示例5: Configure
public override void Configure(IConfigSectionNode node)
{
base.Configure(node);
var email = node.AttrByName(CONFIG_EMAIL_ATTR).Value;
var secretKey = node.AttrByName(CONFIG_SECRETKEY_ATTR).Value;
var publishableKey = node.AttrByName(CONFIG_PUBLISHABLEKEY_ATTR).Value;
var cred = new StripeCredentials(email, secretKey, publishableKey);
var at = new AuthenticationToken(STRIPE_REALM, publishableKey);
User = new User(cred, at, UserStatus.User, publishableKey, publishableKey, Rights.None);
}
示例6: WorkFilter
protected WorkFilter(WorkDispatcher dispatcher, IConfigSectionNode confNode)
{
if (confNode==null||dispatcher==null)
throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName+".ctor(dispatcher|confNode==null|empty)");
m_Dispatcher = dispatcher;
m_Server = dispatcher.ComponentDirector;
m_Name = confNode.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
m_Order = confNode.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt(0);
if (m_Name.IsNullOrWhiteSpace())
throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName+".ctor(confNode$name==null|empty)");
}
示例7: Configure
public override void Configure(IConfigSectionNode node)
{
base.Configure(node);
var accessKey = node.AttrByName(CONFIG_ACCESSKEY_ATTR).Value;
var secretKey = node.AttrByName(CONFIG_SECRETKEY_ATTR).Value;
if (accessKey.IsNotNullOrWhiteSpace())
{
var cred = new S3Credentials(accessKey, secretKey);
var at = new AuthenticationToken(Bucket, accessKey);
User = new User(cred, at, UserStatus.User, accessKey, accessKey, Rights.None);
}
}
示例8: Configure
public override void Configure(IConfigSectionNode node)
{
base.Configure(node);
var unm = node.AttrByName(CONFIG_UNAME_ATTR).Value;
var upwd = node.AttrByName(CONFIG_UPWD_ATTR).Value;
if (unm.IsNotNullOrWhiteSpace())
{
var cred = new IDPasswordCredentials(unm, upwd);
var at = new AuthenticationToken(ServerURL, unm);
User = new User(cred, at, UserStatus.User, unm, unm, Rights.None);
}
}
示例9: Configure
public override void Configure(IConfigSectionNode node)
{
base.Configure(node);
var email = node.AttrByName(CONFIG_EMAIL_ATTR).Value;
var cred = new NOPCredentials(email);
var at = new AuthenticationToken(NOP_REALM, email);
User = new User(cred, at, email, Rights.None);
}
示例10: 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
示例11: Configure
public override void Configure(IConfigSectionNode node)
{
base.Configure(node);
var privateToken = node.AttrByName("private-token").ValueAsString();
if (privateToken.IsNullOrWhiteSpace())
User = User.Fake;
var publicToken = node.AttrByName("public-token").ValueAsString();
if (publicToken.IsNullOrWhiteSpace())
User = User.Fake;
var carrierID = node.AttrByName("carrier-id").ValueAsString();
if (carrierID.IsNotNullOrWhiteSpace())
CarrierID = carrierID;
var cred = new ShippoCredentials(privateToken, publicToken);
var token = new AuthenticationToken(ShippoSystem.SHIPPO_REALM, null);
User = new User(cred, token, null, Rights.None);
}
示例12: TableOptions
public TableOptions(IConfigSectionNode node, bool nameRequired = true)
{
if (nameRequired)
if (node==null || node.AttrByName(Configuration.CONFIG_NAME_ATTR).Value.IsNullOrWhiteSpace())
throw new PileException(StringConsts.ARGUMENT_ERROR + "TableOptions.ctor($name=null|Empty)");
ConfigAttribute.Apply(this, node);
if (this.m_Name.IsNullOrWhiteSpace())
m_Name = Guid.NewGuid().ToString();
}
示例13: Configure
public override void Configure(IConfigSectionNode node)
{
base.Configure(node);
var email = node.AttrByName(CONFIG_EMAIL_ATTR).Value;
var credentials = new GoogleDriveCredentials(email);
var authToken = new AuthenticationToken();
User = new User(credentials, authToken, UserStatus.User, name:null, descr:null, rights:Rights.None);
}
示例14: WorkHandler
protected WorkHandler(WorkDispatcher dispatcher, IConfigSectionNode confNode)
{
if (confNode==null||dispatcher==null)
throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName+".ctor(dispatcher|confNode==null|empty)");
m_Dispatcher = dispatcher;
m_Server = dispatcher.ComponentDirector;
m_Name = confNode.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
m_Order = confNode.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt(0);
if (m_Name.IsNullOrWhiteSpace())
m_Name = "{0}({1})".Args(GetType().FullName, Guid.NewGuid());
foreach(var cn in confNode.Children.Where(cn=>cn.IsSameName(WorkFilter.CONFIG_FILTER_SECTION)))
if(!m_Filters.Register( FactoryUtils.Make<WorkFilter>(cn, typeof(WorkFilter), args: new object[]{ this, cn })) )
throw new WaveException(StringConsts.CONFIG_HANDLER_DUPLICATE_FILTER_NAME_ERROR.Args(cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value));
foreach(var cn in confNode.Children.Where(cn=>cn.IsSameName(WorkMatch.CONFIG_MATCH_SECTION)))
if(!m_Matches.Register( FactoryUtils.Make<WorkMatch>(cn, typeof(WorkMatch), args: new object[]{ cn })) )
throw new WaveException(StringConsts.CONFIG_HANDLER_DUPLICATE_MATCH_NAME_ERROR.Args(cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value));
}
示例15: Configure
public override void Configure(IConfigSectionNode node)
{
base.Configure(node);
var merchantId = node.AttrByName("merchant-id").ValueAsString();
if (merchantId.IsNullOrWhiteSpace())
User = User.Fake; //throw new PaymentException("Braintree: " + StringConsts.PAYMENT_BRAINTREE_MERCHANT_ID_REQUIRED.Args(this.GetType().FullName));
var accessToken = node.AttrByName("access-token").ValueAsString();
if (accessToken.IsNotNullOrWhiteSpace())
User = new User(new BraintreeAuthCredentials(merchantId, accessToken), new AuthenticationToken(BRAINTREE_REALM, accessToken), merchantId, Rights.None);
else
{
var publicKey = node.AttrByName("public-key").ValueAsString();
var privateKey = node.AttrByName("private-key").ValueAsString();
if (publicKey.IsNullOrWhiteSpace() || privateKey.IsNullOrWhiteSpace())
User = User.Fake; //throw new PaymentException("Braintree: " + StringConsts.PAYMENT_BRAINTREE_CREDENTIALS_REQUIRED.Args(this.GetType().FullName));
User = new User(new BraintreeCredentials(merchantId, publicKey, privateKey), new AuthenticationToken(BRAINTREE_REALM, publicKey), merchantId, Rights.None);
}
}