Skip to content

Commit 9a9f7fc

Browse files
SebastianDotNetjozefizso
authored andcommitted
[Regular Commit]
- improve NetOffice Core assembly loader - fix MSProject addin tools - improve standard examples - improve addin removal tool - update assemblies Imported from NetOffice 113493 https://netoffice.codeplex.com/SourceControl/changeset/113493 Legacy NetOffice Git repository commit 0a1e63b4d0ebc545772bf7097bef86909c474201
1 parent bcfeab5 commit 9a9f7fc

File tree

61 files changed

+691
-670
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+691
-670
lines changed

BuildTools/VersionUpdater/Form1.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ private void ChangeToolsVersionEntryInProjectFile(ref string fileContent)
211211

212212
private void ChangeNetVersionEntryInProjectFile(ref string fileContent, string toNetVersion)
213213
{
214+
if (toNetVersion != "4.0")
215+
{
216+
fileContent = fileContent.Replace("<TargetFrameworkProfile>Client</TargetFrameworkProfile>", "");
217+
}
218+
219+
214220
string net1 = "<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>";
215221
int position = fileContent.IndexOf(net1);
216222
if (position > -1)
@@ -250,6 +256,7 @@ private void ChangeNetVersionEntryInProjectFile(ref string fileContent, string t
250256
fileContent = fileContent.Replace(net4, "<TargetFrameworkVersion>v" + toNetVersion + "</TargetFrameworkVersion>");
251257
return;
252258
}
259+
253260
}
254261

255262
private void ChangeFormatVersionInSolutionFile(ref string fileContent, string toNetVersion)

Examples/Access/C#/Standard Examples/AccessExamples/Examples/Example01.cs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ public void RunExample()
2828
{
2929
// start access
3030
Access.Application accessApplication = new Access.Application();
31-
32-
// create database name
33-
string fileExtension = GetDefaultExtension(accessApplication);
34-
string documentFile = string.Format("{0}\\Example01{1}", HostApplication.RootDirectory, fileExtension);
31+
32+
// create a utils instance, not need for but helpful to keep the lines of code low
33+
Access.Tools.CommonUtils utils = new Access.Tools.CommonUtils(accessApplication);
34+
35+
// create database file name
36+
string documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example01", Access.Tools.DocumentFormat.Normal);
3537

3638
// delete old database if exists
3739
if (System.IO.File.Exists(documentFile))
@@ -75,28 +77,5 @@ public UserControl Panel
7577
internal IHost HostApplication { get; private set; }
7678

7779
#endregion
78-
79-
#region Helper
80-
81-
/// <summary>
82-
/// returns the valid file extension for the instance. for example ".mdb" or ".accdb"
83-
/// </summary>
84-
/// <param name="application">the instance</param>
85-
/// <returns>the extension</returns>
86-
private static string GetDefaultExtension(Access.Application application)
87-
{
88-
// Access 2000 doesnt have the Version property(unfortunately)
89-
// we check for support with the SupportEntity method, implemented by NetOffice
90-
if (!application.EntityIsAvailable("Version"))
91-
return ".mdb";
92-
93-
double Version = Convert.ToDouble(application.Version, CultureInfo.InvariantCulture);
94-
if (Version >= 12.00)
95-
return ".accdb";
96-
else
97-
return ".mdb";
98-
}
99-
100-
#endregion
10180
}
10281
}

Examples/Access/C#/Standard Examples/AccessExamples/Examples/Example02.cs

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ public void RunExample()
3030
// start access
3131
Access.Application accessApplication = new Access.Application();
3232

33-
// create database name
34-
string fileExtension = GetDefaultExtension(accessApplication);
35-
string documentFile = string.Format("{0}\\Example02{1}", HostApplication.RootDirectory, fileExtension);
33+
// create a utils instance, not need for but helpful to keep the lines of code low
34+
Access.Tools.CommonUtils utils = new Access.Tools.CommonUtils(accessApplication);
3635

36+
// create database file name
37+
string documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example02", Access.Tools.DocumentFormat.Normal);
3738

3839
// delete old database if exists
3940
if (System.IO.File.Exists(documentFile))
@@ -95,28 +96,5 @@ public UserControl Panel
9596
internal IHost HostApplication { get; private set; }
9697

9798
#endregion
98-
99-
#region Helper
100-
101-
/// <summary>
102-
/// returns the valid file extension for the instance. for example ".mdb" or ".accdb"
103-
/// </summary>
104-
/// <param name="application">the instance</param>
105-
/// <returns>the extension</returns>
106-
private static string GetDefaultExtension(Access.Application application)
107-
{
108-
// Access 2000 doesnt have the Version property(unfortunately)
109-
// we check for support with the SupportEntity method, implemented by NetOffice
110-
if (!application.EntityIsAvailable("Version"))
111-
return ".mdb";
112-
113-
double Version = Convert.ToDouble(application.Version, CultureInfo.InvariantCulture);
114-
if (Version >= 12.00)
115-
return ".accdb";
116-
else
117-
return ".mdb";
118-
}
119-
120-
#endregion
12199
}
122100
}

