Example #1
0
		static IntPtr GetVersion (Version version)
		{
			if ((version == null) || version.Equals (HttpVersion.Version11))
				return _HTTPVersion1_1.Handle;
			else if (version.Equals (HttpVersion.Version10))
				return _HTTPVersion1_0.Handle;
			else if (version.Major == 2 && version.Minor == 0)
				return _HTTPVersion2_0.Handle;
			else
				throw new ArgumentException ();
		}
		private static void CheckPersistentStoreStatus(Version databaseVersion, Version assemblyVersion)
		{
			if (databaseVersion.Equals(assemblyVersion))
			{
				Console.WriteLine("The database is up-to-date.");
				Environment.ExitCode = 0;
				return;
			}

			var ep = new PersistentStoreUpgradeScriptExtensionPoint();
			var extensions = ep.CreateExtensions();

			var found = false;
			foreach (IPersistentStoreUpgradeScript script in extensions)
			{
				if (script.SourceVersion.Equals(databaseVersion))
				{
					found = true;
					break;
				}
			}

			if (found)
			{
				Console.WriteLine("The database must be upgraded from {0} to {1}", databaseVersion.ToString(4),
								  assemblyVersion.ToString(4));
				Environment.ExitCode = 1;
			}
			else
			{
				Console.WriteLine("An unsupported version ({0}) is installed which cannot be upgraded from", databaseVersion.ToString(4));
				Environment.ExitCode = -1;
			}
		}
