当前位置: 首页>>代码示例>>C#>>正文


C# MediaType.ToString方法代码示例

本文整理汇总了C#中MediaType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MediaType.ToString方法的具体用法?C# MediaType.ToString怎么用?C# MediaType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaType的用法示例。


在下文中一共展示了MediaType.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetWeixinMediaId

        public MediaId GetWeixinMediaId(MediaType type, string path)
        {
            DataRow row = TrySelectRowWithKeys(type.ToString(), path);
            if (row == null)
            {
                SetCommands(AdapterCommand.Insert);
                MediaId mediaId = WeUtil.UploadFile(type, path);
                row = NewRow();
                row.BeginEdit();
                row["MediaType"] = type.ToString();
                row["MediaKey"] = path;
                SetMediaRow(row, mediaId);
                row.EndEdit();
                UpdateDatabase();

                return mediaId;
            }
            else
            {
                DateTime validDate = row["ValidDate"].Value<DateTime>();
                if (validDate > DateTime.Now)
                    return new MediaId(row["MediaId"].ToString());
                else
                {
                    SetCommands(AdapterCommand.Update);
                    MediaId mediaId = WeUtil.UploadFile(type, path);
                    row.BeginEdit();
                    SetMediaRow(row, mediaId);
                    row.EndEdit();
                    UpdateDatabase();

                    return mediaId;
                }
            }
        }
开发者ID:ZLLselfRedeem,项目名称:zllinmitu,代码行数:35,代码来源:MediaCacheResolver.cs

示例2: GetUsersRecentMedia

      public MediaItemList GetUsersRecentMedia(string username, MediaType type, int page, int perPage)
      {
         string relativePath = GenerateRelativeUserSearchUrl(username);

         QueryParameterList paramaters = new QueryParameterList();
         paramaters.Add(new QueryParameter(_format, "xml"));
         paramaters.Add(new QueryParameter(_type, type.ToString().ToLower()));
         paramaters.Add(new QueryParameter(_page, page.ToString()));
         paramaters.Add(new QueryParameter(_perpage, perPage.ToString()));

         string getUsersRecentMediaUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getUserMediaMethod, Token, paramaters);

         XmlResponseMessage getUsersRecentMediaResponseMessage = GetXmlResponseMessageFromUrl(getUsersRecentMediaUrl, _getUserMediaMethod);

         return MediaItemList.CreateFromXmlResponseMessage(getUsersRecentMediaResponseMessage);
      }
开发者ID:darocha,项目名称:Photobucket.NET,代码行数:16,代码来源:PhotobucketUserMethods.cs

示例3: UploadMedia

 /// <summary>
 /// 上传多媒体文件,返回 MediaId
 /// </summary>
 /// <param name="mType"></param>
 /// <param name="vpath"></param>
 /// <returns></returns>
 public static string UploadMedia(MediaType mType, string vpath)
 {
     try
     {
         if (string.IsNullOrEmpty(CommonData.UploadMediaFileUrl))
         {
             throw new Exception("UploadMedia方法。。缺少上传多媒体文件路径配置或者该配置为空,无法继续上传");
         }
         string wxurl = string.Format(CommonData.UploadMediaFileUrl,CommonData.AccessToken, mType.ToString());
         string filepath = HttpContext.Current.Server.MapPath("~") + vpath; //(本地服务器的地址)
         LogHelper.FileLog.Debug("UploadMedia方法。。上传路径:" + filepath);
         string result = HttpHelper.UploadFile(wxurl, "post", filepath);
         LogHelper.FileLog.Debug("UploadMedia方法。。上传result:" + result);
         return result;
     }
     catch (Exception ex)
     {
         LogHelper.FileLog.Fatal(string.Format("UploadMedia方法。。上传文件发生错误!AT:{0};Type:{1};vpath:{2};错误信息:{3}", CommonData.AccessToken,
             mType, vpath, ex.Message));
         throw ex;
     }
 }
开发者ID:andyshao,项目名称:Com.Meten.WeChatSmeten,代码行数:28,代码来源:MediaHelper.cs

