本文整理汇总了C#中IConfigSectionNode类的典型用法代码示例。如果您正苦于以下问题:C# IConfigSectionNode类的具体用法?C# IConfigSectionNode怎么用?C# IConfigSectionNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IConfigSectionNode类属于命名空间,在下文中一共展示了IConfigSectionNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NFXSlim
public NFXSlim(TestingSystem context, IConfigSectionNode conf)
: base(context, conf)
{
Type[] known = ReadKnownTypes(conf);
//we create type registry with well-known types that serializer does not have to emit every time
m_TypeRegistry = new TypeRegistry(TypeRegistry.BoxedCommonTypes,
TypeRegistry.BoxedCommonNullableTypes,
TypeRegistry.CommonCollectionTypes,
known);
m_Serializer = new SlimSerializer(m_TypeRegistry);
//batching allows to remember the encountered types and hence it is a "stateful" mode
//where serialization part and deserialization part retain the type registries that
//get auto-updated. This mode is not thread safe
if (m_Batching)
{
m_BatchSer = new SlimSerializer(m_TypeRegistry);
m_BatchSer.TypeMode = TypeRegistryMode.Batch;
m_BatchDeser = new SlimSerializer(m_TypeRegistry);
m_BatchDeser.TypeMode = TypeRegistryMode.Batch;
}
}
示例2: WorkMatch
public WorkMatch(IConfigSectionNode confNode)
{
if (confNode==null)
throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName+".ctor(node==null)");
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());
var ppattern = confNode.AttrByName(CONFIG_PATH_ATTR).Value;
if (ppattern.IsNotNullOrWhiteSpace())
m_PathPattern = new URIPattern( ppattern );
var nppattern = confNode.AttrByName(CONFIG_NOT_PATH_ATTR).Value;
if (nppattern.IsNotNullOrWhiteSpace())
m_NotPathPattern = new URIPattern( nppattern );
//Variables
foreach(var vnode in confNode.Children.Where(c=>c.IsSameName(CONFIG_VAR_SECTION)))
m_Variables.Register(new Variable(vnode) );
ConfigAttribute.Apply(this, confNode);
var permsNode = confNode[Permission.CONFIG_PERMISSIONS_SECTION];
if (permsNode.Exists)
m_Permissions = Permission.MultipleFromConf(permsNode);
}
示例3: IDPasswordCredentials
/// <summary>
/// Warning: storing plain credentials in config file is not secure. Use this method for the most simplistic cases
/// like unit testing
/// </summary>
public IDPasswordCredentials(IConfigSectionNode cfg)
{
if (cfg == null || !cfg.Exists)
throw new SecurityException(StringConsts.ARGUMENT_ERROR + "IDPasswordCredentials.ctor(cfg=null|!exists)");
ConfigAttribute.Apply(this, cfg);
}
示例4: ctor
private void ctor(IConfigSectionNode confNode)
{
//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)));
}
示例5: Event
public Event(IEventTimer timer, string name = null, TimerEvent body = null, TimeSpan? interval = null, IConfigSectionNode config = null) : base(timer)
{
if ((timer as IEventTimerImplementation) == null)
throw new TimeException(StringConsts.ARGUMENT_ERROR + "Event.ctor(timer=null | timer!=IEventTimerImplementation)");
m_Timer = timer;
if (body!=null)
Body += body;
if (interval.HasValue)
m_Interval = interval.Value;
if (config!=null)
{
Configure(config);
m_Name = config.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
}
if (name.IsNotNullOrWhiteSpace())
m_Name = name;
if (m_Name.IsNullOrWhiteSpace()) m_Name = Guid.NewGuid().ToString();
((IEventTimerImplementation)timer).__InternalRegisterEvent(this);
}
示例6: ApplyConfiguredBehaviors
/// <summary>
/// Applies behaviors to instance as configured from config section node
/// </summary>
public static void ApplyConfiguredBehaviors(object target, IConfigSectionNode node)
{
if (target==null) return;
if (typeof(Behavior).IsAssignableFrom(target.GetType())) return;
string descr = string.Empty;
try
{
var firstLevel = true;
while(node.Exists)
{
var bnodes = node[CONFIG_BEHAVIORS_SECTION]
.Children
.Where(c=> c.IsSameName(CONFIG_BEHAVIOR_SECTION) && (firstLevel || c.AttrByName(CONFIG_CASCADE_ATTR).ValueAsBool(false)) )
.OrderBy(c=> c.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt());
foreach(var bnode in bnodes)
{
descr = " config path: '{0}', type: '{1}'".Args(bnode.RootPath, bnode.AttrByName(FactoryUtils.CONFIG_TYPE_ATTR).ValueAsString(StringConsts.NULL_STRING));
var behavior = FactoryUtils.MakeAndConfigure<Behavior>(bnode);
behavior.Apply(target);
}
node = node.Parent;
firstLevel = false;
}
}
catch(Exception error)
{
throw new BehaviorApplyException(StringConsts.CONFIG_BEHAVIOR_APPLY_ERROR.Args(descr, error.ToMessageWithType()), error);
}
}
示例7: TypicalPerson
public TypicalPerson(TestingSystem context, IConfigSectionNode conf)
: base(context, conf)
{
if (m_Count < 1) m_Count = 1;
for (var i = 0; i < m_Count; i++)
m_Data.Add(TypicalPersonData.MakeRandom());
}
示例8: ProtoBufSerializer
public ProtoBufSerializer(TestingSystem context, IConfigSectionNode conf)
: base(context, conf)
{
m_KnownTypes = ReadKnownTypes(conf);
foreach (var knownType in m_KnownTypes)
m_Model.Add(knownType, true);
m_Model.CompileInPlace();
}
示例9: ArrayOfNullableInt
public ArrayOfNullableInt(TestingSystem context, IConfigSectionNode conf)
: base(context, conf)
{
m_Data = Array.CreateInstance(typeof(int?), Dimensions);
NFX.Serialization.SerializationUtils.WalkArrayRead(m_Data,
()=> NFX.ExternalRandomGenerator.Instance.NextRandomInteger >0 ? (int?)null : NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(m_Min, m_Max)
);
}
示例10: ArrayOfDouble
public ArrayOfDouble(TestingSystem context, IConfigSectionNode conf)
: base(context, conf)
{
m_Data = Array.CreateInstance(typeof(double), Dimensions);
NFX.Serialization.SerializationUtils.WalkArrayRead(m_Data,
()=> NFX.ExternalRandomGenerator.Instance.NextRandomDouble
);
}
示例11: ErlLocalNode
internal ErlLocalNode(string node, IConfigSectionNode config)
: base(node, config)
{
var addr = m_AcceptAddressPort.Split(':').FirstOrDefault();
if (node.IndexOf('@') < 0 && addr != null)
node = "{0}@{1}".Args(node, addr);
SetNodeName(node);
}
示例12: SharpSerializer
public SharpSerializer(TestingSystem context, IConfigSectionNode conf)
: base(context, conf)
{
var settings = new Polenter.Serialization.SharpSerializerBinarySettings
{
Mode = BinarySerializationMode.Burst
};
m_Serializer = new Polenter.Serialization.SharpSerializer(settings);
}
示例13: getFiles
static IEnumerable<string> getFiles(IConfigSectionNode configRoot)
{
var pathArg = configRoot.AttrByIndex(0).Value;
if (!Path.IsPathRooted(pathArg)) pathArg = "."+Path.DirectorySeparatorChar + pathArg;
var rootPath = Path.GetDirectoryName(pathArg);
var mask = Path.GetFileName(pathArg);
if (mask.Length == 0) mask = "*";
return rootPath.AllFileNamesThatMatch(mask, configRoot["r"].Exists || configRoot["recurse"].Exists);
}
示例14: Write
/// <summary>
/// Writes LaconicConfiguration data to the string
/// </summary>
public static string Write(IConfigSectionNode data, LaconfigWritingOptions options = null)
{
if (options==null) options = LaconfigWritingOptions.PrettyPrint;
var sb = new StringBuilder();
writeSection(sb, data, 0, options);
return sb.ToString();
}
示例15: 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);
}