public override string ToString() { if (clearTextConnection != null) { return(clearTextConnection); } if (!String.IsNullOrEmpty(keyfile)) { // the keyfile in the .config file is relative to where the assembly is executing var thisAssemblyDirectory = GeneralUtility.GetExecutingAssemblyDirectory(); var keyFileInfo = new FileInfo(Path.Combine(thisAssemblyDirectory.FullName, keyfile)); Check.RequireFileExists(keyFileInfo, $"Could keyfile=\"{keyfile}\" not found (looked in path {keyFileInfo.FullName}) as specified in configuration element {GetType().Name}. Check config file and filesystem."); var crypto = Encryptor.Instance(keyFileInfo); clearTextConnection = crypto.Decrypt(connect); } else { // no keyfile must mean that the connect string is not munged clearTextConnection = connect; } return(clearTextConnection); }
public VersionInformation(Assembly assemblyToDeriveInfoFrom) { _version = assemblyToDeriveInfoFrom.GetName().Version; _dateCompiled = GeneralUtility.GetExecutingAssemblyFile().LastWriteTime; }
public void ReflectionExpressionHelper() { { const string message = "Void Function"; var answer = GeneralUtility.ParseExpressionParts <TestReflectionClass>(tc => tc.TestMethod()); Assert.That(answer.DeclaringTypeName, Is.EqualTo("TestReflectionClass"), message); Assert.That(answer.MethodOrMemberName, Is.EqualTo("TestMethod"), message); } { const string message = "Void Function with parameters"; var answer = GeneralUtility.ParseExpressionParts <TestReflectionClass>(tc => tc.TestMethod1(0)); Assert.That(answer.DeclaringTypeName, Is.EqualTo("TestReflectionClass"), message); Assert.That(answer.MethodOrMemberName, Is.EqualTo("TestMethod1"), message); } { const string message = "Function with parameters"; var answer = GeneralUtility.ParseExpressionParts <TestReflectionClass>(tc => tc.TestFunction()); Assert.That(answer.DeclaringTypeName, Is.EqualTo("TestReflectionClass"), message); Assert.That(answer.MethodOrMemberName, Is.EqualTo("TestFunction"), message); } { const string message = "Function with parameters"; var answer = GeneralUtility.ParseExpressionParts <TestReflectionClass>(tc => tc.TestFunction1(0)); Assert.That(answer.DeclaringTypeName, Is.EqualTo("TestReflectionClass"), message); Assert.That(answer.MethodOrMemberName, Is.EqualTo("TestFunction1"), message); } { const string message = "Function with parameters"; var answer = GeneralUtility.ParseExpressionParts <TestReflectionClass>(tc => tc.TestFunction2(0, 1)); Assert.That(answer.DeclaringTypeName, Is.EqualTo("TestReflectionClass"), message); Assert.That(answer.MethodOrMemberName, Is.EqualTo("TestFunction2"), message); } { const string message = "Property with int return"; var answer1 = GeneralUtility.ParseExpressionParts <TestReflectionClass, int>(tc => tc.TestPropertyInt); Assert.That(answer1.DeclaringTypeName, Is.EqualTo("TestReflectionClass"), message); Assert.That(answer1.MethodOrMemberName, Is.EqualTo("TestPropertyInt"), message); } { const string message = "Property with string return"; var answer2 = GeneralUtility.ParseExpressionParts <TestReflectionClass, string>(tc => tc.TestPropertyString); Assert.That(answer2.DeclaringTypeName, Is.EqualTo("TestReflectionClass"), message); Assert.That(answer2.MethodOrMemberName, Is.EqualTo("TestPropertyString"), message); } { const string message = "Property with DateTime return"; var answer3 = GeneralUtility.ParseExpressionParts <TestReflectionClass, DateTime>(tc => tc.TestPropertyDateTime); Assert.That(answer3.DeclaringTypeName, Is.EqualTo("TestReflectionClass"), message); Assert.That(answer3.MethodOrMemberName, Is.EqualTo("TestPropertyDateTime"), message); } { const string message = "Field with int return"; var answer1 = GeneralUtility.ParseExpressionParts <TestReflectionClass, int>(tc => tc.TestFieldInt); Assert.That(answer1.DeclaringTypeName, Is.EqualTo("TestReflectionClass"), message); Assert.That(answer1.MethodOrMemberName, Is.EqualTo("TestFieldInt"), message); } { const string message = "Field with int[] return"; var answer1 = GeneralUtility.ParseExpressionParts <TestReflectionClass, int[]>(tc => tc.TestFieldIntArray); Assert.That(answer1.DeclaringTypeName, Is.EqualTo("TestReflectionClass"), message); Assert.That(answer1.MethodOrMemberName, Is.EqualTo("TestFieldIntArray"), message); } }