private static void FillCorrelationAliasAttrs(MemberInfo memberInfo, Hashtable correlationAliasAttrs, ValidationErrorCollection validationErrors)
 {
     foreach (object obj2 in memberInfo.GetCustomAttributes(typeof(CorrelationAliasAttribute), false))
     {
         CorrelationAliasAttribute attributeFromObject = Helpers.GetAttributeFromObject <CorrelationAliasAttribute>(obj2);
         if (string.IsNullOrEmpty(attributeFromObject.Name) || (attributeFromObject.Name.Trim().Length == 0))
         {
             ValidationError item = new ValidationError(SR.GetString(CultureInfo.CurrentCulture, "Error_CorrelationAttributeInvalid", new object[] { typeof(CorrelationAliasAttribute).Name, "Name", memberInfo.Name }), 0x150);
             item.UserData.Add(typeof(CorrelationAliasAttribute), memberInfo.Name);
             validationErrors.Add(item);
         }
         else if (string.IsNullOrEmpty(attributeFromObject.Path) || (attributeFromObject.Path.Trim().Length == 0))
         {
             ValidationError error2 = new ValidationError(SR.GetString(CultureInfo.CurrentCulture, "Error_CorrelationAttributeInvalid", new object[] { typeof(CorrelationAliasAttribute).Name, "Path", memberInfo.Name }), 0x150);
             error2.UserData.Add(typeof(CorrelationAliasAttribute), memberInfo.Name);
             validationErrors.Add(error2);
         }
         else if (correlationAliasAttrs.Contains(attributeFromObject.Name))
         {
             ValidationError error3 = new ValidationError(SR.GetString(CultureInfo.CurrentCulture, "Error_DuplicateCorrelationAttribute", new object[] { typeof(CorrelationAliasAttribute).Name, attributeFromObject.Name, memberInfo.Name }), 0x151);
             error3.UserData.Add(typeof(CorrelationAliasAttribute), memberInfo.Name);
             validationErrors.Add(error3);
         }
         else
         {
             correlationAliasAttrs.Add(attributeFromObject.Name, attributeFromObject);
         }
     }
 }
Esempio n. 2
0
        private CorrelationPropertyValue[] GetCorrelationProperties(Type interfaceType, string methodName)
        {
            CorrelationPropertyValue[] correlationProperties = null;

            if (interfaceType.GetCustomAttributes(typeof(ExternalDataExchangeAttribute), true).Length == 0)
            {
                throw new InvalidOperationException(SR.GetString(SR.Error_ExternalDataExchangeException, interfaceType.AssemblyQualifiedName));
            }

            List <Object> correlationParamAttributes = new List <Object>();

            correlationParamAttributes.AddRange(GetCorrelationParameterAttributes(interfaceType));

            if (correlationParamAttributes.Count == 0)
            {
                throw new InvalidOperationException(SR.GetString(SR.Error_CorrelationParameterException, interfaceType.AssemblyQualifiedName));
            }

            correlationProperties = new CorrelationPropertyValue[correlationParamAttributes.Count];

            Dictionary <String, CorrelationAliasAttribute> corrAliases = null;
            MethodInfo methodInfo = null;

            GetMethodInfo(interfaceType, methodName, out methodInfo, out corrAliases);

            if (methodInfo == null)
            {
                throw new MissingMethodException(interfaceType.AssemblyQualifiedName, methodName);
            }

            ParameterInfo[] parameters = methodInfo.GetParameters();

            int i = 0;

            foreach (CorrelationParameterAttribute paramAttribute in correlationParamAttributes)
            {
                String location = paramAttribute.Name;
                CorrelationAliasAttribute aliasAttribute = GetMatchingCorrelationAlias(paramAttribute, corrAliases, correlationParamAttributes.Count == 1);

                if (aliasAttribute != null)
                {
                    location = aliasAttribute.Path;
                }

                CorrelationPropertyValue value = GetCorrelationProperty(parameters, paramAttribute.Name, location);
                if (value == null)
                {
                    throw new InvalidOperationException(SR.GetString(SR.Error_CorrelationParameterException, interfaceType.AssemblyQualifiedName, paramAttribute.Name, methodName));
                }

                correlationProperties[i++] = value;
            }
            return(correlationProperties);
        }
        private CorrelationAliasAttribute GetMatchingCorrelationAlias(CorrelationParameterAttribute paramAttribute, Dictionary <string, CorrelationAliasAttribute> correlationAliases, bool defaultParameter)
        {
            CorrelationAliasAttribute attribute = null;

            if (correlationAliases == null)
            {
                return(null);
            }
            if (!defaultParameter || !correlationAliases.TryGetValue("", out attribute))
            {
                correlationAliases.TryGetValue(paramAttribute.Name, out attribute);
            }
            return(attribute);
        }
        private CorrelationPropertyValue[] GetCorrelationProperties(Type interfaceType, string methodName)
        {
            CorrelationPropertyValue[] valueArray = null;
            if (interfaceType.GetCustomAttributes(typeof(ExternalDataExchangeAttribute), true).Length == 0)
            {
                throw new InvalidOperationException(SR.GetString("Error_ExternalDataExchangeException", new object[] { interfaceType.AssemblyQualifiedName }));
            }
            List <object> list = new List <object>();

            list.AddRange(this.GetCorrelationParameterAttributes(interfaceType));
            if (list.Count == 0)
            {
                throw new InvalidOperationException(SR.GetString("Error_CorrelationParameterException", new object[] { interfaceType.AssemblyQualifiedName }));
            }
            valueArray = new CorrelationPropertyValue[list.Count];
            Dictionary <string, CorrelationAliasAttribute> correlationAliases = null;
            MethodInfo methodInfo = null;

            this.GetMethodInfo(interfaceType, methodName, out methodInfo, out correlationAliases);
            if (methodInfo == null)
            {
                throw new MissingMethodException(interfaceType.AssemblyQualifiedName, methodName);
            }
            ParameterInfo[] parameters = methodInfo.GetParameters();
            int             num        = 0;

            foreach (CorrelationParameterAttribute attribute in list)
            {
                string name = attribute.Name;
                CorrelationAliasAttribute attribute2 = this.GetMatchingCorrelationAlias(attribute, correlationAliases, list.Count == 1);
                if (attribute2 != null)
                {
                    name = attribute2.Path;
                }
                CorrelationPropertyValue value2 = this.GetCorrelationProperty(parameters, attribute.Name, name);
                if (value2 == null)
                {
                    throw new InvalidOperationException(SR.GetString("Error_CorrelationParameterException", new object[] { interfaceType.AssemblyQualifiedName, attribute.Name, methodName }));
                }
                valueArray[num++] = value2;
            }
            return(valueArray);
        }
Esempio n. 5
0
        private CorrelationAliasAttribute GetMatchingCorrelationAlias(CorrelationParameterAttribute paramAttribute, Dictionary <String, CorrelationAliasAttribute> correlationAliases, bool defaultParameter)
        {
            CorrelationAliasAttribute corrAlias = null;

            if (correlationAliases == null)
            {
                return(null);
            }

            if (defaultParameter)
            {
                if (correlationAliases.TryGetValue("", out corrAlias))
                {
                    return(corrAlias);
                }
            }

            correlationAliases.TryGetValue(paramAttribute.Name, out corrAlias);
            return(corrAlias);
        }