public Expression <Func <TTo, bool> > Convert(Expression <Func <TFrom, bool> > predicate) { MaybeExtension.GetOrDefault <BinaryExpression>(MaybeExtension.MaybeAs <BinaryExpression>((object)predicate.Body, true), (BinaryExpression)null); MaybeExtension.GetOrDefault <UnaryExpression>(MaybeExtension.MaybeAs <UnaryExpression>((object)predicate.Body, true), (UnaryExpression)null); MaybeExtension.GetOrDefault <MethodCallExpression>(MaybeExtension.MaybeAs <MethodCallExpression>((object)predicate.Body, true), (MethodCallExpression)null); return((Expression <Func <TTo, bool> >)null); }
public string GetMemberName(Expression expression) { return(Enumerable.FirstOrDefault <string>((IEnumerable <string>) new List <string>() { MaybeExtension.GetOrDefault <string>(MaybeExtension.Bind <MemberExpression, string>(MaybeExtension.MaybeAs <MemberExpression>((object)expression, true), (Func <MemberExpression, string>)(p => p.Member.Name)), (string)null), MaybeExtension.GetOrDefault <string>(MaybeExtension.Bind <UnaryExpression, string>(MaybeExtension.MaybeAs <UnaryExpression>((object)expression, true), (Func <UnaryExpression, Maybe <string> >)(t => MaybeExtension.Bind <MemberExpression, string>(MaybeExtension.MaybeAs <MemberExpression>((object)t.Operand, true), (Func <MemberExpression, string>)(p => p.Member.Name)))), (string)null), MaybeExtension.GetOrDefault <string>(MaybeExtension.Bind <MethodCallExpression, string>(MaybeExtension.MaybeAs <MethodCallExpression>((object)expression, true), (Func <MethodCallExpression, Maybe <string> >)(p => MaybeExtension.Bind <MemberExpression, string>(MaybeExtension.MaybeAs <MemberExpression>((object)MaybeExtension.GetOrDefault <Expression>(MaybeExtension.Bind <LambdaExpression, Expression>(MaybeExtension.MaybeAs <LambdaExpression>((object)Enumerable.Last <Expression>((IEnumerable <Expression>)p.Arguments), true), (Func <LambdaExpression, Expression>)(c => c.Body)), (Expression)null), true), (Func <MemberExpression, string>)(c => c.Member.Name)))), (string)null) }, (Func <string, bool>)(c => c != null))); }
public TValue this[TKey key] { get { return(MaybeExtension.GetOrDefault <TValue>(DictionaryExtensions.GetValue <TKey, TValue>(this._dictionary, key), this._defaultValue)); } set { this._dictionary[key] = value; } }
public List <LastLevelNodeExpressionTreeModel> VisitRights(Expression exp) { WebRockExpressionConverterVisitor converterVisitor = new WebRockExpressionConverterVisitor(); List <LastLevelNodeExpressionTreeModel> list = new List <LastLevelNodeExpressionTreeModel>(); converterVisitor.Visit(exp); for (int index = 0; index < converterVisitor.Rights.Count; ++index) { Expression expression1 = converterVisitor.Lefts.Count < index || converterVisitor.Lefts.Count == 0 ? (Expression)null : converterVisitor.Lefts[index]; Expression expression2 = converterVisitor.Rights[index]; ExpressionType expressionType = converterVisitor.LastLevelNodeTypes.Count < index || converterVisitor.LastLevelNodeTypes.Count == 0 ? ExpressionType.Throw : converterVisitor.LastLevelNodeTypes[index].ValueOfExpressionType; MethodInfo methodInfo = converterVisitor.LastLevelNodeTypes.Count < index || converterVisitor.LastLevelNodeTypes.Count == 0 ? (MethodInfo)null : converterVisitor.LastLevelNodeTypes[index].CurrentMethodInfo; list.Add(new LastLevelNodeExpressionTreeModel() { LeftExpression = expression1, RightExpression = expression2, ExpressionWithMethodModel = new ExpressionWithMethodModel() { ValueOfExpressionType = expressionType, CurrentMethodInfo = methodInfo } }); } UnaryExpression orDefault = MaybeExtension.GetOrDefault <UnaryExpression>(MaybeExtension.MaybeAs <UnaryExpression>((object)exp, true), (UnaryExpression)null); if (orDefault != null) { list.Add(new LastLevelNodeExpressionTreeModel() { LeftExpression = orDefault.Operand, RightExpression = (Expression)null, ExpressionWithMethodModel = new ExpressionWithMethodModel() { ValueOfExpressionType = orDefault.NodeType, CurrentMethodInfo = orDefault.Method } }); } return(list); }
public PropertyInfo GetPropertyInfoFromType(Type nestedType) { return(MaybeExtension.GetOrDefault <PropertyInfo>(MaybeExtension.MaybeAs <PropertyInfo>((object)Enumerable.FirstOrDefault <PropertyInfo>((IEnumerable <PropertyInfo>)nestedType.GetProperties(), (Func <PropertyInfo, bool>)(c => !this.IsStandardType(c.PropertyType))), true), (PropertyInfo)null)); }
public Type GetMemberType(Expression expression) { return(MaybeExtension.GetOrDefault <Type>(MaybeExtension.Bind <MemberExpression, Type>(MaybeExtension.MaybeAs <MemberExpression>((object)expression, true), (Func <MemberExpression, Type>)(p => p.Type)), (Type)null) ?? MaybeExtension.GetOrDefault <Type>(MaybeExtension.Bind <UnaryExpression, Type>(MaybeExtension.MaybeAs <UnaryExpression>((object)expression, true), (Func <UnaryExpression, Type>)(t => t.Operand.Type)), (Type)null)); }
public Type GetPropertyType(Type nestedType, List <Type> exceptTypeList) { return(MaybeExtension.GetOrDefault <Type>(MaybeExtension.Bind <PropertyInfo, Type>(MaybeExtension.MaybeAs <PropertyInfo>((object)Enumerable.FirstOrDefault <PropertyInfo>((IEnumerable <PropertyInfo>)nestedType.GetProperties(), (Func <PropertyInfo, bool>)(c => !this.IsStandardType(c.PropertyType) && !exceptTypeList.Contains(c.PropertyType))), true), (Func <PropertyInfo, Type>)(c => c.PropertyType)), (Type)null)); }
public IEnumerable <string> GetValuesByKeyAndPredicate(string key, Func <XElement, bool> preFunc) { return(Enumerable.SelectMany <XElement, string>(Enumerable.Where <XElement>(this.GetElemetsByKey(key), preFunc), (Func <XElement, IEnumerable <string> >)(c => Enumerable.Select <XAttribute, string>(c.Attributes(), (Func <XAttribute, string>)(x => MaybeExtension.GetOrDefault <string>(MaybeExtension.Bind <XAttribute, string>(MaybeExtension.MaybeAs <XAttribute>((object)x, true), (Func <XAttribute, string>)(z => z.Value)), (string)null)))))); }
public IEnumerable <string> GetValuesByKeyAndAttribute(string key, string attrName) { return(Enumerable.Select <XElement, string>(Enumerable.Where <XElement>(this.GetElemetsByKey(key), (Func <XElement, bool>)(c => c.HasAttributes)), (Func <XElement, string>)(c => MaybeExtension.GetOrDefault <string>(MaybeExtension.Bind <XAttribute, string>(MaybeExtension.MaybeAs <XAttribute>((object)c.Attribute((XName)attrName), true), (Func <XAttribute, string>)(x => x.Value)), (string)null)))); }