예제 #1
0
 public void InsertInterceptor(StrategyInterceptorInterface interceptor)
 {
     strategyInterceptors.Insert(0, interceptor);
 }
예제 #2
0
 public void AddInterceptor(StrategyInterceptorInterface interceptor)
 {
     strategyInterceptors.Add(interceptor);
 }
예제 #3
0
        private bool SetOptimizeValue(StrategyInterface strategy, string name, object value)
        {
            string[] namePairs    = name.Split('.');
            string   propertyName = namePairs[1];
            PropertyDescriptorCollection props    = TypeDescriptor.GetProperties(strategy);
            PropertyDescriptor           property = null;

            for (int i = 0; i < props.Count; i++)
            {
                PropertyDescriptor tempProperty = props[i];
                if (tempProperty.Name == propertyName)
                {
                    property = tempProperty;
                    break;
                }
            }
            if (property == null)
            {
                log.Error("Sorry, the optimizer variable '" + name + "' was not found.");
                return(false);
            }
            if (namePairs.Length == 2)
            {
                if (!SetProperty(strategy, property, value))
                {
                    log.Error("Sorry, the value '" + value + "' isn't valid for optimizer variable '" + name + "'.");
                    return(false);
                }
            }
            else if (namePairs.Length == 3)
            {
                StrategyInterceptorInterface strategySupport = property.GetValue(strategy) as StrategyInterceptorInterface;
                if (strategySupport == null)
                {
                    log.Error("Sorry, the optimizer variable '" + name + "' was not found.");
                    return(false);
                }
                string strategySupportName = namePairs[1];
                propertyName = namePairs[2];
                props        = TypeDescriptor.GetProperties(strategySupport);
                property     = null;
                for (int i = 0; i < props.Count; i++)
                {
                    PropertyDescriptor tempProperty = props[i];
                    if (tempProperty.Name == propertyName)
                    {
                        property = tempProperty;
                        break;
                    }
                }
                if (property == null)
                {
                    log.Error("Sorry, the optimizer variable '" + name + "' was not found.");
                    return(false);
                }
                if (!SetProperty(strategySupport, property, value))
                {
                    log.Error("Sorry, the value '" + value + "' isn't valid for optimizer variable '" + name + "'.");
                    return(false);
                }
            }
            return(true);
        }