Implementing a Cache Proxy Sample Administration Interface
The PluginAdmin.cs file illustrates how to use .NET to create an administration interface that other developers can use to configure the plug-in. To create an administration interface and use it to persist configuration information in the server's namespace, you can perform the following steps.
Create an XML file that identifies the properties you want to persist for your plug-in. For the WMS SDK Sample C# Cache Proxy plug-in, this is done by the cacheproxysampleplugin.xml file. The file is located in the \Program Files\Microsoft Platform SDK\Samples\multimedia\WindowsMediaServices9\CacheProxy\csharp folder. It has not been added to the project. The file looks like this:
<?xml version="1.0" encoding="utf-8" ?> <PersistedConfiguration xmlns="https://schemas.microsoft.com/wms/2002/07/wmsCacheProxyConfigSchema"> <cacheDirectoryPath>c:\wmscache</cacheDirectoryPath> <diskQuota>1024</diskQuota> <archiveQuotaPerStream>-1</archiveQuotaPerStream> <reverseProxyRedirectURL>null</reverseProxyRedirectURL> <backendServer>null</backendServer> <enableCaching>true</enableCaching> <enableProxy>true</enableProxy> <proxyOnDemandCacheMiss>true</proxyOnDemandCacheMiss> <cacheOnDemandCacheMiss>true</cacheOnDemandCacheMiss> <handleUpstreamCacheRequests>true</handleUpstreamCacheRequests> <protocol>clientprotocol</protocol> </PersistedConfiguration>
Use the XML schemas and data types support utility (xsd.exe) to generate a schema file as illustrated by the cacheproxysampleplugin.xsd file.
Use the xsd.exe utility with the /classes option on the .xsd file to generate a .NET class as illustrated by the cacheproxysampleplugin.cs file.
Create an administration interface that identifies the properties and their data types. For example, see the IWMSCacheAdmin interface in the PluginAdmin.cs file.
[Guid("b70d2b4d-3ff5-4ac0-8d23-0fb974618b05")] public interface IWMSCacheAdmin { int DiskQuota { get; set; } string CacheDirectoryPath { get; set; } bool ProxyOnDemandCacheMiss { get; set; } string PreferredProtocol { get; set; } bool CacheOnDemandCacheMiss { get; set; } int ArchiveQuotaPerStream { get; set; } string ProxyRedirectURL { get; set; } string BackendServer { get; set; } }
Implement the administration interface. See the CachePluginAdmin class in the PluginAdmin.cs file and the following example:
public class CachePluginAdmin : IWMSCacheAdmin { private PersistedConfiguration SerializedValues; public CachePluginAdmin() { SerializedValues = new PersistedConfiguration(); SerializedValues.diskQuota = -1; SerializedValues.archiveQuotaPerStream = -1; ... } int IWMSCacheAdmin.DiskQuota { // [DispIdAttribute( 1 )] get { return( SerializedValues.diskQuota ); } // [DispIdAttribute( 1 )] set { if( value != SerializedValues.diskQuota ) { SerializedValues.diskQuota = value; RegisterChange( "DiskQuota", value ); } } } ... }
The WMS SDK Sample C# Cache Proxy plug-in retrieves the administration interface in its implementation of the IWMSBasicPlugin.GetCustomAdminInterface method.