Show / Hide Table of Contents

Class ResourceDllProviderBase

Base class for standard .NET resource DLL based providers

Inheritance
Object
ResourceDllProviderBase
Implements
IResourceProvider
ISearchableResourceProvider
IUnfilteredResourceProvider
Namespace: SuperOffice.Globalization
Assembly: SuperOffice.Plugins.dll
Syntax
public abstract class ResourceDllProviderBase : Object, IResourceProvider, ISearchableResourceProvider, IUnfilteredResourceProvider, IPlugin
Remarks

Using a minimal derivation from this class, you can make your own resource dll that will be picked up by NetServer and inserted into the provider stack. This base class contains sufficient implementation of the whole IResourceProvider interface.

A derivation of the following form is enough:
namespace SuperOffice.SM.Resources
{
	[ResourceProvider("SuperOffice.SM.Resources", int.MaxValue / 2)]
	public class SuperOfficeResourceDllProvider : ResourceDllProviderBase
	{
		public SuperOfficeResourceDllProvider()
			: base(Assembly.GetExecutingAssembly(), ".ResourceStrings")
		{
		}
	}
}	
The name of the provider, declared in the ResourceProvider attribute, should be of a form that ensures uniqueness, <Company>.<Product> is suggested. The priority value can be left at int.MaxValue/2 unless the purpose of the provider is to override existing providers with new values; in that case a numerically lower value will ensure that this provider is called first.

The ".ResourceStrings" constant reflects the name of the resource XML structure, and corresponds to the name of the .resx files in the project.

Constructors

ResourceDllProviderBase(Assembly, String)

Base constructor.

Declaration
protected ResourceDllProviderBase(Assembly resourceAssembly, string resourceRoot)
Parameters
Type Name Description
Assembly resourceAssembly

Resource assembly to assign.

String resourceRoot

Resource root to assign.

Remarks

Using a minimal derivation from this class, you can make your own resource dll that will be picked up by NetServer and inserted into the provider stack. This base class contains sufficient implementation of the whole IResourceProvider interface.

A derivation of the following form is enough:
namespace SuperOffice.SM.Resources
{
	[ResourceProvider("SuperOffice.SM.Resources", int.MaxValue / 2)]
	public class SuperOfficeResourceDllProvider : ResourceDllProviderBase
	{
		public SuperOfficeResourceDllProvider()
			: base(Assembly.GetExecutingAssembly(), ".ResourceStrings")
		{
		}
	}
}	
The name of the provider, declared in the ResourceProvider attribute, should be of a form that ensures uniqueness, <Company>.<Product> is suggested. The priority value can be left at int.MaxValue/2 unless the purpose of the provider is to override existing providers with new values; in that case a numerically lower value will ensure that this provider is called first.

The ".ResourceStrings" constant reflects the name of the resource XML structure, and corresponds to the name of the .resx files in the project.

Methods

CanInitialize()

Reports wheter the ResourceDllProvider can/needs initialization.

Declaration
public virtual bool CanInitialize()
Returns
Type Description
Boolean

true if it can be initlialized.

Remarks

Using a minimal derivation from this class, you can make your own resource dll that will be picked up by NetServer and inserted into the provider stack. This base class contains sufficient implementation of the whole IResourceProvider interface.

A derivation of the following form is enough:
namespace SuperOffice.SM.Resources
{
	[ResourceProvider("SuperOffice.SM.Resources", int.MaxValue / 2)]
	public class SuperOfficeResourceDllProvider : ResourceDllProviderBase
	{
		public SuperOfficeResourceDllProvider()
			: base(Assembly.GetExecutingAssembly(), ".ResourceStrings")
		{
		}
	}
}	
The name of the provider, declared in the ResourceProvider attribute, should be of a form that ensures uniqueness, <Company>.<Product> is suggested. The priority value can be left at int.MaxValue/2 unless the purpose of the provider is to override existing providers with new values; in that case a numerically lower value will ensure that this provider is called first.

The ".ResourceStrings" constant reflects the name of the resource XML structure, and corresponds to the name of the .resx files in the project.

FindResourceStrings(String, String)

Returns all resource strings containing searchString in the specified culture

Declaration
public virtual string[] FindResourceStrings(string searchString, string cultureName)
Parameters
Type Name Description
String searchString

