Beispiel #1
0
        public void Prepare()
        {
            _techLevelText = Label;

            _techLevelOptions = Data.TechLevels.Values.Where(i => i != TechLevel.Undefined)
                                .Select(
                i => new FloatMenuOption(
                    $"TechLevel_{i}".TranslateSimple(),
                    () =>
            {
                _techLevel = i;
                Dirty.Set(true);
            }
                    )
                )
                                .ToList();

            _comparisonOptions = Data.ComparisonTypes.Values.Select(
                i => new FloatMenuOption(
                    i.AsOperator(),
                    () =>
            {
                _comparison = i;
                Dirty.Set(true);
            }
                    )
                )
                                 .ToList();
        }
Beispiel #2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Builds a match criteria that will match on an empty object.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public void SetEmptyObjectMatchCriteria()
 {
     m_comparisonType = ComparisonTypes.kEmpty;
     m_matchValue     = 0;
     m_matchSubitems  = false;
     m_matchEmpty     = true;
     SaveObjectMatchCriteria(null);
 }
Beispiel #3
0
        public static ComparisonReportObjects ReportObjects(Instance a, Instance b, ComparisonTypes comparisons, BasicComparisons basicSelection)
        {
            var report = new ComparisonReportObjects();

            if (comparisons.HasFlag(ComparisonTypes.Basic))
            {
                report.Basics = BasicComparison(a, b, basicSelection).ToList();
            }

            if (comparisons.HasFlag(ComparisonTypes.Contexts))
            {
                report.Contexts = ScenarioComparison(a, b);
            }

            if (comparisons.HasFlag(ComparisonTypes.Facts))
            {
                report.Facts = FactComparison(a, b);
            }

            if (comparisons.HasFlag(ComparisonTypes.DomainNamespaces))
            {
                report.DomainNamespaces = DomainNamespaceComparison(a, b);
            }

            if (comparisons.HasFlag(ComparisonTypes.Units))
            {
                report.Units = UnitComparison(a, b);
            }

            if (comparisons.HasFlag(ComparisonTypes.Entity))
            {
                report.Entities = EntityComparison(a, b);
            }

            if (comparisons.HasFlag(ComparisonTypes.Entity))
            {
                report.Periods = PeriodComparison(a, b);
            }

            if (comparisons.HasFlag(ComparisonTypes.TaxonomyVersion))
            {
                report.TaxonomyVersions = TaxonomyVersionComparison(a, b);
            }

            if (comparisons.HasFlag(ComparisonTypes.SchemaReference))
            {
                report.SchemaReferences = SchemaReferenceComparison(a, b);
            }

            if (comparisons.HasFlag(ComparisonTypes.FilingIndicators))
            {
                report.FilingIndicators = FilingIndicatorComparison(a, b);
            }

            report.Result = GetResultForReport(report);

            return(report);
        }
 public void Add(Func <TCalcOutput, double> property, ComparisonTypes ComparisonType, double value)
 {
     Lines.Add(new MeritFunctionLine <CalculationOutput>
     {
         property       = property,
         value          = value,
         comparisonType = ComparisonType
     });
 }
Beispiel #5
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Save this set of match criteria.
 /// </summary>
 /// <param name="matchVal">Match value</param>
 /// <param name="fIncludeSubitems">Indicates whether to include the subitems of the
 /// given <paramref name="matchVal"/> when looking for a match</param>
 /// <param name="fMatchEmpty">Indicates whether an empty collection should be counted
 /// as a match</param>
 /// ------------------------------------------------------------------------------------
 public void SetObjectMatchCriteria(ICmPossibility matchVal, bool fIncludeSubitems,
                                    bool fMatchEmpty)
 {
     m_comparisonType = ComparisonTypes.kMatches;
     m_matchValue     = matchVal == null ? 0 : matchVal.Hvo;
     m_matchSubitems  = fIncludeSubitems;
     m_matchEmpty     = fMatchEmpty;
     SaveObjectMatchCriteria(matchVal);
 }
Beispiel #6
0
        public static ComparisonReport Report(Instance a, Instance b, ComparisonTypes comparisonTypes)
        {
            var messages = ComparisonMethods.
                           Where(c => comparisonTypes.HasFlag(c.Key)).
                           SelectMany(c => c.Value(a, b)).
                           ToList();

            return(new ComparisonReport(!messages.Any(), messages));
        }
