コード例 #1
0
ファイル: MediaRenderer.cs プロジェクト: jc-design/raumPlayer
        /// <summary>
        ///
        /// </summary>
        /// <param name="serverUDN"></param>
        /// <param name="id"></param>
        /// <param name="metaData"></param>
        /// <returns></returns>
        public async Task <ServiceActionReturnMessage> SetAVTransportUri(bool isContainer, string serverUDN, string containerid, string firstitemid, int index, string metaData)
        {
            try
            {
                if (ServiceActions.TryGetValue("SETAVTRANSPORTURI", out ServiceAction action))
                {
                    action.ClearArgumentsValue();
                    action.SetArgumentValue("InstanceId", "0");
                    action.SetArgumentValue("CurrentURI", HtmlExtension.BuildAvTransportUri(isContainer, serverUDN, containerID: containerid, firstItemID: firstitemid, firstItemIndex: index));
                    action.SetArgumentValue("CurrentURIMetaData", WebUtility.HtmlEncode(metaData));
                    ServiceActionReturnMessage message = await action.InvokeAsync(ServiceTypesString.AVTRANSPORT, serviceControls.Select(c => c).Where(c => c.ServiceType == ServiceTypes.AVTRANSPORT).FirstOrDefault().URI);

                    return(message);
                }
                else
                {
                    return(new ServiceActionReturnMessage()
                    {
                        ActionStatus = ActionStatus.Error, ActionMessage = string.Format("Action not available: SetAVTransportUri")
                    });
                }
            }
            catch (Exception exception)
            {
                return(new ServiceActionReturnMessage()
                {
                    ActionStatus = ActionStatus.Error, ActionMessage = exception.Message
                });
            }
        }
コード例 #2
0
        /// <summary>
        /// Check for RaumfeldZones
        /// http://www.hifi-forum.de/index.php?action=browseT&forum_id=212&thread=420&postID=220#220
        /// http://www.hifi-forum.de/index.php?action=browseT&forum_id=212&thread=420&postID=271#271
        /// Add CancelationTokkens if necessary
        /// </summary>
        /// <returns></returns>
        private async Task raumfeldGetZones()
        {
            if (mediaServer == null)
            {
                return;
            }

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    using (HttpRequestMessage request = new HttpRequestMessage()
                    {
                        RequestUri = new Uri(HtmlExtension.CompleteHttpString(mediaServer.IpAddress, RaumFeldStaticDefinitions.PORT_WEBSERVICE, RaumFeldStaticDefinitions.GETZONES)), Method = HttpMethod.Get
                    })
                    {
                        if (!string.IsNullOrEmpty(raumfeldGetZonesUpdateId))
                        {
                            request.Headers.Add("updateID", raumfeldGetZonesUpdateId);
                        }
                        using (HttpResponseMessage response = await client.SendRequestAsync(request))
                        {
                            if (response.StatusCode == HttpStatusCode.Ok)
                            {
                                raumfeldGetZonesUpdateId = response.Headers["updateID"];
                                string xmlResponse = await response.Content.ReadAsStringAsync();

                                raumFeldZoneConfig = XmlExtension.Deserialize <RaumFeldZoneConfig>(xmlResponse);

                                await matchRaumfeldZones();

                                await raumfeldGetZones();
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception();

                await messagingService.ShowErrorDialogAsync(exception);
            }
        }
コード例 #3
0
        public ActionResult UpdateCart(int?id, int?color, int quantity)
        {
            if (id == null)
            {
                return(HttpNotFound("Id empty"));
            }
            Product product   = Repository.Product.FindById(id);
            Color   colorItem = Repository.Color.FindById(color);

            if (product == null)
            {
                return(HttpNotFound("Item not found"));
            }
            var item = Cart.Update(product, colorItem, quantity);

            if (item != null)
            {
                return(Content(HtmlExtension.FormatCurrency(item.TotalPrice) + " đ"));
            }
            return(HttpNotFound());
        }
コード例 #4
0
ファイル: HtmlExtensionTester.cs プロジェクト: kermina/Brail
 public void SetUp()
 {
     _html = new HtmlExtension(new StringWriter());
     _html.Flush();
 }
コード例 #5
0
        private async Task loadServicesAsync()
        {
            ServiceTypes serviceType;

            foreach (Service service in deviceDescription.Device.Services)
            {
                switch (service.ServiceType)
                {
                case ServiceTypesString.AVTRANSPORT:
                    AVTransport = await XmlExtension.DeserializeUriAsync <AVTransport>(new Uri(HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL)));

                    AVTransport.SetParent();
                    serviceType = ServiceTypes.AVTRANSPORT;
                    break;

                case ServiceTypesString.CONNECTIONMANAGER:
                    ConnectionManager = await XmlExtension.DeserializeUriAsync <ConnectionManager>(new Uri(HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL)));

                    ConnectionManager.SetParent();
                    serviceType = ServiceTypes.CONNECTIONMANAGER;
                    break;

                case ServiceTypesString.CONTENTDIRECTORY:
                    ContentDirectory = await XmlExtension.DeserializeUriAsync <ContentDirectory>(new Uri(HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL)));

                    ContentDirectory.SetParent();
                    serviceType = ServiceTypes.CONTENTDIRECTORY;
                    break;

                case ServiceTypesString.MEDIARECEIVERREGISTRAR:
                    MediaReceiverRegistrar = await XmlExtension.DeserializeUriAsync <MediaReceiverRegistrar>(new Uri(HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL)));

                    MediaReceiverRegistrar.SetParent();
                    serviceType = ServiceTypes.MEDIARECEIVERREGISTRAR;
                    break;

                case ServiceTypesString.RENDERINGCONTROL:
                    RenderingControl = await XmlExtension.DeserializeUriAsync <RenderingControl>(new Uri(HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL)));

                    RenderingControl.SetParent();
                    serviceType = ServiceTypes.RENDERINGCONTROL;
                    break;

                default:
                    serviceType = ServiceTypes.NEUTRAL;
                    break;
                }

                if (serviceType != ServiceTypes.NEUTRAL)
                {
                    serviceSCPDs.Add(new NetWorkSubscriberPayload {
                        MediaDevice = this, URI = HtmlExtension.CompleteHttpString(ipAddress, port, service.SCPDURL), ServiceType = serviceType,
                    });
                    serviceControls.Add(new NetWorkSubscriberPayload {
                        MediaDevice = this, URI = HtmlExtension.CompleteHttpString(ipAddress, port, service.ControlURL), ServiceType = serviceType,
                    });
                    serviceEvents.Add(new NetWorkSubscriberPayload {
                        MediaDevice = this, URI = HtmlExtension.CompleteHttpString(ipAddress, port, service.EventSubURL), ServiceType = serviceType,
                    });
                }
            }
        }