Beispiel #1
0
        SubRouteConfiguration FillSubRoute(IActivityMonitor monitor, XElement xml, SubRouteConfiguration sub)
        {
            using (monitor.OpenGroup(LogLevel.Trace, string.Format("Reading subordinated channel '{0}'.", sub.Name), null))
            {
                var matchOptions = (string)xml.Attribute("MatchOptions");
                var filter       = (string)xml.Attribute("TopicFilter");
                var regex        = (string)xml.Attribute("TopicRegex");
                if ((filter == null) == (regex == null))
                {
                    throw new XmlException("Subordinated Channel must define one TopicFilter or TopicRegex attribute (and not both)." + xml.GetLineColumnString());
                }
                RegexOptions opt = RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Multiline | RegexOptions.ExplicitCapture;
                if (!String.IsNullOrWhiteSpace(matchOptions))
                {
                    if (!Enum.TryParse(matchOptions, true, out opt))
                    {
                        var expected = String.Join(", ", Enum.GetNames(typeof(RegexOptions)).Where(n => n != "None"));
                        throw new XmlException("MatchOptions value must be a subset of: " + expected + xml.GetLineColumnString());
                    }
                    monitor.SendLine(LogLevel.Trace, string.Format("MatchOptions for Channel '{0}' is: {1}.", sub.Name, opt), null);
                }
                else
                {
                    monitor.SendLine(LogLevel.Trace, string.Format("MatchOptions for Channel '{0}' defaults to: IgnoreCase, CultureInvariant, Multiline, ExplicitCapture.", sub.Name), null);
                }

                sub.RoutePredicate = filter != null?CreatePredicateFromWildcards(filter, opt) : CreatePredicateRegex(regex, opt);

                FillRoute(monitor, xml, sub);
                return(sub);
            }
        }
Beispiel #2
0
 internal Route( ProtoResolver r, Route parent, SubRouteConfiguration c )
     : this( c, parent, r )
 {
     _routeDepth = parent._routeDepth + 1;
     _namespace = parent._namespace + c.Namespace;
     _fullName = parent._namespace + _fullName;
     CheckValidity();
     if( c.ImportParentDeclaredActionsAbove ) _declaredActions.AddRange( _parent._declaredActions );
     if( c.ImportParentActions ) _metaConfigurations.AddRange( parent._metaConfigurations );
 }
Beispiel #3
0
 bool IProtoRouteConfigurationContext.AddRoute( SubRouteConfiguration route )
 {
     if( route == null ) throw new ArgumentNullException();
     var newSub = new Route( _resolver, this, route );
     if( !_resolver.RegisterSubRoute( newSub ) )
     {
         Monitor.SendLine( LogLevel.Error, string.Format( "Route named '{0}' is already declared.", newSub._fullName ), null );
         return false;
     }
     using( Monitor.OpenGroup( LogLevel.Info, string.Format( "Preprocessing route '{0}'.", newSub._fullName ), null ) )
     {
         newSub.ExecuteMetaConfigurations();
         _subRoutes.Add( newSub );
     }
     return true;
 }
Beispiel #4
0
 internal Route(ProtoResolver r, Route parent, SubRouteConfiguration c)
     : this(c, parent, r)
 {
     _routeDepth = parent._routeDepth + 1;
     _namespace  = parent._namespace + c.Namespace;
     _fullName   = parent._namespace + _fullName;
     CheckValidity();
     if (c.ImportParentDeclaredActionsAbove)
     {
         _declaredActions.AddRange(_parent._declaredActions);
     }
     if (c.ImportParentActions)
     {
         _metaConfigurations.AddRange(parent._metaConfigurations);
     }
 }
Beispiel #5
0
            bool IProtoRouteConfigurationContext.AddRoute(SubRouteConfiguration route)
            {
                if (route == null)
                {
                    throw new ArgumentNullException();
                }
                var newSub = new Route(_resolver, this, route);

                if (!_resolver.RegisterSubRoute(newSub))
                {
                    Monitor.SendLine(LogLevel.Error, string.Format("Route named '{0}' is already declared.", newSub._fullName), null);
                    return(false);
                }
                using (Monitor.OpenGroup(LogLevel.Info, string.Format("Preprocessing route '{0}'.", newSub._fullName), null))
                {
                    newSub.ExecuteMetaConfigurations();
                    _subRoutes.Add(newSub);
                }
                return(true);
            }