Esempio n. 1
0
        public bool TryDeserialize(object[] array, ref int arrayIndex, out T result)
        {
            result = InstanceOf <T> .Create();

            for (var memberIndex = 0; memberIndex < _members.Length; memberIndex++)
            {
                if (array.Length <= arrayIndex)
                {
                    return(false);
                }

                if (!_members[memberIndex].Deserialize(result, ref array, ref arrayIndex))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        public BaseModule[] Compile(Func <MemberInfo, BaseContainer> getContainer)
        {
            // cache constructor
            InstanceOf <T> .Create();

            // store all the props/fields that we need
            var dict = new SortedDictionary <int, BaseModule>();

            SetDecoratorModules(dict, DiscoverMembers(), getContainer);

            // fill up empty spaces with Ignored
            var last = dict.Keys.LastOrDefault();

            for (var i = 0; i < last; i++)
            {
                if (!dict.ContainsKey(i))
                {
                    dict[i] = new IgnoredLogic();
                }
            }

            // save it as an array
            return(dict.Values.ToArray());
        }