Westwind.Globalization
DbRes.WriteResource for objects?
Gravatar is a globally recognized avatar based on your email address. DbRes.WriteResource for objects?
  Chris
  All
  Aug 7, 2019 @ 03:49pm

Is there a method to write objects like an image to localization? There is only one for string that I see. I can read the image file fine using DbRes.TObject(Id, Images) as byte[];

Thanks!

Gravatar is a globally recognized avatar based on your email address. re: DbRes.WriteResource for objects?
  Rick Strahl
  Chris
  Aug 9, 2019 @ 09:54pm

The IResourceWriter implementations have an object overload for the data parameter that you should be able to use to pass in binary data. Also the data manager has explicit methods for saving data of various types.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: DbRes.WriteResource for objects?
  Chris
  Rick Strahl
  Aug 13, 2019 @ 03:11pm

IResourceWriter? didn't see that anywhere. I used DbResourceDataManager.UpdateOrAddResource. But the method GetResourceItem returns null all the time, so how can I get all the metadata for the file like filename, etc?

Gravatar is a globally recognized avatar based on your email address. re: DbRes.WriteResource for objects?
  Rick Strahl
  Chris
  Aug 14, 2019 @ 09:11am

Hi Chris,

I'm confused what you are asking. DbResourceDataManager.UpdateOrAddResource lets you write the value, so that's working? Wasn't that the original question?

You should be able to use DbResourceManager.GetResourceItem() to retrieve the value assuming it's been added to the database (check the Db to make sure). If that's not working making sure the resourceId and resourceSet match exactly.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: DbRes.WriteResource for objects?
  Chris
  Rick Strahl
  Aug 14, 2019 @ 09:52am

Ok. Here is the db records in the localization table:

Id's 3 and 4 are from your localization UI site. I was using GetResourceObject, which always returns null, so now I just tried the GetResourceItem, and it works, Thanks! And, realized I wasn't setting the valuetype field to 1, and didn't set the value field. Should I set the value field, or does that matter? Thanks Rick!

Gravatar is a globally recognized avatar based on your email address. re: DbRes.WriteResource for objects?
  Rick Strahl
  Chris
  Aug 15, 2019 @ 04:17pm

The value field is auto-set with the type info of the binary data. You shouldn't set the value because if that data is not there the data probably can't be reserialized properly. This behavior matches what is stored in Resx files so there's a good reason for the exact format that is used.

The ValueType comes from an enum and is required to indicate this field is a non-text/binary resource.

+++ Rick ---

© 1996-2019