Example #1
0
        public void AddRecent(CompareDefinition cd)
        {
            if (Recent != null)
            {
                for (int i = 0; i < Recent.Length; i++)
                {
                    if (Recent[i].GetKey() == cd.GetKey())
                    {
                        MoveToTop(Recent[i]);
                        return;
                    }
                }
            }

            if (Recent == null || Recent.Length < 15)
            {
                CompareDefinition [] copy = new CompareDefinition [Recent == null ? 1 : Recent.Length + 1];
                copy [0] = cd;
                if (Recent != null)
                {
                    Recent.CopyTo(copy, 1);
                }
                Recent = copy;
            }
            else
            {
                Array.Copy(Recent, 0, Recent, 1, Recent.Length - 1);
                Recent[0] = cd;
            }
        }
        public CompareDefinition GetCompare()
        {
            if (String.IsNullOrEmpty(reference.File))
            {
                return(Error("No reference file was provided"));
            }

            if (String.IsNullOrEmpty(target.File))
            {
                return(Error("No target file was provided"));
            }

            if (!File.Exists(reference.File))
            {
                return(Error("Reference file {0} does not exist", reference.File));
            }

            if (!File.Exists(target.File))
            {
                return(Error("Target file {0} does not exist", target.File));
            }


            CompareDefinition cd = new CompareDefinition(reference.IsInfo, reference.File, target.IsInfo, target.File);

            cd.IsCustom = true;
            return(cd);
        }
Example #3
0
        /// <summary>
        ///   Starts a preset compare.
        /// </summary>
        /// <param name="assemblyfile">
        /// The full path to a system installed assembly (/mono/lib/mono/1.0/mscorlib.dll)
        /// </param>
        /// <param name="profile">
        /// The profile, for example "1.0"
        /// </param>
        /// <param name="assemblyname">
        /// The name of the assembly to compare, in this case "mscorlib"
        /// </param>
        void StartPresetCompare(string assemblyfile, string profile, string assemblyname, string groupName)
        {
            Ensure(profile, assemblyname, delegate(string masterinfo)
            {
                CompareDefinition cd = new CompareDefinition(true, masterinfo, false, assemblyfile);
                cd.Title             = assemblyname + " (" + groupName + ")";
                main.Config.AddRecent(cd);
                PopulateRecent();
                main.Config.Save();

                main.SetReference(delegate
                {
                    return(new MasterAssembly(masterinfo));
                });
                main.SetTarget(delegate
                {
                    return(new CecilAssembly(assemblyfile));
                });

                main.StartCompare(delegate
                {
                    main.Title = String.Format("{0} to {1}", assemblyfile, masterinfo);
                });
            });

            main.SetComparedProfile(profile);
        }
Example #4
0
        public override bool Equals(object o)
        {
            if (!(o is CompareDefinition))
            {
                return(false);
            }
            CompareDefinition cd = (CompareDefinition)o;

            return(ReferencePath == cd.ReferencePath && ReferenceIsInfo == cd.ReferenceIsInfo &&
                   TargetPath == cd.TargetPath && TargetIsInfo == cd.TargetIsInfo);
        }
Example #5
0
 public void MoveToTop(CompareDefinition cd)
 {
     CompareDefinition [] copy = new CompareDefinition [Recent.Length];
     copy [0] = cd;
     for (int i = 0, j = 0; j < Recent.Length; j++)
     {
         if (Recent [j] == cd)
         {
             continue;
         }
         i++;
         copy [i] = Recent [j];
     }
     Recent = copy;
 }
Example #6
0
		public CompareDefinition GetCompare ()
		{
			if (String.IsNullOrEmpty (reference.File))
				return Error ("No reference file was provided");
			
			if (String.IsNullOrEmpty (target.File))
				return Error ("No target file was provided");
			
			if (!File.Exists (reference.File))
				return Error ("Reference file {0} does not exist", reference.File);
				
			if (!File.Exists (target.File))
				return Error ("Target file {0} does not exist", target.File);
				
			
			CompareDefinition cd = new CompareDefinition (reference.IsInfo, reference.File, target.IsInfo, target.File);
			cd.IsCustom = true;
			return cd;
		}
