public virtual void WriteComponentProperty(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ComponentPropertyAttribute attrib, BaseAttribute parentAttribute) { System.Type componentType = attrib.ComponentType; if(componentType == null) if(member is System.Reflection.FieldInfo) componentType = (member as System.Reflection.FieldInfo).FieldType; else // It MUST be a PropertyInfo componentType = (member as System.Reflection.PropertyInfo).PropertyType; object[] componentAttributes = componentType.GetCustomAttributes(typeof(ComponentAttribute), false); if(componentAttributes.Length == 0) throw new MappingException(componentType.FullName + " doesn't have the attribute [Component]!"); ComponentAttribute componentAttribute = componentAttributes[0] as ComponentAttribute; string componentName = attrib.PropertyName; if(componentName == null) componentName = member.Name; // Default value if(componentAttribute.Name != null && componentAttribute.Name != componentName) // Because, it will be used by the default implementation of "WriteComponent()" throw new MappingException(componentType.FullName + " must have a [Component] with a 'null' Name (or the name '" + componentName + "')"); // Get the helper to set the componentName HbmWriterHelperEx helper = this.DefaultHelper as HbmWriterHelperEx; if(helper == null) throw new MappingException("DefaultHelper must be a HbmWriterHelperEx (or a subType) to use [ComponentProperty]"); // Set the value that will be returned when WriteComponent() will call Get_Component_Name_DefaultValue() string savedValue = helper.DefaultValue; helper.DefaultValue = componentName; try { WriteComponent(writer, componentType); } finally { helper.DefaultValue = savedValue; } }
/// <summary> Write a SqlQuery XML Element from attributes in a member. </summary> public virtual void WriteSqlQuery(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, SqlQueryAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "sql-query" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_SqlQuery_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <resultset-ref> if(attribute.ResultSetRef != null) writer.WriteAttributeString("resultset-ref", GetAttributeValue(attribute.ResultSetRef, mappedClass)); // Attribute: <flush-mode> if(attribute.FlushMode != FlushMode.Unspecified) writer.WriteAttributeString("flush-mode", GetXmlEnumValue(typeof(FlushMode), attribute.FlushMode)); // Attribute: <cacheable> if( attribute.CacheableSpecified ) writer.WriteAttributeString("cacheable", attribute.Cacheable ? "true" : "false"); // Attribute: <cache-region> if(attribute.CacheRegion != null) writer.WriteAttributeString("cache-region", GetAttributeValue(attribute.CacheRegion, mappedClass)); // Attribute: <fetch-size> if(attribute.FetchSize != -9223372036854775808) writer.WriteAttributeString("fetch-size", attribute.FetchSize.ToString()); // Attribute: <timeout> if(attribute.Timeout != -1) writer.WriteAttributeString("timeout", attribute.Timeout.ToString()); // Attribute: <cache-mode> if(attribute.CacheMode != CacheMode.Unspecified) writer.WriteAttributeString("cache-mode", GetXmlEnumValue(typeof(CacheMode), attribute.CacheMode)); // Attribute: <read-only> if( attribute.ReadOnlySpecified ) writer.WriteAttributeString("read-only", attribute.ReadOnly ? "true" : "false"); // Attribute: <comment> if(attribute.Comment != null) writer.WriteAttributeString("comment", GetAttributeValue(attribute.Comment, mappedClass)); // Attribute: <callable> if( attribute.CallableSpecified ) writer.WriteAttributeString("callable", attribute.Callable ? "true" : "false"); WriteUserDefinedContent(writer, member, null, attribute); // Write the content of this element (mixed="true") writer.WriteString(attribute.Content); writer.WriteEndElement(); }
/// <summary> Write a ReturnScalar XML Element from attributes in a member. </summary> public virtual void WriteReturnScalar(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ReturnScalarAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "return-scalar" ); // Attribute: <column> writer.WriteAttributeString("column", attribute.Column==null ? DefaultHelper.Get_ReturnScalar_Column_DefaultValue(member) : GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <type> if(attribute.Type != null) writer.WriteAttributeString("type", GetAttributeValue(attribute.Type, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); writer.WriteEndElement(); }
/// <summary> Write a ReturnJoin XML Element from attributes in a member. </summary> public virtual void WriteReturnJoin(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ReturnJoinAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "return-join" ); // Attribute: <alias> writer.WriteAttributeString("alias", attribute.Alias==null ? DefaultHelper.Get_ReturnJoin_Alias_DefaultValue(member) : GetAttributeValue(attribute.Alias, mappedClass)); // Attribute: <property> writer.WriteAttributeString("property", attribute.Property==null ? DefaultHelper.Get_ReturnJoin_Property_DefaultValue(member) : GetAttributeValue(attribute.Property, mappedClass)); // Attribute: <lock-mode> if(attribute.LockMode != LockMode.Unspecified) writer.WriteAttributeString("lock-mode", GetXmlEnumValue(typeof(LockMode), attribute.LockMode)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the ReturnJoinAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is ReturnJoinAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <return-property> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ReturnPropertyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ReturnJoinAttribute ) break; // Following attributes are for this ReturnJoin if( memberAttrib is ReturnPropertyAttribute ) WriteReturnProperty(writer, member, memberAttrib as ReturnPropertyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ReturnPropertyAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a QueryParam XML Element from attributes in a member. </summary> public virtual void WriteQueryParam(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, QueryParamAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "query-param" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_QueryParam_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <type> writer.WriteAttributeString("type", attribute.Type==null ? DefaultHelper.Get_QueryParam_Type_DefaultValue(member) : GetAttributeValue(attribute.Type, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); writer.WriteEndElement(); }
/// <summary> Write a Properties XML Element from attributes in a member. </summary> public virtual void WriteProperties(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, PropertiesAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "properties" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_Properties_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <unique> if( attribute.UniqueSpecified ) writer.WriteAttributeString("unique", attribute.Unique ? "true" : "false"); // Attribute: <insert> if( attribute.InsertSpecified ) writer.WriteAttributeString("insert", attribute.Insert ? "true" : "false"); // Attribute: <update> if( attribute.UpdateSpecified ) writer.WriteAttributeString("update", attribute.Update ? "true" : "false"); // Attribute: <optimistic-lock> if( attribute.OptimisticLockSpecified ) writer.WriteAttributeString("optimistic-lock", attribute.OptimisticLock ? "true" : "false"); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the PropertiesAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is PropertiesAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <property> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(PropertyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PropertiesAttribute ) break; // Following attributes are for this Properties if( memberAttrib is PropertyAttribute ) WriteProperty(writer, member, memberAttrib as PropertyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(PropertyAttribute), attribute); // Element: <many-to-one> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ManyToOneAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PropertiesAttribute ) break; // Following attributes are for this Properties if( memberAttrib is ManyToOneAttribute ) WriteManyToOne(writer, member, memberAttrib as ManyToOneAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ManyToOneAttribute), attribute); // Element: <component> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ComponentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' } WriteUserDefinedContent(writer, member, typeof(ComponentAttribute), attribute); // Element: <dynamic-component> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(DynamicComponentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is DynamicComponentAttribute ) WriteDynamicComponent(writer, member, memberAttrib as DynamicComponentAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(DynamicComponentAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a Param XML Element from attributes in a member. </summary> public virtual void WriteParam(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ParamAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "param" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_Param_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); // Write the content of this element (mixed="true") writer.WriteString(attribute.Content); writer.WriteEndElement(); }
/// <summary> Write a OneToMany XML Element from attributes in a member. </summary> public virtual void WriteOneToMany(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, OneToManyAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "one-to-many" ); // Attribute: <class> if(attribute.Class != null) writer.WriteAttributeString("class", GetAttributeValue(attribute.Class, mappedClass)); // Attribute: <not-found> if(attribute.NotFound != NotFoundMode.Unspecified) writer.WriteAttributeString("not-found", GetXmlEnumValue(typeof(NotFoundMode), attribute.NotFound)); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); // Attribute: <embed-xml> if( attribute.EmbedXmlSpecified ) writer.WriteAttributeString("embed-xml", attribute.EmbedXml ? "true" : "false"); // Attribute: <entity-name> if(attribute.EntityName != null) writer.WriteAttributeString("entity-name", GetAttributeValue(attribute.EntityName, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); writer.WriteEndElement(); }
/// <summary> Write a ListIndex XML Element from attributes in a member. </summary> public virtual void WriteListIndex(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ListIndexAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "list-index" ); // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <base> if(attribute.Base != -1) writer.WriteAttributeString("base", attribute.Base.ToString()); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the ListIndexAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is ListIndexAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListIndexAttribute ) break; // Following attributes are for this ListIndex if( memberAttrib is ColumnAttribute ) WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a KeyManyToOne XML Element from attributes in a member. </summary> public virtual void WriteKeyManyToOne(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, KeyManyToOneAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "key-many-to-one" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_KeyManyToOne_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <access> if(attribute.Access != null) writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, mappedClass)); // Attribute: <class> if(attribute.Class != null) writer.WriteAttributeString("class", GetAttributeValue(attribute.Class, mappedClass)); // Attribute: <entity-name> if(attribute.EntityName != null) writer.WriteAttributeString("entity-name", GetAttributeValue(attribute.EntityName, mappedClass)); // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <foreign-key> if(attribute.ForeignKey != null) writer.WriteAttributeString("foreign-key", GetAttributeValue(attribute.ForeignKey, mappedClass)); // Attribute: <lazy> if(attribute.Lazy != RestrictedLaziness.Unspecified) writer.WriteAttributeString("lazy", GetXmlEnumValue(typeof(RestrictedLaziness), attribute.Lazy)); // Attribute: <not-found> if(attribute.NotFound != NotFoundMode.Unspecified) writer.WriteAttributeString("not-found", GetXmlEnumValue(typeof(NotFoundMode), attribute.NotFound)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the KeyManyToOneAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is KeyManyToOneAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <meta> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(MetaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is KeyManyToOneAttribute ) break; // Following attributes are for this KeyManyToOne if( memberAttrib is MetaAttribute ) WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(MetaAttribute), attribute); // Element: <column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is KeyManyToOneAttribute ) break; // Following attributes are for this KeyManyToOne if( memberAttrib is ColumnAttribute ) WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a Key XML Element from attributes in a member. </summary> public virtual void WriteKey(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, KeyAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "key" ); // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <property-ref> if(attribute.PropertyRef != null) writer.WriteAttributeString("property-ref", GetAttributeValue(attribute.PropertyRef, mappedClass)); // Attribute: <foreign-key> if(attribute.ForeignKey != null) writer.WriteAttributeString("foreign-key", GetAttributeValue(attribute.ForeignKey, mappedClass)); // Attribute: <on-delete> if(attribute.OnDelete != OnDelete.Unspecified) writer.WriteAttributeString("on-delete", GetXmlEnumValue(typeof(OnDelete), attribute.OnDelete)); // Attribute: <not-null> if( attribute.NotNullSpecified ) writer.WriteAttributeString("not-null", attribute.NotNull ? "true" : "false"); // Attribute: <update> if( attribute.UpdateSpecified ) writer.WriteAttributeString("update", attribute.Update ? "true" : "false"); // Attribute: <unique> if( attribute.UniqueSpecified ) writer.WriteAttributeString("unique", attribute.Unique ? "true" : "false"); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the KeyAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is KeyAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is KeyAttribute ) break; // Following attributes are for this Key if( memberAttrib is ColumnAttribute ) WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a Join XML Element from attributes in a member. </summary> public virtual void WriteJoin(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, JoinAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "join" ); // Attribute: <table> writer.WriteAttributeString("table", attribute.Table==null ? DefaultHelper.Get_Join_Table_DefaultValue(member) : GetAttributeValue(attribute.Table, mappedClass)); // Attribute: <schema> if(attribute.Schema != null) writer.WriteAttributeString("schema", GetAttributeValue(attribute.Schema, mappedClass)); // Attribute: <catalog> if(attribute.Catalog != null) writer.WriteAttributeString("catalog", GetAttributeValue(attribute.Catalog, mappedClass)); // Attribute: <subselect> if(attribute.Subselect != null) writer.WriteAttributeString("subselect", GetAttributeValue(attribute.Subselect, mappedClass)); // Attribute: <fetch> if(attribute.Fetch != JoinFetch.Unspecified) writer.WriteAttributeString("fetch", GetXmlEnumValue(typeof(JoinFetch), attribute.Fetch)); // Attribute: <inverse> if( attribute.InverseSpecified ) writer.WriteAttributeString("inverse", attribute.Inverse ? "true" : "false"); // Attribute: <optional> if( attribute.OptionalSpecified ) writer.WriteAttributeString("optional", attribute.Optional ? "true" : "false"); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the JoinAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is JoinAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <subselect> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SubselectAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is SubselectAttribute ) WriteSubselect(writer, member, memberAttrib as SubselectAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SubselectAttribute), attribute); // Element: <comment> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(CommentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is CommentAttribute ) WriteComment(writer, member, memberAttrib as CommentAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(CommentAttribute), attribute); // Element: <key> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(KeyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is KeyAttribute ) WriteKey(writer, member, memberAttrib as KeyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(KeyAttribute), attribute); // Element: <property> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(PropertyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is PropertyAttribute ) WriteProperty(writer, member, memberAttrib as PropertyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(PropertyAttribute), attribute); // Element: <many-to-one> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ManyToOneAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is ManyToOneAttribute ) WriteManyToOne(writer, member, memberAttrib as ManyToOneAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ManyToOneAttribute), attribute); // Element: <component> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ComponentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' } WriteUserDefinedContent(writer, member, typeof(ComponentAttribute), attribute); // Element: <dynamic-component> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(DynamicComponentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is DynamicComponentAttribute ) WriteDynamicComponent(writer, member, memberAttrib as DynamicComponentAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(DynamicComponentAttribute), attribute); // Element: <any> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(AnyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is AnyAttribute ) WriteAny(writer, member, memberAttrib as AnyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(AnyAttribute), attribute); // Element: <map> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(MapAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is MapAttribute ) WriteMap(writer, member, memberAttrib as MapAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(MapAttribute), attribute); // Element: <set> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SetAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is SetAttribute ) WriteSet(writer, member, memberAttrib as SetAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SetAttribute), attribute); // Element: <list> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ListAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is ListAttribute ) WriteList(writer, member, memberAttrib as ListAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ListAttribute), attribute); // Element: <bag> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(BagAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is BagAttribute ) WriteBag(writer, member, memberAttrib as BagAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(BagAttribute), attribute); // Element: <idbag> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(IdBagAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is IdBagAttribute ) WriteIdBag(writer, member, memberAttrib as IdBagAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(IdBagAttribute), attribute); // Element: <array> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ArrayAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is ArrayAttribute ) WriteArray(writer, member, memberAttrib as ArrayAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ArrayAttribute), attribute); // Element: <primitive-array> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(PrimitiveArrayAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is PrimitiveArrayAttribute ) WritePrimitiveArray(writer, member, memberAttrib as PrimitiveArrayAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(PrimitiveArrayAttribute), attribute); // Element: <sql-insert> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlInsertAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is SqlInsertAttribute ) WriteSqlInsert(writer, member, memberAttrib as SqlInsertAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlInsertAttribute), attribute); // Element: <sql-update> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlUpdateAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is SqlUpdateAttribute ) WriteSqlUpdate(writer, member, memberAttrib as SqlUpdateAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlUpdateAttribute), attribute); // Element: <sql-delete> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlDeleteAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is JoinAttribute ) break; // Following attributes are for this Join if( memberAttrib is SqlDeleteAttribute ) WriteSqlDelete(writer, member, memberAttrib as SqlDeleteAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlDeleteAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a Id XML Element from attributes in a member. </summary> public virtual void WriteId(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, IdAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "id" ); // Attribute: <name> if(attribute.Name != null) writer.WriteAttributeString("name", GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); // Attribute: <access> if(attribute.Access != null) writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, mappedClass)); // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <type> if(attribute.Type != null) writer.WriteAttributeString("type", GetAttributeValue(attribute.Type, mappedClass)); // Attribute: <length> if(attribute.Length != -1) writer.WriteAttributeString("length", attribute.Length.ToString()); // Attribute: <unsaved-value> if(attribute.UnsavedValue != null) writer.WriteAttributeString("unsaved-value", GetAttributeValue(attribute.UnsavedValue, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the IdAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is IdAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <meta> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(MetaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is IdAttribute ) break; // Following attributes are for this Id if( memberAttrib is MetaAttribute ) WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(MetaAttribute), attribute); // Element: <column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is IdAttribute ) break; // Following attributes are for this Id if( memberAttrib is ColumnAttribute ) WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute); // Element: <type> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(TypeAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is IdAttribute ) break; // Following attributes are for this Id if( memberAttrib is TypeAttribute ) WriteType(writer, member, memberAttrib as TypeAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(TypeAttribute), attribute); // Element: <generator> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(GeneratorAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is IdAttribute ) break; // Following attributes are for this Id if( memberAttrib is GeneratorAttribute ) WriteGenerator(writer, member, memberAttrib as GeneratorAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(GeneratorAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a Generator XML Element from attributes in a member. </summary> public virtual void WriteGenerator(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, GeneratorAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "generator" ); // Attribute: <class> writer.WriteAttributeString("class", attribute.Class==null ? DefaultHelper.Get_Generator_Class_DefaultValue(member) : GetAttributeValue(attribute.Class, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the GeneratorAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is GeneratorAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <param> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ParamAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is GeneratorAttribute ) break; // Following attributes are for this Generator if( memberAttrib is ParamAttribute ) WriteParam(writer, member, memberAttrib as ParamAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ParamAttribute), attribute); writer.WriteEndElement(); }
public void MaxReachedDemo(BaseAttribute sender) { _maxReachedEventTriggered += 1; }
/// <summary> Write a Loader XML Element from attributes in a member. </summary> public virtual void WriteLoader(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, LoaderAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "loader" ); // Attribute: <query-ref> writer.WriteAttributeString("query-ref", attribute.QueryRef==null ? DefaultHelper.Get_Loader_QueryRef_DefaultValue(member) : GetAttributeValue(attribute.QueryRef, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); writer.WriteEndElement(); }
/// <summary> Write a NestedCompositeElement XML Element from attributes in a member. </summary> public virtual void WriteNestedCompositeElement(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, NestedCompositeElementAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "nested-composite-element" ); // Attribute: <class> writer.WriteAttributeString("class", attribute.Class==null ? DefaultHelper.Get_NestedCompositeElement_Class_DefaultValue(member) : GetAttributeValue(attribute.Class, mappedClass)); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_NestedCompositeElement_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <access> if(attribute.Access != null) writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, mappedClass)); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the NestedCompositeElementAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is NestedCompositeElementAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <parent> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ParentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is NestedCompositeElementAttribute ) break; // Following attributes are for this NestedCompositeElement if( memberAttrib is ParentAttribute ) WriteParent(writer, member, memberAttrib as ParentAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ParentAttribute), attribute); // Element: <property> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(PropertyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is NestedCompositeElementAttribute ) break; // Following attributes are for this NestedCompositeElement if( memberAttrib is PropertyAttribute ) WriteProperty(writer, member, memberAttrib as PropertyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(PropertyAttribute), attribute); // Element: <many-to-one> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ManyToOneAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is NestedCompositeElementAttribute ) break; // Following attributes are for this NestedCompositeElement if( memberAttrib is ManyToOneAttribute ) WriteManyToOne(writer, member, memberAttrib as ManyToOneAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ManyToOneAttribute), attribute); // Element: <any> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(AnyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is NestedCompositeElementAttribute ) break; // Following attributes are for this NestedCompositeElement if( memberAttrib is AnyAttribute ) WriteAny(writer, member, memberAttrib as AnyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(AnyAttribute), attribute); // Element: <nested-composite-element> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(NestedCompositeElementAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is NestedCompositeElementAttribute ) WriteNestedCompositeElement(writer, member, memberAttrib as NestedCompositeElementAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(NestedCompositeElementAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a ManyToAny XML Element from attributes in a member. </summary> public virtual void WriteManyToAny(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ManyToAnyAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "many-to-any" ); // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <id-type> writer.WriteAttributeString("id-type", attribute.IdType==null ? DefaultHelper.Get_ManyToAny_IdType_DefaultValue(member) : GetAttributeValue(attribute.IdType, mappedClass)); // Attribute: <meta-type> if(attribute.MetaType != null) writer.WriteAttributeString("meta-type", GetAttributeValue(attribute.MetaType, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the ManyToAnyAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is ManyToAnyAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <meta-value> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(MetaValueAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ManyToAnyAttribute ) break; // Following attributes are for this ManyToAny if( memberAttrib is MetaValueAttribute ) WriteMetaValue(writer, member, memberAttrib as MetaValueAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(MetaValueAttribute), attribute); // Element: <column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ManyToAnyAttribute ) break; // Following attributes are for this ManyToAny if( memberAttrib is ColumnAttribute ) WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a OneToOne XML Element from attributes in a member. </summary> public virtual void WriteOneToOne(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, OneToOneAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "one-to-one" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_OneToOne_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <formula> if(attribute.Formula != null) writer.WriteAttributeString("formula", GetAttributeValue(attribute.Formula, mappedClass)); // Attribute: <access> if(attribute.Access != null) writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, mappedClass)); // Attribute: <class> if(attribute.Class != null) writer.WriteAttributeString("class", GetAttributeValue(attribute.Class, mappedClass)); // Attribute: <entity-name> if(attribute.EntityName != null) writer.WriteAttributeString("entity-name", GetAttributeValue(attribute.EntityName, mappedClass)); // Attribute: <cascade> if(attribute.Cascade != null) writer.WriteAttributeString("cascade", GetAttributeValue(attribute.Cascade, mappedClass)); // Attribute: <outer-join> if(attribute.OuterJoin != OuterJoinStrategy.Unspecified) writer.WriteAttributeString("outer-join", GetXmlEnumValue(typeof(OuterJoinStrategy), attribute.OuterJoin)); // Attribute: <fetch> if(attribute.Fetch != FetchMode.Unspecified) writer.WriteAttributeString("fetch", GetXmlEnumValue(typeof(FetchMode), attribute.Fetch)); // Attribute: <constrained> if( attribute.ConstrainedSpecified ) writer.WriteAttributeString("constrained", attribute.Constrained ? "true" : "false"); // Attribute: <foreign-key> if(attribute.ForeignKey != null) writer.WriteAttributeString("foreign-key", GetAttributeValue(attribute.ForeignKey, mappedClass)); // Attribute: <property-ref> if(attribute.PropertyRef != null) writer.WriteAttributeString("property-ref", GetAttributeValue(attribute.PropertyRef, mappedClass)); // Attribute: <lazy> if(attribute.Lazy != Laziness.Unspecified) writer.WriteAttributeString("lazy", GetXmlEnumValue(typeof(Laziness), attribute.Lazy)); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); // Attribute: <embed-xml> if( attribute.EmbedXmlSpecified ) writer.WriteAttributeString("embed-xml", attribute.EmbedXml ? "true" : "false"); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the OneToOneAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is OneToOneAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <meta> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(MetaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is OneToOneAttribute ) break; // Following attributes are for this OneToOne if( memberAttrib is MetaAttribute ) WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(MetaAttribute), attribute); // Element: <formula> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(FormulaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is OneToOneAttribute ) break; // Following attributes are for this OneToOne if( memberAttrib is FormulaAttribute ) WriteFormula(writer, member, memberAttrib as FormulaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(FormulaAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a ManyToMany XML Element from attributes in a member. </summary> public virtual void WriteManyToMany(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ManyToManyAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "many-to-many" ); // Attribute: <class> if(attribute.Class != null) writer.WriteAttributeString("class", GetAttributeValue(attribute.Class, mappedClass)); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); // Attribute: <embed-xml> if( attribute.EmbedXmlSpecified ) writer.WriteAttributeString("embed-xml", attribute.EmbedXml ? "true" : "false"); // Attribute: <entity-name> if(attribute.EntityName != null) writer.WriteAttributeString("entity-name", GetAttributeValue(attribute.EntityName, mappedClass)); // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <formula> if(attribute.Formula != null) writer.WriteAttributeString("formula", GetAttributeValue(attribute.Formula, mappedClass)); // Attribute: <not-found> if(attribute.NotFound != NotFoundMode.Unspecified) writer.WriteAttributeString("not-found", GetXmlEnumValue(typeof(NotFoundMode), attribute.NotFound)); // Attribute: <outer-join> if(attribute.OuterJoin != OuterJoinStrategy.Unspecified) writer.WriteAttributeString("outer-join", GetXmlEnumValue(typeof(OuterJoinStrategy), attribute.OuterJoin)); // Attribute: <fetch> if(attribute.Fetch != FetchMode.Unspecified) writer.WriteAttributeString("fetch", GetXmlEnumValue(typeof(FetchMode), attribute.Fetch)); // Attribute: <lazy> if(attribute.Lazy != RestrictedLaziness.Unspecified) writer.WriteAttributeString("lazy", GetXmlEnumValue(typeof(RestrictedLaziness), attribute.Lazy)); // Attribute: <foreign-key> if(attribute.ForeignKey != null) writer.WriteAttributeString("foreign-key", GetAttributeValue(attribute.ForeignKey, mappedClass)); // Attribute: <unique> if( attribute.UniqueSpecified ) writer.WriteAttributeString("unique", attribute.Unique ? "true" : "false"); // Attribute: <where> if(attribute.Where != null) writer.WriteAttributeString("where", GetAttributeValue(attribute.Where, mappedClass)); // Attribute: <order-by> if(attribute.OrderBy != null) writer.WriteAttributeString("order-by", GetAttributeValue(attribute.OrderBy, mappedClass)); // Attribute: <property-ref> if(attribute.PropertyRef != null) writer.WriteAttributeString("property-ref", GetAttributeValue(attribute.PropertyRef, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the ManyToManyAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is ManyToManyAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <meta> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(MetaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ManyToManyAttribute ) break; // Following attributes are for this ManyToMany if( memberAttrib is MetaAttribute ) WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(MetaAttribute), attribute); // Element: <column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ManyToManyAttribute ) break; // Following attributes are for this ManyToMany if( memberAttrib is ColumnAttribute ) WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute); // Element: <formula> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(FormulaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ManyToManyAttribute ) break; // Following attributes are for this ManyToMany if( memberAttrib is FormulaAttribute ) WriteFormula(writer, member, memberAttrib as FormulaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(FormulaAttribute), attribute); // Element: <filter> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(FilterAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ManyToManyAttribute ) break; // Following attributes are for this ManyToMany if( memberAttrib is FilterAttribute ) WriteFilter(writer, member, memberAttrib as FilterAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(FilterAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a PrimitiveArray XML Element from attributes in a member. </summary> public virtual void WritePrimitiveArray(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, PrimitiveArrayAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "primitive-array" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_PrimitiveArray_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <access> if(attribute.Access != null) writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, mappedClass)); // Attribute: <table> if(attribute.Table != null) writer.WriteAttributeString("table", GetAttributeValue(attribute.Table, mappedClass)); // Attribute: <schema> if(attribute.Schema != null) writer.WriteAttributeString("schema", GetAttributeValue(attribute.Schema, mappedClass)); // Attribute: <catalog> if(attribute.Catalog != null) writer.WriteAttributeString("catalog", GetAttributeValue(attribute.Catalog, mappedClass)); // Attribute: <subselect> if(attribute.Subselect != null) writer.WriteAttributeString("subselect", GetAttributeValue(attribute.Subselect, mappedClass)); // Attribute: <mutable> if( attribute.MutableSpecified ) writer.WriteAttributeString("mutable", attribute.Mutable ? "true" : "false"); // Attribute: <where> if(attribute.Where != null) writer.WriteAttributeString("where", GetAttributeValue(attribute.Where, mappedClass)); // Attribute: <batch-size> if(attribute.BatchSize != -1) writer.WriteAttributeString("batch-size", attribute.BatchSize.ToString()); // Attribute: <outer-join> if(attribute.OuterJoin != PrimitiveArrayOuterJoin.Unspecified) writer.WriteAttributeString("outer-join", GetXmlEnumValue(typeof(PrimitiveArrayOuterJoin), attribute.OuterJoin)); // Attribute: <fetch> if(attribute.Fetch != PrimitiveArrayFetch.Unspecified) writer.WriteAttributeString("fetch", GetXmlEnumValue(typeof(PrimitiveArrayFetch), attribute.Fetch)); // Attribute: <persister> if(attribute.Persister != null) writer.WriteAttributeString("persister", GetAttributeValue(attribute.Persister, mappedClass)); // Attribute: <collection-type> if(attribute.CollectionType != null) writer.WriteAttributeString("collection-type", GetAttributeValue(attribute.CollectionType, mappedClass)); // Attribute: <check> if(attribute.Check != null) writer.WriteAttributeString("check", GetAttributeValue(attribute.Check, mappedClass)); // Attribute: <optimistic-lock> if( attribute.OptimisticLockSpecified ) writer.WriteAttributeString("optimistic-lock", attribute.OptimisticLock ? "true" : "false"); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); // Attribute: <embed-xml> if( attribute.EmbedXmlSpecified ) writer.WriteAttributeString("embed-xml", attribute.EmbedXml ? "true" : "false"); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the PrimitiveArrayAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is PrimitiveArrayAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <meta> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(MetaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is MetaAttribute ) WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(MetaAttribute), attribute); // Element: <subselect> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SubselectAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is SubselectAttribute ) WriteSubselect(writer, member, memberAttrib as SubselectAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SubselectAttribute), attribute); // Element: <cache> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(CacheAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is CacheAttribute ) WriteCache(writer, member, memberAttrib as CacheAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(CacheAttribute), attribute); // Element: <synchronize> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SynchronizeAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is SynchronizeAttribute ) WriteSynchronize(writer, member, memberAttrib as SynchronizeAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SynchronizeAttribute), attribute); // Element: <comment> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(CommentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is CommentAttribute ) WriteComment(writer, member, memberAttrib as CommentAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(CommentAttribute), attribute); // Element: <key> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(KeyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is KeyAttribute ) WriteKey(writer, member, memberAttrib as KeyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(KeyAttribute), attribute); // Element: <index> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(IndexAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is IndexAttribute ) WriteIndex(writer, member, memberAttrib as IndexAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(IndexAttribute), attribute); // Element: <list-index> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ListIndexAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is ListIndexAttribute ) WriteListIndex(writer, member, memberAttrib as ListIndexAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ListIndexAttribute), attribute); // Element: <element> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ElementAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is ElementAttribute ) WriteElement(writer, member, memberAttrib as ElementAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ElementAttribute), attribute); // Element: <loader> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(LoaderAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is LoaderAttribute ) WriteLoader(writer, member, memberAttrib as LoaderAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(LoaderAttribute), attribute); // Element: <sql-insert> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlInsertAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is SqlInsertAttribute ) WriteSqlInsert(writer, member, memberAttrib as SqlInsertAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlInsertAttribute), attribute); // Element: <sql-update> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlUpdateAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is SqlUpdateAttribute ) WriteSqlUpdate(writer, member, memberAttrib as SqlUpdateAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlUpdateAttribute), attribute); // Element: <sql-delete> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlDeleteAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is SqlDeleteAttribute ) WriteSqlDelete(writer, member, memberAttrib as SqlDeleteAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlDeleteAttribute), attribute); // Element: <sql-delete-all> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlDeleteAllAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PrimitiveArrayAttribute ) break; // Following attributes are for this PrimitiveArray if( memberAttrib is SqlDeleteAllAttribute ) WriteSqlDeleteAll(writer, member, memberAttrib as SqlDeleteAllAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlDeleteAllAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a MapKey XML Element from attributes in a member. </summary> public virtual void WriteMapKey(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, MapKeyAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "map-key" ); // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <formula> if(attribute.Formula != null) writer.WriteAttributeString("formula", GetAttributeValue(attribute.Formula, mappedClass)); // Attribute: <type> writer.WriteAttributeString("type", attribute.Type==null ? DefaultHelper.Get_MapKey_Type_DefaultValue(member) : GetAttributeValue(attribute.Type, mappedClass)); // Attribute: <length> if(attribute.Length != -1) writer.WriteAttributeString("length", attribute.Length.ToString()); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the MapKeyAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is MapKeyAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is MapKeyAttribute ) break; // Following attributes are for this MapKey if( memberAttrib is ColumnAttribute ) WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute); // Element: <formula> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(FormulaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is MapKeyAttribute ) break; // Following attributes are for this MapKey if( memberAttrib is FormulaAttribute ) WriteFormula(writer, member, memberAttrib as FormulaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(FormulaAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a Property XML Element from attributes in a member. </summary> public virtual void WriteProperty(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, PropertyAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "property" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_Property_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); // Attribute: <access> if(attribute.Access != null) writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, mappedClass)); // Attribute: <type> if(attribute.Type != null) writer.WriteAttributeString("type", GetAttributeValue(attribute.Type, mappedClass)); else { System.Type type = null; if(member is System.Reflection.PropertyInfo) type = (member as System.Reflection.PropertyInfo).PropertyType; else if(member is System.Reflection.FieldInfo) type = (member as System.Reflection.FieldInfo).FieldType; if(type != null) // Transform using RegularExpressions { string typeName = type.FullName + ", " + type.Assembly.GetName().Name; foreach(System.Collections.DictionaryEntry pattern in Patterns) { if(System.Text.RegularExpressions.Regex.IsMatch(typeName, pattern.Key as string)) { writer.WriteAttributeString( "type", System.Text.RegularExpressions.Regex.Replace(typeName, pattern.Key as string, pattern.Value as string) ); break; } } } } // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <length> if(attribute.Length != -1) writer.WriteAttributeString("length", attribute.Length.ToString()); // Attribute: <precision> if(attribute.Precision != -1) writer.WriteAttributeString("precision", attribute.Precision.ToString()); // Attribute: <scale> if(attribute.Scale != -1) writer.WriteAttributeString("scale", attribute.Scale.ToString()); // Attribute: <not-null> if( attribute.NotNullSpecified ) writer.WriteAttributeString("not-null", attribute.NotNull ? "true" : "false"); // Attribute: <unique> if( attribute.UniqueSpecified ) writer.WriteAttributeString("unique", attribute.Unique ? "true" : "false"); // Attribute: <unique-key> if(attribute.UniqueKey != null) writer.WriteAttributeString("unique-key", GetAttributeValue(attribute.UniqueKey, mappedClass)); // Attribute: <index> if(attribute.Index != null) writer.WriteAttributeString("index", GetAttributeValue(attribute.Index, mappedClass)); // Attribute: <update> if( attribute.UpdateSpecified ) writer.WriteAttributeString("update", attribute.Update ? "true" : "false"); // Attribute: <insert> if( attribute.InsertSpecified ) writer.WriteAttributeString("insert", attribute.Insert ? "true" : "false"); // Attribute: <optimistic-lock> if( attribute.OptimisticLockSpecified ) writer.WriteAttributeString("optimistic-lock", attribute.OptimisticLock ? "true" : "false"); // Attribute: <formula> if(attribute.Formula != null) writer.WriteAttributeString("formula", GetAttributeValue(attribute.Formula, mappedClass)); // Attribute: <lazy> if( attribute.LazySpecified ) writer.WriteAttributeString("lazy", attribute.Lazy ? "true" : "false"); // Attribute: <generated> if(attribute.Generated != PropertyGeneration.Unspecified) writer.WriteAttributeString("generated", GetXmlEnumValue(typeof(PropertyGeneration), attribute.Generated)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the PropertyAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is PropertyAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <meta> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(MetaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PropertyAttribute ) break; // Following attributes are for this Property if( memberAttrib is MetaAttribute ) WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(MetaAttribute), attribute); // Element: <column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PropertyAttribute ) break; // Following attributes are for this Property if( memberAttrib is ColumnAttribute ) WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute); // Element: <formula> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(FormulaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PropertyAttribute ) break; // Following attributes are for this Property if( memberAttrib is FormulaAttribute ) WriteFormula(writer, member, memberAttrib as FormulaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(FormulaAttribute), attribute); // Element: <type> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(TypeAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is PropertyAttribute ) break; // Following attributes are for this Property if( memberAttrib is TypeAttribute ) WriteType(writer, member, memberAttrib as TypeAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(TypeAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a MapKeyManyToMany XML Element from attributes in a member. </summary> public virtual void WriteMapKeyManyToMany(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, MapKeyManyToManyAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "map-key-many-to-many" ); // Attribute: <class> if(attribute.Class != null) writer.WriteAttributeString("class", GetAttributeValue(attribute.Class, mappedClass)); // Attribute: <entity-name> if(attribute.EntityName != null) writer.WriteAttributeString("entity-name", GetAttributeValue(attribute.EntityName, mappedClass)); // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); // Attribute: <formula> if(attribute.Formula != null) writer.WriteAttributeString("formula", GetAttributeValue(attribute.Formula, mappedClass)); // Attribute: <foreign-key> if(attribute.ForeignKey != null) writer.WriteAttributeString("foreign-key", GetAttributeValue(attribute.ForeignKey, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the MapKeyManyToManyAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is MapKeyManyToManyAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is MapKeyManyToManyAttribute ) break; // Following attributes are for this MapKeyManyToMany if( memberAttrib is ColumnAttribute ) WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute); // Element: <formula> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(FormulaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is MapKeyManyToManyAttribute ) break; // Following attributes are for this MapKeyManyToMany if( memberAttrib is FormulaAttribute ) WriteFormula(writer, member, memberAttrib as FormulaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(FormulaAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a ReturnColumn XML Element from attributes in a member. </summary> public virtual void WriteReturnColumn(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ReturnColumnAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "return-column" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_ReturnColumn_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); writer.WriteEndElement(); }
/// <summary> Write a Meta XML Element from attributes in a member. </summary> public virtual void WriteMeta(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, MetaAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "meta" ); // Attribute: <attribute> writer.WriteAttributeString("attribute", attribute.Attribute==null ? DefaultHelper.Get_Meta_Attribute_DefaultValue(member) : GetAttributeValue(attribute.Attribute, mappedClass)); // Attribute: <inherit> if( attribute.InheritSpecified ) writer.WriteAttributeString("inherit", attribute.Inherit ? "true" : "false"); WriteUserDefinedContent(writer, member, null, attribute); // Write the content of this element (mixed="true") writer.WriteString(attribute.Content); writer.WriteEndElement(); }
/// <summary> Write a ReturnProperty XML Element from attributes in a member. </summary> public virtual void WriteReturnProperty(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ReturnPropertyAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "return-property" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_ReturnProperty_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <column> if(attribute.Column != null) writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the ReturnPropertyAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is ReturnPropertyAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <return-column> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ReturnColumnAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ReturnPropertyAttribute ) break; // Following attributes are for this ReturnProperty if( memberAttrib is ReturnColumnAttribute ) WriteReturnColumn(writer, member, memberAttrib as ReturnColumnAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ReturnColumnAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a MetaValue XML Element from attributes in a member. </summary> public virtual void WriteMetaValue(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, MetaValueAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "meta-value" ); // Attribute: <value> writer.WriteAttributeString("value", attribute.Value==null ? DefaultHelper.Get_MetaValue_Value_DefaultValue(member) : GetAttributeValue(attribute.Value, mappedClass)); // Attribute: <class> writer.WriteAttributeString("class", attribute.Class==null ? DefaultHelper.Get_MetaValue_Class_DefaultValue(member) : GetAttributeValue(attribute.Class, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); writer.WriteEndElement(); }
/// <summary> Write a Set XML Element from attributes in a member. </summary> public virtual void WriteSet(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, SetAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "set" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_Set_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <access> if(attribute.Access != null) writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, mappedClass)); // Attribute: <table> if(attribute.Table != null) writer.WriteAttributeString("table", GetAttributeValue(attribute.Table, mappedClass)); // Attribute: <schema> if(attribute.Schema != null) writer.WriteAttributeString("schema", GetAttributeValue(attribute.Schema, mappedClass)); // Attribute: <catalog> if(attribute.Catalog != null) writer.WriteAttributeString("catalog", GetAttributeValue(attribute.Catalog, mappedClass)); // Attribute: <subselect> if(attribute.Subselect != null) writer.WriteAttributeString("subselect", GetAttributeValue(attribute.Subselect, mappedClass)); // Attribute: <lazy> if(attribute.Lazy != CollectionLazy.Unspecified) writer.WriteAttributeString("lazy", GetXmlEnumValue(typeof(CollectionLazy), attribute.Lazy)); // Attribute: <inverse> if( attribute.InverseSpecified ) writer.WriteAttributeString("inverse", attribute.Inverse ? "true" : "false"); // Attribute: <mutable> if( attribute.MutableSpecified ) writer.WriteAttributeString("mutable", attribute.Mutable ? "true" : "false"); // Attribute: <cascade> if(attribute.Cascade != null) writer.WriteAttributeString("cascade", GetAttributeValue(attribute.Cascade, mappedClass)); // Attribute: <order-by> if(attribute.OrderBy != null) writer.WriteAttributeString("order-by", GetAttributeValue(attribute.OrderBy, mappedClass)); // Attribute: <where> if(attribute.Where != null) writer.WriteAttributeString("where", GetAttributeValue(attribute.Where, mappedClass)); // Attribute: <batch-size> if(attribute.BatchSize != -9223372036854775808) writer.WriteAttributeString("batch-size", attribute.BatchSize.ToString()); // Attribute: <outer-join> if(attribute.OuterJoin != OuterJoinStrategy.Unspecified) writer.WriteAttributeString("outer-join", GetXmlEnumValue(typeof(OuterJoinStrategy), attribute.OuterJoin)); // Attribute: <fetch> if(attribute.Fetch != CollectionFetchMode.Unspecified) writer.WriteAttributeString("fetch", GetXmlEnumValue(typeof(CollectionFetchMode), attribute.Fetch)); // Attribute: <persister> if(attribute.Persister != null) writer.WriteAttributeString("persister", GetAttributeValue(attribute.Persister, mappedClass)); // Attribute: <collection-type> if(attribute.CollectionType != null) writer.WriteAttributeString("collection-type", GetAttributeValue(attribute.CollectionType, mappedClass)); // Attribute: <check> if(attribute.Check != null) writer.WriteAttributeString("check", GetAttributeValue(attribute.Check, mappedClass)); // Attribute: <optimistic-lock> if( attribute.OptimisticLockSpecified ) writer.WriteAttributeString("optimistic-lock", attribute.OptimisticLock ? "true" : "false"); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); // Attribute: <embed-xml> if( attribute.EmbedXmlSpecified ) writer.WriteAttributeString("embed-xml", attribute.EmbedXml ? "true" : "false"); // Attribute: <generic> if( attribute.GenericSpecified ) writer.WriteAttributeString("generic", attribute.Generic ? "true" : "false"); // Attribute: <sort> if(attribute.Sort != null) writer.WriteAttributeString("sort", GetAttributeValue(attribute.Sort, mappedClass)); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the SetAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is SetAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <meta> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(MetaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is MetaAttribute ) WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(MetaAttribute), attribute); // Element: <subselect> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SubselectAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is SubselectAttribute ) WriteSubselect(writer, member, memberAttrib as SubselectAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SubselectAttribute), attribute); // Element: <cache> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(CacheAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is CacheAttribute ) WriteCache(writer, member, memberAttrib as CacheAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(CacheAttribute), attribute); // Element: <synchronize> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SynchronizeAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is SynchronizeAttribute ) WriteSynchronize(writer, member, memberAttrib as SynchronizeAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SynchronizeAttribute), attribute); // Element: <comment> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(CommentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is CommentAttribute ) WriteComment(writer, member, memberAttrib as CommentAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(CommentAttribute), attribute); // Element: <key> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(KeyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is KeyAttribute ) WriteKey(writer, member, memberAttrib as KeyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(KeyAttribute), attribute); // Element: <element> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ElementAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is ElementAttribute ) WriteElement(writer, member, memberAttrib as ElementAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ElementAttribute), attribute); // Element: <one-to-many> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(OneToManyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is OneToManyAttribute ) WriteOneToMany(writer, member, memberAttrib as OneToManyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(OneToManyAttribute), attribute); // Element: <many-to-many> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ManyToManyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is ManyToManyAttribute ) WriteManyToMany(writer, member, memberAttrib as ManyToManyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ManyToManyAttribute), attribute); // Element: <composite-element> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(CompositeElementAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is CompositeElementAttribute ) WriteCompositeElement(writer, member, memberAttrib as CompositeElementAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(CompositeElementAttribute), attribute); // Element: <many-to-any> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ManyToAnyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is ManyToAnyAttribute ) WriteManyToAny(writer, member, memberAttrib as ManyToAnyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ManyToAnyAttribute), attribute); // Element: <loader> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(LoaderAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is LoaderAttribute ) WriteLoader(writer, member, memberAttrib as LoaderAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(LoaderAttribute), attribute); // Element: <sql-insert> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlInsertAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is SqlInsertAttribute ) WriteSqlInsert(writer, member, memberAttrib as SqlInsertAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlInsertAttribute), attribute); // Element: <sql-update> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlUpdateAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is SqlUpdateAttribute ) WriteSqlUpdate(writer, member, memberAttrib as SqlUpdateAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlUpdateAttribute), attribute); // Element: <sql-delete> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlDeleteAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is SqlDeleteAttribute ) WriteSqlDelete(writer, member, memberAttrib as SqlDeleteAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlDeleteAttribute), attribute); // Element: <sql-delete-all> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlDeleteAllAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is SqlDeleteAllAttribute ) WriteSqlDeleteAll(writer, member, memberAttrib as SqlDeleteAllAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlDeleteAllAttribute), attribute); // Element: <filter> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(FilterAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is SetAttribute ) break; // Following attributes are for this Set if( memberAttrib is FilterAttribute ) WriteFilter(writer, member, memberAttrib as FilterAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(FilterAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a NaturalId XML Element from attributes in a member. </summary> public virtual void WriteNaturalId(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, NaturalIdAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "natural-id" ); // Attribute: <mutable> if( attribute.MutableSpecified ) writer.WriteAttributeString("mutable", attribute.Mutable ? "true" : "false"); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the NaturalIdAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is NaturalIdAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <property> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(PropertyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is NaturalIdAttribute ) break; // Following attributes are for this NaturalId if( memberAttrib is PropertyAttribute ) WriteProperty(writer, member, memberAttrib as PropertyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(PropertyAttribute), attribute); // Element: <many-to-one> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ManyToOneAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is NaturalIdAttribute ) break; // Following attributes are for this NaturalId if( memberAttrib is ManyToOneAttribute ) WriteManyToOne(writer, member, memberAttrib as ManyToOneAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ManyToOneAttribute), attribute); // Element: <component> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ComponentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' } WriteUserDefinedContent(writer, member, typeof(ComponentAttribute), attribute); // Element: <dynamic-component> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(DynamicComponentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is DynamicComponentAttribute ) WriteDynamicComponent(writer, member, memberAttrib as DynamicComponentAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(DynamicComponentAttribute), attribute); // Element: <any> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(AnyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is NaturalIdAttribute ) break; // Following attributes are for this NaturalId if( memberAttrib is AnyAttribute ) WriteAny(writer, member, memberAttrib as AnyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(AnyAttribute), attribute); writer.WriteEndElement(); }
/// <summary> Write a SqlUpdate XML Element from attributes in a member. </summary> public virtual void WriteSqlUpdate(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, SqlUpdateAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "sql-update" ); // Attribute: <callable> if( attribute.CallableSpecified ) writer.WriteAttributeString("callable", attribute.Callable ? "true" : "false"); // Attribute: <check> if(attribute.Check != CustomSqlCheck.Unspecified) writer.WriteAttributeString("check", GetXmlEnumValue(typeof(CustomSqlCheck), attribute.Check)); WriteUserDefinedContent(writer, member, null, attribute); // Write the content of this element (mixed="true") writer.WriteString(attribute.Content); writer.WriteEndElement(); }
public void ValueChangedDemo(BaseAttribute sender, float value) { _valueChangedEventTriggered += 1; }