+2007-03-12 Igor Zelmanovich <igorz@mainsoft.com>
+
+ * Style.cs: optimization: used CssStyleCollection .ctor w/o parameters.
+
2007-03-09 Marek Habersack <mhabersack@novell.com>
* Login.cs: Make command name comparison case-insensitive in
* CreateUserWizardStep.cs: fixed validators message display
-2006-08-25 Kornél Pál <kornelpal@gmail.com>
+2006-08-25 Korn__l P__l <kornelpal@gmail.com>
* FileUpload.cs: Use assembly name constants.
2006-07-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* DataList.cs: correctly initialize editable items when there's an
- EditItemTemplate. Patch by JarosÅ\82aw Pawlak.
+ EditItemTemplate. Patch by Jaros_\82aw Pawlak.
2006-07-13 Juraj Skripsky <js@hotfeet.ch>
2004-10-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* ListItemCollection.cs: fixed bug when indexing changed elements in
- LoadViewState. Patch from Alois Bělaška.
+ LoadViewState. Patch from Alois B_\9bla__ka.
2004-10-20 Sanjay Gupta <gsanjay@novell.com>
if (CssClass.Length > 0)
writer.AddAttribute (HtmlTextWriterAttribute.Class, CssClass);
#if NET_2_0
- CssStyleCollection col = new CssStyleCollection (new StateBag ());
+ CssStyleCollection col = new CssStyleCollection ();
FillStyleAttributes (col, owner);
foreach (string key in col.Keys) {
writer.AddStyleAttribute (key, col [key]);
public CssStyleCollection GetStyleAttributes (IUrlResolutionService resolver)
{
- CssStyleCollection col = new CssStyleCollection (new StateBag ());
+ CssStyleCollection col = new CssStyleCollection ();
FillStyleAttributes (col, resolver);
return col;
}
{
private StateBag bag;
private CssStyleCollection styleCollection;
+ internal const string StyleAttribute = "style";
public AttributeCollection (StateBag bag)
{
public void Add (string key, string value)
{
- if (0 == String.Compare (key, "style", true, CultureInfo.InvariantCulture)) {
+ if (0 == String.Compare (key, StyleAttribute, true, CultureInfo.InvariantCulture)) {
CssStyle.Value = value;
return;
}
public void Remove (string key)
{
- if (0 == String.Compare (key, "style", true, CultureInfo.InvariantCulture)) {
+ if (0 == String.Compare (key, StyleAttribute, true, CultureInfo.InvariantCulture)) {
CssStyle.Clear ();
return;
}
+2007-03-12 Igor Zelmanovich <igorz@mainsoft.com>
+
+ * AttributeCollection.cs:
+ * CssStyleCollection.cs: fixed: works w/o state bag.
+
2007-03-12 Igor Zelmanovich <igorz@mainsoft.com>
* HtmlTextWriter.cs: fixed:
{
StateBag bag;
HybridDictionary style;
+ string _value;
+
+ string ValueInternal {
+ get { return _value; }
+ set {
+ _value = value;
+ if (bag != null) {
+ if (_value == null) {
+ bag.Remove (AttributeCollection.StyleAttribute);
+ }
+ else {
+ bag [AttributeCollection.StyleAttribute] = _value;
+ }
+ }
+ }
+ }
+
+ internal CssStyleCollection ()
+ {
+#if NET_2_0
+ style = new HybridDictionary (true);
+#else
+ style = new HybridDictionary (false);
+#endif
+ }
internal CssStyleCollection (StateBag bag)
+ : this ()
{
this.bag = bag;
if (bag != null)
- InitFromStyle ();
+ _value = (string) bag [AttributeCollection.StyleAttribute];
+ InitFromStyle ();
}
void InitFromStyle ()
{
-#if NET_2_0
- style = new HybridDictionary (true);
-#else
- style = new HybridDictionary (false);
-#endif
- string att = (string) bag ["style"];
- if (att != null) {
- FillStyle (att);
+ style.Clear ();
+ if (_value != null) {
+ FillStyle (_value);
}
}
public void Add (string key, string value)
{
style [key] = value;
- bag ["style"] = BagToString ();
+ ValueInternal = BagToString ();
}
#if NET_2_0
public void Clear ()
{
style.Clear ();
- bag.Remove ("style");
+ ValueInternal = null;
}
public void Remove (string key)
if (style [key] == null)
return;
style.Remove (key);
- bag ["style"] = BagToString ();
+ if (style.Count == 0)
+ ValueInternal = null;
+ else
+ ValueInternal = BagToString ();
}
#if NET_2_0
public string this [HtmlTextWriterStyle key] {
internal
#endif
string Value {
- get { return BagToString (); }
+ get { return ValueInternal; }
set {
- bag ["style"] = value;
+ ValueInternal = value;
InitFromStyle ();
}
}
}
[Test]
- [Category("NotWorking")]
public void InitialNoBag10()
{
AC ac = new AC(null);
}
[Test]
- [Category("NotWorking")]
public void InitialNoBag11()
{
AC ac = new AC(null);
}
[Test]
- [Category("NotWorking")]
public void InitialNoBag12()
{
AC ac = new AC(null);
Assert.AreEqual ("", str, "value2");
Assert.AreEqual (1, bag.Count, "count2");
}
+
+ [Test]
+ public void Count1 ()
+ {
+ StateBag bag = new StateBag (true);
+ AC ac = new AC (bag);
+ ac.Add ("style", "padding: 0px; margin: 0px");
+ Assert.AreEqual (1, ac.Count, "AttributeCollection.Count");
+ Assert.AreEqual (2, ac.CssStyle.Count, "AttributeCollection.Count");
+
+ ac.Remove ("style");
+ Assert.AreEqual (0, ac.Count, "AttributeCollection.Count");
+ Assert.AreEqual (0, ac.CssStyle.Count, "AttributeCollection.Count");
+ }
+
+ [Test]
+ public void Count2 ()
+ {
+ StateBag bag = new StateBag (true);
+ AC ac = new AC (bag);
+ ac ["style"] = "padding: 0px; margin: 0px";
+ Assert.AreEqual (1, ac.Count, "AttributeCollection.Count");
+ Assert.AreEqual (2, ac.CssStyle.Count, "AttributeCollection.Count");
+
+ ac ["style"] = null;
+ Assert.AreEqual (0, ac.Count, "AttributeCollection.Count");
+ Assert.AreEqual (0, ac.CssStyle.Count, "AttributeCollection.Count");
+ }
+
+ [Test]
+ public void Count3 ()
+ {
+ StateBag bag = new StateBag (true);
+ AC ac = new AC (bag);
+ ac.CssStyle.Add("padding", "0px");
+ ac.CssStyle.Add("margin", "0px");
+ Assert.AreEqual (1, ac.Count, "AttributeCollection.Count");
+ Assert.AreEqual (2, ac.CssStyle.Count, "AttributeCollection.Count");
+
+ ac.CssStyle.Remove ("padding");
+ ac.CssStyle.Remove ("margin");
+ Assert.AreEqual (0, ac.Count, "AttributeCollection.Count");
+ Assert.AreEqual (0, ac.CssStyle.Count, "AttributeCollection.Count");
+ }
+
+#if NET_2_0
+ [Test]
+ public void Count4 ()
+ {
+ StateBag bag = new StateBag (true);
+ AC ac = new AC (bag);
+ ac.CssStyle ["padding"] = "0px";
+ ac.CssStyle ["margin"] = "0px";
+ Assert.AreEqual (1, ac.Count, "AttributeCollection.Count");
+ Assert.AreEqual (2, ac.CssStyle.Count, "AttributeCollection.Count");
+
+ ac.CssStyle.Value = null;
+ Assert.AreEqual (0, ac.Count, "AttributeCollection.Count");
+ Assert.AreEqual (0, ac.CssStyle.Count, "AttributeCollection.Count");
+ }
+#endif
}
}