protected override void DoConfigure(IConfigSectionNode node) { base.DoConfigure(node); LoadLimit = node.AttrByName(CONFIG_LOAD_LIMIT_ATTR).ValueAsLong(DEFAULT_LOAD_LIMIT); ConnectString = node.AttrByName(CONFIG_CONNECT_STRING_ATTR).ValueAsString(); PurgeAfterDays = node.AttrByName(CONFIG_PURGE_AFTER_DAYS_ATTR).ValueAsInt(DEFAULT_PURGE_AFTER_DAYS); }
protected WorkHandler(WorkDispatcher dispatcher, IConfigSectionNode confNode) : base(dispatcher) { 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)); } } }
public TypeLocation(IConfigSectionNode confNode) { if (confNode == null) { throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName + ".ctor(confNode==null)"); } m_Name = confNode.AttrByName(Configuration.CONFIG_NAME_ATTR).ValueAsString(Guid.NewGuid().ToString()); m_Order = confNode.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt(); Portal = confNode.AttrByName(CONFIG_PORTAL_ATTR).Value; AssemblyName = confNode.AttrByName(CONFIG_ASSEMBLY_NAME_ATTR).Value; if (AssemblyName.IsNullOrWhiteSpace()) { throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName + ".ctor(config{$assembly==null|empty})"); } List <string> nsList = null; foreach (var ns in confNode.Children .Where(cn => cn.IsSameName(CONFIG_NAMESPACE_SECTION)) .Select(cn => cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value)) { if (ns.IsNotNullOrWhiteSpace()) { if (nsList == null) { nsList = new List <string>(); } nsList.Add(ns); } } Namespaces = nsList; }
private void configureRoot(IConfigSectionNode node) { var pnode = node[CONFIG_POLICY_SECTION]; if (pnode.Exists) { m_Policy = FactoryUtils.MakeAndConfigure <OperationPolicy>(pnode, typeof(OperationPolicy)); } if (node.AttrByName(CONFIG_TCP_KEEPALIVE_ENABLED_ATTR).ValueAsBool()) { ServicePointManager.SetTcpKeepAlive( true, node.AttrByName(CONFIG_TCP_KEEPALIVE_TIME_MS_ATTR).ValueAsInt(), node.AttrByName(CONFIG_TCP_KEEPALIVE_INTERVAL_MS_ATTR).ValueAsInt()); } var lst = new List <ServicePointConfigurator>(); foreach (var nsp in node.Children.Where(c => c.IsSameName(CONFIG_SERVICE_POINT_SECTION))) { var addr = nsp.AttrByName(CONFIG_URI_ATTR).Value; if (addr.IsNullOrWhiteSpace()) { continue; } var sp = ServicePointManager.FindServicePoint(new Uri(addr)); lst.Add(new ServicePointConfigurator(sp, nsp)); } m_ServicePoints = lst; // atomic }
protected override void DoConfigure(IConfigSectionNode node) { try { base.DoConfigure(node); var sguid = node.AttrByName(CONFIG_GUID_ATTR).ValueAsString(); if (!string.IsNullOrEmpty(sguid)) { StoreGUID = new Guid(sguid); } m_Provider = FactoryUtils.MakeAndConfigure <ObjectStoreProvider>(node[CONFIG_PROVIDER_SECT], typeof(FileObjectStoreProvider), new [] { this }); if (m_Provider == null) { throw new AzosException("Provider is null"); } ObjectLifeSpanMS = node.AttrByName(CONFIG_OBJECT_LIFE_SPAN_MS_ATTR).ValueAsInt(DEFAULT_OBJECT_LEFESPAN_MS); BucketCount = node.AttrByName(CONFIG_BUCKET_COUNT_ATTR).ValueAsInt(DEFAULT_BUCKET_COUNT); } catch (Exception error) { throw new AzosException(StringConsts.OBJSTORESVC_PROVIDER_CONFIG_ERROR + error.Message, error); } }
public override void Configure(IConfigSectionNode node) { m_Options = new SessionOptions(); var serverUrlAttr = node.AttrByName(CONFIG_SERVER_URL_ATTR); if (serverUrlAttr.Exists) { var serverUrl = serverUrlAttr.ValueAsString(); if (serverUrl.IsNotNullOrWhiteSpace()) { m_Options.ParseUrl(serverUrl); } } var protocolAttr = node.AttrByName(CONFIG_PROTOCOL_ATTR); if (protocolAttr.Exists) { m_Options.Protocol = protocolAttr.ValueAsEnum(Protocol.Sftp); } base.Configure(node); var rawSettings = node[CONFIG_RAW_SETTINGS_SECTION]; if (rawSettings.Exists) { foreach (var attr in rawSettings.Attributes) { m_Options.AddRawSettings(attr.Name, attr.ValueAsString()); } } }
public override void Configure(IConfigSectionNode node) { base.Configure(node); var privateToken = node.AttrByName("private-token").ValueAsString(); if (privateToken.IsNullOrWhiteSpace()) { User = User.Fake; return; } var publicToken = node.AttrByName("public-token").ValueAsString(); if (publicToken.IsNullOrWhiteSpace()) { User = User.Fake; return; } var cred = new ShippoCredentials(privateToken, publicToken); var token = new AuthenticationToken(ShippoSystem.SHIPPO_REALM, null); User = new User(cred, token, null, Rights.None); }
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); } }
public void Section(int a, int b, IConfigSectionNode sect) { Aver.AreEqual(1, a); Aver.AreEqual(-1, b); Aver.AreEqual(100, sect.AttrByName("a").ValueAsInt()); Aver.AreEqual(200, sect.AttrByName("b").ValueAsInt()); }
public string Run(IConfigSectionNode node, string inputValue, string macroName, IConfigSectionNode macroParams, object context = null) { if (macroName.StartsWith(AS_PREFIX, StringComparison.InvariantCultureIgnoreCase) && macroName.Length > AS_PREFIX.Length) { var type = macroName.Substring(AS_PREFIX.Length); return(GetValueAs(inputValue, type, macroParams.Navigate("$dflt|$default").Value, macroParams.Navigate("$fmt|$format").Value)); } else if (string.Equals(macroName, "now", StringComparison.InvariantCultureIgnoreCase)) { var utc = macroParams.AttrByName("utc").ValueAsBool(false); var fmt = macroParams.Navigate("$fmt|$format").ValueAsString(); var valueAttr = macroParams.AttrByName("value"); DateTime now; if (utc) { now = App.TimeSource.UTCNow; } else { ILocalizedTimeProvider timeProvider = App.Instance; if (context is ILocalizedTimeProvider) { timeProvider = (ILocalizedTimeProvider)context; } now = timeProvider.LocalizedTime; } // We inspect the "value" param that may be provided for testing purposes if (valueAttr.Exists) { now = valueAttr.Value.AsDateTimeFormat(now, fmt, utc ? DateTimeStyles.AssumeUniversal : DateTimeStyles.AssumeLocal); } return(fmt == null?now.ToString() : now.ToString(fmt)); } else if (string.Equals(macroName, "ctx-name", StringComparison.InvariantCultureIgnoreCase)) { if (context is INamed) { return(((INamed)context).Name); } } return(inputValue); }
/// <summary> /// Invokes a constructor for type feeding it the specified args: /// node{type="NS.Type, Assembly" arg0=1 arg1=true....} /// </summary> public static T MakeUsingCtor <T>(IConfigSectionNode node) { string tpn = CoreConsts.UNKNOWN; try { if (node == null || !node.Exists) { throw new ConfigException(StringConsts.ARGUMENT_ERROR + "node==null|empty"); } tpn = node.AttrByName(CONFIG_TYPE_ATTR).Value; if (tpn.IsNullOrWhiteSpace()) { tpn = typeof(T).AssemblyQualifiedName; } var tp = Type.GetType(tpn, true); var args = new List <object>(); for (var i = 0; true; i++) { var attr = node.AttrByName("arg{0}".Args(i)); if (!attr.Exists) { break; } args.Add(attr.Value); } var cinfo = tp.GetConstructors().FirstOrDefault(ci => ci.GetParameters().Length == args.Count); if (cinfo == null) { throw new NFXException(".ctor arg count mismatch"); } //dynamically re-cast argument types for (var i = 0; i < args.Count; i++) { args[i] = args[i].ToString().AsType(cinfo.GetParameters()[i].ParameterType); } try { return((T)Activator.CreateInstance(tp, args.ToArray())); } catch (TargetInvocationException tie) { throw tie.InnerException; } } catch (Exception error) { throw new ConfigException(StringConsts.CONFIGURATION_MAKE_USING_CTOR_ERROR.Args(tpn, error.ToMessageWithType()), error); } }
public async Task Section(int a, int b, IConfigSectionNode sect) { Aver.AreEqual(1, a); Aver.AreEqual(-1, b); await delay(); Aver.AreEqual(100, sect.AttrByName("a").ValueAsInt()); Aver.AreEqual(200, sect.AttrByName("b").ValueAsInt()); }
public virtual string Run(IConfigSectionNode node, string inputValue, string macroName, IConfigSectionNode macroParams, object context = null) { if (macroName.StartsWith(AS_PREFIX, StringComparison.InvariantCultureIgnoreCase) && macroName.Length > AS_PREFIX.Length) { var type = macroName.Substring(AS_PREFIX.Length); return(GetValueAs(inputValue, type, macroParams.Navigate("$dflt|$default").Value, macroParams.Navigate("$fmt|$format").Value)); } else if (string.Equals(macroName, "now", StringComparison.InvariantCultureIgnoreCase)) { var utc = macroParams.AttrByName("utc").ValueAsBool(false); var fmt = macroParams.Navigate("$fmt|$format").ValueAsString(); var valueAttr = macroParams.AttrByName("value"); var now = Ambient.UTCNow; if (!utc) { ILocalizedTimeProvider timeProvider = context as ILocalizedTimeProvider; if (timeProvider == null && context is IApplicationComponent cmp) { timeProvider = cmp.ComponentDirector as ILocalizedTimeProvider; if (timeProvider == null) { timeProvider = cmp.App; } } now = timeProvider != null ? timeProvider.LocalizedTime : now.ToLocalTime(); } // We inspect the "value" param that may be provided for testing purposes if (valueAttr.Exists) { now = valueAttr.Value.AsDateTimeFormat(now, fmt, utc ? DateTimeStyles.AssumeUniversal : DateTimeStyles.AssumeLocal); } return(fmt == null?now.ToString() : now.ToString(fmt)); } else if (string.Equals(macroName, "ctx-name", StringComparison.InvariantCultureIgnoreCase)) { if (context is Collections.INamed) { return(((Collections.INamed)context).Name); } } return(inputValue); }
protected override void DoConfigure(IConfigSectionNode node) { base.DoConfigure(node); m_ApiUri = node.AttrByName(CFG_API_URI).ValueAsString(DEFAULT_API_URI); m_OAuthTokenExpirationMargin = node.AttrByName(CFG_TOKEN_EXPIRATION_MARGIN).ValueAsInt(DEFAULT_TOKEN_EXPIRATION_MARGIN); m_PayoutEmailSubject = node.AttrByName(CFG_PAYOUT_EMAIL_SUBJECT).ValueAsString(DEFAULT_PAYOUT_EMAIL_SUBJECT); m_PayoutNote = node.AttrByName(CFG_PAYOUT_NOTE).ValueAsString(DEFAULT_PAYOUT_NOTE); m_SyncMode = node.AttrByName(CFG_SYNC_MODE).ValueAsBool(DEFAULT_SYNC_MODE); }
private string enqueue(IConfigSectionNode arg) { var hostSet = arg.AttrByName(CONFIG_HOSTSET_ATTR).ValueAsString(); var svc = arg.AttrByName(CONFIG_SVC_ATTR).ValueAsString(); var todo = arg[CONFIG_TODO_SECTION]; App.ProcessManager.Enqueue(hostSet, svc, todo); return("OK"); }
public DiskPersistenceLocation(IConfigSectionNode node) : base(node) { DiskPath = node.AttrByName(CONFIG_PATH_ATTR).Value; if (DiskPath.IsNullOrWhiteSpace()) { throw new GdidException(StringConsts.ARGUMENT_ERROR + "DiskPersistenceLocation(path=null|empty)"); } Fsync = node.AttrByName(CONFIG_FSYNC_ATTR).ValueAsBool(true); }
/// <summary> /// Override to perform derivative-specific configuration /// </summary> protected virtual void DoConfigure(IConfigSectionNode node) { var expr = node.AttrByName(CONFIG_FILTER_ATTR).Value; if (!string.IsNullOrWhiteSpace(expr)) { m_Filter = new MessageFilterExpression(expr); } m_Levels = ParseLevels(node.AttrByName(CONFIG_LEVELS_ATTR).Value); }
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))); }
private string alloc(IConfigSectionNode arg) { var zone = arg.AttrByName(CONFIG_ZONE_ATTR).ValueAsString(); var mutex = arg.AttrByName(CONFIG_MUTEX_ATTR).ValueAsString(); var pid = mutex.IsNullOrWhiteSpace() ? App.ProcessManager.Allocate(zone) : App.ProcessManager.AllocateMutex(zone, mutex); return(pid.ToString()); }
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); }
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 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); }
protected TypeLookupHandler(WorkDispatcher dispatcher, IConfigSectionNode confNode) : base(dispatcher, confNode) { if (confNode==null) throw new WaveException(StringConsts.ARGUMENT_ERROR+GetType().FullName+".ctor(confNode==null)"); foreach(var ntl in confNode.Children.Where(cn=>cn.IsSameName(TypeLocation.CONFIG_TYPE_LOCATION_SECTION))) m_TypeLocations.Register( FactoryUtils.Make<TypeLocation>(ntl, typeof(TypeLocation), args: new object[]{ ntl }) ); m_DefaultTypeName = confNode.AttrByName(CONFIG_DEFAULT_TYPE_ATTR).Value; m_CloakTypeName = confNode.AttrByName(CONFIG_CLOAK_TYPE_ATTR).Value; m_NotFoundRedirectURL = confNode.AttrByName(CONFIG_NOT_FOUND_REDIRECT_URL_ATTR).Value; }
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); } }
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); }
protected override void DoConfigure(IConfigSectionNode node) { base.DoConfigure(node); LoadLimit = node.AttrByName(CONFIG_LOAD_LIMIT_ATTR).ValueAsLong(DEFAULT_LOAD_LIMIT); RootPath = node.AttrByName(CONFIG_ROOT_PATH_ATTR).ValueAsString(); m_Format = node.AttrByName(CONFIG_FORMAT_ATTR).ValueAsEnum <FileObjectFormat>(FileObjectFormat.Slim); foreach (var cn in node[CONFIG_KNOWN_TYPES_SECTION].Children.Where(cn => cn.IsSameName(CONFIG_KNOWN_SECTION))) { var tn = cn.AttrByName(CONFIG_TYPE_ATTR).ValueAsString(CoreConsts.UNKNOWN); m_KnownTypes.Add(tn); } }
protected override void DoConfigure(IConfigSectionNode node) { if (node == null) { node = App.ConfigRoot[CONFIG_HOST_GOVERNOR_SECTION]; } m_StartupInstallCheck = node.AttrByName(CONFIG_STARTUP_INSTALL_CHECK_ATTR).ValueAsBool(true); m_DynamicHostID = node.AttrByName(CONFIG_DYNAMIC_HOST_ID_ATTR).ValueAsString(); base.DoConfigure(node); }
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 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); } }
protected PersistenceLocation(IConfigSectionNode node) { if (node == null) { throw new GDIDException(StringConsts.ARGUMENT_ERROR + "PersistenceLocation(node=null)"); } Name = node.AttrByName(Configuration.CONFIG_NAME_ATTR).Value; Order = node.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt(); if (Name.IsNullOrWhiteSpace()) { throw new GDIDException(StringConsts.ARGUMENT_ERROR + "PersistenceLocation(name=null|empty)"); } }
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))); } } }
private void ctor(IConfigSectionNode nlsNode) { if (nlsNode.HasChildren) { foreach (var ison in nlsNode.Children) { m_Data[ison.Name] = new NDPair(ison.AttrByName("n").Value, ison.AttrByName("d").Value); } } else { m_Data[nlsNode.Name] = new NDPair(nlsNode.AttrByName("n").Value, nlsNode.AttrByName("d").Value); } }
internal ServicePointConfigurator(ServicePoint sp, IConfigSectionNode node) { this.ServicePoint = sp; sp.BindIPEndPointDelegate += bindIPEndPoint; ConfigAttribute.Apply(this, node); if (node.AttrByName(CONFIG_TCP_KEEPALIVE_ENABLED_ATTR).ValueAsBool()) { sp.SetTcpKeepAlive( true, node.AttrByName(CONFIG_TCP_KEEPALIVE_TIME_MS_ATTR).ValueAsInt(), node.AttrByName(CONFIG_TCP_KEEPALIVE_INTERVAL_MS_ATTR).ValueAsInt()); } }
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); }
/// <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
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 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); }
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)); }
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 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); } }
//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); }
protected ArrayTestBase(TestingSystem context, IConfigSectionNode conf) : base(context, conf) { var dims = conf.AttrByName(CONFIG_DIMENSIONS_ATTR).Value; if (dims.IsNullOrWhiteSpace()) throw new SerbenchException("Array dimensions attribute '{0}' is not specified".Args(CONFIG_DIMENSIONS_ATTR)); m_Dimensions = dims.Split(',',';').Where(s => s.IsNotNullOrWhiteSpace()) .Select(s => s.AsInt()) .ToArray(); if (m_Dimensions.Length<1 || m_Dimensions.Any(d => d<=0)) throw new SerbenchException("Invalid array dimensions attribute '{0}' = '{1}'".Args(CONFIG_DIMENSIONS_ATTR, dims)); }
protected override void DoConfigure(IConfigSectionNode node) { if (node==null) { node = App.ConfigRoot[CommonApplicationLogic.CONFIG_MEMORY_MANAGEMENT_SECTION] .Children .FirstOrDefault(s => s.IsSameName(CONFIG_PILE_SECTION) && s.IsSameNameAttr(Name)); if (node==null) { node = App.ConfigRoot[CommonApplicationLogic.CONFIG_MEMORY_MANAGEMENT_SECTION] .Children .FirstOrDefault(s => s.IsSameName(CONFIG_PILE_SECTION) && !s.AttrByName(Configuration.CONFIG_NAME_ATTR).Exists); if (node==null) return; } } ConfigAttribute.Apply(this, node); var fcs = node.AttrByName(CONFIG_FREE_CHUNK_SIZES_ATTR).ValueAsString(); if (fcs.IsNotNullOrWhiteSpace()) try { int[] isz = new int[FREE_LST_COUNT]; var segs = fcs.Split(',',';'); var i =0; foreach(var seg in segs) { if (seg.IsNullOrWhiteSpace()) continue; if (i==isz.Length) throw new PileException("cnt > "+FREE_LST_COUNT.ToString()); isz[i] = int.Parse(seg); i++; } ensureFreeChunkSizes(isz); m_FreeChunkSizes = isz; } catch(Exception error) { throw new PileException(StringConsts.PILE_CONFIG_PROPERTY_ERROR.Args(CONFIG_FREE_CHUNK_SIZES_ATTR, error.ToMessageWithType()), error); } }
protected override void DoConfigure(IConfigSectionNode node) { base.DoConfigure(node); LoadLimit = node.AttrByName(CONFIG_LOAD_LIMIT_ATTR).ValueAsLong(DEFAULT_LOAD_LIMIT); RootPath = node.AttrByName(CONFIG_ROOT_PATH_ATTR).ValueAsString(); m_Format = node.AttrByName(CONFIG_FORMAT_ATTR).ValueAsEnum<FileObjectFormat>(FileObjectFormat.Slim); foreach(var cn in node[CONFIG_KNOWN_TYPES_SECTION].Children.Where(cn => cn.IsSameName(CONFIG_KNOWN_SECTION))) { var tn = cn.AttrByName(CONFIG_TYPE_ATTR).ValueAsString(CoreConsts.UNKNOWN); m_KnownTypes.Add( tn ); } }
public string Run(IConfigSectionNode node, string inputValue, string macroName, IConfigSectionNode macroParams, object context = null) { if (macroName.StartsWith(AS_PREFIX, StringComparison.InvariantCultureIgnoreCase) && macroName.Length > AS_PREFIX.Length) { var type = macroName.Substring(AS_PREFIX.Length); return GetValueAs(inputValue, type, macroParams.Navigate("$dflt|$default").Value, macroParams.Navigate("$fmt|$format").Value); } else if (string.Equals(macroName, "now", StringComparison.InvariantCultureIgnoreCase)) { var utc = macroParams.AttrByName("utc").ValueAsBool(false); var fmt = macroParams.Navigate("$fmt|$format").ValueAsString(); var valueAttr = macroParams.AttrByName("value"); DateTime now; if (utc) now = App.TimeSource.UTCNow; else { ILocalizedTimeProvider timeProvider = App.Instance; if (context is ILocalizedTimeProvider) timeProvider = (ILocalizedTimeProvider) context; now = timeProvider.LocalizedTime; } // We inspect the "value" param that may be provided for testing purposes if (valueAttr.Exists) now = valueAttr.Value.AsDateTimeFormat(now, fmt, utc ? DateTimeStyles.AssumeUniversal : DateTimeStyles.AssumeLocal); return fmt == null ? now.ToString() : now.ToString(fmt); } else if (string.Equals(macroName, "ctx-name", StringComparison.InvariantCultureIgnoreCase)) { if (context is INamed) return ((INamed)context).Name; } return inputValue; }
/// <summary> /// Override to compile a RDBMS Table /// </summary> protected virtual void DoTable(IConfigSectionNode tableNode, Outputs outputs) { var tname = tableNode.Value; if (tname.IsNullOrWhiteSpace()) { m_CompileErrors.Add(new SchemaCompilationException(tableNode.RootPath, "Table name missing")); return; } var table = new RDBMSEntity(m_All, tableNode, RDBMSEntityType.Table, tname, tableNode.AttrByName(SHORT_NAME_ATTR).Value); TransformEntityName(table); var sb = outputs[RDBMSCompiler.TABLES_OUTPUT]; sb.AppendLine(GetStatementDelimiterScript(RDBMSEntityType.Table, true)); sb.AppendLine("-- {0}".Args( tableNode.AttrByName(SCRIPT_COMMENT_ATTR).ValueAsString("Table " + table.TransformedName))); sb.AppendLine("{0} {1}".Args( TransformKeywordCase("create table"), GetQuotedIdentifierName(RDBMSEntityType.Table, table.TransformedName) )); sb.AppendLine("("); var firstItem = true; foreach(var node in tableNode.Children) { if (node.IsSameName(COLUMN_SECTION)) { DoColumn(node, table, sb, ref firstItem, outputs); } else if (node.IsSameName(PRIMARY_KEY_SECTION)) { DoReadPrimaryKeySection(node, table); } else if (node.IsSameName(INDEX_SECTION)) { DoReadIndexSection(node, table); } else if (node.IsSameName(SCRIPT_INCLUDE_SECTION)) { IncludeScriptFile(node, outputs); sb.AppendLine(); } else if (node.IsSameName(SCRIPT_TEXT_SECTION)) { IncludeScriptText(node, outputs); sb.AppendLine(); } else m_CompileErrors.Add(new SchemaCompilationException(node.RootPath, "Unrecognized item inside '{0}' table section '{1}'".Args(tname, node.Name))); } DoPrimaryKeys(table, sb, ref firstItem); DoForeignKeys(table, sb, ref firstItem, outputs); sb.AppendLine(); sb.AppendLine(")"); var comment = tableNode.AttrByName(COMMENT_ATTR).Value; if (comment.IsNotNullOrWhiteSpace()) { sb.AppendLine(" {0} = {1}".Args(TransformKeywordCase("comment"), EscapeString(comment) )); } sb.AppendLine(GetStatementDelimiterScript(RDBMSEntityType.Table, false)); sb.AppendLine(); DoTableIndexes(table, outputs); }
/// <summary> /// Override to compile a RDBMS Table /// </summary> protected virtual void DoColumn(IConfigSectionNode columnNode, RDBMSEntity table, StringBuilder sb, ref bool firstColumn, Outputs outputs) { var colComment = columnNode.AttrByName(SCRIPT_COMMENT_ATTR).Value; if (colComment.IsNotNullOrWhiteSpace()) sb.AppendLine(" -- {0}".Args( colComment ) ); var columnName = columnNode.Value; if (columnName.IsNullOrWhiteSpace()) { m_CompileErrors.Add(new SchemaCompilationException(columnNode.RootPath, "Table '{0}' missing column name.".Args(table.OriginalName))); return; } var column = new RDBMSEntity(table, columnNode, RDBMSEntityType.Column, columnName, columnNode.AttrByName(SHORT_NAME_ATTR).Value ?? columnName); TransformEntityName(column); var typeNode = columnNode.Navigate(TYPE_ATTR + "|$"+TYPE_ATTR); if (typeNode==null || typeNode.VerbatimValue.IsNullOrWhiteSpace()) { m_CompileErrors.Add(new SchemaCompilationException(columnNode.RootPath, "Column '{0}' missing {1} attribute.".Args(columnName, TYPE_ATTR))); return; } var columnType = typeNode.Value; var type = new RDBMSEntity(column, typeNode, RDBMSEntityType.Domain, columnType); TransformEntityName(type); var domain = CreateDomain("{0}.{1}::{2}".Args(table.OriginalName, column.OriginalName, type.OriginalName), type.OriginalName, typeNode); if (domain==null) { m_CompileErrors.Add(new SchemaCompilationException(columnNode.RootPath, "Domain could not be created: " +type.TransformedName )); return; } domain.TransformColumnName(this, column); if (!firstColumn) sb.AppendLine(","); #region Column Line { var cn = GetQuotedIdentifierName(RDBMSEntityType.Column, column.TransformedName); var tn = GetQuotedIdentifierName(RDBMSEntityType.Domain, domain.GetTypeName(this)); var required = (domain.GetColumnRequirement(this) ?? false) || columnNode.AttrByName(REQUIRED_ATTR).ValueAsBool(); var nn = TransformKeywordCase( GetColumnNullNotNullClause(column, required) ); var auto = domain.GetColumnAutoGeneratedScript(this, column, outputs); var dfltValue = columnNode.AttrByName(DEFAULT_ATTR).Value ?? domain.GetColumnDefaultScript(this, column, outputs); var dflt = dfltValue.IsNotNullOrWhiteSpace()? "{0} {1}".Args(TransformKeywordCase("default"), EscapeString(dfltValue)) : string.Empty; var chk = domain.GetColumnCheckScript(this, column, outputs); var cmntValue = columnNode.AttrByName(COMMENT_ATTR).Value; var cmnt = cmntValue.IsNotNullOrWhiteSpace()? "{0} {1}".Args(TransformKeywordCase("comment"), EscapeString(cmntValue)) : string.Empty; sb.Append( FormatColumnStatement(cn, tn, nn, auto, dflt, chk, cmnt) ); } #endregion firstColumn = false; foreach(var colSubNode in columnNode.Children) { if (colSubNode.IsSameName(PRIMARY_KEY_SECTION) || colSubNode.IsSameName(REFERENCE_SECTION)) { var keyType = colSubNode.IsSameName(PRIMARY_KEY_SECTION) ? RDBMSEntityType.PrimaryKey : RDBMSEntityType.Reference; var keyName = colSubNode.Value; if (keyName.IsNullOrWhiteSpace()) keyName = column.OriginalShortName; var key = new RDBMSEntity(column, colSubNode, keyType, keyName, colSubNode.AttrByName(SHORT_NAME_ATTR).Value); TransformEntityName(key); } else if (colSubNode.IsSameName(TYPE_ATTR)) { } //type may be used as section as well else m_CompileErrors.Add(new SchemaCompilationException(colSubNode.RootPath, "Unrecognized item inside '{0}.{1}' column, section '{2}'" .Args(table.OriginalName, columnName, colSubNode.Name))); } }
private void ctor(IConfigSectionNode confNode) { m_CookieName = confNode.AttrByName(CONF_COOKIE_NAME_ATTR).ValueAsString(DEFAULT_COOKIE_NAME); m_SessionTimeoutMs = confNode.AttrByName(CONF_SESSION_TIMEOUT_MS_ATTR).ValueAsInt(DEFAULT_SESSION_TIMEOUT_MS); }
public override void Configure(IConfigSectionNode node) { base.Configure(node); m_ApiKey = node.AttrByName(CONFIG_APIKEY_ATTR).Value; }
public void Configure(IConfigSectionNode node) { checkNotStarted(); m_ScriptAssembly = node.AttrByName(CONFIG_SCRIPT_ASM_ATTR).ValueAsString( Assembly.GetCallingAssembly().FullName ); foreach(var lnode in node.Children.Where(cn => cn.IsSameName(CONFIG_HANDLER_LOCATION_SECTION))) { var loc = lnode.AttrByName(CONFIG_NS_ATTR).Value; if (loc.IsNotNullOrWhiteSpace()) m_Locations.Add( loc ); else App.Log.Write(Log.MessageType.Warning, StringConsts.CRUD_CONFIG_EMPTY_LOCATIONS_WARNING, "CRUD", "QueryResolver.Configure()"); } }
private static void run(IConfigSectionNode argsConfig, bool hasConfigFile) { //try to read from /config file var localNodeName = argsConfig.AttrByName("local").Value; var remoteNodeName = argsConfig.AttrByName("remote").Value; var cookie = new ErlAtom(argsConfig.AttrByName("cookie").ValueAsString(string.Empty)); var trace = (ErlTraceLevel)Enum.Parse(typeof(ErlTraceLevel), argsConfig.AttrByName("trace").ValueAsString("Off"), true); var timeout = argsConfig.AttrByName("timeout").ValueAsInt(120); if (!hasConfigFile && (localNodeName == null || remoteNodeName == null)) { Console.WriteLine("Usage: {0} [-config ConfigFile.config] [-local NodeName -remote NodeName]\n" + " [-cookie Cookie] [-trace Level] [-timeout Timeout]\n\n" + " -config ConfFile - Provide configuration file\n" + " -trace Level - Turn on trace for level:\n" + " Off (default) | Send | Ctrl | Handshake | Wire\n" + " -timeout Timeout - Wait for messages for this number of seconds before\n" + " exiting (default: 15)\n" + "Example:\n" + "========\n" + " [Shell A] $ erl -sname a\n" + " [Shell B] $ {0} -local b -remote a -trace Send -timeout 60\n\n" + " In the Erlang shell send messages to the C# node:\n" + " [Shell A] (a@localhost)1> {test, b@localhost} ! \"Hello World!\".\n" , MiscUtils.ExeName(false)); Environment.Exit(1); } // Create an local Erlang node that will process all communications with other nodes var node = hasConfigFile ? ErlApp.Node : new ErlLocalNode(localNodeName, cookie, true); node.OnTrace = (t, l, m) => Console.WriteLine("[TRACE {0}] {1} {2}", t, l == Direction.Inbound ? "<-" : "->", m); node.OnNodeStatus = (n, up, info) => Console.WriteLine("<NodeStatus> Node {0} {1} ({2})", n.Value, up ? "up" : "down", info); node.OnConnectAttempt = (n, dir, info) => Console.WriteLine("<ConnAttempt> Node {0}: {1} connection {2}", n, dir.ToString().ToLower(), info); node.OnEpmdFailedConnectAttempt = (n, info) => Console.WriteLine("<EmpdFailure> Node {0} Epmd connectivity failure: {1}", n, info); node.OnUnhandledMsg = (c, msg) => Console.WriteLine("<UnhandMsg> Node {0} unhandled message from node {1}: {2}", c.LocalNode.NodeName, c.RemoteNode.NodeName, msg); node.OnReadWrite = (c, d, n, tn, tm) => Console.WriteLine("<ReadWrite> {0} {1} bytes (total: {2} bytes, {3} msgs)", d == Direction.Inbound ? "Read" : "Written", n, tn, tm); node.OnIoOutput = (_encoding, output) => Console.WriteLine("<I/O output> ==> Received output: {0}", output); // Create a named mailbox "test" var mbox = node.CreateMbox("test"); if (!hasConfigFile) { node.TraceLevel = trace; Console.WriteLine("Node = {0}, cookie = {1}", node.NodeName, node.Cookie); // Start the node try { node.Start(); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); goto exit; } // Connect to remote node var remote = node.Connection(remoteNodeName); Console.WriteLine("{0} to remote node {1}".Args( remote == null ? "Couldn't connect" : "Connected", remoteNodeName)); if (remote == null) { Console.WriteLine("Couldn't connect to {0}", remoteNodeName); goto exit; } // Synchronous RPC call of erlang:now() at the remote node /* new ErlAtom("erlang") */ /* new ErlList() */ var result = mbox.RPC(remote.Name, ConstAtoms.Erlang, new ErlAtom("now"), ErlList.Empty); Console.WriteLine("RPC call to erlang:now() resulted in response: {0}", result.ValueAsDateTime.ToLocalTime()); // Asynchronous RPC call of erlang:now() at the remote node mbox.AsyncRPC(remote.Name, ConstAtoms.Erlang, new ErlAtom("now"), ErlList.Empty); int i = node.WaitAny(mbox); if (i < 0) { Console.WriteLine("Timeout waiting for RPC result"); goto exit; } result = mbox.ReceiveRPC(); Console.WriteLine("AsyncRPC call to erlang:now() resulted in response: {0}", result.ValueAsDateTime.ToLocalTime()); // I/O output call on the remote node of io:format(...) // that will return the output to this local node (because by default RPC // passes node.GroupLeader as the mailbox to receive the output var mfa = ErlObject.ParseMFA("io:format(\"output: 1, 10.0, abc\n\", [])"); result = mbox.RPC(remote.Name, mfa.Item1, mfa.Item2, mfa.Item3); Console.WriteLine("io:format() -> {0}", result.ToString()); // Poll for incoming messages destined to the 'test' mailbox } var deadline = DateTime.UtcNow.AddSeconds(timeout); do { var result = mbox.Receive(1000); if (result != null) Console.WriteLine("Mailbox {0} got message: {1}", mbox.Self, result); } while (DateTime.UtcNow < deadline); exit: if (System.Diagnostics.Debugger.IsAttached) { Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } }
void IConfigurable.Configure(IConfigSectionNode node) { if (node!=null && node.AttrByName(Configuration.CONFIG_NAME_ATTR).Value.IsNullOrWhiteSpace()) throw new NFXException(StringConsts.ARGUMENT_ERROR + "TableOptions.configure(name=null|Empty)"); ConfigAttribute.Apply(this, node); }
/// <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); } }