コード例 #1
0
        /// <summary>
        /// EXPENSIVE! Uses reflection to build a cache item of information about the type and its fields
        /// </summary>
        /// <param name="type">the type to reflect on</param>
        /// <returns>collection of field information</returns>
        private static IEnumerable <FieldPersistenceInfo> ReflectFields(Type type)
        {
            List <FieldPersistenceInfo> toReturn = new List <FieldPersistenceInfo>();

            foreach (
                FieldInfo reflectedFieldInfo in
                type.GetTypeInfo().GetFields(
                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
            {
                FieldPersistenceInfo info = new FieldPersistenceInfo(reflectedFieldInfo);

                // only fields with known location need to be persisted
                if (!string.IsNullOrEmpty(info.Location))
                {
                    toReturn.Add(info);
                }
            }

            return(toReturn);
        }
コード例 #2
0
            /// <summary>
            /// Returns all IFieldPersistenceInfo objects in the bucket, in the order in which they are initially stored in the bucket
            /// </summary>
            /// <returns>requested objects in an array</returns>
            public IFieldPersistenceInfo[] GetAllFieldPersistenceInfoObjects()
            {
                IFieldPersistenceInfo[] toReturn = new FieldPersistenceInfo[_fieldPersistenceInfos.Count];

                for (int i = 0; i < _fieldPersistenceInfosPerIndex.Count; i++)
                {
                    toReturn[i] = (IFieldPersistenceInfo)_fieldPersistenceInfosPerIndex.GetByIndex(i);
                }

                return toReturn;
            }