Пример #1
0
 public void PrintLine(DisplayLevel level, string s)
 {
     if (level <= this.displayLevel)
     {
         Console.WriteLine(s);
     }
 }
Пример #2
0
        private void displayType_lst_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (displayType_lst.SelectedIndex != -1)
            {
                DisplayLevel type = (DisplayLevel)displayType_lst.SelectedIndex;

                switch (type)
                {
                case DisplayLevel.ALL:
                    logView.SetObjects(lManager.Entries);
                    break;

                case DisplayLevel.DEBUG:
                    logView.SetObjects(lManager.Entries.Where(l => l.Level == Level.DEBUG));
                    break;

                case DisplayLevel.NOTICE:
                    logView.SetObjects(lManager.Entries.Where(l => l.Level == Level.NOTICE));
                    break;

                case DisplayLevel.ERRORS:
                    logView.SetObjects(lManager.Entries.Where(l => l.Level == Level.ERROR ||
                                                              l.Level == Level.HASHER_ERROR ||
                                                              l.Level == Level.SQL_ERROR));
                    break;
                }
            }
        }
        internal static TreeNode GetTypeLibNode(TypeLib tlb, DisplayLevel displayLevel)
        {
            string   typeLibName = tlb.GetDocumentation();
            TreeNode root        = new TreeNode(typeLibName);

            root.Tag = tlb;

            int nCount = tlb.GetTypeInfoCount();

            for (int n = 0; n < nCount; ++n)
            {
                TypeInfo type = tlb.GetTypeInfo(n);
                //string typeTypeName = type.GetDocumentation();
                //NativeType2String.AddNativeUserDefinedType(typeTypeName);

                // For dual interfaces, it has a "funky" TKIND_DISPATCH|TKIND_DUAL interface with a parter of TKIND_INTERFACE|TKIND_DUAL interface
                // The first one is pretty bad and has duplicated all the interface members of its parent, which is not we want
                // We want the second v-table interface
                // So, if we indeed has seen this kind of interface, prefer its partner
                // However, we should not blindly get the partner because those two interfaces partners with each other
                // So we need to first test to see if the interface is both dispatch & dual, and then get its partner interface
                using (TypeAttr attr = type.GetTypeAttr())
                {
                    if (attr.IsDual && attr.IsDispatch)
                    {
                        TypeInfo typeReferencedType = type.GetRefTypeNoComThrow();
                        if (typeReferencedType != null)
                        {
                            type = typeReferencedType;
                        }
                    }
                }
                TreeNode            typeInfoNode        = new TreeNode();
                TypeInfoMatchTarget typeInfoMatchTarget = null;
                root.Nodes.Add(typeInfoNode);
                using (TypeAttr attr = type.GetTypeAttr())
                {
                    TYPEKIND kind = attr.typekind;
                    typeInfoMatchTarget = new TypeInfoMatchTarget(tlb, type, kind);
                    if (displayLevel == DisplayLevel.All)
                    {
                        ProcessFunctions(type, typeInfoNode);
                        ProcessFields(type, typeInfoNode);
                    }
                }
                typeInfoNode.Text = typeInfoMatchTarget.Name + ": " +
                                    typeInfoMatchTarget.Type;
                typeInfoNode.Tag = typeInfoMatchTarget;
                SetTlbTreeNodeImage(typeInfoNode);
            }
            return(root);
        }
 /// <summary>
 /// Instantiates a new details matching socre object.
 /// </summary>
 public BaseMatchingScore(DisplayLevel displayLevel = Core.DisplayLevel.FULL)
 {
     if (displayLevel < Core.DisplayLevel.COMPARATOR)
     {
         throw new Exceptions.DisplayLevelNotAllowed();
     }
     else
     {
         this.DisplayLevel = displayLevel;
         this.DetailsData  = new List <object[]>();
         this.DetailsMatch = new List <float>();
     }
 }
        internal static TreeNode GetTypeLibNode(TypeLib tlb, DisplayLevel displayLevel)
        {
            string typeLibName = tlb.GetDocumentation();
            TreeNode root = new TreeNode(typeLibName);
            root.Tag = tlb;

            int nCount = tlb.GetTypeInfoCount();
            for (int n = 0; n < nCount; ++n)
            {
                TypeInfo type = tlb.GetTypeInfo(n);
                //string typeTypeName = type.GetDocumentation();
                //NativeType2String.AddNativeUserDefinedType(typeTypeName);

                // For dual interfaces, it has a "funky" TKIND_DISPATCH|TKIND_DUAL interface with a parter of TKIND_INTERFACE|TKIND_DUAL interface
                // The first one is pretty bad and has duplicated all the interface members of its parent, which is not we want
                // We want the second v-table interface
                // So, if we indeed has seen this kind of interface, prefer its partner
                // However, we should not blindly get the partner because those two interfaces partners with each other
                // So we need to first test to see if the interface is both dispatch & dual, and then get its partner interface
                using (TypeAttr attr = type.GetTypeAttr())
                {
                    if (attr.IsDual && attr.IsDispatch)
                    {
                        TypeInfo typeReferencedType = type.GetRefTypeNoComThrow();
                        if (typeReferencedType != null)
                        {
                            type = typeReferencedType;
                        }
                    }
                }
                TreeNode typeInfoNode = new TreeNode();
                TypeInfoMatchTarget typeInfoMatchTarget = null;
                root.Nodes.Add(typeInfoNode);
                using (TypeAttr attr = type.GetTypeAttr())
                {
                    TYPEKIND kind = attr.typekind;
                    typeInfoMatchTarget = new TypeInfoMatchTarget(tlb, type, kind);
                    if (displayLevel == DisplayLevel.All)
                    {
                        ProcessFunctions(type, typeInfoNode);
                        ProcessFields(type, typeInfoNode);
                    }
                }
                typeInfoNode.Text = typeInfoMatchTarget.Name + ": " +
                                typeInfoMatchTarget.Type;
                typeInfoNode.Tag = typeInfoMatchTarget;
                SetTlbTreeNodeImage(typeInfoNode);
            }
            return root;
        }
