Пример #1
0
        /// <summary>
        /// Unwraps the specified wrap.
        /// </summary>
        /// <param name="wrap">The wrap.</param>
        /// <returns>Instance.</returns>
        private static Instance unwrap(InstanceWrap wrap)
        {
            if (wrap == null)
            {
                return(null);
            }

            return(wrap.Wrapped);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Array{ItemType}"/> class from given data.
        /// </summary>
        /// <param name="data">The data which will initialize current array.</param>
        /// <param name="context">The context.</param>
        public Array(IEnumerable data, AnalyzingContext context)
        {
            int i = 0;

            foreach (var item in data)
            {
                //handle wrapping
                var toSet = item as InstanceWrap;
                if (toSet == null)
                {
                    var instance = item as Instance;
                    if (instance == null)
                    {
                        instance = context.Machine.CreateDirectInstance(item);
                    }
                    toSet = new InstanceWrap(instance);
                }

                //set item
                set_Item(i, toSet as ItemType);
                ++i;
            }
            Length = _data.Count;
        }