示例4: GivenARequest

        public void GivenARequest(string verb, string uri, byte[] content, MediaType contentType)
        {
            var destinationUri = new Uri("http://127.0.0.1:" + _port + uri);

            WebRequest request = WebRequest.Create(destinationUri);
            request.Timeout = int.MaxValue;
            request.Method = verb;
            request.ContentLength = content != null ? content.Length : 0;
            if (request.ContentLength > 0)
            {
                request.ContentType = contentType.ToString();
                using (Stream requestStream = request.GetRequestStream())
                    requestStream.Write(content, 0, content.Length);
            }
            try
            {
                TheResponse = request.GetResponse() as HttpWebResponse;
            }
            catch (WebException exception)
            {
                TheResponse = exception.Response as HttpWebResponse;
            }
        }
开发者ID:rokite,项目名称:openrasta-stable,代码行数:23,代码来源:server_context.cs

示例5: given_request

        public void given_request(string verb, string uri, byte[] content, MediaType contentType)
        {
            var destinationUri = new Uri("http://127.0.0.1:" + _port + uri);

            Request = WebRequest.Create(destinationUri);
            Request.Timeout = int.MaxValue;
            Request.Method = verb;
            Request.ContentLength = content != null ? content.Length : 0;
            if (_username != null)
            {
                Request.Credentials = new NetworkCredential(_username, _password);
            }
            if (Request.ContentLength > 0)
            {
                Request.ContentType = contentType.ToString();
                using (Stream requestStream = Request.GetRequestStream())
                    requestStream.Write(content, 0, content.Length);
            }
        }
开发者ID:endjin,项目名称:openrasta-stable,代码行数:19,代码来源:server_context.cs

示例6: createEmptyEarlGraph


//.........这里部分代码省略.........
            nsmgr.AddNamespace("foaf", "http://xmlns.com/foaf/spec/");
            nsmgr.AddNamespace("dct", "http://purl.org/dc/terms/");
            nsmgr.AddNamespace("doap", "http://usefulinc.com/ns/doap#");
            XmlDocumentType doctype;
            doctype = earl.CreateDocumentType("rdf:RDF", null, null, @"
    <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
    <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
    <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>
    <!ENTITY xml 'http://www.w3.org/XML/1998/namespace'>
    <!ENTITY dc 'http://purl.org/dc/elements/1.1/'>
    <!ENTITY earl 'http://www.w3.org/ns/earl#'>
    <!ENTITY foaf 'http://xmlns.com/foaf/spec/'>
    <!ENTITY dct 'http://purl.org/dc/terms/'>
    <!ENTITY doap 'http://usefulinc.com/ns/doap#'>");
            earl.AppendChild(doctype);


            root = earl.CreateElement("rdf", "RDF", nsmgr.LookupNamespace("rdf"));

            foreach (String prefix in nsmgr)
            {
                if (!String.IsNullOrWhiteSpace(prefix)
                    && !prefix.Equals("xmlns")
                    )
                {
                    var uri = nsmgr.LookupNamespace(prefix);
                    if (!String.IsNullOrWhiteSpace(uri))
                        root.SetAttribute("xmlns:" + prefix, uri);
                }
            }
            earl.AppendChild(root);

            software2 = earl.CreateElement("earl", "Software", nsmgr.LookupNamespace("earl"));
            software2.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            software2.SetAttribute("ID", "pruefdialog");
            root.AppendChild(software2);

            XmlElement desc = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
            desc.AppendChild(earl.CreateTextNode("Ein Dialog zur Bewertung taktiler Grafiken"));
            desc.SetAttributeNode("lang", nsmgr.LookupNamespace("xml"));
            desc.SetAttribute("lang", "de");
            software2.AppendChild(desc);

            XmlElement title = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
            title.AppendChild(earl.CreateTextNode("Pruefdialog taktile Grafiken"));
            title.SetAttributeNode("lang", nsmgr.LookupNamespace("xml"));
            title.SetAttribute("lang", "de");
            software2.AppendChild(title);

            testPerson = earl.CreateElement("foaf", "Person", nsmgr.LookupNamespace("foaf"));
            testPerson.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            testPerson.SetAttribute("ID", "testperson");

            XmlElement name = earl.CreateElement("foaf", "name", nsmgr.LookupNamespace("foaf"));
            name.AppendChild(earl.CreateTextNode("Max Mustermann"));
            testPerson.AppendChild(name);

            group = earl.CreateElement("foaf", "Group", nsmgr.LookupNamespace("foaf"));
            group.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            group.SetAttribute("ID", "assertorgroup");
            root.AppendChild(group);

            //TODOOOOOOOO!!!!
            XmlElement descgroup = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
            descgroup.AppendChild(earl.CreateTextNode("Max Mustermann und Pruefdialog"));
            group.AppendChild(descgroup);

            XmlElement descAssertorGroup = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
            descAssertorGroup.AppendChild(earl.CreateTextNode("Max Mustermann überprüfte die Grafik manuell mit dem Pruefdialog"));
            group.AppendChild(descAssertorGroup);

            XmlElement mainAssertor = earl.CreateElement("earl", "mainAssertor", nsmgr.LookupNamespace("earl"));
            mainAssertor.SetAttributeNode("resource", nsmgr.LookupNamespace("rdf"));
            mainAssertor.SetAttribute("resource", "#"+software2.GetAttribute("ID"));
            group.AppendChild(mainAssertor);

            XmlElement foafMember = earl.CreateElement("foaf", "member", nsmgr.LookupNamespace("foaf"));
            group.AppendChild(foafMember);

            foafMember.AppendChild(testPerson);

            testsubject = earl.CreateElement("earl", "TestSubject", nsmgr.LookupNamespace("earl"));
            testsubject.SetAttributeNode("ID", nsmgr.LookupNamespace("rdf"));
            testsubject.SetAttribute("ID", "testsubject");
            root.AppendChild(testsubject);

            XmlElement bildTitle = earl.CreateElement("dct", "title", nsmgr.LookupNamespace("dct"));
            bildTitle.AppendChild(earl.CreateTextNode("Titel der Grafik"));
            bildTitle.SetAttributeNode("lang", nsmgr.LookupNamespace("xml"));
            bildTitle.SetAttribute("lang", "de");
            testsubject.AppendChild(bildTitle);

            XmlElement mediaType = earl.CreateElement("dct", "description", nsmgr.LookupNamespace("dct"));
            mediaType.AppendChild(earl.CreateTextNode("Die geprüfte Grafik"+"(Medium_"+ chosenMediaType.ToString().Normalize() +")" ));
            testsubject.AppendChild(mediaType);




        }
