PolicyBasedSynchronousEventHandlerInterpretPolicyValue Method Content Studio 5.7 SDK
Content Studio Web Content Management System

[This is preliminary documentation and is subject to change.]

Interprets the value of a specific Policy.

Namespace: ContentStudio.EventActions.SynchronousEventHandlers
Assembly: SyncEvtHand (in SyncEvtHand.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

protected virtual string InterpretPolicyValue(
	Policy policy
)

Parameters

policy
Type: ContentStudio.EventActions.SynchronousEventHandlersPolicy
The policy.

Return Value

Type: String
The value of the Policy interpreted.
Remarks

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 Note

Important

Since this method might be called when a policy has been violated this method shold not throw any exceptions!

Examples

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;
}
See Also

Reference

Other Resources