The string to search for, case insensitive

String cultureName

The name of the culture in the form en-US, nb-NO

Returns
Type Description
String[]

Array of resource strings matching searchString

Remarks

Using a minimal derivation from this class, you can make your own resource dll that will be picked up by NetServer and inserted into the provider stack. This base class contains sufficient implementation of the whole IResourceProvider interface.

A derivation of the following form is enough:
namespace SuperOffice.SM.Resources
{
	[ResourceProvider("SuperOffice.SM.Resources", int.MaxValue / 2)]
	public class SuperOfficeResourceDllProvider : ResourceDllProviderBase
	{
		public SuperOfficeResourceDllProvider()
			: base(Assembly.GetExecutingAssembly(), ".ResourceStrings")
		{
		}
	}
}	
The name of the provider, declared in the ResourceProvider attribute, should be of a form that ensures uniqueness, <Company>.<Product> is suggested. The priority value can be left at int.MaxValue/2 unless the purpose of the provider is to override existing providers with new values; in that case a numerically lower value will ensure that this provider is called first.

The ".ResourceStrings" constant reflects the name of the resource XML structure, and corresponds to the name of the .resx files in the project.

GetResource(String)

Returns a string from this provider in the current culture

Declaration
public virtual string GetResource(string name)
Parameters
Type Name Description
String name

The name of the resource/resource symbol

Returns
Type Description
String

The resource string

Remarks

Using a minimal derivation from this class, you can make your own resource dll that will be picked up by NetServer and inserted into the provider stack. This base class contains sufficient implementation of the whole IResourceProvider interface.

A derivation of the following form is enough:
namespace SuperOffice.SM.Resources
{
	[ResourceProvider("SuperOffice.SM.Resources", int.MaxValue / 2)]
	public class SuperOfficeResourceDllProvider : ResourceDllProviderBase
	{
		public SuperOfficeResourceDllProvider()
			: base(Assembly.GetExecutingAssembly(), ".ResourceStrings")
		{
		}
	}
}	
The name of the provider, declared in the ResourceProvider attribute, should be of a form that ensures uniqueness, <Company>.<Product> is suggested. The priority value can be left at int.MaxValue/2 unless the purpose of the provider is to override existing providers with new values; in that case a numerically lower value will ensure that this provider is called first.

The ".ResourceStrings" constant reflects the name of the resource XML structure, and corresponds to the name of the .resx files in the project.

GetResource(String, String)

Returns a string from this provider in the specified culture

Declaration
public virtual string GetResource(string name, string cultureName)
Parameters
Type Name Description
String name

The name of the resource/resource symbol

String cultureName

The name of the culture in the form en-US, nb-NO

Returns
Type Description
String

The resource string

Remarks

Using a minimal derivation from this class, you can make your own resource dll that will be picked up by NetServer and inserted into the provider stack. This base class contains sufficient implementation of the whole IResourceProvider interface.

A derivation of the following form is enough:
namespace SuperOffice.SM.Resources
{
	[ResourceProvider("SuperOffice.SM.Resources", int.MaxValue / 2)]
	public class SuperOfficeResourceDllProvider : ResourceDllProviderBase
	{
		public SuperOfficeResourceDllProvider()
			: base(Assembly.GetExecutingAssembly(), ".ResourceStrings")
		{
		}
	}
}	
The name of the provider, declared in the ResourceProvider attribute, should be of a form that ensures uniqueness, <Company>.<Product> is suggested. The priority value can be left at int.MaxValue/2 unless the purpose of the provider is to override existing providers with new values; in that case a numerically lower value will ensure that this provider is called first.

The ".ResourceStrings" constant reflects the name of the resource XML structure, and corresponds to the name of the .resx files in the project.

GetSupportedLanguages()

Scan currently loaded assemblies that have the same name as this one, and return the set of cultures (excluding the fallback invariant culture)

Declaration
public virtual CultureInfo[] GetSupportedLanguages()
Returns
Type Description
CultureInfo[]
Remarks

Resource satellite assembly loading works in different ways depending on your execution model. When running as a web application, IIS will shadow-cache and preload all assemblies; this means that all cultures are loaded and we can scan the AppDomain. On the other hand, the file/folder structure of the satellite assemblies is lost.