Пример #6
0
        /// <summary>
        /// Called when [configuration change].
        /// </summary>
        private void OnConfigChange()
        {
            try
            {
                lock (this)
                {
                    ActiveStates states = new ActiveStates();
                    states.RI              = RILogManager.Get(InstanceName) ?? RILogManager.Default;
                    states.DisplayLevel    = String.Compare(DisplayLevel.ToLower().Trim(), "true", false) == 0;
                    states.DisplayLocation = String.Compare(DisplayLocation.ToLower().Trim(), "true", false) == 0;

                    CurrentActiveStates = states;
                }
            }
            catch (Exception ex)
            {
                RIExceptionManager.Publish(ex, "Failed during: LogAppender.OnConfigChange()");
            }
        }
Пример #7
0
        protected void DisplayMessage(string message, DisplayLevel level = DisplayLevel.Message, Exception e = null)
        {
            lock (_synclock)
            {
                // keep all the message together
                if (e != null)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(e.ToString());
                    Console.ResetColor();
                }
                else
                {
                    switch (level)
                    {
                    case DisplayLevel.Error:
                        Console.ForegroundColor = ConsoleColor.Red;
                        break;

                    case DisplayLevel.Warning:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        break;

                    case DisplayLevel.Message:
                        Console.ForegroundColor = ConsoleColor.White;
                        break;

                    case DisplayLevel.Title:
                        Console.ForegroundColor = ConsoleColor.Green;
                        break;

                    case DisplayLevel.Verbose:
                        Console.ForegroundColor = ConsoleColor.Gray;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException("level");
                    }
                    Console.WriteLine(message);
                    Console.ResetColor();
                }
            }
        }
        private float GetThreshold(DisplayLevel level)
        {
            switch (level)
            {
            case DisplayLevel.BASIC:
                return(this.Settings.Threshold.Basic);

            case DisplayLevel.COMPARATOR:
                return(this.Settings.Threshold.Comparator);

            case DisplayLevel.DETAILED:
                return(this.Settings.Threshold.Detailed);

            case DisplayLevel.FULL:
                return(this.Settings.Threshold.Full);

            default:
                throw new Exceptions.DisplayLevelNotFound();
            }
        }
 /// <summary>
 /// Instantiates a new comparator matching socre object.
 /// </summary>
 /// <param name="leftFileName">The left side's comparisson file name.</param>
 /// <param name="rightFileName">The right side's comparisson file name.</param>
 /// <param name="Comparator">The used comparato's name.</param>
 /// <param name="detailsDisplayLevel">The display level for the details (must be lower or the same as the global settings value in order to be displayed at the output).</param>
 /// <returns></returns>
 public ComparatorMatchingScore(string leftFileName, string rightFileName, string Comparator, DisplayLevel detailsDisplayLevel = Core.DisplayLevel.DETAILED) : base(detailsDisplayLevel)
 {
     this.Comparator    = Comparator;
     this.LeftFileName  = leftFileName;
     this.RightFileName = rightFileName;
 }
        /// <summary>
        /// Writes the given set of results into the terminal.
        /// </summary>
        /// <param name="results">A set of results regarding each compared pair of files.</param>
        /// <param name="level">The output details level.</param>DisplayDisplay
        public override void Write(List <ComparatorMatchingScore> results)
        {
            DisplayLevel dl = Enum.Parse <DisplayLevel>(this.Settings.Display.ToUpper());     //TODO: try with enum inside settings

            Console.OutputEncoding = System.Text.Encoding.UTF8;
            WriteSeparator('#', ConsoleColor.DarkGray);

            //The list of CMS must be grouped and sorted in order to display.
            foreach (IGrouping <string, ComparatorMatchingScore> grpLeft in results.GroupBy(x => x.LeftFileName))
            {
                //Displays the left file info with its total match
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.Write("  ⬩ Left file [");

                float match = grpLeft.Sum(x => x.Matching) / grpLeft.Count();
                Console.ForegroundColor = (match < GetThreshold(DisplayLevel.BASIC) ? ConsoleColor.DarkGreen : ConsoleColor.DarkRed);
                Console.Write("{0:P2}", match);

                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.Write("]: ");

                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(grpLeft.Key);

                foreach (IGrouping <string, ComparatorMatchingScore> grpRight in grpLeft.GroupBy(x => x.RightFileName))
                {
                    //Displays the right file info with its total match
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    Console.Write("     ⤷ Right file [");

                    match = grpRight.Sum(x => x.Matching) / grpRight.Count();
                    Console.ForegroundColor = (match < GetThreshold(DisplayLevel.BASIC) ? ConsoleColor.DarkGreen : ConsoleColor.DarkRed);
                    Console.Write("{0:P2}", match);

                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    Console.Write("]: ");

                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine(grpRight.Key);

                    if (dl >= DisplayLevel.COMPARATOR)
                    {
                        foreach (ComparatorMatchingScore comp in grpRight.Select(x => x).ToList())
                        {
                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.Write("        ⤷ Comparator [");

                            Console.ForegroundColor = (comp.Matching < GetThreshold(DisplayLevel.BASIC) ? ConsoleColor.DarkGreen : ConsoleColor.DarkRed);
                            Console.Write("{0:P2}", comp.Matching);

                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.Write("]: ");

                            Console.ForegroundColor = ConsoleColor.White;
                            Console.WriteLine(comp.Comparator);

                            //Looping over the detials
                            DetailsMatchingScore dms = (DetailsMatchingScore)comp;
                            while (dms != null)
                            {
                                if (dl >= dms.DisplayLevel)
                                {
                                    Console.ForegroundColor = ConsoleColor.DarkGray;
                                    Console.WriteLine();
                                    WriteSeparator('·', ConsoleColor.DarkRed);
                                    Console.WriteLine();
                                    Console.WriteLine("  {1}: displaying details for matching values over {0:P2}", GetThreshold(dms.DisplayLevel), comp.Comparator);
                                    Console.WriteLine();

                                    var table = new ConsoleTable(dms.DetailsCaption);
                                    for (int i = 0; i < dms.DetailsData.Count; i++)
                                    {
                                        if (dms.DetailsMatch[i] > GetThreshold(dms.DisplayLevel))
                                        {
                                            List <string> formatedData = new List <string>();
                                            for (int j = 0; j < dms.DetailsFormat.Length; j++)
                                            {
                                                if (dms.DetailsFormat[j].Contains(":L"))
                                                {
                                                    //Custom string length formatting output
                                                    string sl = dms.DetailsFormat[j].Substring(dms.DetailsFormat[j].IndexOf(":L") + 2);
                                                    sl = sl.Substring(0, sl.IndexOf("}"));

                                                    int    length = int.Parse(sl);
                                                    string pText  = dms.DetailsData[i][j].ToString();
                                                    if (pText.Length <= length)
                                                    {
                                                        formatedData.Add(pText);
                                                    }
                                                    else
                                                    {
                                                        formatedData.Add(string.Format("{0}...", pText.Substring(0, length - 3)));
                                                    }
                                                }
                                                else
                                                {
                                                    //Native string formatting output
                                                    formatedData.Add(String.Format(dms.DetailsFormat[j], dms.DetailsData[i][j]));
                                                }
                                            }

                                            table.AddRow(formatedData.ToArray());
                                        }
                                    }

                                    table.Write();
                                    Console.WriteLine();
                                }
                                dms = dms.Child;
                            }
                        }
                    }
                }

                Console.WriteLine();
            }

            WriteSeparator('#', ConsoleColor.DarkGray);
            Console.ForegroundColor = ConsoleColor.White;
        }
