public static void TestPseudoCustomAttributes() { MethodInfo m = typeof(ParametersWithPseudoCustomtAttributes).Project().GetTypeInfo().GetDeclaredMethod("Foo"); ParameterInfo[] pis = m.GetParameters(); { ParameterInfo p = pis[0]; CustomAttributeData cad = p.CustomAttributes.Single(c => c.AttributeType == typeof(InAttribute).Project()); InAttribute i = cad.UnprojectAndInstantiate <InAttribute>(); } { ParameterInfo p = pis[1]; CustomAttributeData cad = p.CustomAttributes.Single(c => c.AttributeType == typeof(OutAttribute).Project()); OutAttribute o = cad.UnprojectAndInstantiate <OutAttribute>(); } { ParameterInfo p = pis[2]; CustomAttributeData cad = p.CustomAttributes.Single(c => c.AttributeType == typeof(OptionalAttribute).Project()); OptionalAttribute o = cad.UnprojectAndInstantiate <OptionalAttribute>(); } { ParameterInfo p = pis[3]; CustomAttributeData cad = p.CustomAttributes.Single(c => c.AttributeType == typeof(MarshalAsAttribute).Project()); MarshalAsAttribute ma = cad.UnprojectAndInstantiate <MarshalAsAttribute>(); Assert.Equal(UnmanagedType.I4, ma.Value); } }
private ProjectionMetadataFlags GetFlags(ProjectionMetadata metadata) { IdAttribute id = metadata.Relation.Annotations?.OfType <IdAttribute>().FirstOrDefault(); OutAttribute out0 = metadata.Relation.Annotations?.OfType <OutAttribute>().FirstOrDefault(); InAttribute in0 = metadata.Relation.Annotations?.OfType <InAttribute>().FirstOrDefault(); IReferenceMetadata reference = metadata.Identity.GetMetadata <IReferenceMetadata>(); ProjectionMetadataFlags flags = ProjectionMetadataFlags.None; if (id != null) { flags |= ProjectionMetadataFlags.Identity; } if (in0 != null || out0 != null) { flags |= in0 != null ? ProjectionMetadataFlags.Input : ProjectionMetadataFlags.None; flags |= out0 != null ? ProjectionMetadataFlags.Output : ProjectionMetadataFlags.None; } else if (id != null) { flags |= ProjectionMetadataFlags.Output; } else if (reference != null && reference.HasAnyFlag(ReferenceMetadataFlags.Key)) { flags |= ProjectionMetadataFlags.Input | ProjectionMetadataFlags.Output; } else { flags |= ProjectionMetadataFlags.Input; } return(flags); }
public static IAskCord AskCordFactory(Type[] argTypes, Type returnType, OutAttribute attr) { var ser = SerializersFactory.Create(argTypes); var des = DeserializersFactory.Create (returnType); var gType = argTypes.Length == 1 ? argTypes [0] : typeof(object[]); var gt = typeof(AskCord<,>).MakeGenericType (returnType, gType); return Activator.CreateInstance (gt, attr.CordId, ser, des) as IAskCord; }
public static IOutCord JustOutCordFactory(Type[] argTypes, OutAttribute attr) { IOutCord ans = null; var ser = SerializersFactory.Create (argTypes); var gType = argTypes.Length == 1 ? argTypes [0] : typeof(object[]); var gt = typeof(OutCord<>).MakeGenericType (gType); ans= Activator.CreateInstance (gt, attr.CordId, ser) as IOutCord; return ans; }
internal static Attribute[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType, out int count) { count = 0; bool flag = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute); if (!flag && PseudoCustomAttribute.s_pca.GetValueOrDefault(caType) == null) { return(null); } Attribute[] array = new Attribute[PseudoCustomAttribute.s_pcasCount]; if (flag || caType == (RuntimeType)typeof(InAttribute)) { Attribute customAttribute = InAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { Attribute[] array2 = array; int num = count; count = num + 1; array2[num] = customAttribute; } } if (flag || caType == (RuntimeType)typeof(OutAttribute)) { Attribute customAttribute = OutAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { Attribute[] array3 = array; int num = count; count = num + 1; array3[num] = customAttribute; } } if (flag || caType == (RuntimeType)typeof(OptionalAttribute)) { Attribute customAttribute = OptionalAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { Attribute[] array4 = array; int num = count; count = num + 1; array4[num] = customAttribute; } } if (flag || caType == (RuntimeType)typeof(MarshalAsAttribute)) { Attribute customAttribute = MarshalAsAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { Attribute[] array5 = array; int num = count; count = num + 1; array5[num] = customAttribute; } } return(array); }
internal object[] GetPseudoCustomAttributes() { int count = 0; if (IsIn) { count++; } if (IsOut) { count++; } if (IsOptional) { count++; } if (marshalAs != null) { count++; } if (count == 0) { return(null); } object[] attrs = new object [count]; count = 0; if (IsIn) { attrs [count++] = new InAttribute(); } if (IsOut) { attrs [count++] = new OutAttribute(); } if (IsOptional) { attrs [count++] = new OptionalAttribute(); } if (marshalAs != null) { #if NETCORE throw new NotImplementedException(); #else attrs [count++] = marshalAs.Copy(); #endif } return(attrs); }
internal object[] GetPseudoCustomAttributes() { int count = 0; if (IsIn) { count++; } if (IsOut) { count++; } if (IsOptional) { count++; } if (marshalAs != null) { count++; } if (count == 0) { return(null); } object[] attrs = new object [count]; count = 0; if (IsIn) { attrs [count++] = new InAttribute(); } if (IsOut) { attrs [count++] = new OutAttribute(); } if (IsOptional) { attrs [count++] = new OptionalAttribute(); } if (marshalAs != null) { #if NETCORE attrs [count++] = (MarshalAsAttribute)marshalAs.CloneInternal(); #else attrs [count++] = marshalAs.Copy(); #endif } return(attrs); }
internal object[] GetPseudoCustomAttributes() { int count = 0; if (IsIn) { count++; } if (IsOut) { count++; } if (IsOptional) { count++; } #if !MICRO_LIB if (marshalAs != null) { count++; } #endif if (count == 0) { return(null); } object[] attrs = new object [count]; count = 0; if (IsIn) { attrs [count++] = new InAttribute(); } if (IsOptional) { attrs [count++] = new OptionalAttribute(); } if (IsOut) { attrs [count++] = new OutAttribute(); } #if !MICRO_LIB if (marshalAs != null) { attrs [count++] = marshalAs.ToMarshalAsAttribute(); } #endif return(attrs); }
internal static Attribute[] GetCustomAttributes(ParameterInfo parameter, Type caType, out int count) { count = 0; bool flag = (caType == typeof(object)) || (caType == typeof(Attribute)); if (!flag && (s_pca[caType] == null)) { return(null); } Attribute[] attributeArray = new Attribute[s_pcasCount]; Attribute customAttribute = null; if (flag || (caType == typeof(InAttribute))) { customAttribute = InAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { attributeArray[count++] = customAttribute; } } if (flag || (caType == typeof(OutAttribute))) { customAttribute = OutAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { attributeArray[count++] = customAttribute; } } if (flag || (caType == typeof(OptionalAttribute))) { customAttribute = OptionalAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { attributeArray[count++] = customAttribute; } } if (flag || (caType == typeof(MarshalAsAttribute))) { customAttribute = MarshalAsAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { attributeArray[count++] = customAttribute; } } return(attributeArray); }
internal object[] GetPseudoCustomAttributes() { int num = 0; if (this.IsIn) { num++; } if (this.IsOut) { num++; } if (this.IsOptional) { num++; } if (this.marshalAs != null) { num++; } if (num == 0) { return(null); } object[] array = new object[num]; num = 0; if (this.IsIn) { array[num++] = new InAttribute(); } if (this.IsOptional) { array[num++] = new OptionalAttribute(); } if (this.IsOut) { array[num++] = new OutAttribute(); } if (this.marshalAs != null) { array[num++] = this.marshalAs.ToMarshalAsAttribute(); } return(array); }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Initialize a instance of OutAttribute class"); try { OutAttribute myInstance = new OutAttribute(); if (myInstance == null) { TestLibrary.TestFramework.LogError("001", "the instance of OutAttribute creating failed"); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e); retVal = false; } return retVal; }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Initialize a instance of OutAttribute class"); try { OutAttribute myInstance = new OutAttribute(); if (myInstance == null) { TestLibrary.TestFramework.LogError("001", "the instance of OutAttribute creating failed"); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e); retVal = false; } return(retVal); }
internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType) { bool flag = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute); return((flag || !(PseudoCustomAttribute.s_pca.GetValueOrDefault(caType) == null)) && (((flag || caType == (RuntimeType)typeof(InAttribute)) && InAttribute.IsDefined(parameter)) || ((flag || caType == (RuntimeType)typeof(OutAttribute)) && OutAttribute.IsDefined(parameter)) || ((flag || caType == (RuntimeType)typeof(OptionalAttribute)) && OptionalAttribute.IsDefined(parameter)) || ((flag || caType == (RuntimeType)typeof(MarshalAsAttribute)) && MarshalAsAttribute.IsDefined(parameter)))); }
internal static bool IsDefined(ParameterInfo parameter, Type caType) { bool flag = (caType == typeof(object)) || (caType == typeof(Attribute)); if (!flag && (s_pca[caType] == null)) { return(false); } return(((flag || (caType == typeof(InAttribute))) && InAttribute.IsDefined(parameter)) || (((flag || (caType == typeof(OutAttribute))) && OutAttribute.IsDefined(parameter)) || (((flag || (caType == typeof(OptionalAttribute))) && OptionalAttribute.IsDefined(parameter)) || ((flag || (caType == typeof(MarshalAsAttribute))) && MarshalAsAttribute.IsDefined(parameter))))); }
internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType) { bool flag = (caType == ((RuntimeType)typeof(object))) || (caType == ((RuntimeType)typeof(Attribute))); if (!flag && (s_pca.GetValueOrDefault(caType) == null)) { return(false); } return(((flag || (caType == ((RuntimeType)typeof(InAttribute)))) && InAttribute.IsDefined(parameter)) || (((flag || (caType == ((RuntimeType)typeof(OutAttribute)))) && OutAttribute.IsDefined(parameter)) || (((flag || (caType == ((RuntimeType)typeof(OptionalAttribute)))) && OptionalAttribute.IsDefined(parameter)) || ((flag || (caType == ((RuntimeType)typeof(MarshalAsAttribute)))) && MarshalAsAttribute.IsDefined(parameter))))); }