When running as a "normal" application, the .NET ResourceManager will load satellite assemblies as needed - so looking at the AppDomain will not tell us much beyond the current and fallback cultures. In this case we need to do a directory scan to determine what other cultures actually exist.

GetUnfilteredResourceForCulture(String, String)

Returns the unfiltered string from this provider in the specified culture

Declaration
public string GetUnfilteredResourceForCulture(string name, string cultureName)
Parameters
Type Name Description
String name

The name of the resource/resource symbol

String cultureName

The name of the culture in the form en-US, nb-NO

Returns
Type Description
String

The unfiltered resource string, or null if not found

Remarks

Using a minimal derivation from this class, you can make your own resource dll that will be picked up by NetServer and inserted into the provider stack. This base class contains sufficient implementation of the whole IResourceProvider interface.

A derivation of the following form is enough:
namespace SuperOffice.SM.Resources
{
	[ResourceProvider("SuperOffice.SM.Resources", int.MaxValue / 2)]
	public class SuperOfficeResourceDllProvider : ResourceDllProviderBase
	{
		public SuperOfficeResourceDllProvider()
			: base(Assembly.GetExecutingAssembly(), ".ResourceStrings")
		{
		}
	}
}	
The name of the provider, declared in the ResourceProvider attribute, should be of a form that ensures uniqueness, <Company>.<Product> is suggested. The priority value can be left at int.MaxValue/2 unless the purpose of the provider is to override existing providers with new values; in that case a numerically lower value will ensure that this provider is called first.

The ".ResourceStrings" constant reflects the name of the resource XML structure, and corresponds to the name of the .resx files in the project.

GetUnfilteredResourcesForCulture(String)

Returns all resource strings for the specified culture as a dictionary

Declaration
public Dictionary<string, string> GetUnfilteredResourcesForCulture(string cultureName)
Parameters
Type Name Description
String cultureName

The name of the culture in the form en-US, nb-NO

Returns
Type Description
Dictionary<String, String>

Dictionary of all resource labels and values

Remarks

Using a minimal derivation from this class, you can make your own resource dll that will be picked up by NetServer and inserted into the provider stack. This base class contains sufficient implementation of the whole IResourceProvider interface.

A derivation of the following form is enough:
namespace SuperOffice.SM.Resources
{
	[ResourceProvider("SuperOffice.SM.Resources", int.MaxValue / 2)]
	public class SuperOfficeResourceDllProvider : ResourceDllProviderBase
	{
		public SuperOfficeResourceDllProvider()
			: base(Assembly.GetExecutingAssembly(), ".ResourceStrings")
		{
		}
	}
}	
The name of the provider, declared in the ResourceProvider attribute, should be of a form that ensures uniqueness, <Company>.<Product> is suggested. The priority value can be left at int.MaxValue/2 unless the purpose of the provider is to override existing providers with new values; in that case a numerically lower value will ensure that this provider is called first.

The ".ResourceStrings" constant reflects the name of the resource XML structure, and corresponds to the name of the .resx files in the project.

Initialize()

Initialize resources.

Declaration
public virtual void Initialize()
Remarks

Using a minimal derivation from this class, you can make your own resource dll that will be picked up by NetServer and inserted into the provider stack. This base class contains sufficient implementation of the whole IResourceProvider interface.

A derivation of the following form is enough:
namespace SuperOffice.SM.Resources
{
	[ResourceProvider("SuperOffice.SM.Resources", int.MaxValue / 2)]
	public class SuperOfficeResourceDllProvider : ResourceDllProviderBase
	{
		public SuperOfficeResourceDllProvider()
			: base(Assembly.GetExecutingAssembly(), ".ResourceStrings")
		{
		}
	}
}	
The name of the provider, declared in the ResourceProvider attribute, should be of a form that ensures uniqueness, <Company>.<Product> is suggested. The priority value can be left at int.MaxValue/2 unless the purpose of the provider is to override existing providers with new values; in that case a numerically lower value will ensure that this provider is called first.

The ".ResourceStrings" constant reflects the name of the resource XML structure, and corresponds to the name of the .resx files in the project.

Implements

IResourceProvider
ISearchableResourceProvider
IUnfilteredResourceProvider

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top