Exemplo n.º 1
0
        public CustomEventAbstract(XElement xElement)
        {
            Name             = xElement.Attribute("Name")?.Value;
            BindingParameter = xElement.Descendants()
                               .Single(a => a.Name.LocalName == "Parameter" && a.Attribute("Name").Value == "bindingParameter")
                               .Attribute("Type")?.Value;

            // Recognize Edm types and transform as necessary.
            var proposedType = xElement.Descendants().SingleOrDefault(a => a.Name.LocalName == "ReturnType")?.Attribute("Type")?.Value;

            if (!string.IsNullOrWhiteSpace(proposedType))
            {
                if (proposedType.StartsWith("Collection("))
                {
                    ReturnsCollection = true;
                    proposedType      = proposedType.TrimStart("Collection(".ToCharArray()).TrimEnd(')');
                }

                ReturnType = TypeMapper.MapType(proposedType);
            }
            else
            {
                ReturnType = "";
            }

            if (!string.IsNullOrWhiteSpace(BindingParameter) && BindingParameter.StartsWith("Collection("))
            {
                IsCollectionAction = true;
                BindingParameter   = BindingParameter.TrimStart("Collection(".ToCharArray()).TrimEnd(')');
            }

            NameSpace =
                xElement.Ancestors().First(a => a.Attribute("Namespace") != null)?.Attribute("Namespace")?.Value;
        }
Exemplo n.º 2
0
        private bool IsMethodValid(MethodInfo info)
        {
#if !NETFX_CORE
            ParameterInfo[] param = info.GetParameters();

            bool valid = true;
            for (int i = 0; i < param.Length; i++)
            {
                if (!BindingParameter.IsValidType(param[i].ParameterType))
                {
                    valid = false;
                    break;
                }

                if (internalParameters.Length > i)
                {
                    Type type = Type.GetType(internalParameters[i]);
                    if (!type.IsAssignableFrom(param[i].ParameterType))
                    {
                        valid = false;
                        break;
                    }
                }
            }

            return(valid);
#else
            return(false);
#endif
        }
Exemplo n.º 3
0
            public object Copy(object destination)
            {
                BindingParameter target = destination as BindingParameter;

                BindingParameter copy = new BindingParameter();

                if (target != null)
                {
                    copy.canBeInternal = target.canBeInternal;
                }
                else
                {
                    copy.canBeInternal = canBeInternal;
                }

                copy.binding           = binding;
                copy.boolValue         = boolValue;
                copy.boundsValue       = boundsValue;
                copy.colorValue        = colorValue;
                copy.component         = component;
                copy.floatValue        = floatValue;
                copy.gameObject        = gameObject;
                copy.intValue          = intValue;
                copy.method            = method;
                copy.qualifiedTypeName = qualifiedTypeName;
                copy.rectValue         = rectValue;
                copy.referenceValue    = referenceValue;
                copy.stringValue       = stringValue;
                copy.type         = type;
                copy.vector2Value = vector2Value;
                copy.vector3Value = vector3Value;
                copy.vector4Value = vector4Value;

                return(copy);
            }
Exemplo n.º 4
0
 public BindingParameterInfo(BindingParameter paramter, BaseViewModel model)
 {
     this.model = model;
     if (paramter.dataFrom == DataFrom.VM)
     {
         propertyInfo = ReflectionTool.GetVmPropertyByName(model.GetType(), paramter.paramStr);
     }
     else
     {
         Type t = Type.GetType(paramter.paramType);
         constValue = Convert.ChangeType(paramter.paramStr, t);
     }
 }
        public static object CreateObject(this ObjectConfigure objectConfigure, IEnumerable <object> _params)
        {
            Expression expr;

            if (!_params.Any())
            {
                expr = Expression.New(objectConfigure.Type);
            }
            else
            {
                var p = new BindingParameter(_params);
                expr = objectConfigure.CreateObjectExpression(p);
            }

            var lambda = Expression.Lambda(expr);

            return(lambda.Compile().DynamicInvoke());
        }
Exemplo n.º 6
0
            public bool Copiable(object destination)
            {
                BindingParameter target = destination as BindingParameter;

                if (target == null)
                {
                    return(false);
                }

                if (target.type != type)
                {
                    return(false);
                }

                if (!target.canBeInternal && binding == BindingType.Internal)
                {
                    return(false);
                }

                return(true);
            }
        public CustomEventAbstract(XElement xElement)
        {
            Name             = xElement.Attribute("Name")?.Value;
            BindingParameter = xElement.Descendants()?
                               .SingleOrDefault(a => a.Name.LocalName == "Parameter" && a.Attribute("Name")?.Value == "bindingParameter")?
                               .Attribute("Type")?.Value;

            ReturnType = xElement.Descendants().SingleOrDefault(a => a.Name.LocalName == "ReturnType")?.Attribute("Type")?.Value;

            if (!string.IsNullOrWhiteSpace(ReturnType) && ReturnType.StartsWith("Collection("))
            {
                ReturnsCollection = true;
                ReturnType        = ReturnType.TrimStart("Collection(".ToCharArray()).TrimEnd(')');
            }

            if (!string.IsNullOrWhiteSpace(BindingParameter) && BindingParameter.StartsWith("Collection("))
            {
                IsCollectionAction = true;
                BindingParameter   = BindingParameter.TrimStart("Collection(".ToCharArray()).TrimEnd(')');
            }

            NameSpace =
                xElement.Ancestors().First(a => a.Attribute("Namespace") != null)?.Attribute("Namespace")?.Value;
        }
            public object Copy(object destination)
            {
                BindingParameter target = destination as BindingParameter;

                BindingParameter copy = new BindingParameter();
                if (target != null)
                    copy.canBeInternal = target.canBeInternal;
                else
                    copy.canBeInternal = canBeInternal;

                copy.binding = binding;
                copy.boolValue = boolValue;
                copy.boundsValue = boundsValue;
                copy.colorValue = colorValue;
                copy.component = component;
                copy.floatValue = floatValue;
                copy.gameObject = gameObject;
                copy.intValue = intValue;
                copy.method = method;
                copy.qualifiedTypeName = qualifiedTypeName;
                copy.rectValue = rectValue;
                copy.referenceValue = referenceValue;
                copy.stringValue = stringValue;
                copy.type = type;
                copy.vector2Value = vector2Value;
                copy.vector3Value = vector3Value;
                copy.vector4Value = vector4Value;

                return copy;
            }
        public static Expression CreateObjectExpression(this ObjectConfigure objectConfigure, BindingParameter _params)
        {
            if (_params == null)
            {
                return(Expression.New(objectConfigure.Type));
            }

            return(Expression.MemberInit(Expression.New(objectConfigure.Type),
                                         objectConfigure.Bindings.Select(x => x.CreateExpression(ref _params)).Where(x => x != null)));
        }