private void ImplementMixinMethods()
        {
            IEnumerable <Type> mixinTypes = this.mixinsModel.GetMixinTypes();

            foreach (Type mixinType in mixinTypes)
            {
                foreach (MethodInfo method in mixinType.GetMethods())
                {
                    MixinModel mixinModel = this.mixinsModel.ImplementMethod(method);

                    MethodConcernsModel methodConcernsModel      = this.concernsModel.ConcernsFor(method, mixinType);
                    MethodConcernsModel mixinMethodConcernsModel = mixinModel.ConcernsFor(method, mixinType);
                    methodConcernsModel = methodConcernsModel.CombineWith(mixinMethodConcernsModel);

                    MethodSideEffectsModel methodSideEffectsModel      = this.sideEffectsModel.SideEffectsFor(method, mixinType);
                    MethodSideEffectsModel mixinMethodSideEffectsModel = mixinModel.SideEffectsFor(method, mixinType);
                    methodSideEffectsModel = methodSideEffectsModel.CombineWith(mixinMethodSideEffectsModel);

                    var methodConstraintsModel = new MethodConstraintsModel(method, this.constraintsModel);

                    var compositeMethodModel = new CompositeMethodModel(methodConstraintsModel, methodConcernsModel, methodSideEffectsModel, this.mixinsModel);
                    this.methods.Add(method, compositeMethodModel);
                }

                foreach (PropertyInfo property in mixinType.GetProperties())
                {
                    this.properties.Add(property);
                }
            }
        }
Example #2
0
        //// Binding
        //public void bind( Resolution resolution ) throws BindingException
        //{
        //    for( MethodConcernModel concernModel : concernsForMethod )
        //    {
        //        concernModel.bind( resolution );
        //    }
        //}


        //public void VisitModel( ModelVisitor modelVisitor )
        //{
        //    modelVisitor.visit( this );
        //    for( MethodConcernModel methodConcernModel : concernsForMethod )
        //    {
        //        methodConcernModel.visitModel( modelVisitor );
        //    }
        //}

        //public MethodConcernsModel combineWith( MethodConcernsModel mixinMethodConcernsModel )
        //{
        //    List<MethodConcernModel> combinedModels = new ArrayList<MethodConcernModel>( concernsForMethod.size() + mixinMethodConcernsModel.concernsForMethod.size() );
        //    combinedModels.addAll( concernsForMethod );
        //    combinedModels.addAll( mixinMethodConcernsModel.concernsForMethod );
        //    return new MethodConcernsModel( method, combinedModels );
        //}

        public MethodConcernsModel CombineWith(MethodConcernsModel that)
        {
            var methodConcernModels = new List<MethodConcernModel>();
            methodConcernModels.AddRange(this.concernsForMethod);
            methodConcernModels.AddRange(that.concernsForMethod);

            var newModel = new MethodConcernsModel(this.Method, methodConcernModels);

            return newModel;
        }
 public CompositeMethodModel(MethodConstraintsModel methodConstraintsModel,
                             MethodConcernsModel methodConcernsModel,
                             MethodSideEffectsModel methodSideEffectsModel,
                             AbstractMixinsModel mixinsModel)
 {
     this.mixins = mixinsModel;
     this.methodConcerns = methodConcernsModel;
     this.methodSideEffects = methodSideEffectsModel;
     this.methodConstraints = methodConstraintsModel;
     this.methodConstraintsInstance = this.methodConstraints.NewInstance();
 }
Example #4
0
        //// Binding
        //public void bind( Resolution resolution ) throws BindingException
        //{
        //    for( MethodConcernModel concernModel : concernsForMethod )
        //    {
        //        concernModel.bind( resolution );
        //    }
        //}


        //public void VisitModel( ModelVisitor modelVisitor )
        //{
        //    modelVisitor.visit( this );
        //    for( MethodConcernModel methodConcernModel : concernsForMethod )
        //    {
        //        methodConcernModel.visitModel( modelVisitor );
        //    }
        //}

        //public MethodConcernsModel combineWith( MethodConcernsModel mixinMethodConcernsModel )
        //{
        //    List<MethodConcernModel> combinedModels = new ArrayList<MethodConcernModel>( concernsForMethod.size() + mixinMethodConcernsModel.concernsForMethod.size() );
        //    combinedModels.addAll( concernsForMethod );
        //    combinedModels.addAll( mixinMethodConcernsModel.concernsForMethod );
        //    return new MethodConcernsModel( method, combinedModels );
        //}

        public MethodConcernsModel CombineWith(MethodConcernsModel that)
        {
            var methodConcernModels = new List <MethodConcernModel>();

            methodConcernModels.AddRange(this.concernsForMethod);
            methodConcernModels.AddRange(that.concernsForMethod);

            var newModel = new MethodConcernsModel(this.Method, methodConcernModels);

            return(newModel);
        }
Example #5
0
 public CompositeMethodModel(MethodConstraintsModel methodConstraintsModel,
                             MethodConcernsModel methodConcernsModel,
                             MethodSideEffectsModel methodSideEffectsModel,
                             AbstractMixinsModel mixinsModel)
 {
     this.mixins                    = mixinsModel;
     this.methodConcerns            = methodConcernsModel;
     this.methodSideEffects         = methodSideEffectsModel;
     this.methodConstraints         = methodConstraintsModel;
     this.methodConstraintsInstance = this.methodConstraints.NewInstance();
 }
Example #6
0
        public MethodConcernsModel ConcernsFor(MethodInfo method, Type type)
        {
            if (!this.methodConcernsModels.ContainsKey(method))
            {
                var concernsForMethod = new List <MethodConcernModel>();
                foreach (ConcernDeclaration concern in this.concerns)
                {
                    if (concern.AppliesTo(method, type))
                    {
                        Type concernType = concern.ModifierClass;
                        concernsForMethod.Add(new MethodConcernModel(concernType));
                    }
                }

                var methodConcerns = new MethodConcernsModel(method, concernsForMethod);
                this.methodConcernsModels.Add(method, methodConcerns);
                return(methodConcerns);
            }

            return(this.methodConcernsModels[method]);
        }
Example #7
0
        public MethodConcernsModel ConcernsFor(MethodInfo method, Type type)
        {
            if (!this.methodConcernsModels.ContainsKey(method))
            {
                var concernsForMethod = new List<MethodConcernModel>();
                foreach (ConcernDeclaration concern in this.concerns)
                {
                    if (concern.AppliesTo(method, type))
                    {
                        Type concernType = concern.ModifierClass;
                        concernsForMethod.Add(new MethodConcernModel(concernType));
                    }
                }

                var methodConcerns = new MethodConcernsModel(method, concernsForMethod);
                this.methodConcernsModels.Add(method, methodConcerns);
                return methodConcerns;
            }

            return this.methodConcernsModels[method];
        }