Пример #1
0
        private string MatchEvaluatorTags(Match m)
        {
            Type   tagType   = null;
            object tagObject = null;

            switch (m.Groups[RegExConstants.RE_CS_TAGS_TAGNAME].Value)
            {
            case "Assembly":
                tagType   = typeof(TagAssembly);
                tagObject = new TagAssembly();
                break;

            case "CodeTemplate":
                tagType   = typeof(TagCodeTemplate);
                tagObject = new TagCodeTemplate();
                break;

            case "Import":
                tagType   = typeof(TagImport);
                tagObject = new TagImport();
                break;

            case "Property":
                tagType   = typeof(TagProperty);
                tagObject = new TagProperty();
                break;

            case "Register":
                tagType   = typeof(TagRegister);
                tagObject = new TagRegister();
                break;

            default:
                tagType   = null;
                tagObject = null;
                break;
            }

            // Only parse if it's a known tag
            if (tagType != null)
            {
                if (m.Groups[RegExConstants.RE_CS_TAGS_KEY].Captures.Count > 0)
                {
                    for (int i = 0; i < m.Groups[RegExConstants.RE_CS_TAGS_KEY].Captures.Count; i++)
                    {
                        SetProperty(tagType,
                                    tagObject,
                                    m.Groups[RegExConstants.RE_CS_TAGS_KEY].Captures[i].Value,
                                    m.Groups[RegExConstants.RE_CS_TAGS_VALUE].Captures[i].Value);
                    }
                }

                // Add the templateobject to the list
                TemplateObjectList.Add(new TemplateObject(tagType, tagObject));
            }

            return(string.Empty);
        }
Пример #2
0
 public ActionResult Edit(TagAssembly model)
 {
     if (!ModelState.IsValid) {
         ModelState.AddModelError("", "表单验证失败。");
         return View(model);
     }
     if (collection.Find(Query<TagAssembly>.EQ(d => d.TagCodes, model.TagCodes)).Any()) {
         ModelState.AddModelError("TagCodes", "TagCodes已存在。");
         return View(model);
     }
     collection.Save(model);
     return RedirectToAction("Index");
 }