1 | // -----------------------------------------------------------------------
|
---|
2 | // <copyright file="SensorStreamHandlerFactory.cs" company="Microsoft">
|
---|
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
|
---|
4 | // </copyright>
|
---|
5 | // -----------------------------------------------------------------------
|
---|
6 |
|
---|
7 | namespace Microsoft.Samples.Kinect.Webserver.Sensor
|
---|
8 | {
|
---|
9 | using System;
|
---|
10 | using Microsoft.Samples.Kinect.Webserver.Properties;
|
---|
11 |
|
---|
12 | /// <summary>
|
---|
13 | /// The supported sensor stream type.
|
---|
14 | /// </summary>
|
---|
15 | public enum StreamHandlerType
|
---|
16 | {
|
---|
17 | Skeleton,
|
---|
18 | Interaction,
|
---|
19 | BackgroundRemoval,
|
---|
20 | SensorStatus,
|
---|
21 | }
|
---|
22 |
|
---|
23 | /// <summary>
|
---|
24 | /// Implementation of ISensorStreamHandlerFactory used to create instances of
|
---|
25 | /// sensor stream handler objects.
|
---|
26 | /// </summary>
|
---|
27 | public class SensorStreamHandlerFactory : ISensorStreamHandlerFactory
|
---|
28 | {
|
---|
29 | /// <summary>
|
---|
30 | /// The type of the created stream.
|
---|
31 | /// </summary>
|
---|
32 | private readonly StreamHandlerType streamType;
|
---|
33 |
|
---|
34 | /// <summary>
|
---|
35 | /// Initializes a new instance of the <see cref="SensorStreamHandlerFactory"/> class.
|
---|
36 | /// </summary>
|
---|
37 | /// <param name="streamType">The stream type.</param>
|
---|
38 | public SensorStreamHandlerFactory(StreamHandlerType streamType)
|
---|
39 | {
|
---|
40 | this.streamType = streamType;
|
---|
41 | }
|
---|
42 |
|
---|
43 | /// <summary>
|
---|
44 | /// Creates a sensor stream handler object and associates it with a context that
|
---|
45 | /// allows it to communicate with its owner.
|
---|
46 | /// </summary>
|
---|
47 | /// <param name="context">
|
---|
48 | /// An instance of <see cref="SensorStreamHandlerContext"/> class.
|
---|
49 | /// </param>
|
---|
50 | /// <returns>
|
---|
51 | /// A new <see cref="ISensorStreamHandler"/> instance.
|
---|
52 | /// </returns>
|
---|
53 | public ISensorStreamHandler CreateHandler(SensorStreamHandlerContext context)
|
---|
54 | {
|
---|
55 | switch (streamType)
|
---|
56 | {
|
---|
57 | case StreamHandlerType.Skeleton:
|
---|
58 | return new SkeletonStreamHandler(context);
|
---|
59 | case StreamHandlerType.Interaction:
|
---|
60 | return new InteractionStreamHandler(context);
|
---|
61 | case StreamHandlerType.BackgroundRemoval:
|
---|
62 | return new BackgroundRemovalStreamHandler(context);
|
---|
63 | case StreamHandlerType.SensorStatus:
|
---|
64 | return new SensorStatusStreamHandler(context);
|
---|
65 | default:
|
---|
66 | throw new NotSupportedException(Resources.UnsupportedStreamType);
|
---|
67 | }
|
---|
68 | }
|
---|
69 | }
|
---|
70 | }
|
---|