开发者ID:TUD-INF-IAI-MCI,项目名称:Tangram_QS-Dialog,代码行数:101,代码来源:Earl.cs

示例7: CallbackUserInfo

 private ActionResult CallbackUserInfo(MediaType mediaType, AccessGrant accessGrant, string userIdOAuth, string nickNameOAuth, string emailOAuth)
 {
     if (base.CurrentUser != null)
     {
         Maticsoft.BLL.Members.UserBind bind = new Maticsoft.BLL.Members.UserBind();
         Maticsoft.Model.Members.UserBind bind2 = new Maticsoft.Model.Members.UserBind {
             MediaID = (int) mediaType,
             MediaNickName = nickNameOAuth,
             MediaUserID = userIdOAuth.ToString(),
             TokenAccess = accessGrant.AccessToken,
             UserId = (base.CurrentUser.UserType == "AA") ? -1 : base.CurrentUser.UserID,
             TokenAccess = accessGrant.AccessToken,
             TokenExpireTime = accessGrant.ExpireTime,
             Comment = true,
             iHome = true,
             GroupTopic = true
         };
         if (!bind.AddEx(bind2))
         {
             return this.Redirect("/");
         }
         if (base.currentUser.UserType == "AA")
         {
             return this.Redirect("/Admin/Accounts/UserBind.aspx");
         }
         return this.RedirectToUserBind();
     }
     string userName = string.Format("{0}_{1}", mediaType.ToString(), userIdOAuth);
     string password = userName + this.SinaSercet;
     Maticsoft.BLL.Members.Users users = new Maticsoft.BLL.Members.Users();
     User user = new User();
     if (user.HasUserByUserName(userName))
     {
         User user2 = new User(userName);
         FormsAuthentication.SetAuthCookie(userName, false);
         base.Session[Globals.SESSIONKEY_USER] = user2;
         base.Session["Style"] = user2.Style;
         new Maticsoft.BLL.Members.PointsDetail().AddPoints("Login", user2.UserID, "登录操作", "");
         if (base.Session["returnPage"] != null)
         {
             string url = base.Session["returnPage"].ToString();
             base.Session["returnPage"] = null;
             return this.Redirect(url);
         }
         return this.RedirectToHome();
     }
     User user3 = new User();
     string nickName = nickNameOAuth;
     while (user3.HasUserByNickName(nickName))
     {
         nickName = nickNameOAuth + "_" + Globals.GenRandomCodeFor6();
     }
     user.UserName = userName;
     user.Email = emailOAuth;
     user.Password = AccountsPrincipal.EncryptPassword(password);
     user.Activity = true;
     user.UserType = "UU";
     user.NickName = nickName;
     user.Style = 1;
     user.User_dateCreate = DateTime.Now;
     user.User_cLang = "zh-CN";
     int num = user.Create();
     if (num <= 0)
     {
         return this.Redirect("/");
     }
     UsersExp model = new UsersExp {
         UserID = num,
         Email = emailOAuth,
         Gravatar = string.Format("/{0}/User/Gravatar/{1}", Maticsoft.Components.MvcApplication.UploadFolder, num),
         BirthdayVisible = 0,
         BirthdayIndexVisible = false,
         ConstellationVisible = 0,
         ConstellationIndexVisible = false,
         NativePlaceVisible = 0,
         NativePlaceIndexVisible = false,
         RegionId = 0,
         AddressVisible = 0,
         AddressIndexVisible = false,
         BodilyFormVisible = 0,
         BodilyFormIndexVisible = false,
         BloodTypeVisible = 0,
         BloodTypeIndexVisible = false,
         MarriagedVisible = 0,
         MarriagedIndexVisible = false,
         PersonalStatusVisible = 0,
         PersonalStatusIndexVisible = false,
         LastAccessIP = "",
         LastAccessTime = new DateTime?(DateTime.Now),
         LastLoginTime = DateTime.Now,
         LastPostTime = new DateTime?(DateTime.Now)
     };
     if (!model.AddUsersExp(model))
     {
         users.Delete(num);
         new UsersExp().DeleteUsersExp(num);
         return this.Redirect("/");
     }
     User user4 = new User(userName);
     FormsAuthentication.SetAuthCookie(userName, false);
//.........这里部分代码省略.........
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:101,代码来源:SocialControllerBase.cs

示例8: UploadFile

        public static MediaId UploadFile(string secret, MediaType mediaType,
            string fileName, byte[] fileData)
        {
            TkDebug.AssertArgumentNullOrEmpty(secret, "secret", null);
            TkDebug.AssertArgumentNullOrEmpty(fileName, "fileName", null);
            TkDebug.AssertArgumentNull(fileData, "fileData", null);

            int maxLength = GetMaxLength(mediaType);
            string url = string.Format(ObjectUtil.SysCulture, WeCorpConst.UPLOAD_URL,
                CorpAccessToken.GetTokenWithSecret(secret),
                mediaType.ToString().ToLower(ObjectUtil.SysCulture));

            return WeUtil.InternalUploadFile(mediaType, fileName, fileData, maxLength, url);
        }
开发者ID:ZLLselfRedeem,项目名称:zllinmitu,代码行数:14,代码来源:WeCorpUtil.cs

示例9: GetForMessage

        public void GetForMessage()
        {
            Expect.Call<bool>(converter.CanRead(typeof(string), null)).Return(true);
            MediaType textPlain = new MediaType("text", "plain");
            IList<MediaType> mediaTypes = new List<MediaType>(1);
            mediaTypes.Add(textPlain);
            Expect.Call<IList<MediaType>>(converter.SupportedMediaTypes).Return(mediaTypes);
            Expect.Call<IClientHttpRequest>(requestFactory.CreateRequest(new Uri("http://example.com"), HttpMethod.GET)).Return(request);
            HttpHeaders requestHeaders = new HttpHeaders();
            Expect.Call<HttpHeaders>(request.Headers).Return(requestHeaders).Repeat.Any();
            ExpectGetResponse();
            Expect.Call<bool>(errorHandler.HasError(response)).Return(false);
            HttpHeaders responseHeaders = new HttpHeaders();
            responseHeaders.ContentType = textPlain;
            Expect.Call<HttpHeaders>(response.Headers).Return(responseHeaders).Repeat.Any();
            ExpectHasMessageBody(responseHeaders);
            Expect.Call<bool>(converter.CanRead(typeof(string), textPlain)).Return(true);
            String expected = "Hello World";
            Expect.Call<string>(converter.Read<string>(response)).Return(expected);
            Expect.Call<HttpStatusCode>(response.StatusCode).Return(HttpStatusCode.OK);
            Expect.Call<string>(response.StatusDescription).Return("OK");

            mocks.ReplayAll();

            HttpResponseMessage<String> result = template.GetForMessage<string>("http://example.com");
            Assert.AreEqual(expected, result.Body, "Invalid GET result");
            Assert.AreEqual(textPlain, result.Headers.ContentType, "Invalid Content-Type");
            Assert.AreEqual(textPlain.ToString(), requestHeaders.GetSingleValue("Accept"), "Invalid Accept header");
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode, "Invalid status code");
            Assert.AreEqual("OK", result.StatusDescription, "Invalid status description");

            mocks.ReplayAll();
        }
