Exemplo n.º 1
0
        public HttpResponseMessage Post(BoxedString contact)
        {
            String a;

            var response = Request.CreateResponse <BoxedString>(System.Net.HttpStatusCode.Created, contact);
            // response.Headers.Add("Access-Control-Allow-Origin", "*");
            var base64Data = Regex.Match(contact.Text, @"data:image/(?<type>.+?),(?<data>.+)").Groups["data"].Value;

            byte[] bytes = Convert.FromBase64String(base64Data);

            Image image;

            using (ImagePocketEntities1 database = new ImagePocketEntities1())
            {
                using (MemoryStream ms = new MemoryStream(bytes))
                {
                    var numb = database.ImagesPathes.Count() + 1;
                    image = Image.FromStream(ms);
                    var newpath = @"~/Photoes/newimage_" + Convert.ToString(numb) + ".png";
                    image.Save(string.Format(@"C:\Users\Андрій\Documents\Visual Studio 2013\Projects\MvcApplication4\MvcApplication4\Photoes\newimage_{0}.png", Convert.ToString(numb)));
                    image.GetThumbnailImage(640, 320, null, new IntPtr()).Save(String.Format(@"C:\Users\Андрій\Documents\Visual Studio 2013\Projects\MvcApplication4\MvcApplication4\Photoes\newimagePreview_{0}.png", Convert.ToString(numb)));
                    database.ImagesPathes.Add(new ImagesPathes {
                        Path = newpath, ID = numb
                    });
                    database.SaveChanges();
                }
            }


            return(response);
        }
Exemplo n.º 2
0
        public static void ExpressionThrowsException(string expression, bool useTokenParser)
        {
            var message = new BoxedString();

            if (useTokenParser)
            {
                try
                {
                    message.String = GetSyntaxDisplayString(JassPidginTokenParser.ParseExpression(expression));
                }
                catch (Exception e) when(e is not ParseException && e is not InvalidDataException)  // InvalidDataException is thrown by tokenizer.
                {
                    Assert.Fail("\r\n{0}", message);
                }
                catch { }
            }
            else
            {
                Assert.ThrowsException <ParseException>(() => message.String = GetSyntaxDisplayString(JassPidginParser.ParseExpression(expression)), "\r\n{0}", message);
            }
        }
Exemplo n.º 3
0
        public static void ExpressionThrowsException(string expression)
        {
            var message = new BoxedString();

            Assert.ThrowsException <ParseException>(() => message.String = GetExpressionDisplayString(JassPidginParser.ParseExpression(expression)), "\r\n{0}", message);
        }