Пример #11
0
 public void PrintFormat(DisplayLevel level, string format, object arg0, object arg1)
 {
     Print(level, String.Format(format, arg0, arg1));
 }
Пример #12
0
        /// <summary>
        /// Writes the given set of results into the terminal.
        /// </summary>
        /// <param name="results">A set of results regarding each compared pair of files.</param>
        /// <param name="level">The output details level.</param>DisplayDisplay
        public override void Write(List <FileMatchingScore> results, DisplayLevel level = DisplayLevel.BASIC)
        {
            foreach (FileMatchingScore fms in results)
            {
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.WriteLine("");
                Console.WriteLine("##############################################################################");
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.Write("  Left file: ");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(fms.LeftFileName);

                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.Write("  Right file: ");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(fms.RightFileName);

                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.Write("  Matching: ");
                Console.ForegroundColor = (fms.Matching < GetThreshold(DisplayLevel.BASIC) ? ConsoleColor.DarkGreen : ConsoleColor.DarkRed);
                Console.WriteLine("{0:P2}", fms.Matching);

                if (level >= DisplayLevel.COMPARATOR)
                {
                    foreach (ComparatorMatchingScore cms in fms.ComparatorResults)
                    {
                        Console.ForegroundColor = ConsoleColor.DarkGray;
                        Console.WriteLine("------------------------------------------------------------------------------");

                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                        Console.Write("    Comparator: ");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine(cms.Comparator);

                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                        Console.Write("    Matching: ");
                        Console.ForegroundColor = (cms.Matching < GetThreshold(DisplayLevel.COMPARATOR) ? ConsoleColor.DarkGreen : ConsoleColor.DarkRed);
                        Console.WriteLine("{0:P2}", cms.Matching);

                        //Looping over the detials
                        DetailsMatchingScore dms = (DetailsMatchingScore)cms;
                        while (dms != null)
                        {
                            if (level >= dms.DisplayLevel)
                            {
                                Console.ForegroundColor = ConsoleColor.DarkGray;
                                Console.WriteLine("··············································································");
                                Console.WriteLine();

                                Console.ForegroundColor = ConsoleColor.DarkRed;
                                Console.WriteLine(string.Format("  Displaying details with a match value > {0:P2}", GetThreshold(dms.DisplayLevel)));
                                Console.WriteLine();

                                var table = new ConsoleTable(dms.DetailsCaption);
                                for (int i = 0; i < dms.DetailsData.Count; i++)
                                {
                                    if (dms.DetailsMatch[i] > GetThreshold(dms.DisplayLevel))
                                    {
                                        List <string> formatedData = new List <string>();
                                        for (int j = 0; j < dms.DetailsFormat.Length; j++)
                                        {
                                            if (dms.DetailsFormat[j].Contains(":L"))
                                            {
                                                //Custom string length formatting output
                                                string sl = dms.DetailsFormat[j].Substring(dms.DetailsFormat[j].IndexOf(":L") + 2);
                                                sl = sl.Substring(0, sl.IndexOf("}"));

                                                int    length = int.Parse(sl);
                                                string pText  = dms.DetailsData[i][j].ToString();
                                                if (pText.Length <= length)
                                                {
                                                    formatedData.Add(pText);
                                                }
                                                else
                                                {
                                                    formatedData.Add(string.Format("{0}...", pText.Substring(0, length - 3)));
                                                }
                                            }
                                            else
                                            {
                                                //Native string formatting output
                                                formatedData.Add(String.Format(dms.DetailsFormat[j], dms.DetailsData[i][j]));
                                            }
                                        }

                                        table.AddRow(formatedData.ToArray());
                                    }
                                }

                                table.Write();
                                Console.WriteLine();
                            }
                            dms = dms.Child;
                        }
                    }
                }

                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.WriteLine("##############################################################################");
                Console.WriteLine("");
                Console.ForegroundColor = ConsoleColor.White;
            }
        }
