Hi
I tried to convert the following C# code to vb.net.
code in C#
_______________ _______________ _______________ _______________ ____
using System;
using System.Reflecti on;
using System.Resource s;
namespace LivingObjects.R esources
{
/// <summary>
/// This Class is used to create the ResourceManager for the site.
/// It manages a single instance of this object.
/// </summary>
internal class ResourceFactory
{
/// <summary>
/// Private Contructor. This factory is a static implementation.
/// It cannot be instanciated.
/// </summary>
private ResourceFactory ()
{
}
private static ResourceManager _rm;
public static ResourceManager ResourceManager
{
get
{
if(_rm == null)
{
lock(typeof(Liv ingObjects.Reso urces.ResourceF actory))
{
if(_rm == null)
{
string resxNamespace =
typeof(LivingOb jects.Resources .ResourceFactor y).Namespace;
_rm = new ResourceManager (resxNamespace + ".Labels",
System.Reflecti on.Assembly.Get ExecutingAssemb ly());
}
}
}
return _rm;
}
}
public static string GetLabel(string resourceID)
{
return ResourceManager .GetString(reso urceID);
}
}
}
_______________ _______________ _______________ _______________ _____________
code in VB.Net
_______________ _______________ _______________ _______________ _____________
Imports System
Imports System.Reflecti on
Imports System.Resource s
Namespace LivingObjects.R esources
' This Class is used to create the ResourceManager for the site.
' It manages a single instance of this object.
Friend Class ResourceFactory
' Private Contructor. This factory is a static implementation.
' It cannot be instanciated.
Private Sub New()
End Sub
Private Shared _rm As ResourceManager
Public Shared ReadOnly Property ResourceManager () As
ResourceManager
Get
If _rm Is Nothing Then
Lock(Type.GetTy pe(LivingObject s.Resources.Res ourceFactory))
If _rm Is Nothing Then
Dim resxNamespace As String =
Type.GetType(Li vingObjects.Res ources.Resource Factory).Namesp ace
_rm = New ResourceManager (resxNamespace +
".Labels", System.Reflecti on.Assembly.Get ExecutingAssemb ly())
End If
Unlock(Type.Get Type(LivingObje cts.Resources.R esourceFactory) )
End If
Return _rm
End Get
End Property
Public Shared Function GetLabel(ByVal resourceID As String) As
String
Return ResourceManager .GetString(reso urceID)
End Function
End Class
End Namespace
_______________ _______________ _______________ _______________ ______________
The error comes in vb.net whenever I use
'LivingObjects. Resources.Resou rceFactory'.
The build error says: "'ResourceFacto ry' is a type in 'Resources' and
cannot be used as an expression."
How can it be implemented then in vb.net? any ideas?
Thanks,
Eelis
p.s. The C# code was created by Jonathan
Gauthier.(http://www.codetools.com/cs/miscctrl...emListView.asp)