Example #1
0
        private static IEnumerable <KeyValuePair <string, PropertyInfo> > GetPropertyPairs(Type type)
        {
            foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (!IniSerializer.PropertyTypeVerifier(property.PropertyType))
                {
                    continue;
                }

                string propertyName = null;
                var    attributes   = property.GetCustomAttributes(typeof(IniSerializationAttribute), false);

                if (attributes.Length > 0)
                {
                    var attribute = (IniSerializationAttribute)attributes[0];
                    if (attribute.Ignore)
                    {
                        continue;
                    }

                    propertyName = attribute.Alias;
                }

                yield return(new KeyValuePair <string, PropertyInfo>((propertyName) ?? property.Name, property));
            }
        }
Example #2
0
 /// <summary>
 /// Deserializes this <see cref="IniSection"/> into an object of specified type.
 /// </summary>
 /// <typeparam name="T">The type of deserialized object.</typeparam>
 /// <returns>The object being deserialized.</returns>
 /// <seealso href="c49dc3a5-866f-4d2d-8f89-db303aceb5fe.htm#serializing" target="_self">IniSection's Object Serialization</seealso>
 public T Deserialize <T>() where T : class, new()
 {
     return(IniSerializer.Deserialize <T>(this));
 }
Example #3
0
 /// <summary>
 /// Serializes the specified object into this <see cref="IniSection"/>.
 /// </summary>
 /// <typeparam name="T">The type of serialized object.</typeparam>
 /// <param name="source">The object to serialize.</param>
 /// <seealso href="c49dc3a5-866f-4d2d-8f89-db303aceb5fe.htm#serializing" target="_self">IniSection's Object Serialization</seealso>
 public void Serialize <T>(T source) where T : class, new()
 {
     IniSerializer.Serialize(source, this);
 }