Example #1
0
 private void SetCollectionValue(WebDevPage.IHTMLElement controlElement, PropertyInfo prop, InfoOwnerCollection collection)
 {
     if (controlElement != null)
     {
         string collectionxml = GetCollectionXml(prop, collection);
         if (collectionxml.Length > 0)
         {
             string html = controlElement.innerHTML;
             int index = IndexOfBeginTag(html, prop.Name);
             int length;
             if (index <= 0)
             {
                 index = 0;
             }
             controlElement.innerHTML = html.Insert(index, collectionxml);
         }
     }
 }
Example #2
0
 private string GetCollectionXml(PropertyInfo prop, InfoOwnerCollection collection)
 {
     StringBuilder builder = new StringBuilder();
     if (prop != null && collection != null && prop.PropertyType == collection.GetType())
     {
         if (collection.Count > 0)
         {
             builder.AppendLine(string.Format("\t<{0}>", prop.Name));
             for (int i = 0; i < collection.Count; i++)
             {
                 builder.Append(string.Format("\t\t<{0}:{1} ", INFOLIGHTMARK, collection.ItemType.Name));
                 PropertyInfo[] infos = collection.ItemType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
                 for (int j = 0; j < infos.Length; j++)
                 {
                     if (!IsVisibilityHidden(infos[j]))
                     {
                         if (infos[j].PropertyType == typeof(string) || infos[j].PropertyType == typeof(int) || infos[j].PropertyType == typeof(bool)
                             || infos[j].PropertyType.BaseType == typeof(Enum))
                         {
                             if (!infos[j].Name.Equals("Name"))
                             {
                                 object value = infos[j].GetValue(collection[i], null);
                                 object defaultvalue = GetDefaultValue(infos[j]);
                                 if (infos[j].CanWrite && value != defaultvalue)
                                 {
                                     builder.Append(string.Format("{0}=\"{1}\" ", infos[j].Name, value));
                                 }
                             }
                         }
                     }
                 }
                 builder.AppendLine("/>");
             }
             builder.AppendLine(string.Format("\t</{0}>", prop.Name));
         }
     }
     return builder.ToString();
 }