Example #1
0
 public Frame(Frame parent, List <Statement> body, bool partial, string kind)
 {
     Contract.Requires <ArgumentNullException>(parent != null);
     Contract.Requires <ArgumentNullException>(tcce.NonNullElements(body), "body");
     // carry over the tactic info
     Body = body;
     _declaredVariables      = new Dictionary <string, object>();
     _DafnyVariables         = new Dictionary <string, VariableData>();
     Parent                  = parent;
     ActiveTactic            = parent.ActiveTactic;
     _reporter               = parent._reporter;
     _generatedCode          = null;
     _rawCodeList            = new List <List <Statement> >();
     WhatKind                = kind;
     FrameCtrlInfo           = parent.FrameCtrlInfo;
     FrameCtrlInfo.IsPartial = FrameCtrlInfo.IsPartial || partial;
 }
Example #2
0
        /// <summary>
        /// 将页面验证信息加入到内存。
        /// </summary>
        private SystemCtrlInfoManager()
        {
            XmlDocument doc = XmlHelper.GetXmlDocument(path);
            // TODO: 添加校验文件功能
            //XmlHelper.Validate(path, schemaPath);

            XmlNodeList nl = doc.SelectNodes("/root/Form");

            // 遍历每个Form(页面)
            foreach (XmlNode node in nl)
            {
                FormCtrlInfo fci = new FormCtrlInfo(node.Attributes["name"].Value.ToLower(), node.Attributes["help"].Value);
                this.allForm.Add(fci.FormName, fci);
                XmlNodeList childNodes = node.SelectNodes("Control");

                // 遍历每个Control(控件)
                foreach (XmlNode childNode in childNodes)
                {
                    int length = 0;
                    if (childNode.Attributes["length"] != null)
                    {
                        length = int.Parse(childNode.Attributes["length"].Value);
                    }

                    // toolTip信息。
                    XmlAttribute ctrlHelp = childNode.Attributes["help"];
                    string       toolTip  = (ctrlHelp == null) ? null : ctrlHelp.Value;

                    // 输入校验。
                    XmlNodeList  ctrlValidators = childNode.SelectNodes("Validator");
                    IValidator[] validators     = FillValidatorCtrl(ctrlValidators);

                    CtrlInfo ci = new CtrlInfo(childNode.Attributes["name"].Value, toolTip, validators, length);
                    fci.Add(ci);
                }
            }
        }
Example #3
0
            private void ParseTacticAttributes(Attributes attr)
            {
                // incase TacticInformation is not created
                FrameCtrlInfo = FrameCtrlInfo ?? new CtrlInfo();
                if (attr == null)
                {
                    return;
                }
                switch (attr.Name)
                {
                case "search":
                    var    expr      = attr.Args.FirstOrDefault();
                    string stratName = (expr as NameSegment)?.Name;
                    Contract.Assert(stratName != null);
                    try {
                        FrameCtrlInfo.SearchStrategy = (Strategy)Enum.Parse(typeof(Strategy), stratName, true); // TODO: change to ENUM
                    } catch {
                        _reporter.Warning(MessageSource.Tacny, ((MemberDecl)ActiveTactic).tok, $"Unsupported search strategy {stratName}; Defaulting to DFS");
                        FrameCtrlInfo.SearchStrategy = Strategy.Dfs;
                    }
                    break;

                case "partial":
                    FrameCtrlInfo.IsPartial = true;
                    break;

                default:
                    //_reporter.Warning(MessageSource.Tacny, ((MemberDecl)ActiveTactic).tok, $"Unrecognized attribute {attr.Name}");
                    break;
                }

                if (attr.Prev != null)
                {
                    ParseTacticAttributes(attr.Prev);
                }
            }
Example #4
0
      private void ParseTacticAttributes(Attributes attr) {
        // incase TacticInformation is not created
        FrameCtrlInfo = FrameCtrlInfo ?? new CtrlInfo();
        if (attr == null)
          return;
        switch (attr.Name) {
          case "search":
            var expr = attr.Args.FirstOrDefault();
            string stratName = (expr as NameSegment)?.Name;
            Contract.Assert(stratName != null);
            try {
              FrameCtrlInfo.SearchStrategy = (Strategy)Enum.Parse(typeof(Strategy), stratName, true); // TODO: change to ENUM
            } catch {
              _reporter.Warning(MessageSource.Tacny, ((MemberDecl)ActiveTactic).tok, $"Unsupported search strategy {stratName}; Defaulting to DFS");
              FrameCtrlInfo.SearchStrategy = Strategy.Dfs;
            }
            break;
           case "partial":
            FrameCtrlInfo.IsPartial = true;
            break;
          default:
            //_reporter.Warning(MessageSource.Tacny, ((MemberDecl)ActiveTactic).tok, $"Unrecognized attribute {attr.Name}");
            break;
        }

        if (attr.Prev != null)
          ParseTacticAttributes(attr.Prev);
      }
Example #5
0
 public Frame(Frame parent, List<Statement> body, bool partial, string kind) {
   Contract.Requires<ArgumentNullException>(parent != null);
   Contract.Requires<ArgumentNullException>(tcce.NonNullElements(body), "body");
   // carry over the tactic info
   Body = body;
   _declaredVariables = new Dictionary<string, object>();
   _DafnyVariables = new Dictionary<string, VariableData>();
   Parent = parent;
   ActiveTactic = parent.ActiveTactic;
   _reporter = parent._reporter;
   _generatedCode = null;
   _rawCodeList = new List<List<Statement>>();
   WhatKind = kind;
   FrameCtrlInfo = parent.FrameCtrlInfo;
   FrameCtrlInfo.IsPartial = FrameCtrlInfo.IsPartial || partial;
 }