public void RemoveNode(object target, MatchingStrategy strategy, bool removeSubsequent)
        {
            IChainRoutingNodeProxy removeProxy = MatchinProxy(target, strategy);
            IChainRoutingNodeProxy nextProxy   = removeSubsequent ? null : removeProxy.NextProxy;

            removeProxy.LastProxy.NextProxy = nextProxy;
        }
Beispiel #2
0
        private string GetCacheKey()
        {
            var keyBuilder = new StringBuilder();

            keyBuilder.AppendFormat("{0}_", GetType().FullName);
            keyBuilder.AppendFormat("{0}_", typeof(TTarget).FullName);
            keyBuilder.AppendFormat("{0}_", typeof(TSource).FullName);
            keyBuilder.AppendFormat("{0}", MatchingStrategy.GetType().FullName);
            return(keyBuilder.ToString());
        }
Beispiel #3
0
        public void InsertNode(object node, object identify, object previous, MatchingStrategy strategy)
        {
            IChainRoutingNodeProxy proxy     = CreateProxy(node, identify);
            IChainRoutingNodeProxy lastProxy = MatchinProxy(previous, strategy);
            IChainRoutingNodeProxy nextProxy = lastProxy.NextProxy;

            lastProxy.NextProxy = proxy;
            proxy.LastProxy     = lastProxy;
            proxy.NextProxy     = nextProxy;
            nextProxy.LastProxy = proxy;
        }
        /// <summary>
        /// 匹配节点
        /// </summary>
        /// <param name="target">匹配目标</param>
        /// <param name="strategy">匹配模式</param>
        /// <returns></returns>
        protected IChainRoutingNodeProxy MatchinProxy(object target, MatchingStrategy strategy)
        {
            if (firstProxy == null)
            {
                return(null);
            }
            IChainRoutingNodeProxy nowProxy = firstProxy;

            switch (strategy)
            {
            case MatchingStrategy.Deep:
                int nowDeep    = 0;
                int targetDeep = (int)target;
                while (firstProxy.NextProxy != null)
                {
                    if (nowDeep == targetDeep)
                    {
                        return(nowProxy);
                    }
                    nowProxy = nowProxy.NextProxy;
                    nowDeep += 1;
                }
                return(nowProxy);

            case MatchingStrategy.Identify:
                while (firstProxy.NextProxy != null)
                {
                    if (nowProxy.ProxyIdentify == target)
                    {
                        return(nowProxy);
                    }
                    nowProxy = nowProxy.NextProxy;
                }
                return(nowProxy);

            case MatchingStrategy.Object:
                while (firstProxy.NextProxy != null)
                {
                    if (nowProxy.ProxyNode == target)
                    {
                        return(nowProxy);
                    }
                    nowProxy = nowProxy.NextProxy;
                }
                return(nowProxy);

            default:
                return(null);
            }
        }
        /// <summary>
        /// Constructs a record with a name.
        /// </summary>
        /// <param name="name">The name, which will be saved in upper case.</param>
        public PositionRecord(string name)
        {
            // Initialise matcher.
            matcher = new RmsdMatching();

            if (name != null)
            {
                Name = name;
            }
            // Give angles the normal precision.
            for (int i = 0; i < Precision.Length; i++)
            {
                this[i].MaxDiff = Precision[i];
            }
            Standalone = true;
        }
Beispiel #6
0
        public ActionResponse <IEnumerable <TEntity> > Find <TValue>(string fieldName, TValue value, MatchingStrategy strategy, int limit = 100)
        {
            FilterDefinition <TEntity> filter;

            switch (strategy)
            {
            case MatchingStrategy.LessThan:
                filter = FilterBuilder.Lt(fieldName, value);
                break;

            case MatchingStrategy.GreaterThan:
                filter = FilterBuilder.Gt(fieldName, value);
                break;

            default:
                filter = FilterBuilder.Eq(fieldName, value);
                break;
            }

            var hits = Collection.Find(filter).Sort(SortBuilder.Descending(fieldName)).Limit(limit);

            return(new ActionResponse <IEnumerable <TEntity> >
            {
                Code = AppStatusCode.Ok,
                Data = hits.ToList()
            });
        }
Beispiel #7
0
 public void InsertNode(object identify, object previous, MatchingStrategy strategy)
 {
     InsertNode(CreateNode(), identify, previous, strategy);
 }
Beispiel #8
0
 public ActionResponse <IEnumerable <Recipe> > FindRecipes <TValue>(string fieldName, TValue value, MatchingStrategy strategy, int limit = 100)
 {
     return(_recipeRepository.Find(fieldName, value, strategy, limit));
 }
 /// <summary>
 /// 冒泡路由事件参数
 /// </summary>
 /// <param name="token">事件令牌</param>
 /// <param name="OriginalSource">事件发起源</param>
 /// <param name="matchingStrategy">匹配策略</param>
 /// <param name="matchingParameter">匹配对象</param>
 /// <param name="parameters">匹配对象</param>
 public BubbleEventArgs(string token, object originalSource, MatchingStrategy matchingStrategy, object matchingParameter, params object[] parameters) : base(token, parameters)
 {
     OriginalSource    = originalSource;
     MatchingStrategy  = matchingStrategy;
     MatchingParameter = matchingParameter;
 }