Value(Id: String): IIOStream;
Value[Id: string]: Prognoz.Platform.Interop.ForeIO.IIOStream;
Id. Image identifier.
The Value property determines a resource editor image, which identifier is passed by the Id parameter.
Image identifier is case-sensitive.
Executing the example requires that the repository contains resources with the APP_RESOURCE identifier containing an image with the main_img identifier. These resources contain default language as Russian and translation language as English.
The file system must contain the following files: c:\ru.png and c:\en.png.
Add links to the IO, Metabase system assemblies.
Sub UserProc;
Var
mb: IMetabase;
Resource: IResourceObject;
Binares: IResourceBinaries;
Locales: IResourceLocales;
Locale: IResourceLocale;
FileImg: IFileInfo;
BinR: IBinaryReader;
Stream: IIOStream;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get resources
Resource := mb.ItemById("APP_RESOURCE").Edit As IResourceObject;
// Get resource languages collection
Locales := Resource.Locales;
// Get default language
Locale := Locales.DefaultLocale;
// Get images for default language
Binares := Locale.Binaries;
// Get file with new image for default language
FileImg := New FileInfo.Attach("c:\ru.png");
If FileImg.Exists Then
BinR := FileImg.OpenBinaryReader;
Stream := BinR.Stream;
// Replace image for default language
Binares.Value("main_img") := Stream;
End If;
// Get the current translation language
Locale := Locales.CurrentLocale;
// Get images for translation language
Binares := Locale.Binaries;
// Get file with new image for translation language
FileImg := New FileInfo.Attach("c:\en.png");
If FileImg.Exists Then
BinR := FileImg.OpenBinaryReader;
Stream := BinR.Stream;
// Replace image for translation language
Binares.Value("main_img") := Stream;
End If;
Dispose FileImg;
// Save changes
(Resource As IMetabaseObject).Save;
End Sub UserProc;
After executing the example default language value and translation language value are set for the main_img image.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.ForeIO;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
Resource: IResourceObject;
Binares: IResourceBinaries;
Locales: IResourceLocales;
Locale: IResourceLocale;
FileImg: IFileInfo;
BinR: IBinaryReader;
Stream: IIOStream;
Begin
// Get current repository
mb := Params.Metabase;
// Get resources
Resource := mb.ItemById["APP_RESOURCE"].Edit() As IResourceObject;
// Get resource languages collection
Locales := Resource.Locales;
// Get default language
Locale := Locales.DefaultLocale;
// Get images for default language
Binares := Locale.Binaries;
// Get file with new image for default language
FileImg := New FileInfoClass.Create();
FileImg.Attach("c:\ru.png");
If FileImg.Exists Then
BinR := FileImg.OpenBinaryReader();
Stream := BinR.Stream;
// Replace image for default language
Binares.Value["main_img"] := Stream;
End If;
// Get the current translation language
Locale := Locales.CurrentLocale;
// Get images for translation language
Binares := Locale.Binaries;
// Get file with new image for translation language
FileImg := New FileInfoClass.Create();
FileImg.Attach("c:\en.png");
If FileImg.Exists Then
BinR := FileImg.OpenBinaryReader();
Stream := BinR.Stream;
// Replace image for translation language
Binares.Value["main_img"] := Stream;
End If;
// Save changes
(Resource As IMetabaseObject).Save();
End Sub;
See also: