protected UPnPService BuildUPnPService()
            {
                UPnPStateVariable[] RetVal = new UPnPStateVariable[8];
                RetVal[0] = new UPnPModeratedStateVariable("AuthorizationDeniedUpdateID", typeof(System.UInt32), true);
                RetVal[1] = new UPnPModeratedStateVariable("A_ARG_TYPE_DeviceID", typeof(System.String), false);
                RetVal[1].AddAssociation("IsAuthorized", "DeviceID");
                RetVal[1].AddAssociation("IsValidated", "DeviceID");
                RetVal[2] = new UPnPModeratedStateVariable("A_ARG_TYPE_RegistrationRespMsg", typeof(System.Byte[]), false);
                RetVal[2].AddAssociation("RegisterDevice", "RegistrationRespMsg");
                RetVal[3] = new UPnPModeratedStateVariable("ValidationRevokedUpdateID", typeof(System.UInt32), true);
                RetVal[4] = new UPnPModeratedStateVariable("ValidationSucceededUpdateID", typeof(System.UInt32), true);
                RetVal[5] = new UPnPModeratedStateVariable("A_ARG_TYPE_Result", typeof(System.Int32), false);
                RetVal[5].AddAssociation("IsAuthorized", "Result");
                RetVal[5].AddAssociation("IsValidated", "Result");
                RetVal[6] = new UPnPModeratedStateVariable("AuthorizationGrantedUpdateID", typeof(System.UInt32), true);
                RetVal[7] = new UPnPModeratedStateVariable("A_ARG_TYPE_RegistrationReqMsg", typeof(System.Byte[]), false);
                RetVal[7].AddAssociation("RegisterDevice", "RegistrationReqMsg");

                UPnPService S = new UPnPService(1, "urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar", "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1", true, this);

                for (int i = 0; i < RetVal.Length; ++i)
                {
                    S.AddStateVariable(RetVal[i]);
                }
                S.AddMethod("IsAuthorized");
                S.AddMethod("IsValidated");
                S.AddMethod("RegisterDevice");
                return(S);
            }
            protected UPnPService BuildUPnPService()
            {
                UPnPStateVariable[] RetVal = new UPnPStateVariable[14];
                RetVal[0] = new UPnPModeratedStateVariable("SearchCapabilities", typeof(System.String), false);
                RetVal[0].AddAssociation("GetSearchCapabilities", "SearchCaps");
                RetVal[1] = new UPnPModeratedStateVariable("A_ARG_TYPE_SortCriteria", typeof(System.String), false);
                RetVal[1].AddAssociation("Browse", "SortCriteria");
                RetVal[1].AddAssociation("Search", "SortCriteria");
                RetVal[2] = new UPnPModeratedStateVariable("A_ARG_TYPE_SearchCriteria", typeof(System.String), false);
                RetVal[2].AddAssociation("Search", "SearchCriteria");
                RetVal[3] = new UPnPModeratedStateVariable("A_ARG_TYPE_Filter", typeof(System.String), false);
                RetVal[3].AddAssociation("Browse", "Filter");
                RetVal[3].AddAssociation("Search", "Filter");
                RetVal[4] = new UPnPModeratedStateVariable("SortCapabilities", typeof(System.String), false);
                RetVal[4].AddAssociation("GetSortCapabilities", "SortCaps");
                RetVal[5] = new UPnPModeratedStateVariable("A_ARG_TYPE_ObjectID", typeof(System.String), false);
                RetVal[5].AddAssociation("Browse", "ObjectID");
                RetVal[5].AddAssociation("DestroyObject", "ObjectID");
                RetVal[5].AddAssociation("Search", "ContainerID");
                RetVal[6] = new UPnPModeratedStateVariable("SystemUpdateID", typeof(System.UInt32), true);
                RetVal[6].AddAssociation("GetSystemUpdateID", "Id");
                RetVal[7] = new UPnPModeratedStateVariable("A_ARG_TYPE_BrowseFlag", typeof(System.String), false);
                RetVal[7].AllowedStringValues = new string[2] {
                    "BrowseMetadata", "BrowseDirectChildren"
                };
                RetVal[7].AddAssociation("Browse", "BrowseFlag");
                RetVal[8] = new UPnPModeratedStateVariable("A_ARG_TYPE_UpdateID", typeof(System.UInt32), false);
                RetVal[8].AddAssociation("Browse", "UpdateID");
                RetVal[8].AddAssociation("Search", "UpdateID");
                RetVal[9]  = new UPnPModeratedStateVariable("ContainerUpdateIDs", typeof(System.String), true);
                RetVal[10] = new UPnPModeratedStateVariable("TransferIDs", typeof(System.String), true);
                RetVal[11] = new UPnPModeratedStateVariable("A_ARG_TYPE_Index", typeof(System.UInt32), false);
                RetVal[11].AddAssociation("Browse", "StartingIndex");
                RetVal[11].AddAssociation("Search", "StartingIndex");
                RetVal[12] = new UPnPModeratedStateVariable("A_ARG_TYPE_Count", typeof(System.UInt32), false);
                RetVal[12].AddAssociation("Browse", "RequestedCount");
                RetVal[12].AddAssociation("Browse", "NumberReturned");
                RetVal[12].AddAssociation("Browse", "TotalMatches");
                RetVal[12].AddAssociation("Search", "RequestedCount");
                RetVal[12].AddAssociation("Search", "NumberReturned");
                RetVal[12].AddAssociation("Search", "TotalMatches");
                RetVal[13] = new UPnPModeratedStateVariable("A_ARG_TYPE_Result", typeof(System.String), false);
                RetVal[13].AddAssociation("Browse", "Result");
                RetVal[13].AddAssociation("Search", "Result");

                UPnPService S = new UPnPService(1, "urn:schemas-upnp-org:service:ContentDirectory", URN, true, this);

                for (int i = 0; i < RetVal.Length; ++i)
                {
                    S.AddStateVariable(RetVal[i]);
                }
                S.AddMethod("Browse");
                S.AddMethod("DestroyObject");
                S.AddMethod("GetSearchCapabilities");
                S.AddMethod("GetSortCapabilities");
                S.AddMethod("GetSystemUpdateID");
                S.AddMethod("Search");
                return(S);
            }