开发者ID:gabrielgreen,项目名称:spring-net-rest,代码行数:33,代码来源:RestTemplateTests.cs

示例10: ParseMedia

        /// <summary>
        /// 网址解析器
        /// </summary>
        /// <param name="url"></param>
        /// <param name="mediaType"></param>
        /// <returns></returns>
        public ActionResult ParseMedia(MediaType mediaType, string url = null)
        {
            if (UserContext.CurrentUser == null)
                return Json(new { errorMessage = "您没有登录" }, JsonRequestBehavior.AllowGet);
            if (string.IsNullOrEmpty(url))
                return Json(new { errorMessage = "url不能为空" }, JsonRequestBehavior.AllowGet);

            if (!Utility.IsAllowableReferrer(Request))
                return Json(new { errorMessage = "站点不支持跨域访问" }, JsonRequestBehavior.AllowGet);
            List<string> keys = GetUrlParserKeys(mediaType);
            string key = keys.FirstOrDefault(n => url.ToLower().Contains(n.ToLower()));
            //若已经在短网址中存在,则直接返回结果
            ShortUrlService shortUrlService = new ShortUrlService();
            bool urlExists = false;
            string alias = shortUrlService.GetUrlAlias(url, out urlExists);
            //string alias = IdGenerator.Next().ToString();
            ParsedMediaService parsedMediaService = new ParsedMediaService();
            ParsedMedia entity = parsedMediaService.Get(alias);
            if (entity != null)
                return Json(entity, JsonRequestBehavior.AllowGet);

            if (string.IsNullOrEmpty(key))
                return View("~/Plugins/MediaParsers/" + mediaType.ToString() + "/Default.cshtml");

            return View("~/Plugins/MediaParsers/" + mediaType.ToString() + "/" + key + ".cshtml");
        }
