Ejemplo n.º 1
0
        private void Build(BuildStep step, AbstractTypeBuilderList builders)
        {
            _context.Step = step;
            _context.TypeBuilders.Clear();

            foreach (IAbstractTypeBuilder builder in builders)
            {
                if (builder.IsApplied(_context, builders))
                {
                    _context.TypeBuilders.Add(builder);
                }
            }

            if (_context.IsVirtualMethod || _context.IsVirtualProperty)
            {
                _context.TypeBuilders.Add(_defaultTypeBuilder);
            }

            if (_context.TypeBuilders.Count == 0)
            {
                return;
            }

            CheckCompatibility(_context, _context.TypeBuilders);

            _context.TypeBuilders.Sort(new BuilderComparer(_context));

            for (int i = 0; i < _context.TypeBuilders.Count; i++)
            {
                IAbstractTypeBuilder builder = _context.TypeBuilders[i];

                builder.Build(_context);
            }
        }
Ejemplo n.º 2
0
        private void DefineInterfaces()
        {
            foreach (KeyValuePair <TypeHelper, IAbstractTypeBuilder> de in _context.InterfaceMap)
            {
                _context.CurrentInterface = de.Key;

                MethodInfo[] interfaceMethods = _context.CurrentInterface.GetMethods();

                foreach (MethodInfo m in interfaceMethods)
                {
                    if (_context.TypeBuilder.OverriddenMethods.ContainsKey(m))
                    {
                        continue;
                    }

                    BeginEmitMethod(m);

                    // Call builder to build the method.
                    //
                    IAbstractTypeBuilder builder = de.Value;

                    if (builder != null)
                    {
                        builder.ID = ++_idCounter;

                        _context.BuildElement = BuildElement.InterfaceMethod;
                        _context.Step         = BuildStep.Build;
                        builder.Build(_context);
                    }

                    EndEmitMethod();
                }

                _context.CurrentInterface = null;
            }
        }