예제 #1
0
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>
        /// </returns>
        public Rule Clone()
        {
            var result = new Rule();

              result.TypeName = this.TypeName;
              result.NotNull = this.NotNull;
              result.CanBeNull = this.CanBeNull;
              result.PublicParameterAssertion = this.PublicParameterAssertion;
              result.NonPublicParameterAssertion = this.NonPublicParameterAssertion;
              result.ReturnAssertion = this.ReturnAssertion;

              foreach (var valueAssertion in this.ValueAssertions)
              {
            result.ValueAssertions.Add(valueAssertion);
              }

              return result;
        }
        /// <summary>Shows the popup menu.</summary>
        /// <param name="element">The element.</param>
        /// <param name="rule">The rule.</param>
        /// <param name="name">The name.</param>
        private void ShowPopupMenu(IElement element, Rule rule, string name)
        {
            var menu = new JetPopupMenu();

              var assertions = new List<SimpleMenuItem>(rule.ValueAssertions.Count);

              foreach (var valueAssertion in rule.ValueAssertions)
              {
            var item = new SimpleMenuItem
            {
              Text = string.Format(valueAssertion, name),
              Style = MenuItemStyle.Enabled
            };

            item.Clicked += delegate { this.InsertAssertion(item.Text, element); };

            assertions.Add(item);
              }

              menu.Caption.Value = WindowlessControl.Create("Assert Assignment");
              menu.SetItems(assertions.ToArray());
              menu.KeyboardAcceleration.SetValue(KeyboardAccelerationFlags.Mnemonics);

              menu.Show();
        }
        /// <summary>
        /// Reads the specified nodes.
        /// </summary>
        /// <param name="nodes">
        /// The nodes.
        /// </param>
        private void Read(XmlNodeList nodes)
        {
            foreach (XmlNode type in nodes)
              {
            var rule = new Rule
            {
              TypeName = GetAttributeString(type, "type"), NotNull = GetAttributeString(type, "notnull") == "true", CanBeNull = GetAttributeString(type, "canbenull") == "true", PublicParameterAssertion = GetElementString(type, "publicparameterassertion"), NonPublicParameterAssertion = GetElementString(type, "nonpublicparameterassertion"), ReturnAssertion = GetElementString(type, "returnassertion")
            };

            var valueAssertions = type.SelectNodes("valueassertions/valueassertion");
            if (valueAssertions != null)
            {
              foreach (XmlNode valueAssertion in valueAssertions)
              {
            rule.ValueAssertions.Add(valueAssertion.InnerText);
              }
            }

            this._rules.Add(rule);
              }
        }