public AttributeMapper(PrevalenceEngine Engine)
        {
            Mapping = new Dictionary <string, Tuple <FieldInfo, Dictionary <string, PropertyInfo> > >();
            foreach (FieldInfo Field in Engine.PrevalentSystem.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
            {
                object[] TableAttributes = Field.GetCustomAttributes(typeof(SQLTableAttribute), false);
                if (TableAttributes.Length == 0)
                {
                    continue;
                }
                string TableName = (TableAttributes[0] as SQLTableAttribute).TableName;

                if (!Field.FieldType.IsGenericType || Field.FieldType.GetGenericTypeDefinition() != typeof(List <>))
                {
                    throw new NotImplementedException("This version of the Bamboo ADO.NET provider only supports List<T> for SQL table associations");
                }

                Type TargetType = Field.FieldType.GetGenericArguments()[0];
                Dictionary <string, PropertyInfo> ColumnAssociations = new Dictionary <string, PropertyInfo>();
                foreach (PropertyInfo InnerMember in TargetType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
                {
                    object[] ColumnAttributes = InnerMember.GetCustomAttributes(typeof(SQLColumnAttribute), false);
                    if (ColumnAttributes.Length == 0)
                    {
                        continue;
                    }
                    ColumnAssociations.Add((ColumnAttributes[0] as SQLColumnAttribute).ColumnName, InnerMember);
                }

                Mapping.Add(TableName, new Tuple <FieldInfo, Dictionary <string, PropertyInfo> >(Field, ColumnAssociations));
            }
        }
示例#2
0
        /// <summary>
        /// Worker method travesers to Depth in the object graph and prints each of the Dynamic Objects
        /// </summary>
        /// <param name="CurrentIndentation">Indentation of</param>
        /// <param name="Depth">Pass the number of levels-deep we'd like to traverse. Pass -1 to print
        /// the entire object graph.</param>
        protected string ToString(int Depth, string CurrentIndentation)
        {
            if (Depth == 0)
            {
                return("");
            }

            StringBuilder sb = new StringBuilder();

            // First print the current node
            sb.Append(this.ToString(CurrentIndentation));

            // Next, we'll print off it's child nodes
            foreach (KeyValuePair <string, object> Member in DistinctChildNodes())
            {
                sb.Append(((XmlDataObject)(Member.Value)).ToString(Depth - 1, CurrentIndentation + Indentation));
            }

            // Finally: cycle through all of the Lists of XmlDataObjects
            foreach (KeyValuePair <string, object> Member in ListsOfRepeatChildNodes())
            {
                List <XmlDataObject> ListOfRepeatNodes = (List <XmlDataObject>)Member.Value;

                foreach (XmlDataObject InnerMember in ListOfRepeatNodes)
                {
                    sb.Append(InnerMember.ToString(Depth - 1, CurrentIndentation + Indentation));
                }
            }

            return(sb.ToString());
        }