public static MethodOnCustomType Create(
            CustomType declaringType = null,
            string name = "UnspecifiedMethod",
            MethodAttributes attributes      = MethodAttributes.Public,
            IEnumerable <Type> typeArguments = null,
            Type returnType = null,
            IEnumerable <ParameterDeclaration> parameters = null)
        {
            declaringType = declaringType ?? CustomTypeObjectMother.Create();
            typeArguments = typeArguments ?? Type.EmptyTypes;
            returnType    = returnType ?? typeof(void);
            parameters    = parameters ?? ParameterDeclaration.None;

            return(new MethodOnCustomType(declaringType, name, attributes, typeArguments, returnType, parameters));
        }
        public static CustomFieldInfo Create(
            CustomType declaringType = null,
            string name = "CustomField",
            Type type   = null,
            FieldAttributes attributes = (FieldAttributes)7,
            IEnumerable <ICustomAttributeData> customAttributes = null)
        {
            declaringType    = declaringType ?? CustomTypeObjectMother.Create();
            type             = type ?? ReflectionObjectMother.GetSomeType();
            customAttributes = customAttributes ?? new ICustomAttributeData[0];

            return(new TestableCustomFieldInfo(declaringType, name, type, attributes)
            {
                CustomAttributeDatas = customAttributes
            });
        }
Esempio n. 3
0
        public static CustomConstructorInfo Create(
            CustomType declaringType               = null,
            MethodAttributes attributes            = (MethodAttributes)7,
            IEnumerable <ParameterInfo> parameters = null,
            IEnumerable <ICustomAttributeData> customAttributes = null)
        {
            declaringType    = declaringType ?? CustomTypeObjectMother.Create();
            attributes      |= MethodAttributes.SpecialName | MethodAttributes.RTSpecialName;
            parameters       = parameters ?? new ParameterInfo[0];
            customAttributes = customAttributes ?? new ICustomAttributeData[0];

            return(new TestableCustomConstructorInfo(declaringType, attributes)
            {
                CustomAttributeDatas = customAttributes,
                Parameters = parameters.ToArray()
            });
        }
Esempio n. 4
0
        public static CustomEventInfo Create(
            CustomType declaringType = null,
            string name = "Event",
            EventAttributes attributes = (EventAttributes)7,
            MethodInfo addMethod       = null,
            MethodInfo removeMethod    = null,
            MethodInfo raiseMethod     = null,
            IEnumerable <ICustomAttributeData> customAttributes = null)
        {
            declaringType = declaringType ?? CustomTypeObjectMother.Create();
            addMethod     = addMethod ?? NormalizingMemberInfoFromExpressionUtility.GetMethod((DomainType o) => o.AddMethod(null));
            removeMethod  = removeMethod ?? NormalizingMemberInfoFromExpressionUtility.GetMethod((DomainType o) => o.RemoveMethod(null));
            // Raise method stays null.
            customAttributes = customAttributes ?? new ICustomAttributeData[0];

            return(new TestableCustomEventInfo(declaringType, name, attributes, addMethod, removeMethod, raiseMethod)
            {
                CustomAttributeDatas = customAttributes
            });
        }
Esempio n. 5
0
        public static ArrayTypeBase Create(CustomType elementType = null, int rank = 1)
        {
            elementType = elementType ?? CustomTypeObjectMother.Create(name: "UnspecifiedType");

            return(new TestableArrayTypeBase(elementType, rank));
        }
Esempio n. 6
0
        public static VectorType Create(CustomType elementType = null)
        {
            elementType = elementType ?? CustomTypeObjectMother.Create(name: "UnspecifiedType");

            return(new VectorType(elementType));
        }
        public static MultiDimensionalArrayType Create(CustomType elementType = null, int rank = 2)
        {
            elementType = elementType ?? CustomTypeObjectMother.Create(name: "UnspecifiedType");

            return(new MultiDimensionalArrayType(elementType, rank));
        }