Ejemplo n.º 1
0
        internal static Type /*!*/ GetOrCreateType(Type /*!*/ baseType, IList <Type /*!*/> /*!*/ interfaces, bool noOverrides)
        {
            Assert.NotNull(baseType);
            Assert.NotNull(interfaces);

            ITypeFeature[] features;
            if (interfaces.Count == 0)
            {
                features = _defaultFeatures;
            }
            else
            {
                features = new ITypeFeature[] {
                    RubyTypeFeature.Instance,
                    InterfaceImplFeature.Create(interfaces)
                };
            }
            noOverrides |= typeof(IRubyType).IsAssignableFrom(baseType);

            TypeDescription typeInfo = new TypeDescription(baseType, features, noOverrides);
            Type            type     = _newTypes.GetOrCreateValue(typeInfo,
                                                                  () => {
                if (TypeImplementsFeatures(baseType, features))
                {
                    return(baseType);
                }
                return(CreateType(typeInfo));
            });

            Debug.Assert(typeof(IRubyObject).IsAssignableFrom(type));
            return(type);
        }
        public override bool Equals(object obj)
        {
            InterfaceImplFeature other = obj as InterfaceImplFeature;

            if (other == null)
            {
                return(false);
            }
            if (_interfaces.Length != other._interfaces.Length)
            {
                return(false);
            }

            for (int i = 0; i < _interfaces.Length; i++)
            {
                if (!_interfaces[i].Equals(other._interfaces[i]))
                {
                    return(false);
                }
            }

            return(true);
        }