private void ConsumeParameters(TextBuffer inParameters, TextBuffer outParameters) { PropertyInfo[] properties = GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo propInfo in properties) { ProtocolKeyAttribute attr = (ProtocolKeyAttribute)ReflectionHelper.GetCustomAttribute(propInfo, typeof(ProtocolKeyAttribute)); if (attr != null && (attr.Sender & KeySender.Target) != 0) { if (inParameters[attr.Name] != null) { object value = ProtocolKeyAttribute.GetValueAsObject(inParameters[attr.Name], propInfo.PropertyType); propInfo.GetSetMethod(true).Invoke(this, new[] { value }); inParameters.Remove(attr.Name); if (attr.Type == KeyType.Negotiated && !_negotiatedParameters.ContainsKey(attr.Name)) { value = propInfo.GetGetMethod(true).Invoke(this, null); outParameters.Add(attr.Name, ProtocolKeyAttribute.GetValueAsString(value, propInfo.PropertyType)); _negotiatedParameters.Add(attr.Name, string.Empty); } } } } Session.ConsumeParameters(inParameters, outParameters); foreach (KeyValuePair <string, string> param in inParameters.Lines) { outParameters.Add(param.Key, "NotUnderstood"); } }
internal void ConsumeParameters(TextBuffer inParameters, TextBuffer outParameters) { PropertyInfo[] properties = GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (var propInfo in properties) { ProtocolKeyAttribute attr = (ProtocolKeyAttribute)ReflectionHelper.GetCustomAttribute(propInfo, typeof(ProtocolKeyAttribute)); if (attr != null) { if (inParameters[attr.Name] != null) { object value = ProtocolKeyAttribute.GetValueAsObject(inParameters[attr.Name], propInfo.PropertyType); propInfo.GetSetMethod(true).Invoke(this, new object[] { value }); inParameters.Remove(attr.Name); if (attr.Type == KeyType.Negotiated && !_negotiatedParameters.ContainsKey(attr.Name)) { value = propInfo.GetGetMethod(true).Invoke(this, null); outParameters.Add(attr.Name, ProtocolKeyAttribute.GetValueAsString(value, propInfo.PropertyType)); _negotiatedParameters.Add(attr.Name, string.Empty); } } } } }