开发者ID:hbulzy,项目名称:SYS,代码行数:32,代码来源:ChannelController.cs

示例11: PostForObject

        public void PostForObject() 
        {
            Uri requestUri = new Uri("http://example.com");
            HttpMethod requestMethod = HttpMethod.POST;
            Expect.Call<bool>(converter.CanRead(typeof(Version), null)).Return(true);
            MediaType textPlain = new MediaType("text", "plain");
            IList<MediaType> mediaTypes = new List<MediaType>(1);
            mediaTypes.Add(textPlain);
            Expect.Call<IList<MediaType>>(converter.SupportedMediaTypes).Return(mediaTypes);
            Expect.Call<IClientHttpRequest>(requestFactory.CreateRequest(requestUri, requestMethod)).Return(request);
            HttpHeaders requestHeaders = new HttpHeaders();
            Expect.Call<HttpHeaders>(request.Headers).Return(requestHeaders).Repeat.Any();
            string helloWorld = "Hello World";
            Expect.Call<bool>(converter.CanWrite(typeof(string), null)).Return(true);
            converter.Write(helloWorld, null, request);
            ExpectGetResponse();
            Expect.Call<bool>(errorHandler.HasError(requestUri, requestMethod, response)).Return(false);
            HttpHeaders responseHeaders = new HttpHeaders();
            responseHeaders.ContentType = textPlain;
            Expect.Call<HttpHeaders>(response.Headers).Return(responseHeaders).Repeat.Any();
            ExpectHasMessageBody(responseHeaders);
            Version expected = new Version(1, 0);
            Expect.Call<bool>(converter.CanRead(typeof(Version), textPlain)).Return(true);
            Expect.Call<Version>(converter.Read<Version>(response)).Return(expected);

            mocks.ReplayAll();

            Version result = template.PostForObject<Version>("http://example.com", helloWorld);
            Assert.AreEqual(expected, result, "Invalid POST result");
            Assert.AreEqual(textPlain.ToString(), requestHeaders.GetSingleValue("Accept"), "Invalid Accept header");
        }
