Beispiel #1
0
        private Expression ReplacementFor(MethodInvocationExpression node, ExternalMethod method)
        {
            if (BinaryOperatorFor(method, out BinaryOperatorType op))
            {
                return new BinaryExpression(op, node.Arguments[0], node.Arguments[1])
                       {
                           ExpressionType = node.ExpressionType
                       }
            }
            ;

            if (UnaryExpressionFor(method, out UnaryOperatorType unaryOperator))
            {
                return new UnaryExpression(unaryOperator, node.Arguments[0])
                       {
                           ExpressionType = node.ExpressionType
                       }
            }
            ;

            if (method.Name != "op_Implicit")
            {
                return(null);
            }

            node.Arguments[0].ExpressionType = node.ExpressionType;
            return(node.Arguments[0]);
        }
        public ActionResult Edit(Guid id, ExternalMethodModel model, string button)
        {
            using (DBEntities context = Settings.CreateDataContext())
            {
                Validate(context, model);

                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                ExternalMethod target = null;
                if (model.Id != Guid.Empty)
                {
                    target = ExternalMethodHelper.Get(model.Id, context);
                    if (target == null)
                    {
                        ModelState.AddModelError("", Resources.Resource.RowNotFound);
                        return(View(model));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Запись не найдена!");
                    target    = new ExternalMethod();
                    target.Id = Guid.NewGuid();
                    context.AddToExternalMethod(target);
                }

                target.Name       = model.Name;
                target.MethodName = model.MethodName;
                target.ClassName  = model.ClassName;
                target.UsingText  = model.UsingText;
                target.CodeText   = model.CodeText;

                try
                {
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    var sb = new StringBuilder(Resources.Resource.SaveError + ": " + ex.Message);
                    if (ex.InnerException != null)
                    {
                        sb.AppendLine(ex.InnerException.Message);
                    }
                    ModelState.AddModelError("", sb.ToString());
                    return(View(model));
                }

                if (button == "SaveAndExit")
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Edit", new { target.Id }));
                }
            }
        }
Beispiel #3
0
        private bool UnaryExpressionFor(ExternalMethod method, out UnaryOperatorType op)
        {
            if (!method.Name.StartsWith("op_"))
            {
                op = 0;
                return(false);
            }

            return(Enum.TryParse(method.Name.Substring("op_".Length), true, out op));
        }
Beispiel #4
0
        private void button_connect_Click(object sender, EventArgs e)
        {
            string result = ExternalMethod.AdbCommand("connect " + textBox_ip.Text + ":" + textBox_port.Text);

            if (result.Contains("connected"))
            {
                label_title.Text = textBox_ip.Text + " Connected Successfully";
            }
            else
            {
                label_title.Text = "Something is Wrong!";
            }
            isChanged = true;
        }
Beispiel #5
0
        private void backgroundWorker_reconnectDevice_DoWork(object sender, DoWorkEventArgs e)
        {
            string cmdadb = "";

            if (currentDevice == null)
            {
                cmdadb = "reconnect";
            }
            else
            {
                cmdadb = string.Format("-s {0} reconnect", currentDevice.Serial);
            }

            ExternalMethod.AdbCommand(cmdadb);
        }
        public ActionResult Edit(Guid?id)
        {
            if (id.HasValue)
            {
                ExternalMethod obj = ExternalMethodHelper.Get(id.Value);
                if (obj == null)
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }

                Mapper.CreateMap <ExternalMethod, ExternalMethodModel>();
                ExternalMethodModel model = Mapper.Map <ExternalMethod, ExternalMethodModel>(obj);
                return(View(model));
            }
            else
            {
                return(View(new ExternalMethodModel()
                {
                    ClassName = "Project",
                    MethodName = "Method1"
                }));
            }
        }
Beispiel #7
0
 private IEnumerable<string> GetConditionalSymbols(ExternalMethod method)
 {
     foreach (ConditionalAttribute attr in method.MethodInfo.GetCustomAttributes(typeof(ConditionalAttribute), false))
         yield return attr.ConditionString;
 }
        public ExternalConstructedMethodInfo(IReflectionTypeSystemProvider tss, ExternalMethod method)
		{
			_method = method;
			_tss = tss;
		}		
Beispiel #9
0
 public IMethod Map(MethodInfo method)
 {
     object key = GetCacheKey(method);
     IMethod entity = (IMethod)_entityCache[key];
     if (null == entity)
     {
         entity = new ExternalMethod(this, method);
         _entityCache[key] = entity;
     }
     return entity;
 }
        public ActionResult Edit(Guid id, ExternalMethodModel model, string button)
        {
            using (DBEntities context = Settings.CreateDataContext())
            {
                Validate(context, model);

                if (!ModelState.IsValid)
                {
                    return View(model);
                }

                ExternalMethod target = null;
                if (model.Id != Guid.Empty)
                {
                    target = ExternalMethodHelper.Get(model.Id, context);
                    if (target == null)
                    {
                        ModelState.AddModelError("", Resources.Resource.RowNotFound);
                        return View(model);
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Запись не найдена!");
                    target = new ExternalMethod();
                    target.Id = Guid.NewGuid();
                    context.AddToExternalMethod(target);
                }

                target.Name = model.Name;
                target.MethodName = model.MethodName;
                target.ClassName = model.ClassName;
                target.UsingText = model.UsingText;
                target.CodeText = model.CodeText;

                try
                {
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    var sb = new StringBuilder(Resources.Resource.SaveError + ": " + ex.Message);
                    if (ex.InnerException != null)
                        sb.AppendLine(ex.InnerException.Message);
                    ModelState.AddModelError("", sb.ToString());
                    return View(model);
                }

                if (button == "SaveAndExit")
                    return RedirectToAction("Index");
                else
                    return RedirectToAction("Edit", new {target.Id});
            }
        }
Beispiel #11
0
 private bool UnaryExpressionFor(ExternalMethod method, out UnaryOperatorType op)
 {
     return(Enum.TryParse(method.Name.Substring("op_".Length), true, out op));
 }
 public ExternalConstructedMethodInfo(TypeSystemServices tss, ExternalMethod method)
 {
     _method = method;
     _tss = tss;
 }