Interface ISharedObjects
Implemented by the framework to provide access to objects that have been published in order to be shared across components used for content processing. Components that are 'interested' in shared objects receive an instance of this interface by implementing ISharedObjectsAware.
Namespace: SdlSdl.FileTypeSupportFrameworkNativeApi
Assembly: Sdl.FileTypeSupport.Framework.Core.dll
Syntax
public interface ISharedObjects
Remarks
Shared objects can be accessed directly using a key (an id), or by iterating over the collection. The SharedObjectPublished event is raised if additional shared objects are published. Any component can publish shared objects by calling PublishSharedObject(string, object, IdConflictResolution).
Shared objects can be used for a number of purposes. Below are some examples:
The host application may pass a translation memory interface as a shared object to the components used for processing a file. A file type supporting 3rd party XLIFF may look for such an object, and if found, use it to populate the translation memory with embedded translation suggestions from >alt-trans< elements in the XLIFF file.
SDL Trados Studio may want to pass settings bundles to file processing components. Publishing the settings bundle as a shared object will make it available to any file type components that implement this interface. Components can query for the settings bundle, and if found, they can then use it.
A native content processor may communicate information to a native parser via a shared object.
Properties
SharedObjectIds
Iterator for the ids of all currently published shared objects
Declaration
IEnumerable<string> SharedObjectIds { get; }
Property Value
Type | Description |
---|---|
IEnumerablestring |
SharedObjects
Iterator for all currently published shared objects
Declaration
IEnumerable<object> SharedObjects { get; }
Property Value
Type | Description |
---|---|
IEnumerableobject |
SharedObjectsWithIds
Iterator for all currently published shared objects and their associated ids as key/value pairs, in which the id acts as the key.
Declaration
IEnumerable<KeyValuePair<string, object>> SharedObjectsWithIds { get; }
Property Value
Type | Description |
---|---|
IEnumerableKeyValuePairstringobject |
Methods
GetSharedObject<T>(string)
Gets the shared object with the specified id; cast to the specified type. If no object with this id is shared, the method returns null. If an object with the specified id exists, but is not of the specified type, an exception is thrown.
Declaration
T GetSharedObject<T>(string id)
Parameters
Type | Name | Description |
---|---|---|
string | id |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
PublishSharedObject(string, object, IdConflictResolution)
Any component may publish objects to be shared by calling this method. The object will be added to the available shared objects, and the SharedObjectPublished event will be raised.
Declaration
void PublishSharedObject(string id, object toBeShared, IdConflictResolution conflictingIdResolution)
Parameters
Type | Name | Description |
---|---|---|
string | id | Unique identifier for the object to be shared. If an object with this id is already shared, the conflict resolution parameter determines what happens. |
object | toBeShared | May be |
IdConflictResolution | conflictingIdResolution | Indicates what should happen if an object with the same id is already shared. |
Events
SharedObjectPublished
Raised if an additional object is published by some component.
Declaration
event EventHandler<SharedObjectPublishedEventArgs> SharedObjectPublished
Event Type
Type | Description |
---|---|
EventHandlerSharedObjectPublishedEventArgs |