Ejemplo n.º 1
0
        public SimpleRule(NvdlRule rule, bool matchAttributes,
                          NvdlCompileContext ctx)
        {
            FillLocation(rule);

            this.matchAttributes = matchAttributes;
            NvdlNamespace nss = rule as NvdlNamespace;

            if (nss == null)
            {
                this.isAny = true;
            }
            else
            {
                this.ns = nss.NS;
                if (nss.Wildcard == null)
                {
                    wildcard = "*";
                }
                else if (nss.Wildcard.Length > 1)
                {
                    throw new NvdlCompileException("'wildCard' attribute can specify at most one character string.", rule);
                }
                else
                {
                    wildcard = nss.Wildcard;
                }
            }

            SimplifyPhase1(rule, ctx);
        }
Ejemplo n.º 2
0
        private void SimplifyPhase1(NvdlRule r, NvdlCompileContext ctx)
        {
            ctx.AddRuleContext(this, r);
            // 6.4.9
            ArrayList al = new ArrayList();

            foreach (NvdlAction a in r.Actions)
            {
                NvdlNoCancelAction nca =
                    a as NvdlNoCancelAction;
                if (nca != null)
                {
                    if (nca.ModeUsage != null)
                    {
                        SimplifyModeUsage(nca, ctx);
                    }
                    NvdlResultAction ra = nca as NvdlResultAction;
                    if (ra != null)
                    {
                        al.Add(new SimpleResultAction(ra, ctx));
                    }
                    else if (nca is NvdlValidate)
                    {
                        al.Add(new SimpleValidate(
                                   (NvdlValidate)nca, ctx));
                    }
                    else if (nca is NvdlAllow)
                    {
                        al.Add(new SimpleValidate(
                                   (NvdlAllow)nca, ctx));
                    }
                    else
                    {
                        al.Add(new SimpleValidate(
                                   (NvdlReject)nca, ctx));
                    }
                }
                else if (nca == null)
                {
                    ctx.CancelledRules.Add(this, this);
                }
            }
            actions = (SimpleAction [])al.ToArray(
                typeof(SimpleAction));
        }
Ejemplo n.º 3
0
        private void ReadAction(NvdlRule el)
        {
            switch (reader.LocalName)
            {
            case "cancelNestedActions":
                el.Actions.Add(ReadCancelAction());
                break;

            case "validate":
                el.Actions.Add(ReadValidate());
                break;

            case "allow":
                el.Actions.Add(ReadAllow());
                break;

            case "reject":
                el.Actions.Add(ReadReject());
                break;

            case "attach":
                el.Actions.Add(ReadAttach());
                break;

            case "attachPlaceHolder":
                el.Actions.Add(ReadAttachPlaceholder());
                break;

            case "unwrap":
                el.Actions.Add(ReadUnwrap());
                break;

            default:
                throw new NotSupportedException();
            }
        }
Ejemplo n.º 4
0
 public void Remove(NvdlRule item)
 {
     List.Add(item);
 }
Ejemplo n.º 5
0
 public void Add(NvdlRule item)
 {
     List.Add(item);
 }
Ejemplo n.º 6
0
 internal void AddRuleContext(SimpleRule r, NvdlRule rctx)
 {
     ruleContexts.Add(r, rctx);
 }
Ejemplo n.º 7
0
		internal void AddRuleContext (SimpleRule r, NvdlRule rctx)
		{
			ruleContexts.Add (r, rctx);
		}
Ejemplo n.º 8
0
		public void Remove (NvdlRule item)
		{
			List.Add (item);
		}
Ejemplo n.º 9
0
		public void Add (NvdlRule item)
		{
			List.Add (item);
		}
Ejemplo n.º 10
0
		private void ReadAction (NvdlRule el)
		{
			switch (reader.LocalName) {
			case "cancelNestedActions":
				el.Actions.Add (ReadCancelAction ());
				break;
			case "validate":
				el.Actions.Add (ReadValidate ());
				break;
			case "allow":
				el.Actions.Add (ReadAllow ());
				break;
			case "reject":
				el.Actions.Add (ReadReject ());
				break;
			case "attach":
				el.Actions.Add (ReadAttach ());
				break;
			case "attachPlaceHolder":
				el.Actions.Add (ReadAttachPlaceholder ());
				break;
			case "unwrap":
				el.Actions.Add (ReadUnwrap ());
				break;
			default:
				throw new NotSupportedException ();
			}
		}
Ejemplo n.º 11
0
		private void SimplifyPhase1 (NvdlRule r, NvdlCompileContext ctx)
		{
			ctx.AddRuleContext (this, r);
			// 6.4.9
			ArrayList al = new ArrayList ();
			foreach (NvdlAction a in r.Actions) {
				NvdlNoCancelAction nca =
					a as NvdlNoCancelAction;
				if (nca != null) {
					if (nca.ModeUsage != null)
						SimplifyModeUsage (nca, ctx);
					NvdlResultAction ra = nca as NvdlResultAction;
					if (ra != null)
						al.Add (new SimpleResultAction (ra, ctx));
					else if (nca is NvdlValidate)
						al.Add (new SimpleValidate (
							(NvdlValidate) nca, ctx));
					else if (nca is NvdlAllow)
						al.Add (new SimpleValidate (
							(NvdlAllow) nca, ctx));
					else
						al.Add (new SimpleValidate (
							(NvdlReject) nca, ctx));
				}
				else if (nca == null)
					ctx.CancelledRules.Add (this, this);
			}
			actions = (SimpleAction []) al.ToArray (
				typeof (SimpleAction));
		}
Ejemplo n.º 12
0
		public SimpleRule (NvdlRule rule, bool matchAttributes,
			NvdlCompileContext ctx)
		{
			FillLocation (rule);

			this.matchAttributes = matchAttributes;
			NvdlNamespace nss = rule as NvdlNamespace;
			if (nss == null)
				this.isAny = true;
			else {
				this.ns = nss.NS;
				if (nss.Wildcard == null)
					wildcard = "*";
				else if (nss.Wildcard.Length > 1)
					throw new NvdlCompileException ("'wildCard' attribute can specify at most one character string.", rule);
				else
					wildcard = nss.Wildcard;
			}

			SimplifyPhase1 (rule, ctx);
		}