Example #3
0
    public bool PosTest2()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest2: Ensure Equals(System.Object) return false when the current Version object and obj are both Version objects but not every component of the current Version object matches the corresponding component of obj.");

        try
        {
            Version TestVersion1 = new Version("2.3.4.5");
			Object TestObject1 = (Object)TestVersion1; 
			Version TestVersion2 = new Version("1.2.3.4");
			if (TestVersion2.Equals(TestObject1))
            {
                TestLibrary.TestFramework.LogError("P02.1", "Equals(System.Object) failed when the current Version object and obj are both Version objects but not every component of the current Version object matches the corresponding component of obj!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("P02.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Example #4
0
        /// <summary>
        ///   Gets the number of commits in the longest single path between HEAD in a repo and the most distant
        ///   ancestor (inclusive) that set the version to the value in the working copy (or HEAD for bare repositories).
        /// </summary>
        /// <param name="repo">The repo with the working copy / HEAD to measure the height of.</param>
        /// <param name="repoRelativeProjectDirectory">The repo-relative project directory for which to calculate the version.</param>
        /// <returns>The height of the repo at HEAD. Always a positive integer.</returns>
        public static int GetVersionHeight(this Repository repo, string repoRelativeProjectDirectory = null)
        {
            if (repo is null)
            {
                return(0);
            }

            if (IsVersionFileChangedInWorkingCopy
                (
                    repo, repoRelativeProjectDirectory,
                    out VersionOptions committedVersionOptions,
                    out VersionOptions workingCopyVersionOptions
                ))
            {
                Version workingCopyVersion = workingCopyVersionOptions?.Version;
                Version headCommitVersion  = committedVersionOptions?.Version ?? Version0;

                if (workingCopyVersion is null || !workingCopyVersion.Equals(headCommitVersion))
                {
                    // The working copy has changed the major.minor version.
                    // So by definition the version height is 0, since no commit represents it yet.
                    return(0);
                }
            }

            // No special changes in the working directory, so apply regular logic.
            return(GetVersionHeight(repo.Head, repoRelativeProjectDirectory));
        }
Example #5
0
 private static void CheckVersion()
 {
     DoWithResponse(WebRequest.Create(VersionUrl), response =>
     {
         var stream = response.GetResponseStream();
         if (stream != default(Stream))
         {
             var internetVersion = new Version(new StreamReader(stream).ReadToEnd());
             if (!internetVersion.Equals(LocalVersion))
             {
                 Chat.Print(
                     "New version found(" + internetVersion +
                     ") of " + Name + " please update it.(To load it anyway type /load)", Color.Red);
             }
             else
             {
                 VersionChecked = true;
             }
         }
         else
         {
             Chat.Print("An error happened while trying to check your version, try again.");
         }
     });
 }
Example #6
0
 public bool Equals(AbstractVersion other)
 {
     if ((object)other == null)
     {
         return(false);
     }
     if (version == null)
     {
         return(false);
     }
     return(version.Equals(other.version));
 }
Example #7
0
        public void ConvertToTestCommandReturnsCorrectResult()
        {
            var verified = false;
            var input = new Version(1, 1);
            Action<Version> expected = v => verified = input.Equals(v);
            var sut = new TestCase<Version>(expected);

            ITestCommand actual = sut.ConvertToTestCommand(dummyMethod);

            var fcc = Assert.IsAssignableFrom<FirstClassCommand>(actual);
            fcc.TestAction(input);
            Assert.True(
                verified,
                "Invoking TestAction on the resulting FirstClassCommand should indirectly indicate that the original test command was invoked.");
        }
        public override bool Equals(object o)
        {
            if (o == null)
            {
                return(false);
            }
            ApplicationId appid = (o as ApplicationId);

            if (appid == null)
            {
                return(false);
            }
            if (_name != appid._name)
            {
                return(false);
            }
            if (_proc != appid._proc)
            {
                return(false);
            }
            if (_culture != appid._culture)
            {
                return(false);
            }
            if (!_version.Equals(appid._version))
            {
                return(false);
            }
            if (_token.Length != appid._token.Length)
            {
                return(false);
            }
            for (int i = 0; i < _token.Length; i++)
            {
                if (_token [i] != appid._token [i])
                {
                    return(false);
                }
            }
            return(true);
        }
Example #9
0
    public bool PosTest2()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest2: Ensure Equals(System.Version) return false when not every component of the current Version object matches the corresponding component of the obj parameter.");

        try
        {
            Version TestVersion1 = new Version("2.3.4.5");
            Version TestVersion2 = new Version("2.3.4.6");
            if (TestVersion2.Equals(TestVersion1))
            {
                TestLibrary.TestFramework.LogError("P02.1", "Equals(System.Version) failed when not every component of the current Version object matches the corresponding component of the obj parameter!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("P02.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Example #10
0
        public static void CheckPlugin(object p)
        {
            TerrariaPlugin plugin = (TerrariaPlugin)p;
            UpdateArgs     args   = new UpdateArgs {
                Plugin = plugin, Success = true, Error = ""
            };
            List <string> files = new List <string>();

            try
            {
                if (!String.IsNullOrEmpty(plugin.UpdateURL))
                {
                    var         request = HttpWebRequest.Create(plugin.UpdateURL);
                    VersionInfo vi;

                    request.Timeout = 5000;
                    using (var response = request.GetResponse())
                    {
                        using (var reader = new StreamReader(response.GetResponseStream()))
                        {
                            vi = JsonConvert.DeserializeObject <VersionInfo>(reader.ReadToEnd());
                        }
                    }

                    System.Version v = System.Version.Parse((vi.version.ToString()));

                    if (!v.Equals(plugin.Version))
                    {
                        DownloadPackage pkg;
                        request = HttpWebRequest.Create(vi.url);

                        request.Timeout = 5000;
                        using (var response = request.GetResponse())
                        {
                            using (var reader = new StreamReader(response.GetResponseStream()))
                            {
                                pkg = JsonConvert.DeserializeObject <DownloadPackage>(reader.ReadToEnd());
                            }
                        }

                        foreach (PluginFile f in pkg.files)
                        {
                            using (WebClient Client = new WebClient())
                            {
                                string dir = Path.Combine(TShock.SavePath, "UpdatedPlugins");
                                if (!Directory.Exists(dir))
                                {
                                    Directory.CreateDirectory(dir);
                                }

                                Client.DownloadFile(f.url,
                                                    Path.Combine(dir, f.destination));

                                files.Add(Path.Combine(dir, f.destination));
                            }
                        }
                    }
                    else
                    {
                        args.Error = "Plugin is up to date.";
                    }
                }
                else
                {
                    args.Error = "Plugin has no updater recorded.";
                }
            }
            catch (Exception e)
            {
                args.Success = false;
                args.Error   = e.Message;
                if (files.Count > 0)
                {
                    foreach (string s in files)
                    {
                        File.Delete(s);
                    }
                }
            }

            OnPluginUpdate(args);
        }
		public void TestClone () 
		{
			Version v1 = new Version (1, 2, 3, 4);
			Version v2 = (Version) v1.Clone ();

			Assert.IsTrue (v1.Equals (v2), "#A1");
			Assert.IsFalse (object.ReferenceEquals (v1, v2), "#A2");

			Version v3 = new Version (); // 0.0
			v2 = (Version) v3.Clone ();

			Assert.IsTrue (v3.Equals (v2), "#B1");
			Assert.IsFalse (object.ReferenceEquals (v3, v2), "#B2");
		}
Example #12
0
        private void DoGameUpdateCheck()
        {
            Console.WriteLine("\nDoGameUpdateCheck()");

            if (!bCanConnectToFTP)
            {
                Console.WriteLine("Game update failed: Unable to connect to FTP");
                return;
            }

            try
            {
                //set a default version of 0.0.0
                string localVersion = "0.0.0";

                //try to get the local version from file
                try
                {
                    localVersion = File.ReadAllText(String.Format(@"{0}\gameVersion.txt", Config.GetGamePath()));
                }
                catch (IOException ioEx)
                {
                    //if we fail then continue with our version of 0.0.0 to compare against remoteVersion
                }

                //get the remote version from the ftp
                string remoteVersionURL = String.Format("{0}/game/gameVersion.txt", Config.GetFTPUrl());
                string remoteVersion    = FTP.ReadFTPFile(Config.GetFTPUsername(), Config.GetFTPPassword(), remoteVersionURL);
                //note remote version may have a trailing '\0' which will cause the console to hang if written

                //we create version objects to format the versions correctly to remove unnecessary spaces, new line characters or '\0' that may exist
                System.Version LocalVersionObject  = new System.Version(localVersion);
                System.Version RemoteVersionObject = new System.Version(remoteVersion);

                Console.WriteLine("localGameVersion: {0}", LocalVersionObject);
                Console.WriteLine("remoteGameVersion: {0}", RemoteVersionObject);

                if (LocalVersionObject.Equals(RemoteVersionObject))
                {
                    bGameNeedsUpdate = false;

                    Console.WriteLine("Local game version {0} does not need to be updated.", LocalVersionObject);
                }
                else
                {
                    bGameNeedsUpdate = true;

                    //if the game update is aborted, we'll still have a local update ping. This needs to be improved.
                    FileStream fs = File.Create(String.Format(@"{0}\.gameNeedsUpdate", Config.GetLocalDir()));
                    fs.Close(); //important that we close this file stream otherwise we will not be able to delete .gameNeedsUpdate after we update

                    Console.WriteLine("Local game version needs to be updated from {0} to {1}", LocalVersionObject, RemoteVersionObject);
                }
            }
            catch (IOException ioEx)
            {
                Console.WriteLine("DoGameUpdateCheck IOException: {0}", ioEx.StackTrace);
            }
            catch (Exception ex)
            {
                Console.WriteLine("DoGameUpdateCheck exception: {0}", ex.StackTrace);
            }
        }
Example #13
0
        public static void TestEqualsGetHashCode()
        {
            var v1 = new Version(100, 200, 300, (400 << 16) + 500);
            var v2 = new Version(100, 200, 300, (400 << 16) + 500);
            var v3 = new Version(101, 200, 300, (400 << 16) + 500);
            var o = new object();
            object o2 = v2;

            Assert.True(v1.Equals(v2), "v1.Equals(v2)");
            Assert.False(v1.Equals(v3), "v1.Equals(v3)");
            Assert.False(v1.Equals(o), "v1.Equals(o)");
            Assert.False(v1.Equals(null), "v1.Equals(null)");
            Assert.False(v1.Equals(100), "v1.Equals(100)");
            Assert.True(v1.Equals(o2), "v1.Equals(o2)");

            Assert.AreEqual(v1.GetHashCode(), 1283637748, "v1.GetHashCode()");
            Assert.AreEqual(v2.GetHashCode(), 1283637748, "v2.GetHashCode()");
            Assert.AreEqual(v3.GetHashCode(), 1552073204, "v3.GetHashCode()");
        }
Example #14
0
 public bool runTest()
   {
   Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
   String strLoc = "Loc_000oo";
   String strValue = String.Empty;
   int iCountErrors = 0;
   int iCountTestcases = 0;
   try
     {
     Version vTest1 = new Version (5,5);
     Version vTest2 = new Version (5,4);
     strLoc = "Loc_100vy";
     iCountTestcases++;
     if (vTest1.Equals(vTest2) == true )
       {
       ++iCountErrors;	
       printerr( "Error_100aa! Expected==false");
       }
     strLoc = "Loc_300vy";
     vTest2 = new Version (5,5);
     iCountTestcases++;
     if (vTest1.Equals(vTest2) == false )
       {
       ++iCountErrors;	
       printerr( "Error_300aa! Expected==true");
       }
     if (vTest2.Equals(vTest1) == false )
       {
       ++iCountErrors;	
       printerr( "Error_300bb! Expected==true");
       }
     vTest1 = new Version (10,10,10);
     vTest2 = new Version (10,10,2);
     strLoc = "Loc_400vy";
     iCountTestcases++;
     if (vTest1.Equals(vTest2) != false )
       {
       ++iCountErrors;	
       printerr( "Error_400aa! Expected==false");
       }
     strLoc = "Loc_600vy";
     vTest2 = new Version (10,10,10);
     iCountTestcases++;
     if (vTest1.Equals(vTest2) != true )
       {
       ++iCountErrors;	
       printerr( "Error_600aa! Expected==true");
       }
     if (vTest2.Equals(vTest1) != true )
       {
       ++iCountErrors;	
       printerr( "Error_600bb! Expected==true");
       }
     vTest1 = new Version (550,500,2,7);
     vTest2 = new Version (550,500,2,5);
     strLoc = "Loc_700vy";
     iCountTestcases++;
     if (vTest1.Equals(vTest2) != false )
       {
       ++iCountErrors;	
       printerr( "Error_700aa! Expected==false");
       }
     strLoc = "Loc_600vy";
     vTest2 = new Version (550,500,2,7);
     iCountTestcases++;
     if (vTest1.Equals(vTest2) != true )
       {
       ++iCountErrors;	
       printerr( "Error_900aa! Expected==true");
       }
     if (vTest2.Equals(vTest1) != true )
       {
       ++iCountErrors;	
       printerr( "Error_900bb! Expected==true");
       }
     strLoc = "Loc_100bb";
     vTest1 = new Version (550,500);
     vTest2 = new Version (550,500,2,7);
     iCountTestcases++;
     if (vTest1.Equals(vTest2) != false )
       {
       ++iCountErrors;	
       printerr( "Error_100xx! Expected==false");
       }
     if (vTest2.Equals(vTest1) != false )
       {
       ++iCountErrors;	
       printerr( "Error_100zz! Expected==false");
       }
     strLoc = "Loc_110zz";
     vTest1 = new Version (Int32.MaxValue,500);
     vTest2 = new Version (550,500,2,0);
     iCountTestcases++;
     if (vTest1.Equals(vTest2) != false )
       {
       ++iCountErrors;	
       printerr( "Error_100xx! Expected==false");
       }
     if (vTest2.Equals(vTest1) != false )
       {
       ++iCountErrors;	
       printerr( "Error_100zz! Expected==false");
       }
     strLoc = "Loc_120zz";
     vTest1 = new Version (5,5);
     vTest2 = new Version (5,5,0,0);
     iCountTestcases++;
     if (vTest1.Equals(vTest2) != false )
       {
       ++iCountErrors;	
       printerr( "Error_120xx! Expected==false value==" + vTest1.Equals(vTest2));
       }
     if (vTest2.Equals(vTest1) != false )
       {
       ++iCountErrors;	
       printerr( "Error_120zz! Expected==false value==" + vTest2.Equals(vTest1));
       }
     } catch (Exception exc_general ) {
     ++iCountErrors;
     Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
     }
   if ( iCountErrors == 0 )
     {
     Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
     return true;
     }
   else
     {
     Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
     return false;
     }
   }
	public void TestEquals ()
	{
		Version v1 = new Version (1, 2);
		Version v2 = new Version (1, 2, 3, 4);
		Version v3 = new Version (1, 2, 3, 4);

		AssertEquals ("A1", true, v2.Equals (v3));
		AssertEquals ("A2", true, v2.Equals (v2));
		AssertEquals ("A3", false, v1.Equals (v3));

		AssertEquals ("A4", true, v2 == v3);
		AssertEquals ("A5", true, v2 == v2);
		AssertEquals ("A6", false, v1 == v3);

		AssertEquals ("A7", false, v2.Equals ((Version) null));
		AssertEquals ("A8", false, v2.Equals ("A string"));
		
	}
	public void TestClone () 
	{
		Version v1 = new Version (1, 2, 3, 4);
		Version v2 = (Version) v1.Clone ();

		Assert ("A1", v1.Equals (v2));
		Assert ("A2", !ReferenceEquals (v1, v2));

		Version v3 = new Version (); // 0.0
		v2 = (Version) v3.Clone ();

		Assert ("A3", v3.Equals (v2));
		Assert ("A4", !ReferenceEquals (v3, v2));
	}
Example #17
0
		private ToolStripMenuItem CreateVersionItem(Version version, Version activeVersion)
		{
			var item = new ToolStripMenuItem(version.Label);
			item.Checked = version.Equals(activeVersion);
			item.Click += (sender, args) => this.Attempt("PHP version to change", async () =>
			{
				await this.phpVersions.SwitchTo(version);
			});

			return item;
		}
        /// <summary>
        /// Performs an action when the module is installed/upgraded, based on the given <paramref name="version"/>.
        /// </summary>
        /// <param name="version">The version to which the module is being upgraded.</param>
        /// <returns>A status message</returns>
        public string UpgradeModule(string version)
        {
            var versionNumber = new Version(version);
            if (versionNumber.Equals(new Version(1, 7, 0)))
            {
                var dataProvider = DataProvider.Instance();
                using (var transaction = dataProvider.GetTransaction())
                using (var timeZoneOffsetsReader = dataProvider.ExecuteReader("Engage_spGetEventTimeZoneOffsetsFor01_07_00Upgrade").AsEnumerable())
                {
                    foreach (var timeZoneOffset in timeZoneOffsetsReader.Select(reader => reader.GetInt32(0)))
                    {
                        var timeZone = Dnn.Utility.ConvertLegacyTimeZoneOffsetToTimeZoneInfo(timeZoneOffset);
                        dataProvider.ExecuteNonQuery(
                            "Engage_spConvertTimeZoneOffsetToTimeZoneFor01_07_00Upgrade",
                            Engage.Utility.CreateIntegerParam("timeZoneOffset", timeZoneOffset),
                            Engage.Utility.CreateVarcharParam("timeZone", timeZone.Id, 50));
                    }

                    dataProvider.CommitTransaction(transaction);
                }

                dataProvider.ExecuteNonQuery("Engage_spCleanup01_07_00Upgrade");

                return "Engage: Events 01.07.00 upgrade complete: time zones converted from offsets to real time zones";
            }

            return "No upgrade action required for version " + version + " of Engage: Events";
        }
Example #19
0
        /// <summary>
        ///     Checks if the string is equal to the current one.
        /// </summary>
        /// <param name="version">Version</param>
        /// <returns>String is equal to the current one.</returns>
        public static bool IsEqual(string version)
        {
            var d = new System.Version(version);

            return(CurrentVersion.Equals(d));
        }
Example #20
0
    public bool PosTest4()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest4: Ensure Equals(System.Object) return false when obj is a null reference.");

        try
        {
            Version TestVersion2 = new Version("2.3.4.8");
            if (TestVersion2.Equals(null))
            {
                TestLibrary.TestFramework.LogError("P04.1", "Equals(System.Object) failed when obj is a null reference!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("P04.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
        private static void RegisterConfigurationReaderSelector(ContainerBuilder builder)
        {
            builder.Register(
                c =>
                    {
                        var ctx = c.Resolve<IComponentContext>();
                        Func<Version, IVersionedConfigurationReader> readerSelector =
                            version =>
                            {
                                // Get a collection of lazy resolved meta data objects for the
                                // IVersionedXmlConfigurationReader
                                var allReadersAsLazy = ctx.Resolve<IEnumerable<Meta<IVersionedConfigurationReader>>>();

                                // Now find the reader that we want
                                // This is done by comparing the version numbers. If the
                                // first 2 digits of the input version number match the
                                // first 2 digits of the version number stored in the
                                // meta data, then we assume we found our reader.
                                // This is based on the idea that if we change the
                                // XML config format then we have to increment at least
                                // the minor version number.
                                IVersionedConfigurationReader selectedReader = null;
                                foreach (var reader in allReadersAsLazy)
                                {
                                    var inputShort = new Version(version.Major, version.Minor);

                                    var storedVersion = reader.Metadata["ReaderVersion"] as Version;
                                    var storedShort = new Version(storedVersion.Major, storedVersion.Minor);

                                    if (storedShort.Equals(inputShort))
                                    {
                                        selectedReader = reader.Value;
                                    }
                                }

                                return selectedReader;
                            };

                        return readerSelector;
                    });
        }
Example #22
0
    public bool PosTest3()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest3: Ensure Equals(System.Object) return false when obj is not Version object.");

        try
        {
            String TestString1 = new String(new char[] { '2', '.', '3', '.', '4', '.', '8' });
            Version TestVersion2 = new Version("2.3.4.8");
            if (TestVersion2.Equals(TestString1))
            {
                TestLibrary.TestFramework.LogError("P03.1", "Equals(System.Object) failed when obj is not Version object!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("P03.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Example #23
0
        public static void TestEqualsGetHashCode(Assert assert)
        {
            assert.Expect(9);

            var v1 = new Version(100, 200, 300, (400 << 16) + 500);
            var v2 = new Version(100, 200, 300, (400 << 16) + 500);
            var v3 = new Version(101, 200, 300, (400 << 16) + 500);
            var o = new object();
            object o2 = v2;

            assert.Ok(v1.Equals(v2), "v1.Equals(v2)");
            assert.NotOk(v1.Equals(v3), "v1.Equals(v3)");
            assert.NotOk(v1.Equals(o), "v1.Equals(o)");
            assert.NotOk(v1.Equals(null), "v1.Equals(null)");
            assert.NotOk(v1.Equals(100), "v1.Equals(100)");
            assert.Ok(v1.Equals(o2), "v1.Equals(o2)");

            assert.Equal(v1.GetHashCode(), 1283637748, "v1.GetHashCode()");
            assert.Equal(v2.GetHashCode(), 1283637748, "v2.GetHashCode()");
            assert.Equal(v3.GetHashCode(), 1552073204, "v3.GetHashCode()");
        }
Example #24
0
        /// <summary>
        /// Load and parse the referenced model but ignored any further referenced model.
        /// </summary>
        /// <param name="mainEdmxVersion">The main edm version.</param>
        /// <returns>A list of CsdlModel (no semantics) of the referenced models.</returns>
        private List<CsdlModel> LoadAndParseReferencedEdmxFiles(Version mainEdmxVersion)
        {
            List<CsdlModel> referencedAstModels = new List<CsdlModel>();
            if (this.getReferencedModelReaderFunc == null)
            {
                // don't try to load Edm xml doc, but this.edmReferences's namespace-alias need to be used later.
                return referencedAstModels;
            }

            foreach (var tmp in this.edmReferences)
            {
                if (!tmp.Includes.Any() && !tmp.IncludeAnnotations.Any())
                {
                    this.RaiseError(EdmErrorCode.ReferenceElementMustContainAtLeastOneIncludeOrIncludeAnnotationsElement, Strings.EdmxParser_InvalidReferenceIncorrectNumberOfIncludes);
                    continue;
                }

                if (tmp.Uri != null && (tmp.Uri.EndsWith(CoreVocabularyConstants.VocabularyUrlSuffix, StringComparison.Ordinal) ||
                    tmp.Uri.EndsWith(CapabilitiesVocabularyConstants.VocabularyUrlSuffix, StringComparison.Ordinal) ||
                    tmp.Uri.EndsWith(AlternateKeysVocabularyConstants.VocabularyUrlSuffix, StringComparison.Ordinal)))
                {
                    continue;
                }

                XmlReader referencedXmlReader = this.getReferencedModelReaderFunc(new Uri(tmp.Uri, UriKind.RelativeOrAbsolute));
                if (referencedXmlReader == null)
                {
                    this.RaiseError(EdmErrorCode.UnresolvedReferenceUriInEdmxReference, Strings.EdmxParser_UnresolvedReferenceUriInEdmxReference);
                    continue;
                }

                // recursively use EdmxReader to parse sub edm:
                EdmxReader referencedEdmxReader = new EdmxReader(referencedXmlReader, /*getReferencedModelReaderFunc*/ null);
                referencedEdmxReader.source = tmp.Uri;
                referencedEdmxReader.ignoreUnexpectedAttributesAndElements = this.ignoreUnexpectedAttributesAndElements;
                Version referencedEdmxVersion;
                CsdlModel referencedAstModel;
                if (referencedEdmxReader.TryParseEdmxFileToCsdlModel(out referencedEdmxVersion, out referencedAstModel))
                {
                    if (!mainEdmxVersion.Equals(referencedEdmxVersion))
                    {
                        // TODO: REF add exception message
                        this.errors.Add(null);
                    }

                    referencedAstModel.AddParentModelReferences(tmp);
                    referencedAstModels.Add(referencedAstModel);
                }

                this.errors.AddRange(referencedEdmxReader.errors);
            }

            return referencedAstModels;
        }
Example #25
0
        private void DoLauncherUpdateCheck()
        {
            Console.WriteLine("\nDoLauncherUpdateCheck()");

            if (!bCanConnectToFTP)
            {
                Console.WriteLine("Launcher update failed: Unable to connect to FTP");
                return;
            }

            try
            {
                //get the latest launcher version from the FTP
                string remoteLauncherVersionTXTURL = String.Format("{0}/launcher/launcherVersion.txt", Config.GetFTPUrl());
                string FTPUsername = Config.GetFTPUsername();
                string FTPPassword = Config.GetFTPPassword();
                //Console.WriteLine("Attempting to ReadFTPFile: userName: {0}, pass:{1}, remoteLauncherVersionTXTURL: {2}", FTPUsername, FTPPassword, remoteLauncherVersionTXTURL);
                string remoteLauncherVersion = FTP.ReadFTPFile(FTPUsername, FTPPassword, remoteLauncherVersionTXTURL).Replace("\0", string.Empty);

                //get the current launcher version from file
                string launcherVersion = Config.GetLauncherVersion();

                //we create version objects to format the versions correctly to remove unnecessary spaces or new line characters that may exist
                System.Version RemoteVersion   = new System.Version(remoteLauncherVersion);
                System.Version LauncherVersion = new System.Version(launcherVersion);

                //update the progress label to let the user know what we are doing
                progress_label.Text = "Checking launcher version...";
                progress_label.Refresh();

                if (RemoteVersion.Equals(LauncherVersion))
                {
                    Console.WriteLine("Launcher version is update to date.");

                    //launcher does not need to be updated
                    bLauncherNeedsUpdate = false;
                    if (File.Exists(String.Format(@"{0}\update.bat", Config.GetLocalDir())))
                    {
                        File.Delete(String.Format(@"{0}\update.bat", Config.GetLocalDir()));
                    }
                }
                else
                {
                    Console.WriteLine("Launcher version {0} is NOT up to date: {1}", LauncherVersion, RemoteVersion);

                    bLauncherNeedsUpdate = true;
                }

                bLauncherVersionCheckFailed = false;
            }
            catch (WebException ex)
            {
                Console.WriteLine(ex.Status);
                bLauncherVersionCheckFailed = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                bLauncherVersionCheckFailed = true;
            }
        }
Example #26
0
        private static bool IsFileTheDesiredAssembly(string filePath, string fileName, string version, string culture, string publicKey)
        {
            Debug.Assert(!string.IsNullOrEmpty(filePath), "The assembly file path should not be empty.");
            if (!Path.GetFileName(filePath).Equals(fileName, StringComparison.CurrentCultureIgnoreCase))
            {
                return false;
            }

            if ((!string.IsNullOrEmpty(version)) || (!string.IsNullOrEmpty(culture)) || (!string.IsNullOrEmpty(publicKey)))
            {
                AssemblyName assemblyName;
                try
                {
                    // Load the assembly name but without loading the assembly file into the AppDomain.
                    assemblyName = AssemblyName.GetAssemblyName(filePath);
                }
                catch (ArgumentException)
                {
                    // filePath is invalid, e.g. an assembly with an invalid culture.
                    return false;
                }
                catch (FileNotFoundException)
                {
                    // filePath doesn't point to a valid file or doesn't exist
                    return false;
                }
                catch (SecurityException)
                {
                    // The caller doesn't have discovery permission for the given path
                    return false;
                }
                catch (BadImageFormatException)
                {
                    // The file is not a valid assembly file
                    return false;
                }
                catch (FileLoadException)
                {
                    // the file was already loaded but with a different set of evidence
                    return false;
                }

                if (!string.IsNullOrEmpty(version))
                {
                    var expectedVersion = new Version(version);
                    if (!expectedVersion.Equals(assemblyName.Version))
                    {
                        return false;
                    }
                }

                if (!string.IsNullOrEmpty(culture))
                {
                    // The 'Neutral' culture is actually the invariant culture. This is the culture an
                    // assembly gets if no culture was specified so...
                    if (culture.Equals(AssemblyNameElements.InvariantCulture, StringComparison.OrdinalIgnoreCase))
                    {
                        culture = string.Empty;
                    }

                    var expectedCulture = new CultureInfo(culture);
                    if (!expectedCulture.Equals(assemblyName.CultureInfo))
                    {
                        return false;
                    }
                }

                if ((!string.IsNullOrEmpty(publicKey))
                    && (!publicKey.Equals(AssemblyNameElements.NullString, StringComparison.OrdinalIgnoreCase)))
                {
                    var actualPublicKeyToken = assemblyName.GetPublicKeyToken();
                    var str = actualPublicKeyToken.Aggregate(
                        string.Empty,
                        (current, value) => current + value.ToString("x2", CultureInfo.InvariantCulture));

                    return str.Equals(publicKey, StringComparison.OrdinalIgnoreCase);
                }
            }

            return true;
        }
 public override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
 {
     string majorVersion = postCollection[postDataKey + "_Major"];
     string minorVersion = postCollection[postDataKey + "_Minor"];
     string buildVersion = postCollection[postDataKey + "_Build"];
     bool dataChanged = false;
     Version presentValue = Version;
     var postedValue = new Version(majorVersion + "." + minorVersion + "." + buildVersion);
     if (!postedValue.Equals(presentValue))
     {
         Value = postedValue;
         dataChanged = true;
     }
     return dataChanged;
 }
Example #28
0
        /// <summary>
        /// Generates the sub-toolset version to be used with this toolset.  Sub-toolset version is based on:
        /// 1. If the "VisualStudioVersion" global property exists in the set of properties passed to us, use it. 
        /// 2. Otherwise, if "VisualStudioVersion" is set as a property on the toolset itself (global or environment), 
        ///    use that. 
        /// 3. Otherwise, use Visual Studio version from solution file if it maps to an existing sub-toolset. 
        /// 4. Otherwise, use the default sub-toolset version for this toolset. 
        /// 
        /// The sub-toolset version returned may be null; if so, that means that no sub-toolset should be used, 
        /// just the base toolset on its own. The sub-toolset version returned may not map to an existing 
        /// sub-toolset.  
        /// 
        /// The global properties dictionary may be null. 
        /// </summary>
        internal string GenerateSubToolsetVersion(int visualStudioVersionFromSolution)
        {
            // Next, try the toolset global properties (before environment properties because if there's a clash between the
            // two, global should win)
            if (_globalProperties != null)
            {
                ProjectPropertyInstance visualStudioVersionProperty = _globalProperties[Constants.SubToolsetVersionPropertyName];

                if (visualStudioVersionProperty != null)
                {
                    return visualStudioVersionProperty.EvaluatedValue;
                }
            }

            // Next, try the toolset environment properties 
            if (_environmentProperties != null)
            {
                ProjectPropertyInstance visualStudioVersionProperty = _environmentProperties[Constants.SubToolsetVersionPropertyName];

                if (visualStudioVersionProperty != null)
                {
                    return visualStudioVersionProperty.EvaluatedValue;
                }
            }

            // The VisualStudioVersion derived from parsing the solution version in the solution file
            string subToolsetVersion = null;
            if (visualStudioVersionFromSolution > 0)
            {
                Version visualStudioVersionFromSolutionAsVersion = new Version(visualStudioVersionFromSolution, 0);
                subToolsetVersion = SubToolsets.Keys.FirstOrDefault(version => visualStudioVersionFromSolutionAsVersion.Equals(VersionUtilities.ConvertToVersion(version)));
            }

            // Solution version also didn't work out, so fall back to default. 
            // If subToolsetVersion is null, there simply wasn't a matching solution version. 
            if (subToolsetVersion == null)
            {
                subToolsetVersion = DefaultSubToolsetVersion;
            }

            return subToolsetVersion;
        }
Example #29
0
        private void okButton_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < mReferences.Length; ++i) {
            Version selected = (Version) referenceListView.Items[i].SubItems[2].Tag;

            Version curVersion = new Version(mReferences[i].Version == string.Empty ? "0.0.0.0" : mReferences[i].Version);
            Reference reference = mReferences[i];
            string name = reference.Name;

            // Work out if we're updating the reference or not.
            if (selected != null && !curVersion.Equals(selected)) {
              List<Reference> updateReferences = new List<Reference>();
              updateReferences.Add(reference); // Always update our reference

              // Check if any other projects in the solution use this reference
              VSProject vsProj = (VSProject)mReferences[i].ContainingProject.Object;
              Reference[] otherReferences = FindReferenceInOtherProjects(reference.Name, vsProj.Project.UniqueName);
              if (otherReferences.Length > 0) {
            StringBuilder message = new StringBuilder();
            message.AppendFormat("The following projects also have references to {0}:\n", name);
            foreach (Reference otherRef in otherReferences) {
              message.AppendFormat("  {0}\n", otherRef.ContainingProject.Name);
            }
            message.Append("Do you wish to update the reference in these projects too?");

            DialogResult result =
              MessageBox.Show(this, message.ToString(), "Other Projects using " + name, MessageBoxButtons.YesNoCancel,
                              MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
            if (result == System.Windows.Forms.DialogResult.Cancel) {
              return;
            } else if (result == System.Windows.Forms.DialogResult.Yes) {
              updateReferences.AddRange(otherReferences);
            }
              }

              foreach (Reference updateRef in updateReferences) {
            VSProject owner = (VSProject)updateRef.ContainingProject.Object;

            updateRef.Remove();
            owner.References.Add(mGac.Resolve(name, selected, null, null, mCurrentConfiguration, mAllConfigurations));
              }
            }
              }

              this.Close();
        }
		public void TestEquals ()
		{
			Version v1 = new Version (1, 2);
			Version v2 = new Version (1, 2, 3, 4);
			Version v3 = new Version (1, 2, 3, 4);

			Assert.IsTrue (v2.Equals (v3), "#A1");
			Assert.IsTrue (v2.Equals (v2), "#A2");
			Assert.IsFalse (v1.Equals (v3), "#A3");

			Assert.IsTrue (v2 == v3, "#B1");
#pragma warning disable 1718
			Assert.IsTrue (v2 == v2, "#B2");
#pragma warning restore 1718
			Assert.IsFalse (v1 == v3, "#B3");

			Assert.IsFalse (v2.Equals ((Version) null), "#C1");
			Assert.IsFalse (v2.Equals ("A string"), "#C2");
		}
Example #31
0
        public static void Equals(Version version1, object obj, bool expected)
        {
            Version version2 = obj as Version;

            Assert.Equal(expected, version1.Equals(version2));
            Assert.Equal(expected, version1.Equals(obj));

            Assert.Equal(expected, version1 == version2);
            Assert.Equal(!expected, version1 != version2);

            if (version2 != null)
            {
                Assert.Equal(expected, version1.GetHashCode().Equals(version2.GetHashCode()));
            }
        }
Example #32
0
 public Assembly ShadowLoad(string simpleName, Version versionIfKnown, string filePathIfKnown, Assembly requestingAssembly)
 {
     simpleName = simpleName.ToLowerInvariant();
     Assembly assembly = null;
     if (!_loadedAssemblies.TryGetValue(simpleName, out assembly))
     {
         Assembly assembly3 = (from a in System.AppDomain.CurrentDomain.GetAssemblies()
             let name = a.GetName()
             where simpleName.Equals(name.Name, StringComparison.OrdinalIgnoreCase) && ((versionIfKnown == null) || versionIfKnown.Equals(name.Version))
             select a).FirstOrDefault<Assembly>();
         if (assembly3 != null)
         {
             return assembly3;
         }
         string path = null;
         bool flag = false;
         string data = System.AppDomain.CurrentDomain.GetData("LINQPad.ShadowPath") as string;
         if (!(string.IsNullOrEmpty(data) || !Directory.Exists(data)))
         {
             path = PathHelper.GetAssemblyFromFolderIfPresent(data, simpleName, filePathIfKnown);
         }
         if (path == null)
         {
             path = PathHelper.GetAssemblyFromFolderIfPresent(System.AppDomain.CurrentDomain.BaseDirectory, simpleName, filePathIfKnown);
         }
         if (path == null)
         {
             string str3 = System.AppDomain.CurrentDomain.GetData("LINQPad.StaticDCFolder") as string;
             if (!(string.IsNullOrEmpty(str3) || !Directory.Exists(str3)))
             {
                 path = PathHelper.GetAssemblyFromFolderIfPresent(str3, simpleName, filePathIfKnown);
                 if (path != null)
                 {
                     flag = true;
                 }
             }
         }
         if (path == null)
         {
             string str4 = System.AppDomain.CurrentDomain.GetData("LINQPad.DCDriverFolder") as string;
             if (!(string.IsNullOrEmpty(str4) || !Directory.Exists(str4)))
             {
                 path = PathHelper.GetAssemblyFromFolderIfPresent(str4, simpleName, filePathIfKnown);
                 if (path != null)
                 {
                     flag = true;
                 }
             }
         }
         if (((path == null) && (filePathIfKnown != null)) && File.Exists(filePathIfKnown))
         {
             path = filePathIfKnown;
             flag = true;
         }
         if (!(((path != null) || (requestingAssembly == null)) || string.IsNullOrEmpty(requestingAssembly.Location)))
         {
             path = PathHelper.GetAssemblyFromFolderIfPresent(Path.GetDirectoryName(requestingAssembly.Location), simpleName, filePathIfKnown);
             if (path != null)
             {
                 flag = true;
             }
         }
         if (this._additionalRefs == null)
         {
             this._additionalRefs = new string[0];
         }
         if (path == null)
         {
             path = this._additionalRefs.FirstOrDefault<string>(r => Path.GetFileNameWithoutExtension(r).ToLowerInvariant() == simpleName);
         }
         if ((path == null) && (filePathIfKnown != null))
         {
             path = filePathIfKnown;
         }
         if (((path == null) && (CurrentQueryAssemblyPath != null)) && CurrentQueryAssemblyPath.ToLowerInvariant().Contains(simpleName.ToLowerInvariant()))
         {
             path = CurrentQueryAssemblyPath;
         }
         if (path == null)
         {
             return null;
         }
         assembly = flag ? Assembly.LoadFile(path) : Assembly.LoadFrom(path);
         _loadedAssemblies[simpleName] = assembly;
     }
     return assembly;
 }
 private void tstbValue_TextChanged(object sender, EventArgs e)
 {
     bool flag = string.IsNullOrEmpty(this.tstbValue.Text);
     if (flag || VersionRegex.IsMatch(this.tstbValue.Text))
     {
         if (!flag)
         {
             Version version = new Version(this.tstbValue.Text);
             if (!version.Equals(this.tstbValue.Tag))
             {
                 this.tstbValue.Tag = version;
                 base.RaiseFilterChanged();
             }
         }
         this.tstbValue.ResetBackColor();
         this.tstbValue.ResetForeColor();
     }
     else
     {
         this.tstbValue.BackColor = Settings.TextBoxError;
         this.tstbValue.ForeColor = SystemColors.HighlightText;
     }
 }