Esempio 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);
        }
Esempio 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));
        }
Esempio 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();
            }
        }
Esempio n. 4
0
 public void Remove(NvdlRule item)
 {
     List.Add(item);
 }
Esempio n. 5
0
 public void Add(NvdlRule item)
 {
     List.Add(item);
 }
Esempio n. 6
0
 internal void AddRuleContext(SimpleRule r, NvdlRule rctx)
 {
     ruleContexts.Add(r, rctx);
 }
Esempio n. 7
0
		internal void AddRuleContext (SimpleRule r, NvdlRule rctx)
		{
			ruleContexts.Add (r, rctx);
		}
Esempio n. 8
0
		public void Remove (NvdlRule item)
		{
			List.Add (item);
		}
Esempio n. 9
0
		public void Add (NvdlRule item)
		{
			List.Add (item);
		}
Esempio 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 ();
			}
		}
Esempio 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));
		}
Esempio 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);
		}