Beispiel #7
0
        public static ComparisonReport Report(Instance a, Instance b, ComparisonTypes comparisonTypes, BasicComparisons basicComparisons)
        {
            var messages = new List <string>();

            if (comparisonTypes.HasFlag(ComparisonTypes.Basic))
            {
                messages.AddRange(BasicComparison(a, b, basicComparisons));
            }

            messages.AddRange(ComparisonMethods.
                              Where(c => comparisonTypes.HasFlag(c.Key)).
                              SelectMany(c => c.Value(a, b)));

            return(new ComparisonReport(!messages.Any(), messages));
        }
Beispiel #8
0
        /// <summary>
        /// Registers the startup script.
        /// </summary>
        private void RegisterStartupScript()
        {
            string errorMessage;

            if (!string.IsNullOrWhiteSpace(RequiredErrorMessage))
            {
                errorMessage = RequiredErrorMessage;
            }
            else if (!string.IsNullOrWhiteSpace(Label))
            {
                errorMessage = Label + " Is Required";
            }
            else
            {
                errorMessage = "Filter Field Is Required";
            }

            var comparisionTypeList = ComparisonTypes.GetFlags <Model.ComparisonType>().OrderBy(v => v)
                                      .Select(v => new
            {
                Value = ( int )v,
                Text  = v.Humanize(LetterCasing.Title)
            })
                                      .ToList();

            var script = string.Format(
                @"
Rock.controls.valueFilter.initialize({{
    controlId: '{0}',
    required: {1},
    requiredMessage: '{2}',
    btnToggleOnClass: '{3}',
    btnToggleOffClass: '{4}',
    hideFilterMode: {5},
    comparisonTypes: {6}
}});
",
                this.ClientID,                            // {0}
                this.Required.ToString().ToLower(),       // {1}
                errorMessage.Replace("'", "\\'"),         // {2}
                "btn-info",                               // {3}
                "btn-default",                            // {4}
                this.HideFilterMode.ToString().ToLower(), // {5}
                comparisionTypeList.ToJson()              // {6}
                );

            ScriptManager.RegisterStartupScript(this, this.GetType(), "ValueFilterInitialization_" + this.ClientID, script, true);
        }
Beispiel #9
0
        public void Prepare()
        {
            _weightText = "TKUtils.Fields.Weight".TranslateSimple();

            _comparisonOptions = Data.ComparisonTypes.Values.Select(
                i => new FloatMenuOption(
                    i.AsOperator(),
                    () =>
            {
                _comparison = i;
                Dirty.Set(true);
            }
                    )
                )
                                 .ToList();
        }
Beispiel #10
0
        public void Prepare()
        {
            _priceText = Label;

            _comparisonOptions = Data.ComparisonTypes.Values.Select(
                i => new FloatMenuOption(
                    i.AsOperator(),
                    () =>
            {
                _comparison = i;
                Dirty.Set(true);
            }
                    )
                )
                                 .ToList();
        }
        private void CompareValues(ref bool valid, ComparisonTypes comparison, long originalValue, long testValue)
        {
            bool result = true;

            switch (comparison)
            {
            case ComparisonTypes.Equal: result = originalValue == testValue; break;

            case ComparisonTypes.NotEqual: result = originalValue != testValue; break;

            case ComparisonTypes.GreaterThan: result = originalValue > testValue; break;

            case ComparisonTypes.LessThan: result = originalValue < testValue; break;
            }
            if (!result)
            {
                valid = false;
            }
        }