开发者ID:nsavga,项目名称:spring-net-rest,代码行数:31,代码来源:RestTemplateTests.cs

示例12: GetNoContentType

        public void GetNoContentType()
        {
            Uri requestUri = new Uri("http://example.com");
            HttpMethod requestMethod = HttpMethod.GET;
            Expect.Call<bool>(converter.CanRead(typeof(string), null)).Return(true);
            MediaType applicationOctetStream = new MediaType("application", "octet-stream");
            IList<MediaType> mediaTypes = new List<MediaType>(1);
            mediaTypes.Add(applicationOctetStream);
            Expect.Call<IList<MediaType>>(converter.SupportedMediaTypes).Return(mediaTypes);
            Expect.Call<IClientHttpRequest>(requestFactory.CreateRequest(requestUri, requestMethod)).Return(request);
            HttpHeaders requestHeaders = new HttpHeaders();
            Expect.Call<HttpHeaders>(request.Headers).Return(requestHeaders).Repeat.Any();
            ExpectGetResponse();
            Expect.Call<bool>(errorHandler.HasError(requestUri, requestMethod, response)).Return(false);
            HttpHeaders responseHeaders = new HttpHeaders();
            // No content-type
            Expect.Call<HttpHeaders>(response.Headers).Return(responseHeaders).Repeat.Any();
            ExpectHasMessageBody(responseHeaders);
            Expect.Call<bool>(converter.CanRead(typeof(string), applicationOctetStream)).Return(true);
            String expected = "Hello World";
            Expect.Call<string>(converter.Read<string>(response)).Return(expected);

            mocks.ReplayAll();

            string result = template.GetForObject<string>("http://example.com");
            Assert.AreEqual(expected, result, "Invalid GET result");
            Assert.AreEqual(applicationOctetStream.ToString(), requestHeaders.GetSingleValue("Accept"), "Invalid Accept header");
        }
开发者ID:nsavga,项目名称:spring-net-rest,代码行数:28,代码来源:RestTemplateTests.cs

示例13: ToString

 public static string ToString(MediaType value)
 {
     if( value==MediaType.Photo )
         return "photo";
     else if( value==MediaType.Video )
         return "video";
     else if( value==MediaType.Audio )
         return "audio";
     else
         throw new ArgumentException("Unrecognized MediaType value: " + value.ToString());
 }
开发者ID:avontd2868,项目名称:vista-novo-fhir,代码行数:11,代码来源:Media.cs

