示例#1
0
        public override void Initialize(XmlNode ruleInstance)
        {
            // Initialize from XmlNode:
            this.target   = (RuleTarget)Enum.Parse(typeof(RuleTarget), ruleInstance.Attributes["target"].Value, true);
            this.typeName = ruleInstance.Attributes["type"].Value;

            // Initialize caches on context:
            if (!this.Context.Properties.ContainsKey(MethodCacheKey))
            {
                this.Context.Properties[MethodCacheKey] = new MethodAttributesCache();
            }
            if (!this.Context.Properties.ContainsKey(TypeCacheKey))
            {
                this.Context.Properties[TypeCacheKey] = new TypeAttributesCache();
            }
            if (!this.Context.Properties.ContainsKey(AssemblyCacheKey))
            {
                this.Context.Properties[AssemblyCacheKey] = new AssemblyAttributesCache();
            }

            // Keep local references to caches:
            this.methodAttributesCache
                = (MethodAttributesCache)this.Context.Properties[MethodCacheKey];
            this.typeAttributesCache
                = (TypeAttributesCache)this.Context.Properties[TypeCacheKey];
            this.assemblyAttributesCache
                = (AssemblyAttributesCache)this.Context.Properties[AssemblyCacheKey];
        }
		public override void Initialize(XmlNode ruleInstance)
		{
			this.target = (RuleTarget)Enum.Parse(typeof(RuleTarget), ruleInstance.Attributes["target"].Value, true);
            if (ruleInstance.Attributes["match"] != null)
                this.match = new Regex(ruleInstance.Attributes["match"].Value, RegexOptions.Compiled);
            else if (ruleInstance.Attributes["like"] != null)
                this.match = GetLikeRegex(ruleInstance.Attributes["like"].Value, RegexOptions.Compiled);
            else
                throw new InvalidOperationException(String.Format("Name matching rule must have either match or like attribute in \"{0}\".", ruleInstance.OuterXml));
		}
示例#3
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        public bool Matches(Context context, RuleTarget target)
        {
            foreach (Rule rule in Rules)
            {
                if (!rule.Matches(context, target))
                {
                    return(false);
                }
            }

            return(true);
        }
 public override void Initialize(XmlNode ruleInstance)
 {
     this.target = (RuleTarget)Enum.Parse(typeof(RuleTarget), ruleInstance.Attributes["target"].Value, true);
     if (ruleInstance.Attributes["match"] != null)
     {
         this.match = new Regex(ruleInstance.Attributes["match"].Value, RegexOptions.Compiled);
     }
     else if (ruleInstance.Attributes["like"] != null)
     {
         this.match = GetLikeRegex(ruleInstance.Attributes["like"].Value, RegexOptions.Compiled);
     }
     else
     {
         throw new InvalidOperationException(String.Format("Name matching rule must have either match or like attribute in \"{0}\".", ruleInstance.OuterXml));
     }
 }
		public override void Initialize(XmlNode ruleInstance)
		{
			this.target = (RuleTarget)Enum.Parse(typeof(RuleTarget), ruleInstance.Attributes["target"].Value, true);
			switch(this.target)
			{
				case RuleTarget.Method:
					InitializeMethod(ruleInstance);
					break;
				case RuleTarget.Type:
					InitializeType(ruleInstance);
					break;
				default:
					throw new InvalidOperationException(String.Format("Invalid target '{0}' for {1}.", this.target, this.GetType().Name));
			}

            if (ruleInstance.Attributes["reverse"] != null)
                this.reverse = Convert.ToBoolean(ruleInstance.Attributes["reverse"].Value);
        }
		public override void Initialize(XmlNode ruleInstance)
		{
            // Initialize from XmlNode:
			this.target = (RuleTarget)Enum.Parse(typeof(RuleTarget), ruleInstance.Attributes["target"].Value, true);
			this.typeName = ruleInstance.Attributes["type"].Value;

            // Initialize caches on context:
            if (!this.Context.Properties.ContainsKey(MethodCacheKey))
                this.Context.Properties[MethodCacheKey] = new MethodAttributesCache();
            if (!this.Context.Properties.ContainsKey(TypeCacheKey))
                this.Context.Properties[TypeCacheKey] = new TypeAttributesCache();
            if (!this.Context.Properties.ContainsKey(AssemblyCacheKey))
                this.Context.Properties[AssemblyCacheKey] = new AssemblyAttributesCache();

            // Keep local references to caches:
            this.methodAttributesCache
                = (MethodAttributesCache)this.Context.Properties[MethodCacheKey];
            this.typeAttributesCache
                = (TypeAttributesCache)this.Context.Properties[TypeCacheKey];
            this.assemblyAttributesCache
                = (AssemblyAttributesCache)this.Context.Properties[AssemblyCacheKey];
        }
        public override void Initialize(XmlNode ruleInstance)
        {
            this.target = (RuleTarget)Enum.Parse(typeof(RuleTarget), ruleInstance.Attributes["target"].Value, true);
            switch (this.target)
            {
            case RuleTarget.Method:
                InitializeMethod(ruleInstance);
                break;

            case RuleTarget.Type:
                InitializeType(ruleInstance);
                break;

            default:
                throw new InvalidOperationException(String.Format("Invalid target '{0}' for {1}.", this.target, this.GetType().Name));
            }

            if (ruleInstance.Attributes["reverse"] != null)
            {
                this.reverse = Convert.ToBoolean(ruleInstance.Attributes["reverse"].Value);
            }
        }
 ///////////////////////////////////////////////////////////////////////////////////////////
 public bool Matches(Context context, RuleTarget target)
 {
     return(true);
 }
示例#9
0
文件: Rule.cs 项目: aPisC/MuzsikaTS3
 public Rule(string value, RuleMode mode, RuleTarget target)
 {
     _value  = value;
     _mode   = mode;
     _target = target;
 }
示例#10
0
 ///////////////////////////////////////////////////////////////////////////////////////////
 public bool Matches(Context context, RuleTarget target)
 {
     return(!SubRule.Matches(context, target));
 }
示例#11
0
 ///////////////////////////////////////////////////////////////////////////////////////////
 public bool Matches(Context context, RuleTarget target)
 {
     return(Name.IsMatch(target.Name));
 }