Exemple #3
0
            protected UPnPService BuildUPnPService()
            {
                UPnPStateVariable[] RetVal = new UPnPStateVariable[12];
                RetVal[0] = new UPnPModeratedStateVariable("A_ARG_TYPE_EndpointID", typeof(System.String), false);
                RetVal[0].AddAssociation("AcquireNonce", "HostId");
                RetVal[0].AddAssociation("Advertise", "HostId");
                RetVal[0].AddAssociation("Advertise", "ApplicationId");
                RetVal[0].AddAssociation("Inhibit", "HostId");
                RetVal[0].AddAssociation("Inhibit", "ApplicationId");
                RetVal[1] = new UPnPModeratedStateVariable("A_ARG_TYPE_AnyString", typeof(System.String), false);
                RetVal[1].AddAssociation("Advertise", "ApplicationData");
                RetVal[1].AddAssociation("Advertise", "ExperienceEndpointData");
                RetVal[1].AddAssociation("Inhibit", "ApplicationData");
                RetVal[1].AddAssociation("Inhibit", "ReasonMessage");
                RetVal[2] = new UPnPModeratedStateVariable("A_ARG_TYPE_SignAlgorithmList", typeof(System.String), false);
                RetVal[2].AddAssociation("AcquireNonce", "SupportedSignatureAlgorithms");
                RetVal[3] = new UPnPModeratedStateVariable("A_ARG_TYPE_Bool", typeof(System.Boolean), false);
                RetVal[3].AddAssociation("AcquireNonce", "AttachCertificate");
                RetVal[4] = new UPnPModeratedStateVariable("A_ARG_TYPE_ReasonCode", typeof(System.UInt32), false);
                RetVal[4].AddAssociation("Inhibit", "ReasonCode");
                RetVal[5] = new UPnPModeratedStateVariable("A_ARG_TYPE_Uri", typeof(System.String), false);
                RetVal[5].AddAssociation("Advertise", "ExperienceIconUri");
                RetVal[5].AddAssociation("Advertise", "ExperienceEndpointUri");
                RetVal[6] = new UPnPModeratedStateVariable("A_ARG_TYPE_Certificate", typeof(System.String), false);
                RetVal[6].AddAssociation("Advertise", "HostCertificate");
                RetVal[6].AddAssociation("Inhibit", "HostCertificate");
                RetVal[7] = new UPnPModeratedStateVariable("A_ARG_TYPE_Version", typeof(System.String), false);
                RetVal[7].AddAssociation("Advertise", "ApplicationVersion");
                RetVal[7].AddAssociation("Inhibit", "ApplicationVersion");
                RetVal[8] = new UPnPModeratedStateVariable("A_ARG_TYPE_Name", typeof(System.String), false);
                RetVal[8].AddAssociation("Advertise", "HostFriendlyName");
                RetVal[8].AddAssociation("Advertise", "ExperienceFriendlyName");
                RetVal[9] = new UPnPModeratedStateVariable("A_ARG_TYPE_SignAlgorithm", typeof(System.String), false);
                RetVal[9].AddAssociation("Advertise", "SignatureAlgorithm");
                RetVal[9].AddAssociation("Inhibit", "SignatureAlgorithm");
                RetVal[10] = new UPnPModeratedStateVariable("A_ARG_TYPE_Signature", typeof(System.String), false);
                RetVal[10].AddAssociation("Advertise", "Signature");
                RetVal[10].AddAssociation("Inhibit", "Signature");
                RetVal[11] = new UPnPModeratedStateVariable("A_ARG_TYPE_Nonce", typeof(System.UInt32), false);
                RetVal[11].AddAssociation("AcquireNonce", "Nonce");
                RetVal[11].AddAssociation("Advertise", "Nonce");
                RetVal[11].AddAssociation("Inhibit", "Nonce");

                UPnPService S = new UPnPService(1, "urn:schemas-microsoft-com:serviceId:MSRX", "urn:schemas-microsoft-com:service:msremotedexperience:1", true, this);

                for (int i = 0; i < RetVal.Length; ++i)
                {
                    S.AddStateVariable(RetVal[i]);
                }
                S.AddMethod("AcquireNonce");
                S.AddMethod("Advertise");
                S.AddMethod("Inhibit");
                return(S);
            }
            protected UPnPService BuildUPnPService()
            {
                UPnPStateVariable[] RetVal = new UPnPStateVariable[10];
                RetVal[0] = new UPnPModeratedStateVariable("A_ARG_TYPE_ProtocolInfo", typeof(System.String), false);
                RetVal[0].AddAssociation("GetCurrentConnectionInfo", "ProtocolInfo");
                RetVal[0].AddAssociation("PrepareForConnection", "RemoteProtocolInfo");
                RetVal[1] = new UPnPModeratedStateVariable("A_ARG_TYPE_ConnectionStatus", typeof(System.String), false);
                RetVal[1].AllowedStringValues = new string[5] {
                    "OK", "ContentFormatMismatch", "InsufficientBandwidth", "UnreliableChannel", "Unknown"
                };
                RetVal[1].AddAssociation("GetCurrentConnectionInfo", "Status");
                RetVal[2] = new UPnPModeratedStateVariable("A_ARG_TYPE_AVTransportID", typeof(System.Int32), false);
                RetVal[2].AddAssociation("GetCurrentConnectionInfo", "AVTransportID");
                RetVal[2].AddAssociation("PrepareForConnection", "AVTransportID");
                RetVal[3] = new UPnPModeratedStateVariable("A_ARG_TYPE_RcsID", typeof(System.Int32), false);
                RetVal[3].AddAssociation("GetCurrentConnectionInfo", "RcsID");
                RetVal[3].AddAssociation("PrepareForConnection", "RcsID");
                RetVal[4] = new UPnPModeratedStateVariable("A_ARG_TYPE_ConnectionID", typeof(System.Int32), false);
                RetVal[4].AddAssociation("GetCurrentConnectionInfo", "ConnectionID");
                RetVal[4].AddAssociation("GetCurrentConnectionInfo", "PeerConnectionID");
                RetVal[4].AddAssociation("PrepareForConnection", "PeerConnectionID");
                RetVal[4].AddAssociation("PrepareForConnection", "ConnectionID");
                RetVal[4].AddAssociation("ConnectionComplete", "ConnectionID");
                RetVal[5] = new UPnPModeratedStateVariable("A_ARG_TYPE_ConnectionManager", typeof(System.String), false);
                RetVal[5].AddAssociation("GetCurrentConnectionInfo", "PeerConnectionManager");
                RetVal[5].AddAssociation("PrepareForConnection", "PeerConnectionManager");
                RetVal[6] = new UPnPModeratedStateVariable("SourceProtocolInfo", typeof(System.String), true);
                RetVal[6].AddAssociation("GetProtocolInfo", "Source");
                RetVal[7] = new UPnPModeratedStateVariable("SinkProtocolInfo", typeof(System.String), true);
                RetVal[7].AddAssociation("GetProtocolInfo", "Sink");
                RetVal[8] = new UPnPModeratedStateVariable("A_ARG_TYPE_Direction", typeof(System.String), false);
                RetVal[8].AllowedStringValues = new string[2] {
                    "Input", "Output"
                };
                RetVal[8].AddAssociation("GetCurrentConnectionInfo", "Direction");
                RetVal[8].AddAssociation("PrepareForConnection", "Direction");
                RetVal[9] = new UPnPModeratedStateVariable("CurrentConnectionIDs", typeof(System.String), true);
                RetVal[9].AddAssociation("GetCurrentConnectionIDs", "ConnectionIDs");

                UPnPService S = new UPnPService(1, "urn:schemas-upnp-org:service:ConnectionManager", "urn:schemas-upnp-org:service:ConnectionManager:1", true, this);

                for (int i = 0; i < RetVal.Length; ++i)
                {
                    S.AddStateVariable(RetVal[i]);
                }
                S.AddMethod("GetCurrentConnectionInfo");
                S.AddMethod("PrepareForConnection");
                S.AddMethod("ConnectionComplete");
                S.AddMethod("GetProtocolInfo");
                S.AddMethod("GetCurrentConnectionIDs");
                return(S);
            }