Example #7
0
        /// <summary>
        ///   Populates the "RecentComparison" sub menu from File
        /// </summary>
        public void PopulateRecent()
        {
            foreach (MenuItem mi in recentmenu.AllChildren)
            {
                recentmenu.Remove(mi);
            }

            if (main.Config.Recent == null || main.Config.Recent.Length == 0)
            {
                MenuItem empty = new MenuItem("(Empty)");
                empty.Sensitive = false;
                recentmenu.Add(empty);
            }
            else
            {
                foreach (CompareDefinition cdd in main.Config.Recent)
                {
                    CompareDefinition cd = cdd;
                    if (cd == null)
                    {
                        throw new Exception("FGGG");
                    }

                    MenuItem c = new MenuItem(cd.ToString());
                    c.Activated += delegate
                    {
                        main.SetCompareDefinition(cd);

                        main.StartCompare(delegate
                        {
                            main.Title = cd.ToString();
                        });
                        main.Config.MoveToTop(cd);
                        PopulateRecent();
                        main.Config.Save();
                    };

                    recentmenu.Add(c);
                }
            }
            recentmenu.ShowAll();
        }
Example #8
0
 public void MoveToTop(CompareDefinition cd)
 {
     CompareDefinition [] copy = new CompareDefinition [Recent.Length];
     copy [0] = cd;
     for (int i = 0, j = 0; j < Recent.Length; j++){
         if (Recent [j] == cd)
             continue;
         i++;
         copy [i] = Recent [j];
     }
     Recent = copy;
 }
Example #9
0
        public void AddRecent(CompareDefinition cd)
        {
            if (Recent != null) {
                for (int i = 0; i < Recent.Length; i ++) {
                    if (Recent[i].GetKey() == cd.GetKey()) {
                        MoveToTop (Recent[i]);
                        return;
                    }
                }
            }

            if (Recent == null || Recent.Length < 15){
                CompareDefinition [] copy = new CompareDefinition [Recent == null ? 1 : Recent.Length+1];
                copy [0] = cd;
                if (Recent != null)
                    Recent.CopyTo (copy, 1);
                Recent = copy;
            } else {
                Array.Copy (Recent, 0, Recent, 1, Recent.Length - 1);
                Recent[0] = cd;
            }
        }
Example #10
0
	public void ComparePaths (string reference, string target)
	{
		var cd = new CompareDefinition (false, reference, false, target);
		SetCompareDefinition (cd);
		StartCompare (delegate { Title = cd.ToString (); });
		Config.AddRecent (cd);
		Config.Save ();
		info_manager.PopulateRecent ();
	}
Example #11
0
	public void SetCompareDefinition (CompareDefinition cd)
	{
		if (cd.ReferenceIsInfo)
			SetReference (delegate { return new MasterAssembly (cd.ReferencePath); });
		else
			SetReference (delegate { return new CecilAssembly (cd.ReferencePath); });
		
		if (cd.TargetIsInfo)
			SetTarget (delegate { return new MasterAssembly (cd.TargetPath); });
		else
			SetTarget (delegate { return new CecilAssembly (cd.TargetPath); });
	}
Example #12
0
		/// <summary>
		///   Starts a preset compare.
		/// </summary>
		/// <param name="assemblyfile">
		/// The full path to a system installed assembly (/mono/lib/mono/1.0/mscorlib.dll)
		/// </param>
		/// <param name="profile">
		/// The profile, for example "1.0"
		/// </param>
		/// <param name="assemblyname">
		/// The name of the assembly to compare, in this case "mscorlib"
		/// </param>
		void StartPresetCompare (string assemblyfile, string profile, string assemblyname, string groupName)
		{
			Ensure (profile, assemblyname, delegate (string masterinfo){
				CompareDefinition cd = new CompareDefinition (true, masterinfo, false, assemblyfile);
				cd.Title = assemblyname + " (" + groupName + ")";
				main.Config.AddRecent (cd);
				PopulateRecent ();
				main.Config.Save ();
				
				main.SetReference (delegate {
						return new MasterAssembly (masterinfo);
					});
				main.SetTarget (delegate {
						return new CecilAssembly (assemblyfile);
					 });
					
				main.StartCompare (delegate {
					main.Title = String.Format ("{0} to {1}", assemblyfile, masterinfo);
				});
			});
			
			main.SetComparedProfile (profile);
		}