-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ComponentPropertyType and denormalized data.
PostPosted: Fri May 11, 2007 3:55 pm 
Newbie

Joined: Thu May 10, 2007 10:54 am
Posts: 3
Location: central illinois, usa
Am I missing something? (using version 1.2)

Code:
/* ... snip ... */
public abstract class AgentRow
{
   /* ... begin ... */
   [ComponentProperty(ComponentType=typeof(DenormalizedList<string>), PropertyName="Languages")]
   [Property(1, Name="Item1")]
   [Column(2, Name="Languages1", SqlType="char", Length=3, NotNull=false)]
   [Property(3, Name="Item2")]
   [Column(4, Name="Languages2", SqlType="char", Length=3, NotNull=false)]
   [Property(5, Name="Item3")]
   [Column(6, Name="Languages3", SqlType="char", Length=3, NotNull=false)]
   [Property(7, Name="Item4")]
   [Column(8, Name="Languages4", SqlType="char", Length=3, NotNull=false)]
   [Property(9, Name="Item5")]
   [Column(10, Name="Languages5", SqlType="char", Length=3, NotNull=false)]
   public virtual DenormalizedList<string> Languages
   {
      get { return _languages; }
      protected set { _languages = value; }
   }
   /* ... end ... */
}
/* ... snip ... */
[Serializable]
[Component]
public class DenormalizedList<T> : List<T>
{
   public DenormalizedList() : base(5) { }

   private void __add(T item)
   {
      if (item != null) Add(item);
   }

   private T __get(int index)
   {
      if (index > 0 && index < Count)
         return this[index];

      return default(T);
   }

   protected virtual T Item1 { set { __add(value); } get { return __get(0); } }
   protected virtual T Item2 { set { __add(value); } get { return __get(1); } }
   protected virtual T Item3 { set { __add(value); } get { return __get(2); } }
   protected virtual T Item4 { set { __add(value); } get { return __get(3); } }
   protected virtual T Item5 { set { __add(value); } get { return __get(4); } }
}
/* ... snip ... */




... Is generating invalid xml.... the workaround I came up with was...


Code:
/* ... snip ... */
public abstract class AgentRow
{
   /* ... snip ... */
   [RawXml(After=typeof(PropertyAttribute), Content=@"
<component name=""Languages"" class=""DenormalizedList`1[[System.String, mscorlib]]"">
    <property name=""Item1"">
      <column name=""Languages1"" length=""3"" not-null=""false"" sql-type=""char"" />
    </property>
    <property name=""Item2"">
      <column name=""Languages2"" length=""3"" not-null=""false"" sql-type=""char"" />
    </property>
    <property name=""Item3"">
      <column name=""Languages3"" length=""3"" not-null=""false"" sql-type=""char"" />
    </property>
    <property name=""Item4"">
      <column name=""Languages4"" length=""3"" not-null=""false"" sql-type=""char"" />
    </property>
    <property name=""Item5"">
      <column name=""Languages5"" length=""3"" not-null=""false"" sql-type=""char"" />
    </property>
</component>
")]
   public virtual DenormalizedList<string> Languages
   {
      get { return _languages; }
      protected set { _languages = value; }
   }
   /* ... snip ... */
}
/* ... snip ... */
[Serializable]
[Component]
public class DenormalizedList<T> : List<T>
{
   public DenormalizedList() : base(5) { }

   private void __add(T item)
   {
      if (item != null) Add(item);
   }

   private T __get(int index)
   {
      if (index > 0 && index < Count)
         return this[index];

      return default(T);
   }

   protected virtual T Item1 { set { __add(value); } get { return __get(0); } }
   protected virtual T Item2 { set { __add(value); } get { return __get(1); } }
   protected virtual T Item3 { set { __add(value); } get { return __get(2); } }
   protected virtual T Item4 { set { __add(value); } get { return __get(3); } }
   protected virtual T Item5 { set { __add(value); } get { return __get(4); } }
}
/* ... snip ... */



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.