Exemple #5
0
            protected UPnPService BuildUPnPService()
            {
                UPnPStateVariable[] RetVal = new UPnPStateVariable[1];
                RetVal[0] = new UPnPModeratedStateVariable("Target", typeof(System.Boolean), false);

                UPnPService S = new UPnPService(1, "urn:microsoft-com:serviceId:NULL", "urn:schemas-microsoft-com:service:NULL:1", true, this);

                for (int i = 0; i < RetVal.Length; ++i)
                {
                    S.AddStateVariable(RetVal[i]);
                }
                return(S);
            }
            protected UPnPService BuildUPnPService()
            {
                UPnPStateVariable[] RetVal = new UPnPStateVariable[7];
                RetVal[0] = new UPnPModeratedStateVariable("A_ARG_TYPE_EndpointID", typeof(System.String), false);
                RetVal[0].AddAssociation("Commit", "HostID");
                RetVal[0].AddAssociation("Confirm", "HostID");
                RetVal[0].AddAssociation("Exchange", "HostID");
                RetVal[0].AddAssociation("Exchange", "DeviceID");
                RetVal[0].AddAssociation("Validate", "HostID");
                RetVal[1] = new UPnPModeratedStateVariable("TrustState", typeof(System.Byte), false);
                RetVal[1].SetRange((System.Byte)(0), (System.Byte)(4), null);
                RetVal[2] = new UPnPModeratedStateVariable("A_ARG_TYPE_Rounds", typeof(System.Byte), false);
                RetVal[2].SetRange((System.Byte)(2), (System.Byte)(20), null);
                RetVal[2].AddAssociation("Confirm", "IterationsRequired");
                RetVal[2].AddAssociation("Exchange", "IterationsRequired");
                RetVal[3] = new UPnPModeratedStateVariable("A_ARG_TYPE_Nonce", typeof(System.String), false);
                RetVal[3].AddAssociation("Confirm", "HostConfirmNonce");
                RetVal[3].AddAssociation("Confirm", "DeviceConfirmNonce");
                RetVal[3].AddAssociation("Validate", "HostValidateNonce");
                RetVal[3].AddAssociation("Validate", "DeviceValidateNonce");
                RetVal[4] = new UPnPModeratedStateVariable("A_ARG_TYPE_Authenticator", typeof(System.String), false);
                RetVal[4].AddAssociation("Commit", "HostValidateAuthenticator");
                RetVal[4].AddAssociation("Commit", "DeviceValidateAuthenticator");
                RetVal[4].AddAssociation("Exchange", "HostConfirmAuthenticator");
                RetVal[4].AddAssociation("Exchange", "DeviceConfirmAuthenticator");
                RetVal[5] = new UPnPModeratedStateVariable("A_ARG_TYPE_Certificate", typeof(System.String), false);
                RetVal[5].AddAssociation("Exchange", "HostCertificate");
                RetVal[5].AddAssociation("Exchange", "DeviceCertificate");
                RetVal[6] = new UPnPModeratedStateVariable("A_ARG_TYPE_Iteration", typeof(System.Byte), false);
                RetVal[6].SetRange((System.Byte)(1), (System.Byte)(20), null);
                RetVal[6].AddAssociation("Commit", "Iteration");
                RetVal[6].AddAssociation("Validate", "Iteration");

                UPnPService S = new UPnPService(1, "urn:microsoft-com:serviceId:MSTA", "urn:schemas-microsoft-com:service:mstrustagreement:1", true, this);

                for (int i = 0; i < RetVal.Length; ++i)
                {
                    S.AddStateVariable(RetVal[i]);
                }
                S.AddMethod("Commit");
                S.AddMethod("Confirm");
                S.AddMethod("Exchange");
                S.AddMethod("Validate");
                return(S);
            }
