Exemplo n.º 1
0
        internal object Read(Type t, INIFile f, string fieldName, string defaultSection, IResolver resolver)
        {
            if (!t.IsArray || t.GetElementType().IsArray)
            {
                throw new InvalidOperationException(Resource.Strings.Error_INISubSectionKeyListInvalidType.F(t.Name));
            }

            string s = INIAttributeExt.GetSection(Section, defaultSection ?? fieldName);
            INIKeyListAttribute kattr = new INIKeyListAttribute(s, ValueSource, Required);

            string[] subsections = kattr.Read(typeof(string[]), f, s);

            MethodInfo mRead  = GetType().GetMethod(nameof(InnerRead), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo gmRead = mRead.MakeGenericMethod(t.GetElementType());

            return(gmRead.Invoke(this, new object[] { f, subsections, resolver }));
        }
Exemplo n.º 2
0
        private void InnerWrite <T>(INIFile f, T[] value, string fieldName, string defaultSection)
        {
            if (value == default)
            {
                return;
            }

            string s = INIAttributeExt.GetSection(Section, defaultSection ?? fieldName);

            string[] keys = new string[value.Length];
            for (int i = 0; i < value.Length; i++)
            {
                T o = value[i];
                keys[i] = fieldName + i.ToString();
                f.UpdateByAttribute(ref o, keys[i]);
            }

            INIKeyListAttribute kattr = new INIKeyListAttribute(s, ValueSource, Required);

            kattr.Write(typeof(string[]), f, keys, s);

            //f.SetValue(s, k, Parser.Write(keys));
        }