示例14: Stream

        public static void Stream(MediaType mediatype, string id)
        {
            StopStreaming();

            string fileName = string.Empty;
            string userName = string.Empty;
            int card = 0;
            EncoderConfig cfg = null;

            switch (mediatype)
            {
                case Streamer.MediaType.Tv:
                case Streamer.MediaType.Radio:

                    if (mediatype == Streamer.MediaType.Tv)
                    {
                        Log.Info("iPiMPWeb - TV stream requested");
                        cfg = Utils.LoadConfig()[0];
                    }
                    else
                    {
                        Log.Info("iPiMPWeb - Radio stream requested");
                        cfg = Utils.LoadConfig()[3];
                    }

                    WebTvResult res = uWiMP.TVServer.Cards.StartTimeshifting(Convert.ToInt32(id));
                    Log.Info("iPiMPWeb - StartTimeshifting result is {0}", res.result.ToString());
                    if (res.result != 0)
                        return;

                    card = res.user.idCard;
                    userName = res.user.name;
                    fileName = res.timeshiftFile;

                    UpdateStreamTracker(mediatype.ToString(), id, card.ToString(), userName);
                    break;

                case Streamer.MediaType.Recording:
                    cfg = Utils.LoadConfig()[1];
                    Recording recording = uWiMP.TVServer.Recordings.GetRecordingById(Convert.ToInt32(id));
                    fileName = recording.FileName;
                    UpdateStreamTracker(mediatype.ToString(), id.ToString(), "", "");
                    break;

                case Streamer.MediaType.TvSeries:
                    cfg = Utils.LoadConfig()[2];
                    fileName = id;
                    UpdateStreamTracker(mediatype.ToString(), id.ToString(), "", "");
                    break;

                default:
                    return;
            }

            if (!(File.Exists(fileName) || fileName.StartsWith("rtsp://")))
            {
                Log.Info("iPiMPWeb - StartTimeshifting StopStreaming file does not exist or starts with rtsp {0}", fileName);
                StopStreaming();
                return;
            }

            try
            {
                if ((cfg.inputMethod != TransportMethod.Filename))
                {
                    if ((mediatype == Streamer.MediaType.Tv) | (mediatype == Streamer.MediaType.Radio))
                    {
                        _mediaStream = new TsBuffer(fileName);
                    }
                    else
                    {
                        _mediaStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    }
                    _encoder = new EncoderWrapper(_mediaStream, cfg);
                }
                else
                {
                    _encoder = new EncoderWrapper(fileName, cfg);
                }
            }
            catch (Exception ex)
            {
                Log.Info("iPiMPWeb - StartTimeshifting exception {0}", ex.Message);
            }
        }
开发者ID:rndthoughts,项目名称:ipimpplus,代码行数:85,代码来源:Streamer.cs

示例15: PostForObjectNull

        public void PostForObjectNull()
        {
            Expect.Call<bool>(converter.CanRead(typeof(Version), null)).Return(true);
            MediaType textPlain = new MediaType("text", "plain");
            IList<MediaType> mediaTypes = new List<MediaType>(1);
            mediaTypes.Add(textPlain);
            Expect.Call<IList<MediaType>>(converter.SupportedMediaTypes).Return(mediaTypes);
            Expect.Call<IClientHttpRequest>(requestFactory.CreateRequest(new Uri("http://example.com"), HttpMethod.POST)).Return(request);
            HttpHeaders requestHeaders = new HttpHeaders();
            Expect.Call<HttpHeaders>(request.Headers).Return(requestHeaders).Repeat.Any();
            ExpectGetResponse();
            Expect.Call<bool>(errorHandler.HasError(response)).Return(false);
            HttpHeaders responseHeaders = new HttpHeaders();
            responseHeaders.ContentType = textPlain;
            Expect.Call<HttpHeaders>(response.Headers).Return(responseHeaders).Repeat.Any();
            ExpectHasMessageBody(responseHeaders);
            Expect.Call<bool>(converter.CanRead(typeof(Version), textPlain)).Return(true);
            Expect.Call<Version>(converter.Read<Version>(response)).Return(null);

            mocks.ReplayAll();

            Version result = template.PostForObject<Version>("http://example.com", null);
            Assert.IsNull(result, "Invalid POST result");
            Assert.AreEqual(textPlain.ToString(), requestHeaders.GetSingleValue("Accept"), "Invalid Accept header");

            Assert.AreEqual(0, requestHeaders.ContentLength, "Invalid content length");
        }
开发者ID:gabrielgreen,项目名称:spring-net-rest,代码行数:27,代码来源:RestTemplateTests.cs


注:本文中的MediaType.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。