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; } }
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); }
/// <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); }
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))); }
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); }
/// <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); } }
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()); }
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(); }
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) ); }
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 ); }
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); }
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); }
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); }
/// <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(); }
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); }
public Group(IConfigSectionNode node) { ConfigAttribute.Apply(this, node); if (m_Name.IsNullOrWhiteSpace()) m_Name = Guid.NewGuid().ToString(); if (node!=null) foreach(var cn in node.Children.Where(cn=>cn.IsSameName(NetGate.CONFIG_ADDRESS_SECTION))) if(!m_Addresses.Register( FactoryUtils.Make<Address>(cn, typeof(Address), args: new object[]{ cn })) ) throw new NetGateException(StringConsts.NETGATE_CONFIG_DUPLICATE_ENTITY_ERROR.Args(cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value, "Group."+NetGate.CONFIG_ADDRESS_SECTION)); }
public CompositeHandler(WorkDispatcher dispatcher, IConfigSectionNode confNode) : base(dispatcher, confNode) { foreach(var hNode in confNode.Children.Where(cn=>cn.IsSameName(WorkHandler.CONFIG_HANDLER_SECTION))) { var sub = FactoryUtils.Make<WorkHandler>(hNode, args: new object[] {dispatcher, hNode}); sub.___setParentHandler( this ); if(!m_Handlers.Register(sub)) throw new WaveException(StringConsts.CONFIG_DUPLICATE_HANDLER_NAME_ERROR.Args(hNode.AttrByName(Configuration.CONFIG_NAME_ATTR).Value)); } }
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(); }
public static void ConfigureServerInspectors(Registry<IServerMsgInspector> registry, IConfigSectionNode node) { node = node[CONFIG_SERVER_INSPECTORS_SECTION]; if (!node.Exists) return; foreach(var inode in node.Children.Where(c => c.IsSameName(CONFIG_INSPECTOR_SECTION))) { var si = FactoryUtils.MakeAndConfigure<IServerMsgInspector>(inode); registry.Register(si); } }
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); }
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); }
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); }
private void ctor(IConfigSectionNode confNode) { var permsNode = confNode[Permission.CONFIG_PERMISSIONS_SECTION]; if (permsNode.Exists) m_Permissions = Permission.MultipleFromConf(permsNode); foreach(var cn in confNode[CONFIG_BYPASS_SECTION].Children.Where(cn=>cn.IsSameName(WorkMatch.CONFIG_MATCH_SECTION))) if(!m_BypassMatches.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))); }
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); }
public NFXJson(TestingSystem context, IConfigSectionNode conf) : base(context, conf) { var nopt = conf[CONFIG_OPTIONS_SECTION]; if (nopt.Exists) { m_Options = new JSONWritingOptions(); m_Options.Configure(nopt); } else m_Options = JSONWritingOptions.Compact; }
//private MockActualAccountData[] m_AccountActualDatas; //public IEnumerable<MockActualAccountData> AccountActualDatas { get { return m_AccountActualDatas; } } public override void Configure(IConfigSectionNode node) { base.Configure(node); var email = node.AttrByName(CONFIG_EMAIL_ATTR).Value; var cred = new MockCredentials(email); var at = new AuthenticationToken(MOCK_REALM, email); User = new User(cred, at, email, Rights.None); //var nAccounts = node[CONFIG_ACCOUNTS_SECTION]; //configureAccounts(nAccounts); }
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); }
public virtual void Configure(IConfigSectionNode node) { if (node == null || !node.Exists) return; ConfigAttribute.Apply(this, node); var cvn = node[CONFIG_DEFAULT_CERTIFICATE_VALIDATION_SECTION]; CertValTrustedDefault = cvn.AttrByName(CONFIG_TRUSTED_ATTR).ValueAsBool(); foreach (var un in cvn.Children.Where(c => c.IsSameName(CONFIG_CASE_SECTION))) { m_DefaultCertValUris.Register(new _uri { Name = un.AttrByName(CONFIG_URI_ATTR).Value, Trusted = un.AttrByName(CONFIG_TRUSTED_ATTR).ValueAsBool()}); } }
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)"); }
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); } }