Пример #1
0
 public override IList <CustomAttributeData> GetCustomAttributesData()
 {
     return(CollectionServices.Empty <CustomAttributeData>());
 }
Пример #2
0
 public override int GetHashCode()
 {
     return(Name.GetHashCode() ^
            DeclaringType.GetHashCode() ^
            CollectionServices.GetArrayHashCode(GetParameterTypes()));
 }
Пример #3
0
 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
 {
     return(CollectionServices.IEnumerableToArray(AttributeUtils.FilterCustomAttributes(_attributes, attributeType), attributeType));
 }
Пример #4
0
 public override object[] GetCustomAttributes(bool inherit)
 {
     return(CollectionServices.IEnumerableToArray(_attributes, typeof(Attribute)));
 }
Пример #5
0
 public override ParameterInfo[] GetParameters()
 {
     return(CollectionServices.Empty <ParameterInfo>());
 }
Пример #6
0
 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
 {
     return(CollectionServices.Empty <object>());
 }
Пример #7
0
        private ICollection <object> GetNormalizedCollection(Type itemType, object instance)
        {
            Assumes.NotNull(itemType);

            object collectionObject = null;

            if (this._member.CanRead)
            {
                try
                {
                    collectionObject = this._member.GetValue(instance);
                }
                catch (TargetInvocationException exception)
                {
                    throw new ComposablePartException(
                              CompositionErrorId.ReflectionModel_ImportCollectionGetThrewException,
                              String.Format(CultureInfo.CurrentCulture,
                                            Strings.ReflectionModel_ImportCollectionGetThrewException,
                                            this._member.GetDisplayName()),
                              this.Definition.ToElement(),
                              exception.InnerException);
                }
            }

            if (collectionObject == null)
            {
                ConstructorInfo constructor = this.ImportType.ActualType.GetConstructor(new Type[0]);

                // If it contains a default public constructor create a new instance.
                if (constructor != null)
                {
                    try
                    {
                        collectionObject = constructor.Invoke(new object[] { });
                    }
                    catch (TargetInvocationException exception)
                    {
                        throw new ComposablePartException(
                                  CompositionErrorId.ReflectionModel_ImportCollectionConstructionThrewException,
                                  String.Format(CultureInfo.CurrentCulture,
                                                Strings.ReflectionModel_ImportCollectionConstructionThrewException,
                                                this._member.GetDisplayName(),
                                                this.ImportType.ActualType.FullName),
                                  this.Definition.ToElement(),
                                  exception.InnerException);
                    }

                    SetSingleMemberValue(instance, collectionObject);
                }
            }

            if (collectionObject == null)
            {
                throw new ComposablePartException(
                          CompositionErrorId.ReflectionModel_ImportCollectionNull,
                          String.Format(CultureInfo.CurrentCulture,
                                        Strings.ReflectionModel_ImportCollectionNull,
                                        this._member.GetDisplayName()),
                          this.Definition.ToElement());
            }

            return(CollectionServices.GetCollectionWrapper(itemType, collectionObject));
        }
Пример #8
0
 public override sealed Type[] GetGenericArguments()
 {
     return(CollectionServices.Empty <Type>());
 }
Пример #9
0
        private ICollection <object> GetNormalizedCollection(Type itemType, object instance)
        {
            if (itemType == null)
            {
                throw new ArgumentNullException(nameof(itemType));
            }

            object collectionObject = null;

            if (_member.CanRead)
            {
                try
                {
                    collectionObject = _member.GetValue(instance);
                }
                catch (TargetInvocationException exception)
                {
                    throw new ComposablePartException(
                              SR.Format(
                                  SR.ReflectionModel_ImportCollectionGetThrewException,
                                  _member.GetDisplayName()),
                              Definition.ToElement(),
                              exception.InnerException);
                }
            }

            if (collectionObject == null)
            {
                ConstructorInfo constructor = ImportType.ActualType.GetConstructor(Type.EmptyTypes);

                // If it contains a default public constructor create a new instance.
                if (constructor != null)
                {
                    try
                    {
                        collectionObject = constructor.SafeInvoke();
                    }
                    catch (TargetInvocationException exception)
                    {
                        throw new ComposablePartException(
                                  SR.Format(
                                      SR.ReflectionModel_ImportCollectionConstructionThrewException,
                                      _member.GetDisplayName(),
                                      ImportType.ActualType.FullName),
                                  Definition.ToElement(),
                                  exception.InnerException);
                    }

                    SetSingleMemberValue(instance, collectionObject);
                }
            }

            if (collectionObject == null)
            {
                throw new ComposablePartException(
                          SR.Format(
                              SR.ReflectionModel_ImportCollectionNull,
                              _member.GetDisplayName()),
                          Definition.ToElement());
            }

            return(CollectionServices.GetCollectionWrapper(itemType, collectionObject));
        }
Пример #10
0
 public CollectionController()
 {
     collectionServices = new CollectionServices();
 }
Пример #11
0
 protected override Type[] GetParameterTypes()
 {
     return(CollectionServices.Empty <Type>());
 }
Пример #12
0
 public override object[] GetCustomAttributes(bool inherit)
 {
     return(CollectionServices.Empty <Attribute>());
 }
Пример #13
0
 public override sealed Type[] GetRequiredCustomModifiers()
 {
     return(CollectionServices.Empty <Type>());
 }