Examples/Access/C#/Standard Examples/AccessExamples/Examples/Example03.cs

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ public void RunExample()
3131
// start access
3232
Access.Application accessApplication = new Access.Application();
3333

34-
// create database name
35-
string fileExtension = GetDefaultExtension(accessApplication);
36-
string documentFile = string.Format("{0}\\Example03{1}", HostApplication.RootDirectory, fileExtension);
34+
// create a utils instance, not need for but helpful to keep the lines of code low
35+
Access.Tools.CommonUtils utils = new Access.Tools.CommonUtils(accessApplication);
3736

37+
// create database file name
38+
string documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example03", Access.Tools.DocumentFormat.Normal);
3839

3940
// delete old database if exists
4041
if (System.IO.File.Exists(documentFile))
@@ -61,12 +62,12 @@ public void RunExample()
6162
}
6263
oleConnection.Close();
6364

64-
// now we do CompactDatabase
65-
66-
string newDocumentFile = string.Format("{0}\\CompactDatabase{1}", HostApplication, fileExtension);
65+
// delete old file if exists
66+
string newDocumentFile = string.Format("{0}\\CompactDatabase{1}", HostApplication, utils.File.FileExtension(Access.Tools.DocumentFormat.Normal));
6767
if (File.Exists(newDocumentFile))
6868
File.Delete(newDocumentFile);
6969

70+
// now we do CompactDatabase
7071
accessApplication.DBEngine.CompactDatabase(documentFile, newDocumentFile);
7172

7273
// close access and dispose reference
@@ -104,28 +105,5 @@ public UserControl Panel
104105
internal IHost HostApplication { get; private set; }
105106

106107
#endregion
107-
108-
#region Helper
109-
110-
/// <summary>
111-
/// returns the valid file extension for the instance. for example ".mdb" or ".accdb"
112-
/// </summary>
113-
/// <param name="application">the instance</param>
114-
/// <returns>the extension</returns>
115-
private static string GetDefaultExtension(Access.Application application)
116-
{
117-
// Access 2000 doesnt have the Version property(unfortunately)
118-
// we check for support with the SupportEntity method, implemented by NetOffice
119-
if (!application.EntityIsAvailable("Version"))
120-
return ".mdb";
121-
122-
double Version = Convert.ToDouble(application.Version, CultureInfo.InvariantCulture);
123-
if (Version >= 12.00)
124-
return ".accdb";
125-
else
126-
return ".mdb";
127-
}
128-
129-
#endregion
130108
}
131109
}

Examples/Access/VB/Standard Examples/AccessExamples/Examples/Example01.vb

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ Public Class Example01
1717
' start access
1818
Dim accessApplication As New Access.Application()
1919

20-
' create database name
21-
Dim fileExtension As String = GetDefaultExtension(accessApplication)
22-
Dim documentFile As String = String.Format("{0}\\Example01{1}", _hostApplication.RootDirectory, fileExtension)
20+
' create a utils instance, not need for but helpful to keep the lines of code low
21+
Dim utils As Access.Tools.CommonUtils = New Access.Tools.CommonUtils(accessApplication)
22+
23+
' create database file name
24+
Dim documentFile As String = utils.File.Combine(_hostApplication.RootDirectory, "Example01", Access.Tools.DocumentFormat.Normal)
2325

2426
' delete old database if exists
2527
If (System.IO.File.Exists(documentFile)) Then
@@ -63,31 +65,4 @@ Public Class Example01
6365

6466
#End Region
6567

66-
#Region "Helper"
67-
68-
''' <summary>
69-
''' returns the valid file extension for the instance. for example ".mdb" or ".accdb"
70-
''' </summary>
71-
''' <param name="application">the instance</param>
72-
''' <returns>the extension</returns>
73-
''' <remarks></remarks>
74-
Private Function GetDefaultExtension(ByVal application As Access.Application) As String
75-
76-
' Access 2000 doesnt have the Version property(unfortunately)
77-
' we check for support with the SupportEntity method, implemented by NetOffice
78-
If (Not application.EntityIsAvailable("Version")) Then
79-
Return ".mdb"
80-
End If
81-
82-
Dim version As Double = Convert.ToDouble(application.Version, CultureInfo.InvariantCulture)
83-
If (version >= 12.0) Then
84-
Return ".accdb"
85-
Else
86-
Return ".mdb"
87-
End If
88-
89-
End Function
90-
91-
#End Region
92-
9368
End Class

Examples/Access/VB/Standard Examples/AccessExamples/Examples/Example02.vb

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ Public Class Example02
2020
' start access
2121
Dim accessApplication As New Access.Application()
2222

