コード例 #1
0
ファイル: CallInfo.cs プロジェクト: redchew-fork/Fasterflect
 public override bool Equals(object obj)
 {
     if (obj is CallInfo other &&
         Name == other.Name &&
         TargetType.Equals(other.TargetType) &&
         ParameterTypes.Length == other.ParameterTypes.Length &&
         GenericTypes.Length == other.GenericTypes.Length &&
         BindingFlags == other.BindingFlags)
     {
         for (int i = 0, count = ParameterTypes.Length; i < count; ++i)
         {
             if (!ParameterTypes[i].Equals(other.ParameterTypes[i]))
             {
                 return(false);
             }
         }
         for (int i = 0, count = GenericTypes.Length; i < count; ++i)
         {
             if (!ParameterTypes[i].Equals(other.GenericTypes[i]))
             {
                 return(false);
             }
         }
         return(true);
     }
     return(false);
 }
        public override Expression <Func <TModel, bool> > GetExpression <TModel>(IColumn column, ISearch search, ParameterExpression parameterExpression)
        {
            var sourcePropertyName = column.Field ?? column.Name;
            var sourceProperty     = GetProperty <TModel> .ByName(sourcePropertyName);

            var sourcePropertyType = sourceProperty.PropertyType;
            var sourceNullableType = Nullable.GetUnderlyingType(sourcePropertyType);

            Expression property = Expression.Property(parameterExpression, sourceProperty);
            bool       canBeConvertedToColumnType = TryConvert(search.Value, out TColumn filterValue);

            if (canBeConvertedToColumnType)
            {
                if (TargetType.Equals(sourcePropertyType))
                {
                    Expression valueCheck = Expression.Equal(property, Expression.Constant(filterValue));

                    return(Expression.Lambda <Func <TModel, bool> >(valueCheck, new ParameterExpression[] { parameterExpression }));
                }
                else if (TargetType.Equals(sourceNullableType))
                {
                    Expression nullCheck  = Expression.NotEqual(property, Expression.Constant(null, sourcePropertyType));
                    Expression valueCheck = Expression.Equal(property, Expression.Convert(Expression.Constant(filterValue), sourcePropertyType));

                    //Expression.Lambda
                    return(Expression.Lambda <Func <TModel, bool> >(Expression.AndAlso(nullCheck, valueCheck), new ParameterExpression[] { parameterExpression }));
                }
            }
            return(null);
        }
コード例 #3
0
        public static bool ImplicitConversionExists(MdbEvaluationContext ctx,
                                                    TargetType source, TargetType target)
        {
            if (source.Equals(target))
            {
                return(true);
            }

            if (source is TargetArrayType && target.Name == "System.Array")
            {
                return(true);
            }

            if (ObjectUtil.FixTypeName(target.Name) == "System.Object")
            {
                return(true);
            }

            if (source is TargetArrayType && target is TargetArrayType)
            {
                TargetArrayType sa = (TargetArrayType)source;
                TargetArrayType ta = (TargetArrayType)target;
                return(sa.ElementType.Equals(ta.ElementType));
            }

            if (source is TargetEnumType)
            {
                TargetEnumType e = (TargetEnumType)source;
                if (ImplicitConversionExists(ctx, e.Value.Type, target))
                {
                    return(true);
                }
            }

            if (target is TargetEnumType)
            {
                TargetEnumType e = (TargetEnumType)target;
                if (ImplicitConversionExists(ctx, source, e.Value.Type))
                {
                    return(true);
                }
            }

            if ((source is TargetFundamentalType) && (target is TargetFundamentalType))
            {
                return(ImplicitFundamentalConversionExists(
                           (TargetFundamentalType)source,
                           (TargetFundamentalType)target));
            }

            if ((source is TargetClassType) && (target is TargetClassType))
            {
                return(ImplicitReferenceConversionExists(
                           ctx, (TargetClassType)source,
                           (TargetClassType)target));
            }

            return(false);
        }
コード例 #4
0
 public override bool Equals(object obj)
 {
     if (obj == null || !(obj is ReflectionBasedType))
     {
         return(false);
     }
     return(TargetType.Equals(((ReflectionBasedType)obj).TargetType));
 }
コード例 #5
0
        private static bool IsTargetTypeCorrect(string methodName, TargetType expected)
        {
            if (STRING_TO_TARGET_TYPE.ContainsKey(methodName))
            {
                return(expected.Equals(STRING_TO_TARGET_TYPE[methodName]));
            }

            return(false);
        }
コード例 #6
0
 public override bool Equals(object obj)
 {
     return(obj is MemberCallInfo other &&
            other != null &&
            TargetType.Equals(other.TargetType) &&
            BindingFlags == other.BindingFlags &&
            MemberName == other.MemberName &&
            (other.MemberType & MemberType) != 0);
 }
コード例 #7
0
    public bool InRange(AbilityManager manager)
    {
        if (targetType.Equals(TargetType.Self))
        {
            return(true);
        }
        if (target == null)
        {
            return(false);
        }
        var distance = Math.Abs(Vector3.Distance(manager.transform.position, target.transform.position));

        return(distance <= range);
    }
コード例 #8
0
        private void SetSelectable(char c, bool state, TargetType targetType = TargetType.ALL)
        {
            if (hero.passToStock)
            {
                return;
            }

            if (targetType.Equals(TargetType.SELF))
            {
                nowActor.GetComponent <BoxCollider2D>().enabled = state;
                return;
            }

            foreach (var actor in battleMgr.actorList)
            {
                var e = actor.GetComponent <Entity>();
                if (e.battleID.ToLowerInvariant().IndexOf(c) != -1)
                {
                    e.GetComponent <BoxCollider2D>().enabled = state;
                }
            }
        }
コード例 #9
0
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            if (binder == null)
            {
                throw new ArgumentNullException(nameof(binder));
            }
            result = null;
            if (TargetType.BaseType.Equals(typeof(DynamicObject)))
            {
                //var binder2 = new ExGetMemberBinder(binder.Name, true);
                var dic = Instance.GetType().GetField("Dictionary").GetValue(Instance) as IDictionary <string, object>;
                if (dic != null && dic.ContainsKey(binder.Name.ToLower()))
                {
                    var ssss = dic[binder.Name];
                    result = ssss.AsDynamic();
                }
                else
                {
                    return(true);
                }
            }
            else if (TargetType.Equals(typeof(ExpandoObject)))
            {
                result = ((IDictionary <string, object>)Instance)[binder.Name].AsDynamic();
            }
            else
            {
                IProperty prop = GetProperty(binder.Name);

                // Get the property value
                result = prop.GetValue(Instance, index: null);

                // Wrap the sub object if necessary. This allows nested anonymous objects to work.
                result = result.AsDynamic();
            }
            return(true);
        }
コード例 #10
0
 private bool Equals(CastExpression other)
 {
     return(TargetType.Equals(other.TargetType) && Operator == other.Operator &&
            Reference.Equals(other.Reference));
 }