ATMLModelLibrary.model.Physical.Validate C# (CSharp) Method

Validate() public method

public Validate ( ) : void
return void
        public void Validate()
        {
            foreach (RangingInformation rangingInformation in _ranges)
                rangingInformation.Validate();
            foreach (QualifiedQuantity qualifiedQuantity in _quantities)
                qualifiedQuantity.Validate();
            foreach (Quantity resolution in _resolutions)
                resolution.Validate();
            foreach (ErrorLimit errorLimit in _errorLimits)
                errorLimit.Validate();
            if(_magnitude!=null )
                _magnitude.Validate();
            var rgx = new Regex(PHYSICAL_PATTERN);
            if (!rgx.Match(ToString()).Success)
                throw new Exception(string.Format("Invalid Physical Expression - {0}", ToString()));
        }

Usage Example

 private void signalAttributes_RowValidating( object sender, DataGridViewCellCancelEventArgs e )
 {
     var name = signalAttributes.Rows[e.RowIndex].Cells[0].Value as string;
     var type = signalAttributes.Rows[e.RowIndex].Cells[1].Value as string;
     var value = signalAttributes.Rows[e.RowIndex].Cells[2].Value as string;
     try
     {
         SignalFunctionType sf = _signalFunctionType as SignalFunctionType;
         XmlElement element = _signalFunctionType as XmlElement;
         if (sf != null && (!string.IsNullOrWhiteSpace(value) && IsPhysicalType( ATMLContext.NS_STDBSC, sf.GetType().Name, name)))
         {
             var physical = new Physical( value );
             physical.Validate();
             signalAttributes.Rows[e.RowIndex].Cells[2].Style.BackColor =
                 signalAttributes.Rows[e.RowIndex].Cells[1].Style.BackColor;
             signalAttributes.Rows[e.RowIndex].Cells[2].ToolTipText = "";
         }
         if (element != null)
         {
             if (type != null && ( "Physical".Equals(type) || "Frequency".Equals(type) ) )//TODO: Lookup attribute type in schema
             {
                 var physical = new Physical(value);
                 physical.Validate();
                 signalAttributes.Rows[e.RowIndex].Cells[2].Style.BackColor =
                     signalAttributes.Rows[e.RowIndex].Cells[1].Style.BackColor;
                 signalAttributes.Rows[e.RowIndex].Cells[2].ToolTipText = "";
             }
         }
     }
     catch (Exception err)
     {
         signalAttributes.Rows[e.RowIndex].Cells[2].Style.BackColor = Color.LightPink;
         signalAttributes.Rows[e.RowIndex].Cells[2].ToolTipText = err.Message;
     }
 }