[This is preliminary documentation and is subject to change.]
Namespace: ContentStudio.EventActions.SynchronousEventHandlers
Assembly: SyncEvtHand (in SyncEvtHand.dll) Version: 1.0.0.0 (1.0.0.0)
Parameters
- policy
- Type: ContentStudio.EventActions.SynchronousEventHandlersPolicy
The policy.
Return Value
Type: StringThe value of the Policy interpreted.
This method can be used to transform the policy value to a more specific value. In the default implementation of the PerformPolicyValidation method when a policy is violated an error message is create based on the ViolationMessage supplied by the administrator and, optionally, the value that has been violated. By overriding this method developers of the event handler can provide a more specfic information on the value violated. A policy value that is combine with its value class can be more specific than the value itself.
Note |
---|
Important Since this method might be called when a policy has been violated this method shold not throw any exceptions! |
For example, if the policy value specifies a maximum allowed file size ,which is just a number, the interpretation of the this value is depenedent on whether the value class specifies that the value should be interpreted as the number of bytes, Kilobytes, Megabytes or even Gigabytes. In this case the developer would combine the value with a an interpretation of the value class
protected override string InterpretValue(Policy policy) { if(policy == null) return String.Empty; if(String.IsNullOrEmpty(policy.Value)) return String.Format("{0} {1}", policy.Value, "bytes"); if (policy.Value.Equals("B", StringComparison.OrdinalIgnoreCase)) return String.Format("{0} {1}", policy.Value, "bytes"); if (policy.Value.Equals("KB", StringComparison.OrdinalIgnoreCase)) return String.Format("{0} {1}", policy.Value, "Kb"); if (policy.Value.Equals("MB", StringComparison.OrdinalIgnoreCase)) return String.Format("{0} {1}", policy.Value, "Mb"); if (policy.Value.Equals("GB", StringComparison.OrdinalIgnoreCase)) return String.Format("{0} {1}", policy.Value, "Gb"); //this value cannot be interpreted return policy.Value; }