Exemplo n.º 1
0
 internal override sealed void ProvideScopes(
     ProjectionType       projectionType,
     Type                 underlyingType,
     ITypeScopeAggregator aggregator)
 {
     scope.ProvideScopes(projectionType, underlyingType, aggregator);
 }
 internal TypeInitializerInvocation(
     ProjectionType            type,
     Cell<IProjectionBehavior> behavior)
 {
     this.type     = type;
     this.behavior = behavior;
 }
            public void CopyTo()
            {
                var array = new ProjectionType[2];

                BaseTypes.CopyTo(array, 1);

                Assert.That(array[0], Is.Null);
                Assert.That(array[1], Is.Null);
            }
Exemplo n.º 4
0
        internal bool AppliesTo(ProjectionType type)
        {
            var restrictions = this.restrictions;
            if (restrictions != null)
                foreach (var restriction in restrictions)
                    if (!restriction.AppliesTo(type))
                        return false;

            return true;
        }
Exemplo n.º 5
0
        public void GetProjectionType_Concurrent()
        {
            var types = new ProjectionType[ConcurrentTests.ThreadCount];

            ConcurrentTests.ParallelInvoke(i =>
            {
                types[i] = Factory.GetProjectionType(typeof(PopularType));
            });

            Assert.That(types, Has.All.SameAs(types[0]));
        }
Exemplo n.º 6
0
        // TODO: 'trait' instead of 'attribute'?
        internal static Exception AttributeConflict(ProjectionType projectionType, Type attributeType)
        {
            var message = string.Format
            (
                "Conflicting '{0}' attributes inherited by type {1}.  " +
                "Override the attribute, or use inheritance directives to resolve the conflict.",
                attributeType.GetPrettyName(false).RemoveSuffix(AttributeSuffix),
                projectionType.UnderlyingType.GetPrettyName(true)
            );

            return new ProjectionException(message);
        }
Exemplo n.º 7
0
        internal ProjectionCollectionType(TypeKind kind, Type type, ProjectionFactory factory)
            : base(type, kind, factory)
        {
            // Must register before getting key/item types, due to possible cycles
            // Example: A -> IList<B> -> B -> IList<B>
            factory.RegisterProjectionType(this);

            Type keyType, itemType;
            GetSubtypes(out keyType, out itemType);

            this.keyType  = factory.GetProjectionTypeUnsafe(keyType );
            this.itemType = factory.GetProjectionTypeUnsafe(itemType);
        }
Exemplo n.º 8
0
        public ITraitResolution Resolve(ProjectionType projectionType, Type underlyingType)
        {
            if (projectionType == null)
                throw Error.ArgumentNull("projectionType");
            if (underlyingType == null)
                throw Error.ArgumentNull("underlyingType");

            var resolution = new StandardTraitResolution(projectionType, underlyingType);
            var assembly   = underlyingType.Assembly;

            AddIncludedSpecs(resolution);
            AddDetectedSpecs(resolution, GetSharedSpecName (underlyingType), assembly);
            AddDetectedSpecs(resolution, GetPerTypeSpecName(underlyingType), assembly);

            return resolution;
        }
Exemplo n.º 9
0
        internal ProjectionProperty(PropertyInfo property, ProjectionStructureType declaringType,
            ProjectionPropertyCollection properties, ProjectionFactory factory, ITraitResolution resolution)
        {
            this.name          = property.Name;
            this.declaringType = declaringType;
            this.propertyType  = factory.GetProjectionTypeUnsafe(property.PropertyType);
            this.accessors     = new IPropertyAccessor[4]; // factory.Providers.Count

            var getter = property.GetGetMethod();
            var setter = property.GetSetMethod();
            if (getter != null) { getterHandle = getter.MethodHandle; flags |= Flags.CanRead;  }
            if (setter != null) { setterHandle = setter.MethodHandle; flags |= Flags.CanWrite; }

            var aggregator = new ProjectionPropertyTraitAggregator(this, properties);
            resolution.ProvidePropertyTraits(this, property, aggregator);

            this.aggregator = aggregator;
            this.overrides  = aggregator.Overrides;
        }
Exemplo n.º 10
0
 public bool AppliesTo(ProjectionType type)
 {
     return regex.IsMatch(type.Name);
 }
Exemplo n.º 11
0
 private static void InitializeTypeProperty(Type type, ProjectionType projectionType)
 {
     SetStaticField(type, TypeFieldName, projectionType);
 }
Exemplo n.º 12
0
 internal StandardTraitResolution(ProjectionType projectionType, Type underlyingType)
 {
     this.projectionType = projectionType;
     this.underlyingType = underlyingType;
 }
Exemplo n.º 13
0
 private static MethodInfo GetMethod(RuntimeMethodHandle handle, ProjectionType declaringType)
 {
     var typeHandle = declaringType.UnderlyingType.TypeHandle;
     return (MethodInfo) MethodBase.GetMethodFromHandle(handle, typeHandle);
 }
            public void CopyTo()
            {
                var array = new ProjectionType[3];

                BaseTypes.CopyTo(array, 1);

                Assert.That(array[0], Is.Null);
                Assert.That(array[1], Is.SameAs(TypeOf<IBase>()));
                Assert.That(array[2], Is.Null);
            }
Exemplo n.º 15
0
 public bool AppliesTo(ProjectionType type)
 {
     return HasKind(type.Kind);
 }
Exemplo n.º 16
0
 public bool AppliesTo(ProjectionType type)
 {
     return type.UnderlyingType == typeof(TestType);
 }
Exemplo n.º 17
0
 public bool AppliesTo(ProjectionType type)
 {
     return AppliesTo(type.Name);
 }
Exemplo n.º 18
0
 internal abstract void ProvideScopes(
     ProjectionType       projectionType,
     Type                 underlyingType,
     ITypeScopeAggregator action
 );
Exemplo n.º 19
0
        private static HashSet<ProjectionType> GetImmediateBaseTypes(ProjectionType[] baseTypes)
        {
            var result = new HashSet<ProjectionType>();

            foreach (var baseType in baseTypes)
                result.Add(baseType);

            foreach (var baseType in baseTypes)
                result.ExceptWith(baseType.BaseTypes);

            return result;
        }
Exemplo n.º 20
0
 public bool AppliesTo(ProjectionType type)
 {
     return type.Name.Equals(name, comparison);
 }
Exemplo n.º 21
0
        private static ProjectionType[] GetProjectionTypes(Type[] interfaces, ProjectionFactory factory)
        {
            var baseTypes = new ProjectionType[interfaces.Length];

            for (var i = 0; i < interfaces.Length; i++)
            {
                var baseType = baseTypes[i] =
                    factory.GetProjectionTypeUnsafe(interfaces[i])
                    as ProjectionStructureType;
                if (baseType == null)
                    throw Error.InvalidProjectionType(interfaces[i]);
            }

            return baseTypes;
        }
Exemplo n.º 22
0
 internal override sealed void ProvideScopes(
     ProjectionType projectionType, Type underlyingType, ITypeScopeAggregator action)
 {
     // Stub only
 }
Exemplo n.º 23
0
 public bool AppliesTo(ProjectionType type)
 {
     return type.Kind == kind;
 }