Exemple #7
0
            protected UPnPService BuildUPnPService()
            {
                UPnPStateVariable[] RetVal = new UPnPStateVariable[3];
                RetVal[0] = new UPnPModeratedStateVariable("OysterConnectionPort", typeof(System.Int32), false);
                RetVal[0].DefaultValue = UPnPService.CreateObjectInstance(typeof(System.Int32),"13075");
                RetVal[0].AddAssociation("GetConnectionVariables", "int32ConnectionPort");
                RetVal[1] = new UPnPModeratedStateVariable("OysterFilePort", typeof(System.Int32), false);
                RetVal[1].AddAssociation("GetConnectionVariables", "int32FilePort");
                RetVal[2] = new UPnPModeratedStateVariable("OysterConnectionAddress", typeof(System.String), false);
                RetVal[2].DefaultValue = UPnPService.CreateObjectInstance(typeof(System.String),"OysterMini");
                RetVal[2].AddAssociation("GetConnectionVariables", "stringConnectionAddress");

                UPnPService S = new UPnPService(1, "ConnectionService", "urn:schemas-upnp-org:OysterConnection::1", true, this);
                for(int i=0;i<RetVal.Length;++i)
                {
                   S.AddStateVariable(RetVal[i]);
                }
                S.AddMethod("GetConnectionVariables");
                return(S);
            }
