/// /// Copyright © 2003-2008 JetBrains s.r.o. /// You may distribute under the terms of the GNU General Public License, as published by the Free Software Foundation, version 2 (see License.txt in the repository root folder). /// using System; using System.Collections; using System.Diagnostics; using System.IO; using System.Runtime.Serialization; using System.Security.Permissions; namespace JetBrains.Omea.OpenAPI { /// /// Specifies the data type of a property. /// public enum PropDataType { /// /// Values of the property are 32-bit integers. /// Int, /// /// Values of the property are Unicode strings. /// String, /// /// Values of the property are values. /// Date, /// /// Values of the property are links to other resources. /// Link, /// /// Values of the property are BLOBs (binary large objects), accessible as /// read-write streams. /// Blob, /// /// Values of the property are double precision floating-point values. /// Double, /// /// Values of the property are Unicode strings which cannot be used in /// searches by value (for example, text of email messages). /// LongString, /// /// Values of the property are boolean (true/false). /// Bool, /// /// Values of the property are variable-sized lists of strings which /// preserve the ordering. /// StringList }; public class PropDataTypeGeneric { private PropDataType _type; internal PropDataTypeGeneric(PropDataType type) { _type = type; } public PropDataType Type { get { return _type; } } } public class PropDataTypes { public static readonly PropDataTypeGeneric Int = new PropDataTypeGeneric(PropDataType.Int); public static readonly PropDataTypeGeneric String = new PropDataTypeGeneric(PropDataType.String); public static readonly PropDataTypeGeneric DateTime = new PropDataTypeGeneric(PropDataType.Date); public static readonly PropDataTypeGeneric Link = new PropDataTypeGeneric(PropDataType.Link); public static readonly PropDataTypeGeneric Blob = new PropDataTypeGeneric(PropDataType.Blob); public static readonly PropDataTypeGeneric Double = new PropDataTypeGeneric(PropDataType.Double); public static readonly PropDataTypeGeneric LongString = new PropDataTypeGeneric(PropDataType.LongString); public static readonly PropDataTypeGeneric Bool = new PropDataTypeGeneric(PropDataType.Bool); public static readonly PropDataTypeGeneric StringList = new PropDataTypeGeneric(PropDataType.StringList); } /// /// Specifies the special attributes of a property type. /// [Flags] public enum PropTypeFlags { /// /// The property type has no special attributes. /// Normal = 0, /// /// Properties of the type are internal to the system and are never shown to /// the user by the core UI components. /// Internal = 1, /// /// Properties of the type link a contact to its accounts (email, ICQ and others). /// The flag can only be set on link properties. /// ContactAccount = 2, /// /// Properties of the type are directed links. The flag can only be set on link /// properties. /// DirectedLink = 4, /// /// Properties of the type link resources which can be unread to containers which /// maintain unread counts. Changing the IsUnread property of the resource on one /// end of the link increments or decrements the UnreadCount property of the resource /// on the other end of the link. The flag can only be set on link properties. /// CountUnread = 16, /// /// Properties of the type are never included in the XML serialization of resources. /// NoSerialize = 32, /// /// The user is prompted whether the properties of the type should be included in the /// XML serialization of resources. The flag can only be set on non-link properties /// (the prompting behavior is the default for link properties). /// AskSerialize = 64, /// /// Properties of the type link a file format resource (TXT, HTML, PDF and so on) /// to a resource which provides the stream from which the format resource is /// loaded (file folder, email attachment, cached file from the Web and so on). /// The flag can only be set on link properties. /// SourceLink = 128, /// /// Properties of the type can only be returned by virtual property providers and never exist /// on actual resources. /// Virtual = 256 } /// /// Specifies the special attributes of a property type. /// [Flags] public enum ResourceTypeFlags { /// /// The property type has no special attributes. /// Normal = 0, /// /// Resources of the type are internal to the system and are never shown to /// the user by the core UI components. /// Internal = 1, /// /// Resources of the type can have Parent links from other resources, and thus /// can be expanded in the resource tree views. /// ResourceContainer = 2, /// /// Resources of the type never provide text which is indexed by the full-text /// indexer. /// NoIndex = 4, /// /// Resources of the type can be unread (have the IsUnread property set). /// CanBeUnread = 8, /// /// Resources of the type are file format resources (TXT, HTML, PDF and so on), /// which get their content streams from stream provider resources. /// FileFormat = 16 } /// /// Represents a single property type registered in the resource store. /// public interface IPropType { /// /// Gets the numeric ID of the property type. /// int Id { get; } /// /// Gets the internal (non-localized) name of the property type. /// string Name { get; } /// /// The data type of the property type. /// PropDataType DataType { get; } /// /// Gets or sets the flags of the property type. /// PropTypeFlags Flags { get; set; } /// /// The user-visible name of the property type, or the name displayed at the "From" end /// of a directed link. /// string DisplayName { get; } /// /// For directed links - the name displayed at the "To" end of a directed link. /// string ReverseDisplayName { get; } /// /// Gets the value signifying whether the plugin owning the property type is loaded. /// /// true if no owner plugin has been assigned for the property type or if /// at least one of the owner plugins is loaded; false otherwise. bool OwnerPluginLoaded { get; } /// /// Checks if the property type has the specified flag. /// /// The flag to check. /// true if the property type has the flag, false otherwise. bool HasFlag( PropTypeFlags flag ); } /// /// The collection of all property types registered in the resource store. /// public interface IPropTypeCollection: IEnumerable { /// /// Returns the property type with the specified ID. /// IPropType this [int id] { get; } /// /// Returns the property type with the specified name. /// IPropType this [string name] { get; } /// /// Returns the count of property types registered in the resource store. /// int Count { get; } /// /// Checks if all property types in the specified list are registered. /// /// The name or names of property types to check. /// true if all the specified property type names are registered, false otherwise. bool Exist( params string[] propNames ); /// /// Registers a new property type with the default flags. /// /// The name of the property type to register. /// The data type of the property. /// The ID of the property type. /// If a property type with the specified name already exists, the function /// checks if it is compatible with the existing definition. If the data type does not match, /// an exception is thrown. /// To avoid conflicts with properties used by Omea core and standard plugins, /// it is recommended to prefix the names of the plugin-defined properties with the domain /// name of the plugin Web site (for example, com.jetbrains.Name). /// Standard properties do not have any dotted prefixes. Custom properties defined by the /// user have the prefix Custom. int Register( string name, PropDataType dataType ); PropId Register(string name, PropDataTypeGeneric dataType); /// /// Registers a new property type with the specified flags. /// /// The name of the property type to register. /// The data type of the property. /// The flags of the property type. /// The ID of the property type. /// If a property type with the specified name already exists, the function /// checks if it is compatible with the existing definition. If the data type does not match, /// an exception is thrown. If the flags do not match, the existing flags are ORed with /// the flags specified as the method parameter. /// To avoid conflicts with properties used by Omea core and standard plugins, /// it is recommended to prefix the names of the plugin-defined properties with the domain /// name of the plugin Web site (for example, com.jetbrains.Name). /// Standard properties do not have any dotted prefixes. Custom properties defined by the /// user have the prefix Custom. int Register( string name, PropDataType dataType, PropTypeFlags flags ); PropId Register(string name, PropDataTypeGeneric dataType, PropTypeFlags flags); /// /// Registers a new property type with the specified flags and owner plugin. /// /// The name of the property type to register. /// The data type of the property. /// The flags of the property type. /// The plugin which owns the property type. The property type /// and the properties of that type will be hidden from several places in the program /// interface if the owner plugin is not loaded. /// The ID of the property type. /// If a property type with the specified name already exists, the function /// checks if it is compatible with the existing definition. If the data type does not match, /// an exception is thrown. If the flags do not match, the existing flags are ORed with /// the flags specified as the method parameter. /// To avoid conflicts with properties used by Omea core and standard plugins, /// it is recommended to prefix the names of the plugin-defined properties with the domain /// name of the plugin Web site (for example, com.jetbrains.Name). /// Standard properties do not have any dotted prefixes. Custom properties defined by the /// user have the prefix Custom. int Register( string name, PropDataType dataType, PropTypeFlags flags, IPlugin ownerPlugin ); PropId Register(string name, PropDataTypeGeneric dataType, PropTypeFlags flags, IPlugin ownerPlugin); /// /// Registers a user-visible name for a property type. /// /// The ID of the property type for which the display name /// is registered. /// The display name to be used for the property. /// This overload should be used for non-link properties and for not directed /// links. For directed links, the /// three-parameter overload must be used. void RegisterDisplayName( int propId, string displayName ); void RegisterDisplayName(PropId propId, string displayName); /// /// Registers a user-visible name for a directed link property type. /// /// The ID of the property type for which the display name /// is registered. /// The display name shown at the source end of the /// link. /// The display name shown at the target end of the /// link. void RegisterDisplayName( int propId, string fromDisplayName, string toDisplayName ); void RegisterDisplayName(PropId propId, string fromDisplayName, string toDisplayName); /// /// Deletes a property type. /// /// The ID of the property type to delete. /// Deleting a property type deletes all properties of that type. void Delete( int id ); /// /// Returns the display name for the property with the specified ID. /// /// ID of the property for which the display name is checked. /// The display name of the property. /// If is negative and specifies the ID of a /// directed link property, the display name for the link target end is returned. string GetPropDisplayName( int propId ); } /// /// Represents a single resource type registered in the resource store. /// public interface IResourceType { /// /// Gets the numeric ID of the resource type. /// int Id { get; } /// /// Gets the internal (non-localized) name of the resource type. /// /// This is the string which is used as "resource type" parameter for all core /// methods. string Name { get; } /// /// Gets the user-visible name of the resource type. /// /// By default, returns the same string as . string DisplayName { get; set; } /// /// Gets or sets the resource display name template of the resource type. /// string ResourceDisplayNameTemplate { get; set; } /// /// Gets the flags of the resource type. /// ResourceTypeFlags Flags { get; set; } /// /// Gets the value signifying whether the plugin owning the resource type is loaded. /// /// true if no owner plugin has been assigned for the resource type or if /// at least one of the owner plugins is loaded; false otherwise. bool OwnerPluginLoaded { get; } /// /// Checks if the resource type has the specified flag. /// /// The flag to check. /// true if the resource type has the flag, false otherwise. bool HasFlag( ResourceTypeFlags flag ); } /// /// The collection of all resource types registered in the resource store. /// public interface IResourceTypeCollection: IEnumerable { /// /// Returns the resource type with the specified ID. /// IResourceType this [int id] { get; } /// /// Returns the resource type with the specified name. /// IResourceType this [string name] { get; } /// /// Returns the count of resource types registered in the resource store. /// int Count { get; } /// /// Checks if all resource types in the specified list are registered. /// /// The name or names of resource types to check. /// true if all the specified resource type names are registered, false otherwise. bool Exist( params string[] resourceTypeNames ); /// /// Registers a new resource type with the default flags. /// /// The name of the resource type to register. /// The template for building display names /// of resources having that type. /// The ID of the registered resource type. /// If a resource type with the specified name already exists, the function /// checks if it is compatible with the existing definition. If the display name template /// does not match, an exception is thrown. /// To avoid conflicts with resource types used by Omea core and standard plugins, /// it is recommended to prefix the names of the plugin-defined resource types with the domain /// name of the plugin Web site (for example, com.jetbrains.Email). /// Standard resource types do not have any dotted prefixes. /// The display name template is a space-separated list of property names from which /// the display names of resources are constructed. The display name template can contain /// several alternatives, separated with the | character. Alternatives are evaluated in sequence, /// until one is found which produces a non-empty result. For example, if the display name /// template is FirstName LastName | EmailAcct, the display name of the resource will /// be composed of the values of FirstName and LastName properties if /// at least one of these properties is set, or of the value of the EmailAcct property /// if neither first name or last name are specified. /// If a link property is used in a display name template, it is evaluated as the display /// name of the resource on the other end of the link (or the names of all resources on the other /// end of the link, separated with commas). /// All property types referenced in the display name template must be registered before /// the resource type is registered. int Register( string name, string resourceDisplayNameTemplate ); /// /// Registers a new resource type with the specified flags. /// /// The name of the resource type to register. /// The template for building display names /// of resources having that type. /// The flags of the resource type. /// The ID of the registered resource type. /// If a resource type with the specified name already exists, the function /// checks if it is compatible with the existing definition. If the display name template /// does not match, an exception is thrown. If the flags do not match, the existing flags /// are ORed with the flags specified as the method parameter. /// To avoid conflicts with resource types used by Omea core and standard plugins, /// it is recommended to prefix the names of the plugin-defined resource types with the domain /// name of the plugin Web site (for example, com.jetbrains.Email). /// Standard resource types do not have any dotted prefixes. /// The display name template is a space-separated list of property names from which /// the display names of resources are constructed. The display name template can contain /// several alternatives, separated with the | character. Alternatives are evaluated in sequence, /// until one is found which produces a non-empty result. For example, if the display name /// template is FirstName LastName | EmailAcct, the display name of the resource will /// be composed of the values of FirstName and LastName properties if /// at least one of these properties is set, or of the value of the EmailAcct property /// if neither first name or last name are specified. /// If a link property is used in a display name template, it is evaluated as the display /// name of the resource on the other end of the link (or the names of all resources on the other /// end of the link, separated with commas). /// All property types referenced in the display name template must be registered before /// the resource type is registered. int Register( string name, string resourceDisplayNameTemplate, ResourceTypeFlags flags ); /// /// Registers a new resource type with the default flags and the specified user-visible name. /// /// The name of the resource type to register. /// The user-visible name of the resource type. /// The template for building display names /// of resources having that type. /// The ID of the registered resource type. /// If a resource type with the specified name already exists, the function /// checks if it is compatible with the existing definition. If the display name template /// does not match, an exception is thrown. /// To avoid conflicts with resource types used by Omea core and standard plugins, /// it is recommended to prefix the names of the plugin-defined resource types with the domain /// name of the plugin Web site (for example, com.jetbrains.Email). /// Standard resource types do not have any dotted prefixes. /// The display name template is a space-separated list of property names from which /// the display names of resources are constructed. The display name template can contain /// several alternatives, separated with the | character. Alternatives are evaluated in sequence, /// until one is found which produces a non-empty result. For example, if the display name /// template is FirstName LastName | EmailAcct, the display name of the resource will /// be composed of the values of FirstName and LastName properties if /// at least one of these properties is set, or of the value of the EmailAcct property /// if neither first name or last name are specified. /// If a link property is used in a display name template, it is evaluated as the display /// name of the resource on the other end of the link (or the names of all resources on the other /// end of the link, separated with commas). /// All property types referenced in the display name template must be registered before /// the resource type is registered. int Register( string name, string displayName, string resourceDisplayNameTemplate ); /// /// Registers a new resource type with the specified flags and user-visible name. /// /// The name of the resource type to register. /// The user-visible name of the resource type. /// The template for building display names /// of resources having that type. /// The flags of the resource type. /// The ID of the registered resource type. /// If a resource type with the specified name already exists, the function /// checks if it is compatible with the existing definition. If the display name template /// does not match, an exception is thrown. If the flags do not match, the existing flags /// are ORed with the flags specified as the method parameter. /// To avoid conflicts with resource types used by Omea core and standard plugins, /// it is recommended to prefix the names of the plugin-defined resource types with the domain /// name of the plugin Web site (for example, com.jetbrains.Email). /// Standard resource types do not have any dotted prefixes. /// The display name template is a space-separated list of property names from which /// the display names of resources are constructed. The display name template can contain /// several alternatives, separated with the | character. Alternatives are evaluated in sequence, /// until one is found which produces a non-empty result. For example, if the display name /// template is FirstName LastName | EmailAcct, the display name of the resource will /// be composed of the values of FirstName and LastName properties if /// at least one of these properties is set, or of the value of the EmailAcct property /// if neither first name or last name are specified. /// If a link property is used in a display name template, it is evaluated as the display /// name of the resource on the other end of the link (or the names of all resources on the other /// end of the link, separated with commas). /// All property types referenced in the display name template must be registered before /// the resource type is registered. int Register( string name, string displayName, string resourceDisplayNameTemplate, ResourceTypeFlags flags ); /// /// Registers a new resource type with the specified flags, user-visible name /// and owner plugin. /// /// The name of the resource type to register. /// The user-visible name of the resource type. /// The template for building display names /// of resources having that type. /// The flags of the resource type. /// The plugin which owns the resource type. The resource type /// and the resources of that type will be hidden from several places in the program /// interface if the owner plugin is not loaded. /// The ID of the registered resource type. /// If a resource type with the specified name already exists, the function /// checks if it is compatible with the existing definition. If the display name template /// does not match, an exception is thrown. If the flags do not match, the existing flags /// are ORed with the flags specified as the method parameter. /// To avoid conflicts with resource types used by Omea core and standard plugins, /// it is recommended to prefix the names of the plugin-defined resource types with the domain /// name of the plugin Web site (for example, com.jetbrains.Email). /// Standard resource types do not have any dotted prefixes. /// The display name template is a space-separated list of property names from which /// the display names of resources are constructed. The display name template can contain /// several alternatives, separated with the | character. Alternatives are evaluated in sequence, /// until one is found which produces a non-empty result. For example, if the display name /// template is FirstName LastName | EmailAcct, the display name of the resource will /// be composed of the values of FirstName and LastName properties if /// at least one of these properties is set, or of the value of the EmailAcct property /// if neither first name or last name are specified. /// If a link property is used in a display name template, it is evaluated as the display /// name of the resource on the other end of the link (or the names of all resources on the other /// end of the link, separated with commas). /// All property types referenced in the display name template must be registered before /// the resource type is registered. int Register( string name, string displayName, string resourceDisplayNameTemplate, ResourceTypeFlags flags, IPlugin ownerPlugin ); /// /// Deletes the resource type with the specified name. /// /// The name of the resource type to delete. /// Deleting a resource type deletes all resources with that type. void Delete( string name ); } /// /// Specifies the update notification mode of a resource list. /// public enum SelectionType { /// /// Indicates that no update notifications are sent for the resource list after /// it has been instantiated. /// Normal, /// /// Indicates that all changes in a resource list (new resources, deleted resources, /// resource changes) cause update notifications to be sent for the resource list. /// Live, /// /// Applies only to resource lists which have been returned by one of the /// family /// of methods. Indicates that all changes in a resource list cause update /// notifications to be sent, with one exception: changes of the property /// by which the selection was made never cause the resources to be deleted from /// the list, even if the new property value no longer matches the selection /// condition. /// LiveSnapshot }; /// /// The main interface for creating and accessing resources. /// /// At most times when Omea is running (except for the time when the /// method is called), only one thread is designated /// as the resource store write thread, and all operations that modify the resource store /// (creating resources, changing resource properties, deleting resources) must be executed /// in that thread. The class provides an easy way to run a resource write /// operation synchronously or asynchronously. public interface IResourceStore { /// /// Returns the ID of the property with the specified name. /// /// Name of the property to look up. /// The ID of the property with the specified name. /// If no property with that name has been registered, an exception /// is thrown. int GetPropId( string name ); /// /// Returns the collection of all property types registered in the resource store. /// IPropTypeCollection PropTypes { get; } /// /// Returns the collection of all resource types registered in the resource store. /// IResourceTypeCollection ResourceTypes { get; } /// /// Creates a new resource of the specified type. /// /// The type of the resource to create. /// The new resource instance. IResource NewResource( string type ); /// /// Creates a new resource of the specified type and begins a batch update operation for it. /// /// The type of the resource to create. /// The new resource instance. /// After the initial properties are set, must /// be called. Only after that notifications about the resource creation will be processed. /// IResource BeginNewResource( string type ); /// /// Creates a new in-memory resource of the specified type. /// /// The type of the resource to create. /// The new resource instance. /// The resource exists only in the memory, and is not returned by any queries, /// until the method is called. Transient resources /// can be created, modified and deleted in any thread (since all these operations are /// performed in memory and do not involve any actual resource store modifications), but /// the must be run in the resource store write thread. IResource NewResourceTransient( string type ); /// /// Returns the existing resource with the specified ID. /// /// The ID of the resource to load. /// The instance of the resource. /// If the resource exists in the resource cache, the cached copy is /// returned. Otherwise, the resource is loaded from the disk. /// IResource LoadResource( int id ); /// /// Returns the resource with the specified ID if the resource is valid, or null /// if the resource with the specified ID has been deleted or no longer exists. /// /// The ID of the resource to load. /// The instance of the resource or null. /// 1.0.2 IResource TryLoadResource( int id ); /// /// Returns the non-live list of resources for which the property with the specified ID /// has the specified value. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The ID of the property for which the selection is done. /// The value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Selection on bool properties is only supported if is true. /// Selection on link, long string, double and blob properties is not supported. IResourceList FindResources( string resType, int propId, object propValue ); /// /// Returns the non-live list of resources for which the property with the specified name /// has the specified value. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The name of the property for which the selection is done. /// The value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Selection on bool properties is only supported if is true. /// Selection on link, long string, double and blob properties is not supported. IResourceList FindResources( string resType, string propName, object propValue ); IResourceList FindResources(string resType, PropId propId, T propValue); BusinessObjectList FindResources(ResourceTypeId resType, PropId propId, V propValue) where T : BusinessObject; /// /// Returns the live list of resources for which the property with the specified ID /// has the specified value. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The ID of the property for which the selection is done. /// The value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Selection on bool properties is only supported if is true. /// Selection on link, long string, double and blob properties is not supported. IResourceList FindResourcesLive( string resType, int propId, object propValue ); /// /// Returns the live list of resources for which the property with the specified name /// has the specified value. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The name of the property for which the selection is done. /// The value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Selection on bool properties is only supported if is true. /// Selection on link, long string, double and blob properties is not supported. IResourceList FindResourcesLive( string resType, string propName, object propValue ); IResourceList FindResourcesLive(string resType, PropId propName, T propValue); /// /// Returns an optionally live list of resources for which the property with the specified ID /// has the specified value. /// /// Type of the selection (non-live, live or live snapshot). /// The type of resources to return, or null if resources of /// any type should be returned. /// The ID of the property for which the selection is done. /// The value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Selection on bool properties is only supported if is true. /// Selection on link, long string, double and blob properties is not supported. IResourceList FindResources( SelectionType selectionType, string resType, int propId, object propValue ); /// /// Returns an optionally live list of resources for which the property with the specified name /// has the specified value. /// /// Type of the selection (non-live, live or live snapshot). /// The type of resources to return, or null if resources of /// any type should be returned. /// The name of the property for which the selection is done. /// The value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Selection on bool properties is only supported if is true. /// Selection on link, long string, double and blob properties is not supported. IResourceList FindResources( SelectionType selectionType, string resType, string propName, object propValue ); /// /// Returns the non-live list of resources for which the property with the specified ID /// has a value in the specified range. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The ID of the property for which the selection is done. /// The minimum matching value of the property. /// The maximum matching value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Range selection is only supported for int and date properties. IResourceList FindResourcesInRange( string resType, int propId, object minValue, object maxValue ); /// /// Returns the non-live list of resources for which the property with the specified name /// has a value in the specified range. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The name of the property for which the selection is done. /// The minimum matching value of the property. /// The maximum matching value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Range selection is only supported for int and date properties. IResourceList FindResourcesInRange( string resType, string propName, object minValue, object maxValue ); /// /// Returns the live list of resources for which the property with the specified ID /// has a value in the specified range. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The ID of the property for which the selection is done. /// The minimum matching value of the property. /// The maximum matching value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Range selection is only supported for int and date properties. IResourceList FindResourcesInRangeLive( string resType, int propId, object minValue, object maxValue ); /// /// Returns the live list of resources for which the property with the specified name /// has a value in the specified range. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The name of the property for which the selection is done. /// The minimum matching value of the property. /// The maximum matching value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Range selection is only supported for int and date properties. IResourceList FindResourcesInRangeLive( string resType, string propName, object minValue, object maxValue ); /// /// Returns an optionally live list of resources for which the property with the specified ID /// has a value in the specified range. /// /// Type of the selection (non-live, live or live snapshot). /// The type of resources to return, or null if resources of /// any type should be returned. /// The ID of the property for which the selection is done. /// The minimum matching value of the property. /// The maximum matching value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Range selection is only supported for int and date properties. IResourceList FindResourcesInRange( SelectionType selectionType, string resType, int propId, object minValue, object maxValue ); /// /// Returns an optionally live list of resources for which the property with the specified name /// has a value in the specified range. /// /// Type of the selection (non-live, live or live snapshot). /// The type of resources to return, or null if resources of /// any type should be returned. /// The name of the property for which the selection is done. /// The minimum matching value of the property. /// The maximum matching value of the property. /// The list of resources, or an empty resource list if no resources match the condition. /// Range selection is only supported for int and date properties. IResourceList FindResourcesInRange( SelectionType selectionType, string resType, string propName, object minValue, object maxValue ); /// /// Returns the non-live list of resources which have the property with the specified ID. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The ID of the property to search for. /// The list of resources which have the property. /// This method works for any property type, except for long string properties. /// It also works for link properties. /// For directed links, a resource is included in the result only if there are links /// from that resource to other resources. (If there are only links to the resource from /// other resources, it is not included.) IResourceList FindResourcesWithProp( string resType, int propId ); /// /// Returns the non-live list of resources which have the property with the specified name. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The name of the property to search for. /// The list of resources which have the property. /// This method works for any property type, except for long string properties. /// It also works for link properties. /// For directed links, a resource is included in the result only if there are links /// from that resource to other resources. (If there are only links to the resource from /// other resources, it is not included.) IResourceList FindResourcesWithProp( string resType, string propName ); IResourceList FindResourcesWithProp(string resType, PropId propId); /// /// Returns the live list of resources which have the property with the specified ID. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The ID of the property to search for. /// The list of resources which have the property. /// This method works for any property type, except for long string properties. /// It also works for link properties. /// For directed links, a resource is included in the result only if there are links /// from that resource to other resources. (If there are only links to the resource from /// other resources, it is not included.) IResourceList FindResourcesWithPropLive( string resType, int propId ); /// /// Returns the live list of resources which have the property with the specified name. /// /// The type of resources to return, or null if resources of /// any type should be returned. /// The name of the property to search for. /// The list of resources which have the property. /// This method works for any property type, except for long string properties. /// It also works for link properties. /// For directed links, a resource is included in the result only if there are links /// from that resource to other resources. (If there are only links to the resource from /// other resources, it is not included.) IResourceList FindResourcesWithPropLive( string resType, string propName ); IResourceList FindResourcesWithPropLive(string resType, PropId propId); /// /// Returns an optionally live list of resources which have the property with the specified ID. /// /// Type of the selection (non-live, live or live snapshot). /// The type of resources to return, or null if resources of /// any type should be returned. /// The ID of the property to search for. /// The list of resources which have the property. /// This method works for any property type, except for long string properties. /// It also works for link properties. /// For directed links, a resource is included in the result only if there are links /// from that resource to other resources. (If there are only links to the resource from /// other resources, it is not included.) IResourceList FindResourcesWithProp( SelectionType selectionType, string resType, int propId ); /// /// Returns an optionally live list of resources which have the property with the specified name. /// /// Type of the selection (non-live, live or live snapshot). /// The type of resources to return, or null if resources of /// any type should be returned. /// The name of the property to search for. /// The list of resources which have the property. /// This method works for any property type, except for long string properties. /// It also works for link properties. /// For directed links, a resource is included in the result only if there are links /// from that resource to other resources. (If there are only links to the resource from /// other resources, it is not included.) IResourceList FindResourcesWithProp( SelectionType selectionType, string resType, string propName ); /// /// Returns a non-live list of all resources of the specified type. /// /// The type of resources to return. /// The list of all resources of that type. IResourceList GetAllResources( string resType ); BusinessObjectList GetAllResources(ResourceTypeId resType) where T : BusinessObject; /// /// Returns a live list of all resources of the specified type. /// /// The type of resources to return. /// The list of all resources of that type. IResourceList GetAllResourcesLive( string resType ); /// /// Returns a non-live list of all resources of any of the specified types. /// /// The types of resources to return. /// The list of all resources of those types. /// 2.0 IResourceList GetAllResources( string[] resTypes ); /// /// Returns a non-live list of all resources of any of the specified types. /// /// The types of resources to return. /// The list of all resources of those types. /// 2.0 IResourceList GetAllResourcesLive( string[] resTypes ); /// /// Returns an empty resource list instance. /// IResourceList EmptyResourceList { get; } /// /// Returns an optionally live list containing the resources with the specified IDs. /// /// The resource IDs from which the list is constructed. /// If True, a live list is returned. /// The list of resources. /// Use a live list if you need to get notified when a resource with any /// of the specified IDs is changed or deleted. IResourceList ListFromIds( int[] resourceIds, bool live ); /// /// Returns an optionally live list containing the resources with the specified IDs. /// /// The resource IDs from which the list is constructed. /// If True, a live list is returned. /// The list of resources. /// Use a live list if you need to get notified when a resource with any /// of the specified IDs is changed or deleted. IResourceList ListFromIds( ICollection resourceIds, bool live ); /// /// Returns a unique resource for which the property with the specified ID has the /// specified value. /// /// Type of the resource to return, or null if a resource of /// any type should be returned. /// The ID of the property to search for. /// The value of the property. /// The resource matching the condition, or null if no resources match /// the condition. /// If multiple resources match the condition, an exception is thrown. /// In order to guarantee safe usage of the method, it is recommended to use /// to register a unique restriction for the /// resource and property types used in the call. IResource FindUniqueResource( string resType, int propId, object propValue ); /// /// Returns a unique resource for which the property with the specified name has the /// specified value. /// /// Type of the resource to return, or null if a resource of /// any type should be returned. /// The name of the property to search for. /// The value of the property. /// The resource matching the condition, or null if no resources match /// the condition. /// If multiple resources match the condition, an exception is thrown. /// In order to guarantee safe usage of the method, it is recommended to use /// to register a unique restriction for the /// resource and property types used in the call. IResource FindUniqueResource( string resType, string propName, object propValue ); /// /// Returns true if the current thread is allowed to perform resource store write /// operations. /// /// true if write operations are allowed (no write thread was assigned or /// the current thread is the write thread), false if the write operations must /// be marshalled to the write thread. /// The class can be used for easy marshalling /// of resource write operations to the resource thread. bool IsOwnerThread(); /// /// Registers a restriction on the links of the specified type for resources of the specified /// type. /// /// Type of the resource for which the restriction is registered. /// ID of the link property type for which the restriction is registered. /// The resource type which must be on the other end of the link, /// or null if the link can point to a resource of any type. /// The minimum count of links going from the resource, or 0 if there /// is no limit. /// The maximum count of links going from the resource, or /// Int32.MaxValue if there is no limit. void RegisterLinkRestriction( string fromResourceType, int linkType, string toResourceType, int minCount, int maxCount ); void RegisterLinkRestriction(string fromResourceType, PropId linkType, string toResourceType, int minCount, int maxCount); /// /// Returns the minimum link count restriction for the specified resource type and property type. /// /// Type of the resource for which the restriction is queried. /// ID of the link property type for which the restriction is queried. /// The minimum count of links, or 0 if there is no limit. int GetMinLinkCountRestriction( string fromResourceType, int linkType ); /// /// Returns the maximum link count restriction for the specified resource type and property type. /// /// Type of the resource for which the restriction is queried. /// ID of the link property type for which the restriction is queried. /// The maximum count of links, or Int32.MaxValue if there is no limit. int GetMaxLinkCountRestriction( string fromResourceType, int linkType ); /// /// Returns the target resource type restriction for links with specified property type going /// from resources of specified resource type. /// /// Type of the resource for which the restriction is queried. /// ID of the link property type for which the restriction is queried. /// The type of the resource which must be on the other end of the link, or null if /// the link can point to a resource of any type. string GetLinkResourceTypeRestriction( string fromResourceType, int linkType ); /// /// Registers a unique restriction for the specified resource type and property type. /// /// The resource type for which the restriction is registered. /// ID of the property type for which the restriction is registered. /// A unique restriction specifies that the values of the specified property are unique /// among resources of the specified type (for example, ArticleId values are unique among news articles). /// A unique restriction ensures correct operation of the method. void RegisterUniqueRestriction( string resourceType, int propId ); /// /// Deletes a unique restriction for the specified resource type and property type. /// /// The resource type for which the restriction is deleted. /// ID of the property type for which the restriction is deleted. void DeleteUniqueRestriction( string resourceType, int propId ); /// /// Registers a custom restriction for the specified resource type and property type. /// /// The resource type for which the restriction is registered. /// ID of the property type for which the restriction is registered. /// The restriction implementation. /// The restriction is checked when a new resource is created or when the specified /// property of theresource is changed. /// If the plugin which registered the restriction on a previous run of Omea is not loaded /// on the current run, all operations which would be checked by the restriction always fail. void RegisterCustomRestriction( string resourceType, int propId, IResourceRestriction restriction ); /// /// Deletes a custom restriction for the specified resource type and property type. /// /// The resource type for which the restriction is deleted. /// ID of the property type for which the restriction is deleted. void DeleteCustomRestriction( string resourceType, int propId ); /// /// Registers a custom restriction which checks the possibility to delete resources of the specified /// type. /// /// The resource type for which the restriction is registered. /// The restriction implementation. /// Restrictions on resource delete may be required to enforce that deleting resources /// of the specified type is performed through the "semantic delete" API and does not bypass it /// by deleting resources directly from the resource store. void RegisterRestrictionOnDelete( string resourceType, IResourceRestriction restriction ); /// /// Deletes a custom restriction which checks the possibility to delete resources of the specified /// type. /// /// The resource type for which the restriction is deleted. void DeleteRestrictionOnDelete( string resourceType ); /// /// Registers a custom display name provider. /// /// 2.0 void RegisterDisplayNameProvider( IDisplayNameProvider provider ); /// /// Occurs after a single property or a batch of properties of any resource /// is changed. /// event ResourcePropEventHandler ResourceSaved; /// /// Obsolete, not recommended to be used by plugins. Please use instead. /// event LinkEventHandler LinkAdded; /// /// Obsolete, not recommended to be used by plugins. Please use instead. /// event LinkEventHandler LinkDeleted; } /// /// Defines the interface of a custom resource restriction. /// /// 2.0 public interface IResourceRestriction { /// /// Checks if the specified resource matches the restriction. /// /// The resource to check. /// The method should throw an exception ( /// or an exception derived from that class) if the resource does not match the restriction. /// Custom restrictions are checked on every resource change or , /// so the code in this method must not perform any expensive checks. void CheckResource( IResource res ); } /// /// Defines the interface for a custom provider of resource display names. /// /// The custom providers are registered through . /// Custom providers are invoked after an attempt to calculate the display name based on the standard /// display name template fails (returns an empty result). /// 2.0 public interface IDisplayNameProvider { /// /// Returns the display name for the specified resource, or null if the provider cannot /// provide a display name for the resource. /// /// The resource for which the display name is requested. /// The calculated display name or null. string GetDisplayName( IResource res ); } /// /// Contains IDs for special resource properties which can be used when sorting lists. /// public class ResourceProps { /// /// The ID of a pseudo-property the value of which is equal to the type of the resource. /// public const int Type = Int32.MaxValue-1; /// /// The ID of a pseudo-property the value of which is equal to the display name of the resource. /// public const int DisplayName = Int32.MaxValue-2; /// /// The ID of a pseudo-property the value of which is equal to the ID of the resource. /// public const int Id = Int32.MaxValue-3; } /// /// Specifies the type of a link change in a . /// public enum LinkChangeType { /// /// The link to the specified resource was added. /// Add, /// /// The link to the specified resource was deleted. /// Delete, /// /// The link to the specified resource was neither added nor deleted. /// None }; /// /// Describes a single change of a link in a . /// public struct LinkChange { private int _targetId; private LinkChangeType _changeType; public LinkChange( int targetId, LinkChangeType changeType ) { _targetId = targetId; _changeType = changeType; } /// /// Gets the ID of the resource the link to which was added or deleted. /// public int TargetId { get { return _targetId; } } /// /// Gets the link change type (whether the link was added or deleted). /// public LinkChangeType ChangeType { get { return _changeType; } } } /// /// Describes a batch of changes to links and properties of a resource. /// public interface IPropertyChangeSet { /// /// Checks if the change set describes the creation of a new resource. /// bool IsNewResource { get; } /// /// Checks if the changes described by the change set caused the display name /// of the resource to change. /// bool IsDisplayNameAffected { get; } /// /// Returns the list of properties affected by the change. /// /// An array of changed property IDs. int[] GetChangedProperties(); /// /// Checks if the property with the specified ID was changed. /// /// The ID of the property to check. /// true if the property was changed, false otherwise. [Obsolete] bool IsPropertyChanged( int propId ); bool IsPropertyChanged(PropId propId); /// /// Returns the value of the specified property before the change. /// /// The ID of the property to check. /// The value of the property before the change, or null if the /// property did not exist before the change. /// The method also returns null if the property was not affected /// by the change. The return value of the method for link properties is not /// defined. object GetOldValue( int propId ); /// /// Checks if the link to the specified resource was created or deleted /// in the change set. /// /// The ID of the link property to check. /// The ID of the resource the link to which /// is checked. /// The type of the change. LinkChangeType GetLinkChange( int propId, int targetId ); /// /// Returns all link changes for the specified link type. /// /// The ID of the link property for which /// the changes are checked. /// The array of link change structures, or an empty /// array if no links of the specified type were added or deleted /// in the change set. LinkChange[] GetLinkChanges( int propId ); /// /// Returns a change set which contains all the changes from this /// change set and another change set. /// /// The change set to merge the current change set with. /// The change set which is the result of the merge. IPropertyChangeSet Merge( IPropertyChangeSet other ); } /// /// Provides data for events related to a single resource. /// public class ResourceEventArgs : EventArgs { private IResource _resource; public ResourceEventArgs( IResource resource ) { _resource = resource; } public IResource Resource { get { return _resource; } } } /// /// Provides data for events related to a resource and the changes which occurred to it. /// public class ResourcePropEventArgs: EventArgs { private IResource _resource; private IPropertyChangeSet _changeSet; [DebuggerStepThrough] public ResourcePropEventArgs( IResource resource, IPropertyChangeSet changeSet ) { _resource = resource; _changeSet = changeSet; } /// /// Gets the resource to which the event is related. /// public IResource Resource { [DebuggerStepThrough] get { return _resource; } } /// /// Gets the change set describing the specific changes to the resource. /// public IPropertyChangeSet ChangeSet { [DebuggerStepThrough] get { return _changeSet; } } } /// /// Provides data for events related to a resource and its position in a list. /// public class ResourceIndexEventArgs: EventArgs { private IResource _resource; private int _index; public ResourceIndexEventArgs( IResource resource, int index ) { _resource = resource; _index = index; } /// /// Gets the resource to which the event is related. /// public IResource Resource { get { return _resource; } } /// /// Gets the index of the resource in the list to which the event is related. /// public int Index { get { return _index; } } } /// /// Provides data for events related to a resource, its position in the list /// and the changes which occurred to it. /// public class ResourcePropIndexEventArgs: EventArgs { private IResource _resource; private int _index; private IPropertyChangeSet _changeSet; public ResourcePropIndexEventArgs( IResource resource, int index, IPropertyChangeSet changeSet ) { _resource = resource; _index = index; _changeSet = changeSet; } /// /// Gets the resource to which the event is related. /// public IResource Resource { get { return _resource; } } /// /// Gets the index of the resource in the list to which the event is related. /// public int Index { get { return _index; } } /// /// Gets the change set describing the specific changes to the resource. /// public IPropertyChangeSet ChangeSet { get { return _changeSet; } } } /// /// Provides data for events related to a resource list. /// public class ResourceListEventArgs: System.EventArgs { private IResourceList _resList; public ResourceListEventArgs( IResourceList resList ) { _resList = resList; } public IResourceList ResourceList { get { return _resList; } } } public class LinkEventArgs: EventArgs { private IResource _source; private IResource _target; private int _propType; public LinkEventArgs( IResource source, IResource target, int propType ) { _source = source; _target = target; _propType = propType; } public IResource Source { get { return _source; } } public IResource Target { get { return _target; } } public int PropType { get { return _propType; } } } /// /// Provides information about the change of a virtual property provided by /// a . /// public class PropertyProviderChangeEventArgs: EventArgs { private int _resourceID; private int _propID; private object _oldValue; /// /// Initializes a new instance of the class. /// /// The ID of the resource for which the property value has changed. /// The ID of the changed property. /// The value of the property before the change. public PropertyProviderChangeEventArgs( int resourceId, int propId, object oldValue ) { _resourceID = resourceId; _propID = propId; _oldValue = oldValue; } /// /// Gets the ID of the resource for which the property value has changed. /// public int ResourceId { get { return _resourceID; } } /// /// Gets the ID of the changed property. /// public int PropId { get { return _propID; } } /// /// Gets the value of the property before the change. /// public object OldValue { get { return _oldValue; } } } public delegate void ResourceEventHandler( object sender, ResourceEventArgs e ); public delegate void ResourcePropEventHandler( object sender, ResourcePropEventArgs e ); public delegate void ResourceIndexEventHandler( object sender, ResourceIndexEventArgs e ); public delegate void ResourcePropIndexEventHandler( object sender, ResourcePropIndexEventArgs e ); public delegate void ResourceListEventHandler( object sender, ResourceListEventArgs e ); public delegate void LinkEventHandler( object sender, LinkEventArgs e ); public delegate void PropertyProviderChangeEventHandler( object sender, PropertyProviderChangeEventArgs e ); /// /// Base class for all exceptions thrown by the resource store. /// [Serializable] public class StorageException: Exception { public StorageException() : base() { } public StorageException( string message ) : base( message ) { } public StorageException( string message, Exception innerException ) : base( message, innerException ) { } protected StorageException( SerializationInfo info, StreamingContext context ) : base( info, context ) { } } /// /// The exception is thrown when an attempt is made to load a deleted resource. /// [Serializable] public class ResourceDeletedException: StorageException { private int _resourceId = -1; public ResourceDeletedException() : base( "Attempt to perform an operation on a deleted resource" ) { } public ResourceDeletedException( int resourceId, string resourceType ) : base( "The resource with ID=" + resourceId + " of type " + resourceType + " has been deleted" ) { _resourceId = resourceId; } public ResourceDeletedException( string message ) : base( message ) { } public ResourceDeletedException( string message, Exception innerException ) : base( message, innerException ) { } protected ResourceDeletedException( SerializationInfo info, StreamingContext context ) : base( info, context ) { _resourceId = info.GetInt32( "_resourceId" ); } [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter=true)] public override void GetObjectData( SerializationInfo info, StreamingContext context ) { base.GetObjectData( info, context ); info.AddValue( "_resourceId", _resourceId ); } public int ResourceId { get { return _resourceId; } } } /// /// The exception is thrown when an attempt is made to load a resource with a non-existing ID. /// [Serializable] public class InvalidResourceIdException: StorageException { private int _resourceId; public InvalidResourceIdException() : base( ) { } public InvalidResourceIdException( int resourceId ) : base( "Invalid resource ID " + resourceId ) { _resourceId = resourceId; } public InvalidResourceIdException( int resourceId, string message ) : base( message ) { _resourceId = resourceId; } public InvalidResourceIdException( string message ) : base( message ) { } public InvalidResourceIdException( string message, Exception innerException ) : base( message, innerException ) { } protected InvalidResourceIdException( SerializationInfo info, StreamingContext context ) : base( info, context ) { _resourceId = info.GetInt32( "_resourceId" ); } [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter=true)] public override void GetObjectData( SerializationInfo info, StreamingContext context ) { base.GetObjectData( info, context ); info.AddValue( "_resourceId", _resourceId ); } public int ResourceId { get { return _resourceId; } } } /// /// The exception is thrown when a resource restriction is violated. /// [Serializable] public class ResourceRestrictionException: StorageException { public ResourceRestrictionException() : base( ) { } public ResourceRestrictionException( string message ) : base( message ) { } public ResourceRestrictionException( string message, Exception innerException ) : base( message, innerException ) { } protected ResourceRestrictionException( SerializationInfo info, StreamingContext context ) : base( info, context ) { } } }