Ejemplo n.º 1
0
        private void ReadCommonActionContent(NvdlNoCancelAction el)
        {
            FillLocation(el);
            NvdlModeUsage mu = new NvdlModeUsage();

            el.ModeUsage = mu;
            FillLocation(el);
            el.SimpleMessage = reader.GetAttribute("message");
            mu.UseMode       = reader.GetAttribute("useMode");
            FillForeignAttribute(el);
            if (reader.IsEmptyElement)
            {
                reader.Skip();
                return;
            }
            reader.Read();
            do
            {
                reader.MoveToContent();
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
                if (reader.NamespaceURI != Nvdl.Namespace)
                {
                    el.Foreign.Add(XDocument.ReadFrom(reader));
                    continue;
                }
                switch (reader.LocalName)
                {
                case "mode":
                    mu.NestedMode = ReadNestedMode();
                    break;

                case "message":
                    el.Messages.Add(ReadMessage());
                    break;

                case "context":
                    mu.Contexts.Add(ReadContext());
                    break;

                default:
                    throw new NotSupportedException();
                }
            } while (!reader.EOF);
            if (!reader.EOF)
            {
                reader.Read();
            }
        }
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
        protected SimpleAction(NvdlNoCancelAction action)
        {
            FillLocation(action);

            if (action.ModeUsage != null)
            {
                modeUsage = new SimpleModeUsage(action.ModeUsage);
            }
            messages = new ListDictionary();
            if (action.SimpleMessage != null)
            {
                messages.Add("", action.SimpleMessage);
            }
            foreach (NvdlMessage msg in action.Messages)
            {
                messages.Add(msg.XmlLang, msg.Text);
            }
        }
Ejemplo n.º 4
0
        private void SimplifyModeUsage(
            NvdlNoCancelAction nca, NvdlCompileContext ctx)
        {
            NvdlModeUsage usage = nca.ModeUsage;

            if (usage.NestedMode != null && ctx.GetCompiledMode(usage) == null)
            {
                SimpleMode sm = new SimpleMode(String.Empty,
                                               usage.NestedMode, ctx);
                ctx.AddCompiledMode(usage, sm);
            }
            foreach (NvdlContext c in usage.Contexts)
            {
                if (c.NestedMode != null)
                {
                    SimpleMode sm = new SimpleMode(
                        String.Empty, c.NestedMode, ctx);
                    ctx.AddCompiledMode(c, sm);
                }
            }
        }
Ejemplo n.º 5
0
		private void ReadCommonActionContent (NvdlNoCancelAction el)
		{
			FillLocation (el);
			NvdlModeUsage mu = new NvdlModeUsage ();
			el.ModeUsage = mu;
			FillLocation (el);
			el.SimpleMessage = reader.GetAttribute ("message");
			mu.UseMode = reader.GetAttribute ("useMode");
			FillForeignAttribute (el);
			if (reader.IsEmptyElement) {
				reader.Skip ();
				return;
			}
			reader.Read ();
			do {
				reader.MoveToContent ();
				if (reader.NodeType == XmlNodeType.EndElement)
					break;
				if (reader.NamespaceURI != Nvdl.Namespace) {
					el.Foreign.Add (doc.ReadNode (reader));
					continue;
				}
				switch (reader.LocalName) {
				case "mode":
					mu.NestedMode = ReadNestedMode ();
					break;
				case "message":
					el.Messages.Add (ReadMessage ());
					break;
				case "context":
					mu.Contexts.Add (ReadContext ());
					break;
				default:
					throw new NotSupportedException ();
				}
			} while (!reader.EOF);
			if (!reader.EOF)
				reader.Read ();
		}
Ejemplo n.º 6
0
		protected SimpleAction (NvdlNoCancelAction action)
		{
			FillLocation (action);

			if (action.ModeUsage != null)
				modeUsage = new SimpleModeUsage (action.ModeUsage);
			messages = new ListDictionary ();
			if (action.SimpleMessage != null)
				messages.Add ("", action.SimpleMessage);
			foreach (NvdlMessage msg in action.Messages)
				messages.Add (msg.XmlLang, msg.Text);
		}
Ejemplo n.º 7
0
		private void SimplifyModeUsage (
			NvdlNoCancelAction nca, NvdlCompileContext ctx)
		{
			NvdlModeUsage usage = nca.ModeUsage;
			if (usage.NestedMode != null && ctx.GetCompiledMode (usage) == null) {
				SimpleMode sm = new SimpleMode (String.Empty,
					usage.NestedMode, ctx);
				ctx.AddCompiledMode (usage, sm);
			}
			foreach (NvdlContext c in usage.Contexts) {
				if (c.NestedMode != null) {
					SimpleMode sm = new SimpleMode (
						String.Empty, c.NestedMode, ctx);
					ctx.AddCompiledMode (c, sm);
				}
			}
		}