Beispiel #12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Parse the existing Contents to determine the object match criteria and set member
        /// data needed by MatchesCriteria.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void ParseObjectMatchCriteria()
        {
            lock (SyncRoot)
            {
                string criteria = Contents.Text;
                m_comparisonType = ComparisonTypes.kUndefined;
                m_matchValue     = 0;
                m_matchSubitems  = criteria.IndexOf("+subitems", StringComparison.Ordinal) >= 0;
                m_matchEmpty     = criteria.IndexOf("Empty", StringComparison.Ordinal) >= 0;

                if (criteria.IndexOf("Matches", StringComparison.Ordinal) >= 0)
                {
                    m_comparisonType = ComparisonTypes.kMatches;
                }
                else if (m_matchEmpty)
                {
                    m_comparisonType = ComparisonTypes.kEmpty;
                }

                Debug.Assert(m_comparisonType != ComparisonTypes.kUndefined);

                m_matchValues = null;

                // Check to see whether the criteria specifies a specific (default) object.
                if (criteria.IndexOf(StringUtils.kChObject) >= 0)
                {
                    ITsTextProps ttp     = Contents.get_Properties(1);                 //assume second run
                    string       objData = ttp.GetStrPropValue((int)FwTextPropType.ktptObjData);
                    if (objData[0] == (char)FwObjDataTypes.kodtNameGuidHot)
                    {
                        Guid                     guid = MiscUtils.GetGuidFromObjData(objData.Substring(1));
                        ICmPossibility           poss;
                        ICmPossibilityRepository repo = Cache.ServiceLocator.GetInstance <ICmPossibilityRepository>();
                        if (repo.TryGetObject(guid, out poss))
                        {
                            m_matchValue = poss.Hvo;
                        }
                    }

                    InitializeMatchValuesArray();
                }
            }
        }
        private bool CompareFileCore(FileInfo firstFileInfo, FileInfo secondFileInfo)
        {
            if (ComparisonTypes.HasFlag(FileComparisonTypes.Hash))
            {
                if (!CompareByHash(firstFileInfo, secondFileInfo))
                {
                    return(false);
                }
            }

            if (ComparisonTypes.HasFlag(FileComparisonTypes.Size))
            {
                if (firstFileInfo.Length != secondFileInfo.Length)
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #14
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Parse the existing Contents to determine the integer match criteria and set member
        /// data needed by MatchesCriteria.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void ParseIntegerMatchCriteria()
        {
            lock (SyncRoot)
            {
                m_comparisonType = ComparisonTypes.kUndefined;
                string filterCellContents = Contents.Text;
                int    iSpace             = filterCellContents.IndexOf(' ');
                string strOperator        = filterCellContents.Substring(0, iSpace).Trim();
                string strMatchValue      = filterCellContents.Substring(iSpace).Trim();

                switch (strOperator)
                {
                case "=":
                    m_comparisonType = ComparisonTypes.kEquals;
                    break;

                case ">=":
                    m_comparisonType = ComparisonTypes.kGreaterThanEqual;
                    break;

                case "<=":
                    m_comparisonType = ComparisonTypes.kLessThanEqual;
                    break;

                default:
                    Debug.Fail("Unexpected operator!");
                    break;
                }
                if (string.IsNullOrEmpty(strMatchValue))
                {
                    m_comparisonType = ComparisonTypes.kUndefined;
                }
                else
                {
                    m_matchValue = Int32.Parse(strMatchValue);
                }
            }
        }
Beispiel #15
0
        public static string AsOperator(this ComparisonTypes type)
        {
            switch (type)
            {
            case ComparisonTypes.Greater:
                return(">");

            case ComparisonTypes.Equal:
                return("==");

            case ComparisonTypes.Less:
                return("<");

            case ComparisonTypes.GreaterEqual:
                return(">=");

            case ComparisonTypes.LessEqual:
                return("<=");

            default:
                return(null);
            }
        }
        public void CompareValues(ref bool valid, ComparisonTypes comparison, long[] originalValues, long testValue, bool all)
        {
            bool result  = all;
            bool result2 = false;

            if (originalValues.Length > 0)
            {
                foreach (long originalValue in originalValues)
                {
                    switch (comparison)
                    {
                    case ComparisonTypes.Equal: result2 = originalValue == testValue; break;

                    case ComparisonTypes.NotEqual: result2 = originalValue != testValue; break;

                    case ComparisonTypes.GreaterThan: result2 = originalValue > testValue; break;

                    case ComparisonTypes.LessThan: result2 = originalValue < testValue; break;
                    }
                    if (result2 && !all)
                    {
                        result = true;
                        break;
                    }
                    else if (!result2 && all)
                    {
                        result = false;
                        break;
                    }
                }
            }
            if (!result)
            {
                valid = false;
            }
        }
Beispiel #17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Builds a match criteria that will match on an empty object.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void SetEmptyObjectMatchCriteria()
		{
			m_comparisonType = ComparisonTypes.kEmpty;
			m_matchValue = 0;
			m_matchSubitems = false;
			m_matchEmpty = true;
			SaveObjectMatchCriteria(null);
		}
Beispiel #18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Parse the existing Contents to determine the integer match criteria and set member
		/// data needed by MatchesCriteria.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void ParseIntegerMatchCriteria()
		{
			lock (SyncRoot)
			{
				m_comparisonType = ComparisonTypes.kUndefined;
				string filterCellContents = Contents.Text;
				int iSpace = filterCellContents.IndexOf(' ');
				string strOperator = filterCellContents.Substring(0, iSpace).Trim();
				string strMatchValue = filterCellContents.Substring(iSpace).Trim();

				switch (strOperator)
				{
					case "=":
						m_comparisonType = ComparisonTypes.kEquals;
						break;
					case ">=":
						m_comparisonType = ComparisonTypes.kGreaterThanEqual;
						break;
					case "<=":
						m_comparisonType = ComparisonTypes.kLessThanEqual;
						break;
					default:
						Debug.Fail("Unexpected operator!");
						break;
				}
				if (string.IsNullOrEmpty(strMatchValue))
					m_comparisonType = ComparisonTypes.kUndefined;
				else
					m_matchValue = Int32.Parse(strMatchValue);
			}
		}
Beispiel #19
0
 public static ComparisonReport Report(Instance a, Instance b, ComparisonTypes comparisonTypes)
 => Report(a, b, comparisonTypes, BasicComparisons.All);
Beispiel #20
0
 public static ComparisonReport Report(Stream a, Stream b, ComparisonTypes comparisonTypes)
 => Report(Instance.FromStream(a), Instance.FromStream(b), comparisonTypes);
Beispiel #21
0
 public static ComparisonReport Report(string a, string b, ComparisonTypes comparisonTypes)
 => Report(Instance.FromFile(a), Instance.FromFile(b), comparisonTypes);
Beispiel #22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Parse the existing Contents to determine the object match criteria and set member
		/// data needed by MatchesCriteria.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void ParseObjectMatchCriteria()
		{
			lock (SyncRoot)
			{
				string criteria = Contents.Text;
				m_comparisonType = ComparisonTypes.kUndefined;
				m_matchValue = 0;
				m_matchSubitems = criteria.IndexOf("+subitems") >= 0;
				m_matchEmpty = criteria.IndexOf("Empty") >= 0;

				if (criteria.IndexOf("Matches") >= 0)
					m_comparisonType = ComparisonTypes.kMatches;
				else if (m_matchEmpty)
					m_comparisonType = ComparisonTypes.kEmpty;

				Debug.Assert(m_comparisonType != ComparisonTypes.kUndefined);

				m_matchValues = null;

				// Check to see whether the criteria specifies a specific (default) object.
				if (criteria.IndexOf(StringUtils.kChObject) >= 0)
				{
					ITsTextProps ttp = Contents.get_Properties(1); //assume second run
					string objData = ttp.GetStrPropValue((int)FwTextPropType.ktptObjData);
					if (objData[0] == (char)FwObjDataTypes.kodtNameGuidHot)
					{
						Guid guid = MiscUtils.GetGuidFromObjData(objData.Substring(1));
						ICmPossibility poss;
						ICmPossibilityRepository repo = Cache.ServiceLocator.GetInstance<ICmPossibilityRepository>();
						if (repo.TryGetObject(guid, out poss))
							m_matchValue = poss.Hvo;
					}

					InitializeMatchValuesArray();
				}
			}
		}
Beispiel #23
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Save this set of match criteria.
		/// </summary>
		/// <param name="comparisonType">Type of camparison</param>
		/// <param name="min">Minimum (or only) match value</param>
		/// ------------------------------------------------------------------------------------
		public void SetIntegerMatchCriteria(ComparisonTypes comparisonType, int min)
		{
			m_comparisonType = comparisonType;
			m_matchValue = min;
			SaveIntegerMatchCriteria();
		}
Beispiel #24
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Save this set of match criteria.
 /// </summary>
 /// <param name="comparisonType">Type of camparison</param>
 /// <param name="min">Minimum (or only) match value</param>
 /// ------------------------------------------------------------------------------------
 public void SetIntegerMatchCriteria(ComparisonTypes comparisonType, int min)
 {
     m_comparisonType = comparisonType;
     m_matchValue     = min;
     SaveIntegerMatchCriteria();
 }
Beispiel #25
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Save this set of match criteria.
		/// </summary>
		/// <param name="matchVal">Match value</param>
		/// <param name="fIncludeSubitems">Indicates whether to include the subitems of the
		/// given <paramref name="matchVal"/> when looking for a match</param>
		/// <param name="fMatchEmpty">Indicates whether an empty collection should be counted
		/// as a match</param>
		/// ------------------------------------------------------------------------------------
		public void SetObjectMatchCriteria(ICmPossibility matchVal, bool fIncludeSubitems,
			bool fMatchEmpty)
		{
			m_comparisonType = ComparisonTypes.kMatches;
			m_matchValue = matchVal == null ? 0 : matchVal.Hvo;
			m_matchSubitems = fIncludeSubitems;
			m_matchEmpty = fMatchEmpty;
			SaveObjectMatchCriteria(matchVal);
		}