Пример #13
0
 private float GetThreshold(DisplayLevel level)
 {
     return(float.Parse(Settings.Instance.Get(string.Format("threshold:{0}", level.ToString().ToLower())), System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
 }
Пример #14
0
 public void PrintLineFormat(DisplayLevel level, string format, object arg0, object arg1, object arg2)
 {
     PrintLine(level, String.Format(format, arg0, arg1, arg2));
 }
Пример #15
0
        public bool Equals(DestinyActivity input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     ActivityHash == input.ActivityHash ||
                     (ActivityHash.Equals(input.ActivityHash))
                     ) &&
                 (
                     IsNew == input.IsNew ||
                     (IsNew != null && IsNew.Equals(input.IsNew))
                 ) &&
                 (
                     CanLead == input.CanLead ||
                     (CanLead != null && CanLead.Equals(input.CanLead))
                 ) &&
                 (
                     CanJoin == input.CanJoin ||
                     (CanJoin != null && CanJoin.Equals(input.CanJoin))
                 ) &&
                 (
                     IsCompleted == input.IsCompleted ||
                     (IsCompleted != null && IsCompleted.Equals(input.IsCompleted))
                 ) &&
                 (
                     IsVisible == input.IsVisible ||
                     (IsVisible != null && IsVisible.Equals(input.IsVisible))
                 ) &&
                 (
                     DisplayLevel == input.DisplayLevel ||
                     (DisplayLevel.Equals(input.DisplayLevel))
                 ) &&
                 (
                     RecommendedLight == input.RecommendedLight ||
                     (RecommendedLight.Equals(input.RecommendedLight))
                 ) &&
                 (
                     DifficultyTier == input.DifficultyTier ||
                     (DifficultyTier != null && DifficultyTier.Equals(input.DifficultyTier))
                 ) &&
                 (
                     Challenges == input.Challenges ||
                     (Challenges != null && Challenges.SequenceEqual(input.Challenges))
                 ) &&
                 (
                     ModifierHashes == input.ModifierHashes ||
                     (ModifierHashes != null && ModifierHashes.SequenceEqual(input.ModifierHashes))
                 ) &&
                 (
                     BooleanActivityOptions == input.BooleanActivityOptions ||
                     (BooleanActivityOptions != null && BooleanActivityOptions.SequenceEqual(input.BooleanActivityOptions))
                 ) &&
                 (
                     LoadoutRequirementIndex == input.LoadoutRequirementIndex ||
                     (LoadoutRequirementIndex.Equals(input.LoadoutRequirementIndex))
                 ));
        }
