private bool IsRuleSetToRangeNone(RoutingPreferenceManager routingPreferenceManager, RoutingPreferenceRuleGroupType groupType, int index) { if (routingPreferenceManager.GetNumberOfRules(groupType) == 0) { return(false); } RoutingPreferenceRule rule = routingPreferenceManager.GetRule(groupType, index); if (rule.NumberOfCriteria == 0) { return(false); } PrimarySizeCriterion psc = rule.GetCriterion(0) as PrimarySizeCriterion; if (psc.IsEqual(PrimarySizeCriterion.None())) { return(true); } else { return(false); } }
/// <summary> /// Create Xml from a RoutingPreferenceRule /// </summary> /// <param name="rule"></param> /// <param name="groupType"></param> /// <returns></returns> private XElement createXmlFromRoutingPreferenceRule(RoutingPreferenceRule rule, RoutingPreferenceRuleGroupType groupType) { XElement xRoutingPreferenceRule = new XElement(XName.Get("RoutingPreferenceRule")); xRoutingPreferenceRule.Add(new XAttribute(XName.Get("description"), rule.Description)); xRoutingPreferenceRule.Add(new XAttribute(XName.Get("ruleGroup"), groupType.ToString())); if (rule.NumberOfCriteria >= 1) { PrimarySizeCriterion psc = rule.GetCriterion(0) as PrimarySizeCriterion; if (psc.IsEqual(PrimarySizeCriterion.All())) { xRoutingPreferenceRule.Add(new XAttribute(XName.Get("minimumSize"), "All")); } else if (psc.IsEqual(PrimarySizeCriterion.None())) { xRoutingPreferenceRule.Add(new XAttribute(XName.Get("minimumSize"), "None")); } else //Only specify "maximumSize" if not specifying "All" or "None" for minimum size, just like in the UI. { xRoutingPreferenceRule.Add(new XAttribute(XName.Get("minimumSize"), (Convert.ConvertValueDocumentUnits(psc.MinimumSize, m_document)).ToString())); xRoutingPreferenceRule.Add(new XAttribute(XName.Get("maximumSize"), (Convert.ConvertValueDocumentUnits(psc.MaximumSize, m_document)).ToString())); } } else { xRoutingPreferenceRule.Add(new XAttribute(XName.Get("minimumSize"), "All")); } if (groupType == RoutingPreferenceRuleGroupType.Segments) { xRoutingPreferenceRule.Add(new XAttribute(XName.Get("partName"), GetSegmentNameById(rule.MEPPartId))); } else { xRoutingPreferenceRule.Add(new XAttribute(XName.Get("partName"), GetFittingNameById(rule.MEPPartId))); } return(xRoutingPreferenceRule); }