23-
' create database name
24-
Dim fileExtension As String = GetDefaultExtension(accessApplication)
25-
Dim documentFile As String = String.Format("{0}\\Example02{1}", _hostApplication.RootDirectory, fileExtension)
23+
' create a utils instance, not need for but helpful to keep the lines of code low
24+
Dim utils As Access.Tools.CommonUtils = New Access.Tools.CommonUtils(accessApplication)
25+
26+
' create database file name
27+
Dim documentFile As String = utils.File.Combine(_hostApplication.RootDirectory, "Example02", Access.Tools.DocumentFormat.Normal)
2628

2729
' delete old database if exists
2830
If (System.IO.File.Exists(documentFile)) Then
@@ -85,31 +87,4 @@ Public Class Example02
8587

8688
#End Region
8789

88-
#Region "Helper"
89-
90-
''' <summary>
91-
''' returns the valid file extension for the instance. for example ".mdb" or ".accdb"
92-
''' </summary>
93-
''' <param name="application">the instance</param>
94-
''' <returns>the extension</returns>
95-
''' <remarks></remarks>
96-
Private Function GetDefaultExtension(ByVal application As Access.Application) As String
97-
98-
' Access 2000 doesnt have the Version property(unfortunately)
99-
' we check for support with the SupportEntity method, implemented by NetOffice
100-
If (Not application.EntityIsAvailable("Version")) Then
101-
Return ".mdb"
102-
End If
103-
104-
Dim version As Double = Convert.ToDouble(application.Version, CultureInfo.InvariantCulture)
105-
If (version >= 12.0) Then
106-
Return ".accdb"
107-
Else
108-
Return ".mdb"
109-
End If
110-
111-
End Function
112-
113-
#End Region
114-
11590
End Class

Examples/Access/VB/Standard Examples/AccessExamples/Examples/Example03.vb

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ Public Class Example03
2020
' start access
2121
Dim accessApplication As New Access.Application()
2222

23-
' create database name
24-
Dim fileExtension As String = GetDefaultExtension(accessApplication)
25-
Dim documentFile As String = String.Format("{0}\\Example03{1}", _hostApplication.RootDirectory, fileExtension)
23+
' create a utils instance, not need for but helpful to keep the lines of code low
24+
Dim utils As Access.Tools.CommonUtils = New Access.Tools.CommonUtils(accessApplication)
25+
26+
' create database file name
27+
Dim documentFile As String = utils.File.Combine(_hostApplication.RootDirectory, "Example03", Access.Tools.DocumentFormat.Normal)
2628

2729
' delete old database if exists
2830
If (System.IO.File.Exists(documentFile)) Then
@@ -48,17 +50,16 @@ Public Class Example03
4850
Dim oleInsertCommand As New OleDbCommand(insertCommand, oleConnection)
4951
oleInsertCommand.ExecuteReader().Close()
5052

51-
5253
Next
5354
oleConnection.Close()
5455

55-
' now we do CompactDatabase
56-
57-
Dim newDocumentFile As String = String.Format("{0}\\CompactDatabase{1}", _hostApplication.RootDirectory, fileExtension)
56+
' delete old if exists
57+
Dim newDocumentFile As String = String.Format("{0}\\CompactDatabase{1}", _hostApplication.RootDirectory, utils.File.FileExtension(Access.Tools.DocumentFormat.Normal))
5858
If (File.Exists(newDocumentFile)) Then
5959
File.Delete(newDocumentFile)
6060
End If
6161

62+
' now we do CompactDatabase
6263
accessApplication.DBEngine.CompactDatabase(documentFile, newDocumentFile)
6364

6465
' close access and dispose reference
@@ -93,31 +94,4 @@ Public Class Example03
9394

9495
#End Region
9596

96-
#Region "Helper"
97-
98-
''' <summary>
99-
''' returns the valid file extension for the instance. for example ".mdb" or ".accdb"
100-
''' </summary>
101-
''' <param name="application">the instance</param>
102-
''' <returns>the extension</returns>
103-
''' <remarks></remarks>
104-
Private Function GetDefaultExtension(ByVal application As Access.Application) As String
105-
106-
' Access 2000 doesnt have the Version property(unfortunately)
107-
' we check for support with the SupportEntity method, implemented by NetOffice
108-
If (Not application.EntityIsAvailable("Version")) Then
109-
Return ".mdb"
110-
End If
111-
112-
Dim version As Double = Convert.ToDouble(application.Version, CultureInfo.InvariantCulture)
113-
If (version >= 12.0) Then
114-
Return ".accdb"
115-
Else
116-
Return ".mdb"
117-
End If
118-
119-
End Function
120-
121-
#End Region
122-
12397
End Class

0 commit comments

Comments
 (0)