Пример #16
0
 /// <summary>
 /// Writes the gioven scores to the configured outputs.
 /// </summary>
 /// <param name="results">A set of file matching scores</param>
 public void WriteOutput(DisplayLevel level = DisplayLevel.COMPARATOR){
Пример #17
0
 /// <summary>
 /// Writes the gioven scores to the configured outputs.
 /// </summary>
 /// <param name="results">A set of file matching scores</param>
 public void WriteOutput(DisplayLevel level = DisplayLevel.COMPARATOR)
 {
     //TODO: must be selected by settings
     Outputs.Terminal4 t = new Outputs.Terminal4();
     t.Write(this.MatchingResults, level);
 }
Пример #18
0
 public static void ToggleDebugLevel()
 {
     DebugDisplayLevel = (DisplayLevel)((int)(DebugDisplayLevel + 1) % 3);
 }
Пример #19
0
 public void PrintLineFormat(DisplayLevel level, string format, params object[] args)
 {
     PrintLine(level, String.Format(format, args));
 }
Пример #20
0
 /// <summary>
 /// Instantiates a new comparator matching socre object.
 /// </summary>
 /// <param name="Comparator">The Comparator's name.</param>
 public ComparatorMatchingScore(string Comparator, DisplayLevel detailsDisplayLevel = Core.DisplayLevel.COMPARATOR) : base(detailsDisplayLevel)
 {
     this.Comparator = Comparator;
 }
Пример #21
0
 /// <summary>
 /// This method must be implemented in order to writes the score's content into the output with the selected detail level.
 /// </summary>
 /// <param name="results">A set of scores regarding each pair of compared files.</param>
 /// <param name="displayLevel">The detail level that will be displayed.</param>
 public abstract void Write(List <FileMatchingScore> results, DisplayLevel displayLevel = DisplayLevel.BASIC);
 /// <summary>
 /// Instantiates a new details matching socre object.
 /// </summary>
 public DetailsMatchingScore(DisplayLevel displayLevel = Core.DisplayLevel.FULL) : base(displayLevel)
 {
 }