public static void TryChangeObjectType(IList list, int index, Type type, TaggedTypesCfg cfg, ListMetaData ld = null)
        {
            object previous = null;

            if (list != null && index >= 0 && index < list.Count)
            {
                previous = list[index];
            }

            var el = previous;

            var iTag = el as IGotClassTag;

            var std = (el as ICfgCustom);

            var ed = ld.TryGetElement(index);

            if (ed != null && ld.keepTypeData && iTag != null)
            {
                ed.ChangeType(ref el, type, cfg, ld.keepTypeData);
            }
            else
            {
                el = std.TryDecodeInto <object>(type);
                CfgExtensions.TryCopy_Std_AndOtherData(previous, el);
            }

            list[index] = el;
        }
Esempio n. 2
0
        public static void TryChangeObjectType(IList list, int index, Type type, ListMetaData ld = null)
        {
            var previous = list.TryGetObj(index);

            var el = previous;

            var iTag = el as IGotClassTag;

            var std = (el as ICfg);

            var ed = ld.TryGetElement(index);

            if (ed != null && ld.keepTypeData && iTag != null)
            {
                ed.ChangeType(ref el, type, iTag.GetTaggedTypes_Safe(), ld.keepTypeData);
            }
            else
            {
                el = std.TryDecodeInto <object>(type);
                StdExtensions.TryCopy_Std_AndOtherData(previous, el);
            }

            list[index] = el;
        }