Esempio n. 1
0
        private void InitiateProperties()
        {
            var slave  = GetType().GetProperties();
            var master = _raw.GetType().GetProperties();

            foreach (var property in slave)
            {
                var corresponding = master.FirstOrDefault(p => p.Name == property.Name && p.PropertyType == property.PropertyType);
                if (corresponding == null)
                {
                    continue;
                }

                property.SetValue(this, corresponding.GetValue(_raw));
            }
        }
        private static void SetStatusCode(HttpWebResponse webResponce, int sttausCode)
        {
            var statusCodeProp = webResponce.GetType()
                .GetField("m_StatusCode", BindingFlags.NonPublic | BindingFlags.Instance);

            statusCodeProp.SetValue(webResponce, sttausCode);
        }
 /// <summary>
 /// Populates <paramref name="target"/> with values from <paramref name="response"/> as defined by <paramref name="map"/>.
 /// </summary>
 /// <param name="response">The response object from which to get values.</param>
 /// <param name="map">A field map definition.</param>
 /// <param name="target">The target object to populate with mapped key/values.</param>
 private void MapPropertyField(HttpWebResponse response, MappedField map, ApplicationData target)
 {
     PropertyInfo info = response.GetType().GetProperty(map.Source);
     object propertyValue = info.GetValue(response);
     target.SetValue(map.Target, propertyValue);
 }