Exemple #8
0
            protected UPnPService BuildUPnPService()
            {
                UPnPStateVariable[] RetVal = new UPnPStateVariable[5];
                RetVal[0] = new UPnPModeratedStateVariable("PageMax", typeof(System.Int32), true);
                RetVal[0].DefaultValue = UPnPService.CreateObjectInstance(typeof(System.Int32),"1");
                RetVal[0].AddAssociation("PowerOn", "PageMax");
                RetVal[1] = new UPnPModeratedStateVariable("Power", typeof(System.Boolean), true);
                RetVal[1].AddAssociation("GetStatus", "Power");
                RetVal[1].AddAssociation("PowerOff", "Power");
                RetVal[1].AddAssociation("PowerOn", "Power");
                RetVal[2] = new UPnPModeratedStateVariable("File", typeof(System.String), true);
                RetVal[2].DefaultValue = UPnPService.CreateObjectInstance(typeof(System.String),"default.ppt");
                RetVal[2].AddAssociation("GetStatus", "File");
                RetVal[2].AddAssociation("PowerOn", "File");
                RetVal[3] = new UPnPModeratedStateVariable("PageNumber", typeof(System.Int32), true);
                RetVal[3].DefaultValue = UPnPService.CreateObjectInstance(typeof(System.Int32),"1");
                RetVal[3].AddAssociation("GetStatus", "PageNumber");
                RetVal[3].AddAssociation("Go", "PageNumber");
                RetVal[3].AddAssociation("NextPage", "PageNumber");
                RetVal[3].AddAssociation("PowerOn", "PageNumber");
                RetVal[3].AddAssociation("PreviousPage", "PageNumber");
                RetVal[4] = new UPnPModeratedStateVariable("Files", typeof(System.String), true);
                RetVal[4].DefaultValue = UPnPService.CreateObjectInstance(typeof(System.String),"default.ppt");
                RetVal[4].AddAssociation("GetFiles", "Files");

                UPnPService S = new UPnPService(1, "control", "urn:schemas-upnp-org:service:control:1", true, this);
                for(int i=0;i<RetVal.Length;++i)
                {
                   S.AddStateVariable(RetVal[i]);
                }
                S.AddMethod("GetFiles");
                S.AddMethod("GetStatus");
                S.AddMethod("Go");
                S.AddMethod("NextPage");
                S.AddMethod("PowerOff");
                S.AddMethod("PowerOn");
                S.AddMethod("PreviousPage");
                return(S);
            }
        private static void AddWeMoSwitch()
        {
            var localDevice = UPnPDevice.CreateRootDevice(/* expiration */ 3600, /* version*/ 1, /* web dir */ null);

            localDevice.StandardDeviceType = "urn:Belkin:device:controllee";
            localDevice.UniqueDeviceName   = "Lightswitch-32f9a52c-79d2-4ae2-8957-1f5a0f044e36";
            localDevice.FriendlyName       = "Test Lamp";
            //localDevice.Icon = null;
            //localDevice.HasPresentation = true;
            //localDevice.PresentationURL = presentationUrl;
            localDevice.Major            = 1; localDevice.Minor = 0;
            localDevice.SerialNumber     = "1234567890";
            localDevice.ModelNumber      = "3.1234";
            localDevice.Manufacturer     = "Belkin International Inc.";
            localDevice.ManufacturerURL  = "http://www.belkin.com";
            localDevice.ModelName        = "Socket";
            localDevice.ModelDescription = "Belkin Plugin Socket 1.0";

            /*if (Uri.IsWellFormedUriString(manufacturerUrl, UriKind.Absolute))
             * {
             *  localDevice.ModelURL = new Uri(manufacturerUrl);
             * }
             */
            localDevice.UserAgentTag = "redsonic";

            // Create an instance of the BasicEvent service
            dynamic instance = new ExpandoObject();

            // Declare the "BasicEvent1" service
            var service = new UPnPService(
                // Version
                1.0,
                // Service ID
                "urn:Belkin:serviceId:basicevent1",
                // Service Type
                "urn:Belkin:service:basicevent:1",
                // Standard Service?
                true,
                // Service Object Instance
                instance
                );

            service.ControlURL = "/upnp/control/basicevent1";
            service.EventURL   = "/upnp/event/basicevent1";
            service.SCPDURL    = "/eventservice.xml";

            string stateVarName  = "BinaryState";
            var    stateVariable = new UPnPStateVariable(stateVarName, typeof(bool), true);

            stateVariable.AddAssociation("GetBinaryState", stateVarName);
            stateVariable.AddAssociation("SetBinaryState", stateVarName);
            stateVariable.Value = false;
            service.AddStateVariable(stateVariable);

            instance.GetBinaryState = new Func <bool>(() => (bool)service.GetStateVariable(stateVarName));
            instance.SetBinaryState = new Action <int>((BinaryState) => {
                Console.WriteLine("SetBinaryState({0})", BinaryState);
                service.SetStateVariable(stateVarName, BinaryState != 0);
            });

            // Add the methods
            service.AddMethod("GetBinaryState", stateVarName);
            service.AddMethod("SetBinaryState", stateVarName);

            // Add the service
            localDevice.AddService(service);
            // Start the WeMo switch device UPnP simulator
            localDevice.StartDevice();
        }
            protected UPnPService BuildUPnPService()
            {
                UPnPStateVariable[] RetVal = new UPnPStateVariable[12];
                RetVal[0] = new UPnPModeratedStateVariable("Reverse", typeof(System.Boolean), false);
                RetVal[0].AddAssociation("Register", "Reverse");
                RetVal[1] = new UPnPModeratedStateVariable("ErrorString", typeof(System.String), false);
                RetVal[1].AddAssociation("InvokeAsyncResponse", "ErrorString");
                RetVal[2] = new UPnPModeratedStateVariable("StateVariableName", typeof(System.String), false);
                RetVal[2].AddAssociation("FireEvent", "StateVariable");
                RetVal[3] = new UPnPModeratedStateVariable("ServiceID", typeof(System.String), false);
                RetVal[3].AddAssociation("Invoke", "ServiceID");
                RetVal[3].AddAssociation("FireEvent", "ServiceID");
                RetVal[3].AddAssociation("InvokeAsync", "ServiceID");
                RetVal[3].AddAssociation("GetDocument", "ServiceID");
                RetVal[3].AddAssociation("GetStateTable", "ServiceID");
                RetVal[4] = new UPnPModeratedStateVariable("Document", typeof(System.Byte[]), false);
                RetVal[4].AddAssociation("GetDocument", "Document");
                RetVal[5] = new UPnPModeratedStateVariable("Args", typeof(System.Byte[]), false);
                RetVal[5].AddAssociation("Invoke", "InArgs");
                RetVal[5].AddAssociation("Invoke", "OutArgs");
                RetVal[5].AddAssociation("InvokeAsync", "InArgs");
                RetVal[5].AddAssociation("InvokeAsyncResponse", "OutArgs");
                RetVal[5].AddAssociation("GetStateTable", "Variables");
                RetVal[6] = new UPnPModeratedStateVariable("Handle", typeof(System.Int32), false);
                RetVal[6].AddAssociation("InvokeAsync", "Handle");
                RetVal[6].AddAssociation("InvokeAsyncResponse", "Handle");
                RetVal[7] = new UPnPModeratedStateVariable("ProxyUri", typeof(System.Uri), false);
                RetVal[7].AddAssociation("Register", "Proxy");
                RetVal[7].AddAssociation("UnRegister", "Proxy");
                RetVal[8] = new UPnPModeratedStateVariable("ActionName", typeof(System.String), false);
                RetVal[8].AddAssociation("Invoke", "Action");
                RetVal[8].AddAssociation("InvokeAsync", "Action");
                RetVal[9] = new UPnPModeratedStateVariable("StateVariableValue", typeof(System.String), false);
                RetVal[9].AddAssociation("FireEvent", "Value");
                RetVal[10] = new UPnPModeratedStateVariable("DeviceUDN", typeof(System.String), false);
                RetVal[10].AddAssociation("Invoke", "DeviceUDN");
                RetVal[10].AddAssociation("FireEvent", "DeviceUDN");
                RetVal[10].AddAssociation("AddDevice", "Sender");
                RetVal[10].AddAssociation("AddDevice", "DeviceUDN");
                RetVal[10].AddAssociation("InvokeAsync", "Caller");
                RetVal[10].AddAssociation("InvokeAsync", "DeviceUDN");
                RetVal[10].AddAssociation("GetDocument", "DeviceUDN");
                RetVal[10].AddAssociation("GetStateTable", "DeviceUDN");
                RetVal[10].AddAssociation("RemoveDevice", "DeviceUDN");
                RetVal[11] = new UPnPModeratedStateVariable("ErrorCode", typeof(System.Int32), false);
                RetVal[11].AddAssociation("InvokeAsyncResponse", "ErrorCode");

                UPnPService S = new UPnPService(1, "UPNPRELAY_0-2", "urn:schemas-upnp-org:service:UPnPRelay:1", true, this);

                for (int i = 0; i < RetVal.Length; ++i)
                {
                    S.AddStateVariable(RetVal[i]);
                }
                S.AddMethod("Invoke");
                S.AddMethod("FireEvent");
                S.AddMethod("AddDevice");
                S.AddMethod("InvokeAsync");
                S.AddMethod("GetDocument");
                S.AddMethod("InvokeAsyncResponse");
                S.AddMethod("Register");
                S.AddMethod("GetStateTable");
                S.AddMethod("RemoveDevice");
                S.AddMethod("UnRegister");
                return(S);
            }
        public MainForm(string[] args)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            foreach (string parm in args)
            {
                if (parm.ToUpper().StartsWith("/CACHE:"))
                {
                    DText p = new DText();
                    p.ATTRMARK = ":";
                    p[0]       = parm;
                    try
                    {
                        CacheTime = int.Parse(p[2]);
                    }
                    catch (Exception)
                    {
                    }
                }
                else if (parm.ToUpper() == "/DEBUG")
                {
                    OpenSource.Utilities.EventLogger.Enabled = true;
                    OpenSource.Utilities.EventLogger.ShowAll = true;
                    OpenSource.Utilities.InstanceTracker.Display();
                }
                else if (parm.ToUpper().StartsWith("/PORT:"))
                {
                    DText p = new DText();
                    p.ATTRMARK = ":";
                    p[0]       = parm;
                    try
                    {
                        PortNum = int.Parse(p[2]);
                    }
                    catch (Exception)
                    {
                    }
                }
            }


            upnpLightDevice                    = UPnPDevice.CreateRootDevice(CacheTime, 1, "web\\");
            upnpLightDevice.Icon               = iconImageList.Images[0];
            upnpLightDevice.HasPresentation    = true;
            upnpLightDevice.PresentationURL    = "/";
            upnpLightDevice.FriendlyName       = this.Text + " (" + System.Windows.Forms.SystemInformation.ComputerName + ")";
            upnpLightDevice.Manufacturer       = "OpenSource";
            upnpLightDevice.ManufacturerURL    = "http://opentools.homeip.net";
            upnpLightDevice.ModelName          = "Network Light Bulb";
            upnpLightDevice.ModelDescription   = "Software Emulated Light Bulb";
            upnpLightDevice.ModelURL           = new Uri("http://opentools.homeip.net");
            upnpLightDevice.ModelNumber        = "XPC-L1";
            upnpLightDevice.StandardDeviceType = "DimmableLight";
            upnpLightDevice.UniqueDeviceName   = System.Guid.NewGuid().ToString();

            // Switch Power
            upnpLightService = new UPnPService(1, "SwitchPower.0001", "SwitchPower", true, this);
            upnpLightService.AddMethod("SetTarget");
            upnpLightService.AddMethod("GetTarget");
            upnpLightService.AddMethod("GetStatus");

            UPnPStateVariable upnpStatusVar = new UPnPStateVariable("Status", typeof(bool), true);

            upnpStatusVar.AddAssociation("GetStatus", "ResultStatus");
            upnpStatusVar.Value = false;
            upnpLightService.AddStateVariable(upnpStatusVar);
            UPnPStateVariable upnpTargetVar = new UPnPStateVariable("Target", typeof(bool), false);

            upnpTargetVar.AddAssociation("SetTarget", "newTargetValue");
            upnpTargetVar.AddAssociation("GetTarget", "newTargetValue");
            upnpTargetVar.Value = false;
            upnpLightService.AddStateVariable(upnpTargetVar);

            // Dimmable device
            upnpDimmerService = new UPnPService(1, "Dimming.0001", "Dimming", true, this);
            upnpDimmerService.AddMethod("SetLoadLevelTarget");
            upnpDimmerService.AddMethod("GetLoadLevelTarget");
            upnpDimmerService.AddMethod("GetLoadLevelStatus");
            upnpDimmerService.AddMethod("GetMinLevel");

            UPnPStateVariable upnpLevelTargetVar = new UPnPStateVariable("LoadLevelTarget", typeof(byte), false);

            upnpLevelTargetVar.AddAssociation("SetLoadLevelTarget", "NewLoadLevelTarget");
            upnpLevelTargetVar.AddAssociation("GetLoadLevelTarget", "NewLoadLevelTarget");
            upnpLevelTargetVar.Value = (byte)100;
            upnpLevelTargetVar.SetRange((byte)0, (byte)100, null);
            upnpDimmerService.AddStateVariable(upnpLevelTargetVar);
            UPnPStateVariable upnpLevelStatusVar = new UPnPStateVariable("LoadLevelStatus", typeof(byte), true);

            upnpLevelStatusVar.AddAssociation("GetLoadLevelStatus", "RetLoadLevelStatus");
            upnpLevelStatusVar.Value = (byte)100;
            upnpLevelStatusVar.SetRange((byte)0, (byte)100, null);
            upnpDimmerService.AddStateVariable(upnpLevelStatusVar);
            UPnPStateVariable upnpMinLevelVar = new UPnPStateVariable("MinLevel", typeof(byte), false);

            upnpMinLevelVar.AddAssociation("GetMinLevel", "MinLevel");
            upnpMinLevelVar.Value = (byte)0;
            upnpDimmerService.AddStateVariable(upnpMinLevelVar);

            // Add Services
            upnpLightDevice.AddService(upnpLightService);
            upnpLightDevice.AddService(upnpDimmerService);
        }