Provides the base class from which the classes that represent bindings that are used to initialize members of a newly created object derive.
Exemple #1
0
            private MemberBinding Convert(LinqExp.MemberBinding linqBinding)
            {
                switch (linqBinding.BindingType)
                {
                case LinqExp.MemberBindingType.Assignment:
                    var linqMemberAssignment = (LinqExp.MemberAssignment)linqBinding;

                    return(Expression.Bind(
                               linqMemberAssignment.Member,
                               ConvertExp(linqMemberAssignment.Expression)));

                case LinqExp.MemberBindingType.MemberBinding:
                    var linqMemberBinding = (LinqExp.MemberMemberBinding)linqBinding;

                    return(Expression.MemberBind(
                               linqMemberBinding.Member,
                               linqMemberBinding.Bindings.Project(Convert)));

                case LinqExp.MemberBindingType.ListBinding:
                    var linqListBinding = (LinqExp.MemberListBinding)linqBinding;

                    return(Expression.ListBind(
                               linqListBinding.Member,
                               linqListBinding.Initializers.Project(Convert)));

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
 public static EditableMemberBinding CreateEditableMemberBinding(MemberBinding member)
 {
     if (member is MemberAssignment) return new EditableMemberAssignment(member as MemberAssignment);
     else if (member is MemberListBinding) return new EditableMemberListBinding(member as MemberListBinding);
     else if (member is MemberMemberBinding) return new EditableMemberMemberBinding(member as MemberMemberBinding);
     else return null;
 }
        public static Expression CreateExpression(IContainerContext containerContext, ResolutionConstructor resolutionConstructor, ResolutionInfo resolutionInfo,
            Expression resolutionInfoExpression, ResolutionMember[] members = null)
        {
            var length = resolutionConstructor.Parameters.Length;
            var arguments = new Expression[length];

            for (var i = 0; i < length; i++)
            {
                var parameter = resolutionConstructor.Parameters[i];
                arguments[i] = containerContext.ResolutionStrategy.GetExpressionForResolutionTarget(parameter, resolutionInfo, resolutionInfoExpression);
            }

            var newExpression = Expression.New(resolutionConstructor.Constructor, arguments);

            if (members == null || members.Length == 0) return newExpression;
            {
                var propLength = members.Length;
                var propertyExpressions = new MemberBinding[propLength];
                for (var i = 0; i < propLength; i++)
                {
                    var member = members[i];
                    var propertyExpression = Expression.Bind(member.MemberInfo,
                        containerContext.ResolutionStrategy.GetExpressionForResolutionTarget(member.ResolutionTarget, resolutionInfo, resolutionInfoExpression));
                    propertyExpressions[i] = propertyExpression;
                }

                return Expression.MemberInit(newExpression, propertyExpressions);
            }
        }
        public static CreateInstance CreateConstructorExpression(IContainerContext containerContext, ResolutionConstructor resolutionConstructor,
            ResolutionMember[] members = null)
        {
            var strategyParameter = Expression.Constant(containerContext.ResolutionStrategy, typeof(IResolutionStrategy));
            var resolutionInfoParameter = Expression.Parameter(typeof(ResolutionInfo), "resolutionInfo");

            var arguments = CreateExpressionFromResolutionTargets(resolutionConstructor.Parameters, strategyParameter, resolutionInfoParameter);

            var newExpression = Expression.New(resolutionConstructor.Constructor, arguments);

            if (members == null || members.Length == 0)
                return Expression.Lambda<CreateInstance>(newExpression, resolutionInfoParameter).Compile();

            var length = members.Length;
            var propertyExpressions = new MemberBinding[length];
            for (var i = 0; i < length; i++)
            {
                var member = members[i];
                var propertyExpression = Expression.Bind(member.MemberInfo,
                    CreateResolutionTargetExpression(member.ResolutionTarget, strategyParameter,
                        resolutionInfoParameter));
                propertyExpressions[i] = propertyExpression;

            }

            var initExpression = Expression.MemberInit(newExpression, propertyExpressions);
            return Expression.Lambda<CreateInstance>(initExpression, resolutionInfoParameter).Compile();
        }
        protected override MemberBinding VisitMemberBinding(MemberBinding memberBinding)
        {
            if(memberBinding.BindingType == MemberBindingType.Assignment)
            {
#if PORTABLE
                var propertyInfo = memberBinding.Member as PropertyInfo;
                var assignment = memberBinding as MemberAssignment;
                if (propertyInfo != null 
                    && assignment != null 
                    && assignment.Expression.Type.IsValueType 
                    && !propertyInfo.PropertyType.IsValueType)
                {
                    var valueExpression = Expression.TypeAs(VisitExpression(assignment.Expression), propertyInfo.PropertyType);
                    return Expression.Bind(memberBinding.Member, valueExpression);
                }
#else
                if (memberBinding.Member.MemberType == MemberTypes.Property)
                {
                    var propertyInfo = memberBinding.Member as PropertyInfo;
                    var assignment = memberBinding as MemberAssignment;
                    if (assignment.Expression.Type.IsValueType && !propertyInfo.PropertyType.IsValueType)
                    {
                        var valueExpression = Expression.TypeAs(VisitExpression(assignment.Expression), propertyInfo.PropertyType);
                        return Expression.Bind(memberBinding.Member, valueExpression);
                    }
                }
#endif
            }
            return base.VisitMemberBinding(memberBinding);
        }
        /// <summary>
        /// Transforms a call to <code>entity.Mixin&lt;T&gt;()</code> to <code>new MixinType { Properties, ... }</code>
        /// </summary>
        /// <param name="method">The method call expression.</param>
        /// <returns>The</returns>
        public Expression TransformMixinMethodExpression(MethodCallExpression method)
        {
            var mixinType = method.Type;
            var entityType = method.Object.Type;
            string prefix = $"{mixinType.Name}_";

            // Get the available properties of the mixin.
            var entity = _model.GetEntityType(entityType);
            var properties = entity
                .GetProperties()
                .Where(p => p.Name.StartsWith(prefix))
                .ToArray();

            // Create an object initializer expression.
            var ctor = Expression.New(mixinType);
            var memberBindings = new MemberBinding[properties.Length];
            for (int i = 0; i < properties.Length; i++)
            {
                var property = properties[i];
                string propertyName = property.Name.Replace(prefix, "");
                var member = mixinType.GetProperty(propertyName);
                var value = Expression.Call(
                    EntityQueryModelVisitor.PropertyMethodInfo.MakeGenericMethod(member.PropertyType),
                    method.Object,
                    Expression.Constant(property.Name));

                memberBindings[i] = Expression.Bind(member, value);
            }

            return Expression.MemberInit(ctor, memberBindings);
        }
Exemple #7
0
 private static void BindToProjectedWrapperMany(Expression[] bindingExpressions, int expressionStartIndex, MemberBinding[] bindings, int bindingStartIndex)
 {
     int propertyIndex = 0;
     while ((propertyIndex < (precreatedProjectedWrapperTypes.Length - 1)) && ((propertyIndex + expressionStartIndex) < bindingExpressions.Length))
     {
         bindings[bindingStartIndex + propertyIndex] = BindToProjectedProperty(typeof(ProjectedWrapperMany), propertyIndex, bindingExpressions[expressionStartIndex + propertyIndex]);
         propertyIndex++;
     }
     if (bindingExpressions.Length <= ((precreatedProjectedWrapperTypes.Length - 1) + expressionStartIndex))
     {
         while (propertyIndex < (precreatedProjectedWrapperTypes.Length - 1))
         {
             bindings[bindingStartIndex + propertyIndex] = BindToProjectedProperty(typeof(ProjectedWrapperMany), propertyIndex, Expression.Constant(string.Empty, typeof(string)));
             propertyIndex++;
         }
         bindings[(bindingStartIndex + precreatedProjectedWrapperTypes.Length) - 1] = Expression.Bind(typeof(ProjectedWrapperMany).GetProperty("Next"), Expression.MemberInit(Expression.New(typeof(ProjectedWrapperManyEnd)), new MemberBinding[] { Expression.Bind(typeof(ProjectedWrapperManyEnd).GetProperty("ResourceTypeName"), Expression.Constant(string.Empty, typeof(string))) }));
     }
     else
     {
         int length = bindingExpressions.Length - ((precreatedProjectedWrapperTypes.Length - 1) + expressionStartIndex);
         if (length > (precreatedProjectedWrapperTypes.Length - 1))
         {
             length = precreatedProjectedWrapperTypes.Length;
         }
         MemberBinding[] bindingArray = new MemberBinding[precreatedProjectedWrapperTypes.Length + 2];
         bindingArray[0] = Expression.Bind(typeof(ProjectedWrapperMany).GetProperty("ResourceTypeName"), Expression.Constant(string.Empty, typeof(string)));
         bindingArray[1] = Expression.Bind(typeof(ProjectedWrapperMany).GetProperty("PropertyNameList"), Expression.Constant(string.Empty, typeof(string)));
         BindToProjectedWrapperMany(bindingExpressions, (expressionStartIndex + precreatedProjectedWrapperTypes.Length) - 1, bindingArray, 2);
         Expression expression = Expression.MemberInit(Expression.New(typeof(ProjectedWrapperMany)), bindingArray);
         bindings[(bindingStartIndex + precreatedProjectedWrapperTypes.Length) - 1] = Expression.Bind(typeof(ProjectedWrapperMany).GetProperty("Next"), expression);
     }
 }
 protected override MemberBinding VisitBinding(MemberBinding binding)
 {
     var save = receivingMember;
     receivingMember = binding.Member;
     var result = base.VisitBinding(binding);
     receivingMember = save;
     return result;
 }
        protected override MemberBinding VisitBinding(MemberBinding node)
        {
            var elementName = BsonClassMap.LookupClassMap(_classes.Peek()).GetMemberMap(node.Member.Name).ElementName;
            _assigments.Push(elementName);

            MemberBinding visitMemberBinding = base.VisitBinding(node);
            _assigments.Pop();
            return visitMemberBinding;
        }
Exemple #10
0
        private static MemberInitExpression CreateMemberInitExpression(ParameterExpression left, Type entityType, Type dtoType, Tuple <Type, string>[] linkEntityNames)
        {
            System.Linq.Expressions.NewExpression newAnimal = System.Linq.Expressions.Expression.New(dtoType);

            List <MemberBinding> bindings = new List <MemberBinding>();
            var members = dtoType.GetProperties();//获取Dto的各个属性

            members.ToList().ForEach(p =>
            {
                try
                {
                    if (linkEntityNames != null && linkEntityNames.Length > 0)
                    {
                        var container = linkEntityNames.ToList().FirstOrDefault(x => p.Name.Contains(x.Item2));
                        if (container != null)
                        {
                            var rightStr = p.Name.Replace(container.Item2, "");

                            Expression right = Expression.Property(left, entityType.GetProperty(container.Item2));

                            MemberExpression mem = Expression.Property(right, rightStr);
                            //这里传的mem是 用 a.name给它赋值
                            System.Linq.Expressions.MemberBinding speciesMemberBinding = System.Linq.Expressions.Expression.Bind(p, mem);
                            bindings.Add(speciesMemberBinding);
                        }
                        else
                        {
                            MemberExpression mem = Expression.Property(left, p.Name);
                            //这里传的mem是 用 a.name给它赋值
                            System.Linq.Expressions.MemberBinding speciesMemberBinding = System.Linq.Expressions.Expression.Bind(p, mem);
                            bindings.Add(speciesMemberBinding);
                        }
                    }
                    else
                    {
                        try
                        {
                            MemberExpression mem = Expression.Property(left, p.Name);
                            //这里传的mem是 用 a.name给它赋值
                            System.Linq.Expressions.MemberBinding speciesMemberBinding = System.Linq.Expressions.Expression.Bind(p, mem);
                            bindings.Add(speciesMemberBinding);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
                catch
                {
                }
            });

            System.Linq.Expressions.MemberInitExpression memberInitExpression = System.Linq.Expressions.Expression.MemberInit(newAnimal, bindings.ToArray());

            return(memberInitExpression);
        }
 public MemberBinding[] Decode(ref byte* data, ref int remainingBytes, bool doNotCheckBounds)
 {
     int count = intCodec.Decode(ref data, ref remainingBytes, doNotCheckBounds);
     if (count == -1)
         return null;
     var result = new MemberBinding[count];
     for (int i = 0; i < count; i++)
         result[i] = memberBindingCodec.Decode(ref data, ref remainingBytes, doNotCheckBounds);
     return result;
 }
		protected virtual MemberBinding VisitBinding (MemberBinding binding)
		{
			switch (binding.BindingType)
			{
				case MemberBindingType.Assignment:
					return VisitMemberAssignment ((MemberAssignment)binding);
				default:
					throw new ArgumentException (string.Format ("Unhandled binding type '{0}'", binding.BindingType));
			}
		}
 public static IMemberBindingMutator GetMutator(MemberBinding memberBinding)
 {
     if (memberBinding is MemberAssignment)
         return new MemberAssignmentMutator((MemberAssignment)memberBinding);
     if (memberBinding is MemberMemberBinding)
         return new MemberMemberBindingMutator((MemberMemberBinding)memberBinding);
     if (memberBinding is MemberListBinding)
         return new MemberListBindingMutator((MemberListBinding)memberBinding);
     throw Error.BadArgument("S0040: Unknown Expression Type '{0}'", memberBinding.GetType());
 }
Exemple #14
0
        public static void CreateMemberInitExpression()
        {
            System.Linq.Expressions.NewExpression newAnimal =
                System.Linq.Expressions.Expression.New(typeof(Animal));

            System.Reflection.MemberInfo speciesMember =
                typeof(Animal).GetMember("Species")[0];
            System.Reflection.MemberInfo ageMember =
                typeof(Animal).GetMember("Age")[0];

            // Create a MemberBinding object for each member
            // that you want to initialize.
            System.Linq.Expressions.MemberBinding speciesMemberBinding =
                System.Linq.Expressions.Expression.Bind(
                    speciesMember,
                    System.Linq.Expressions.Expression.Constant("horse"));
            System.Linq.Expressions.MemberBinding ageMemberBinding =
                System.Linq.Expressions.Expression.Bind(
                    ageMember,
                    System.Linq.Expressions.Expression.Constant(12));

            // Create a MemberInitExpression that represents initializing
            // two members of the 'Animal' class.
            System.Linq.Expressions.MemberInitExpression memberInitExpression =
                System.Linq.Expressions.Expression.MemberInit(
                    newAnimal,
                    speciesMemberBinding,
                    ageMemberBinding);


            //// Create a MemberInitExpression that represents initializing
            //// two members of the 'Animal' class.
            //System.Linq.Expressions.MemberInitExpression memberInitExpression =
            //    System.Linq.Expressions.Expression.MemberInit(
            //        newAnimal,
            //        speciesMemberBinding);

            Console.WriteLine(memberInitExpression.ToString());

            var expression = Expression.Lambda <Func <Dog, Animal> >(memberInitExpression);
            var compile    = expression.Compile();

            var dog = new Dog()
            {
                Species = "DOG"
            };

            var test = compile(dog);

            Console.WriteLine(test.ToJson());
            // This code produces the following output:
            //
            // new Animal() {Species = "horse", Age = 12}
        }
 internal static Expression ReduceMemberBinding(ParameterExpression objVar, MemberBinding binding) {
     MemberExpression member = Expression.MakeMemberAccess(objVar, binding.Member);
     switch (binding.BindingType) {
         case MemberBindingType.Assignment:
             return Expression.Assign(member, ((MemberAssignment)binding).Expression);
         case MemberBindingType.ListBinding:
             return ReduceListInit(member, ((MemberListBinding)binding).Initializers, false);
         case MemberBindingType.MemberBinding:
             return ReduceMemberInit(member, ((MemberMemberBinding)binding).Bindings, false);
         default: throw Assert.Unreachable;
     }
 }
		internal virtual MemberBinding VisitBinding(MemberBinding binding) {
			switch (binding.BindingType) {
				case MemberBindingType.Assignment:
					return this.VisitMemberAssignment((MemberAssignment)binding);
				case MemberBindingType.MemberBinding:
					return this.VisitMemberMemberBinding((MemberMemberBinding)binding);
				case MemberBindingType.ListBinding:
					return this.VisitMemberListBinding((MemberListBinding)binding);
				default:
					throw Error.UnhandledBindingType(binding.BindingType);
			}
		}
		protected virtual MemberBinding VisitBinding(MemberBinding binding, Stack<string> stack, Stack<IElasticPropertyAttribute> properties)
		{
			switch (binding.BindingType)
			{
				case MemberBindingType.Assignment:
					return this.VisitMemberAssignment((MemberAssignment)binding, stack, properties);
				case MemberBindingType.MemberBinding:
					return this.VisitMemberMemberBinding((MemberMemberBinding)binding, stack, properties);
				case MemberBindingType.ListBinding:
					return this.VisitMemberListBinding((MemberListBinding)binding, stack, properties);
				default:
					throw new Exception(string.Format("Unhandled binding type '{0}'", binding.BindingType));
			}
		}
 protected virtual MemberBinding VisitBinding(MemberBinding binding)
 {
     switch (binding.BindingType)
     {
         case MemberBindingType.Assignment:
             return this.VisitMemberAssignment((MemberAssignment)binding);
         case MemberBindingType.MemberBinding:
             return this.VisitMemberMemberBinding((MemberMemberBinding)binding);
         case MemberBindingType.ListBinding:
             return this.VisitMemberListBinding((MemberListBinding)binding);
         default:
             throw new Exception($"Unhandled binding type '{binding.BindingType}'");
     }
 }
        internal static MemberBindingNode Create(INodeFactory factory, MemberBinding memberBinding)
        {
            MemberBindingNode memberBindingNode = null;

            if (memberBinding is MemberAssignment)
                memberBindingNode = new MemberAssignmentNode(factory, (MemberAssignment)memberBinding);
            else if (memberBinding is MemberListBinding)
                memberBindingNode = new MemberListBindingNode(factory, (MemberListBinding)memberBinding);
            else if (memberBinding is MemberMemberBinding)
                memberBindingNode = new MemberMemberBindingNode(factory, (MemberMemberBinding)memberBinding);
            else if (memberBinding != null)
                throw new ArgumentException("Unknown member binding of type " + memberBinding.GetType(), "memberBinding");

            return memberBindingNode;
        }
        internal static Expression ReduceMemberBinding(ParameterExpression objVar, MemberBinding binding)
        {
            MemberExpression left = Expression.MakeMemberAccess(objVar, binding.Member);
            switch (binding.BindingType)
            {
                case MemberBindingType.Assignment:
                    return Expression.Assign(left, ((MemberAssignment) binding).Expression);

                case MemberBindingType.MemberBinding:
                    return ReduceMemberInit(left, ((MemberMemberBinding) binding).Bindings, false);

                case MemberBindingType.ListBinding:
                    return ReduceListInit(left, ((MemberListBinding) binding).Initializers, false);
            }
            throw ContractUtils.Unreachable;
        }
 protected virtual bool AreEqualBinding(MemberBinding x, MemberBinding y)
 {
     if (x.BindingType != y.BindingType)
         return false;
     
     switch (x.BindingType)
     {
         case MemberBindingType.Assignment:
             return this.AreEqualMemberAssignment((MemberAssignment)x, (MemberAssignment)y);                    
         case MemberBindingType.MemberBinding:
             return this.AreEqualMemberMemberBinding((MemberMemberBinding)x, (MemberMemberBinding)y);                    
         case MemberBindingType.ListBinding:
             return this.AreEqualMemberListBinding((MemberListBinding)x, (MemberListBinding)y);                                        
         default:
             throw new Exception(string.Format("Unhandled binding type '{0}'", y.BindingType));
     }
 }
Exemple #22
0
        public static MemberBinding Serialize(E.MemberBinding binding)
        {
            switch (binding.BindingType)
            {
            case E.MemberBindingType.Assignment:
                return(MemberAssignment.Serialize((E.MemberAssignment)binding));

            case E.MemberBindingType.MemberBinding:
                return(MemberMemberBinding.Serialize((E.MemberMemberBinding)binding));

            case E.MemberBindingType.ListBinding:
                return(MemberListBinding.Serialize((E.MemberListBinding)binding));

            default:
                throw new ArgumentOutOfRangeException("binding.BindingType");
            }
        }
Exemple #23
0
 internal static MemberBinding[] Bind(Expression[] bindingExpressions, Type projectedWrapperType)
 {
     MemberBinding[] bindingArray;
     int length = bindingExpressions.Length;
     if (length <= (precreatedProjectedWrapperTypes.Length + 1))
     {
         bindingArray = new MemberBinding[length];
         BindResourceTypeAndPropertyNameList(projectedWrapperType, bindingArray, bindingExpressions);
         for (int i = 0; i < (length - 2); i++)
         {
             bindingArray[i + 2] = BindToProjectedProperty(projectedWrapperType, i, bindingExpressions[i + 2]);
         }
         return bindingArray;
     }
     bindingArray = new MemberBinding[precreatedProjectedWrapperTypes.Length + 2];
     BindResourceTypeAndPropertyNameList(projectedWrapperType, bindingArray, bindingExpressions);
     BindToProjectedWrapperMany(bindingExpressions, 2, bindingArray, 2);
     return bindingArray;
 }
		protected object Visit(object obj, MemberBinding binding)
		{
			switch (binding.BindingType)
			{
			case MemberBindingType.Assignment:
				var assignment = ((MemberAssignment)binding);

				var value = this.Visit(assignment.Expression);

				if (value == InterpretFailed)
				{
					return value;
				}

				var fieldInfo = assignment.Member as FieldInfo;

				if (fieldInfo != null)
				{
					fieldInfo.SetValue(obj, value);

					return binding;
				}

				var propertyInfo = assignment.Member as PropertyInfo;

				if (propertyInfo != null)
				{
					propertyInfo.SetValue(obj, value, null);

					return binding;
				}

				return InterpretFailed;
			}

			return InterpretFailed;
		}
 private Expression ParseNew()
 {
     NextToken();
     ValidateToken(TokenId.OpenParen, Res.OpenParenExpected);
     NextToken();
     List<DynamicProperty> properties = new List<DynamicProperty>();
     List<Expression> expressions = new List<Expression>();
     while (true)
     {
         int exprPos = token.pos;
         Expression expr = ParseExpression();
         string propName;
         if (TokenIdentifierIs("as"))
         {
             NextToken();
             propName = GetIdentifier();
             NextToken();
         }
         else
         {
             MemberExpression me = expr as MemberExpression;
             if (me == null) throw ParseError(exprPos, Res.MissingAsClause);
             propName = me.Member.Name;
         }
         expressions.Add(expr);
         properties.Add(new DynamicProperty(propName, expr.Type));
         if (token.id != TokenId.Comma) break;
         NextToken();
     }
     ValidateToken(TokenId.CloseParen, Res.CloseParenOrCommaExpected);
     NextToken();
     Type type = DynamicExpression.CreateClass(properties);
     MemberBinding[] bindings = new MemberBinding[properties.Count];
     for (int i = 0; i < bindings.Length; i++)
         bindings[i] = Expression.Bind(type.GetProperty(properties[i].Name), expressions[i]);
     return Expression.MemberInit(Expression.New(type), bindings);
 }
Exemple #26
0
 /// <summary>
 /// MemberBinding visit method
 /// </summary>
 /// <param name="binding">The MemberBinding expression to visit</param>
 /// <returns>The visited MemberBinding expression </returns>
 public virtual MemberBinding VisitBinding(MemberBinding binding)
 {
     switch (binding.BindingType)
     {
         case MemberBindingType.Assignment:
             return this.VisitMemberAssignment((MemberAssignment)binding);
         case MemberBindingType.MemberBinding:
             return this.VisitMemberMemberBinding((MemberMemberBinding)binding);
         case MemberBindingType.ListBinding:
             return this.VisitMemberListBinding((MemberListBinding)binding);
         default:
             throw new NotSupportedException();
     }
 }
 private static MemberBinding VisitMemberBinding(MemberBinding node)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Returns the <see cref="TypeRegistration"/> entry for the actual trace listener represented by this 
        /// configuration object.
        /// </summary>
        /// <returns>A registry entry.</returns>
        protected TypeRegistration GetTraceListenerTypeRegistration()
        {
            IEnumerable<MemberBinding> extraBindings;

            Expression creationExpression = GetCreationExpression().Body;

            NewExpression newExpression = creationExpression as NewExpression;
            if (newExpression != null)
            {
                extraBindings = new MemberBinding[0];
            }
            else
            {
                MemberInitExpression memberInitExpression = creationExpression as MemberInitExpression;
                if (memberInitExpression != null)
                {
                    newExpression = memberInitExpression.NewExpression;
                    extraBindings = memberInitExpression.Bindings;
                }
                else
                {
                    throw new NotSupportedException(Logging.Properties.Resources.ExceptionCreationLinqExpressionMustBeNew);
                }
            }

            MemberInitExpression memberInit =
                LambdaExpression.MemberInit(newExpression, GetSharedBindings().Concat(extraBindings));

            TypeRegistration registration =
                new TypeRegistration<TraceListener>(LambdaExpression.Lambda<Func<TraceListener>>(memberInit))
                {
                    Name = this.WrappedTraceListenerName,
                    Lifetime = TypeRegistrationLifetime.Transient
                };

            return registration;
        }
        protected override MemberBinding VisitBinding(MemberBinding binding)
        {
            // we need to visit the original expression tree first in order to collect all
            // necessary informations
            base.VisitBinding(binding);

            // now we replace the original member binding for our
            // GetValues call to the ResponseCatalogue
            if (binding is MemberAssignment) {
                var assignment = (MemberAssignment) binding;

                var type = assignment.Expression.Type;
                var identifier = _processor.Items.Last().Identifier;
                var expression = CreateSurrogateExpression(type, identifier);
                var surrogate = assignment.Update(expression);
                return surrogate;
            }

            throw new NotSupportedException();
        }
 public ScriptBuilderException(CSharpToJSExceptionType type, Expression root, MemberBinding binding, Exception innerException)
     : base(root, binding, innerException)
 {
     Type = type;
 }
 public virtual MemberBinding VisitBinding(MemberBinding binding)
 {
     switch (binding.BindingType)
     {
         case MemberBindingType.Assignment:
             return this.VisitMemberAssignment((MemberAssignment)binding);
         case MemberBindingType.MemberBinding:
             return this.VisitMemberMemberBinding((MemberMemberBinding)binding);
         case MemberBindingType.ListBinding:
             return this.VisitMemberListBinding((MemberListBinding)binding);
         default:
             throw new Exception(string.Format("Unhandled binding type '{0}'", binding.BindingType));
     }
 }
 protected virtual bool CompareBinding(MemberBinding a, MemberBinding b)
 {
     if (a == b)
         return true;
     if (a == null || b == null)
         return false;
     if (a.BindingType != b.BindingType)
         return false;
     if (a.Member != b.Member)
         return false;
     switch (a.BindingType)
     {
         case MemberBindingType.Assignment:
             return this.CompareMemberAssignment((MemberAssignment)a, (MemberAssignment)b);
         case MemberBindingType.ListBinding:
             return this.CompareMemberListBinding((MemberListBinding)a, (MemberListBinding)b);
         case MemberBindingType.MemberBinding:
             return this.CompareMemberMemberBinding((MemberMemberBinding)a, (MemberMemberBinding)b);
         default:
             throw new Exception(string.Format("Unhandled binding type: '{0}'", a.BindingType));
     }
 }
 /// <summary>
 /// Visit a bindingExp expression.
 /// </summary>
 /// <param name="bindingExp"></param>
 /// <returns></returns>
 protected virtual MemberBinding VisitBinding(MemberBinding bindingExp)
 {
     switch (bindingExp.BindingType)
     {
         case MemberBindingType.Assignment:
             return VisitMemberAssignment((MemberAssignment)bindingExp);
         case MemberBindingType.MemberBinding:
             return VisitMemberMemberBinding((MemberMemberBinding)bindingExp);
         case MemberBindingType.ListBinding:
             return VisitMemberListBinding((MemberListBinding)bindingExp);
         default:
             throw new NotSupportedException(string.Format("Unhandled binding type '{0}'", bindingExp.BindingType));
     }
 }
 /// <summary>
 /// Visits a MemberBinding.
 /// </summary>
 /// <param name="node">The MemberBinding.</param>
 /// <returns>The MemberBinding (possibly modified).</returns>
 protected override MemberBinding VisitMemberBinding(MemberBinding node)
 {
     throw new NotImplementedException();
 }
 public MemberBindingExpressionTree Visit(MemberBinding node) => base.VisitMemberBinding(node);