示例#1
0
        public bool Match(string suppliedValue, RolloutStrategyAttribute attr)
        {
            var vals = attr.Values.Where(v => v != null).Select(v => new IPNetworkProxy(v.ToString())).ToList();
            var ip   = new IPNetworkProxy(suppliedValue);

            switch (attr.Conditional)
            {
            case RolloutStrategyAttributeConditional.EQUALS:
            case RolloutStrategyAttributeConditional.INCLUDES:
                return(vals.Any(v => v.Contains(ip)));

            case RolloutStrategyAttributeConditional.NOTEQUALS:
            case RolloutStrategyAttributeConditional.EXCLUDES:
                return(!vals.Any(v => v.Contains(ip)));

            case RolloutStrategyAttributeConditional.REGEX:
                return(false);

            case null:
                return(false);

            default:
                return(false);
            }
        }
示例#2
0
        public bool Contains(IPNetworkProxy proxy)
        {
            if (proxy._isAddress && _isAddress)
            {
                return(_address.Equals(proxy._address));
            }

            if (!proxy._isAddress && !_isAddress)
            {
                return(_network.Equals(this._network));
            }

            // they are an address and we are a network
            if (proxy._isAddress && !_isAddress)
            {
                return(_network.Contains(proxy._address));
            }

            return(false); // an ip address cannot contain a network
        }