Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/PresentationFramework')
-rw-r--r--mcs/class/PresentationFramework/ChangeLog9
-rw-r--r--mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs19
-rw-r--r--mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs35
-rw-r--r--mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlWriter.cs4
4 files changed, 29 insertions, 38 deletions
diff --git a/mcs/class/PresentationFramework/ChangeLog b/mcs/class/PresentationFramework/ChangeLog
index 32741738996..ebdb2d7bb4e 100644
--- a/mcs/class/PresentationFramework/ChangeLog
+++ b/mcs/class/PresentationFramework/ChangeLog
@@ -2,6 +2,15 @@
* Mono.Windows.Serialization/XamlParser.cs,
Mono.Windows.Serialization/XamlWriter.cs,
+ Mono.Windows.Serialization/CodeWriter.cs: removed TypeConverter
+ stuff from everything except CodeWriter. By using TypeDescriptor,
+ the generator doesn't need to be told about the converter and since
+ the framework will find it we don't have to search for it.
+
+2005-07-08 Iain McCoy <iain@mccoy.id.au>
+
+ * Mono.Windows.Serialization/XamlParser.cs,
+ Mono.Windows.Serialization/XamlWriter.cs,
Mono.Windows.Serialization/CodeWriter.cs: support for x:Name
attributes and for considering Name properties to have the same
affect.
diff --git a/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs b/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs
index 5ed0c3118fb..b6939555538 100644
--- a/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs
+++ b/mcs/class/PresentationFramework/Mono.Windows.Serialization/CodeWriter.cs
@@ -222,20 +222,29 @@ namespace Mono.Windows.Serialization {
expr);
constructor.Statements.Add(assignment);
}
+
+ private CodeExpression fetchConverter(Type propertyType)
+ {
+ return new CodeMethodInvokeExpression(
+ new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression(typeof(System.ComponentModel.TypeDescriptor)),
+ "GetConverter"),
+ new CodeTypeOfExpression(propertyType));
+ }
// top of stack is reference to a property
- public void CreatePropertyText(string text, Type propertyType, Type converterType)
+ public void CreatePropertyText(string text, Type propertyType)
{
- CreateDependencyPropertyText(text, propertyType, converterType);
+ CreateDependencyPropertyText(text, propertyType);
}
// top of stack is reference to an attached property
- public void CreateDependencyPropertyText(string text, Type propertyType, Type converterType)
+ public void CreateDependencyPropertyText(string text, Type propertyType)
{
CodeExpression expr = new CodePrimitiveExpression(text);
- if (converterType != null) {
+ if (propertyType != typeof(string)) {
expr = new CodeCastExpression(
new CodeTypeReference(propertyType),
new CodeMethodInvokeExpression(
- new CodeObjectCreateExpression(converterType),
+ fetchConverter(propertyType),
"ConvertFromString",
expr));
}
diff --git a/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs b/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs
index 369c6532fea..fb9f2a26b18 100644
--- a/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs
+++ b/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlParser.cs
@@ -164,39 +164,13 @@ namespace Mono.Windows.Serialization {
writer.CreateElementText(reader.Value);
} else if (currentState.type == CurrentType.DependencyProperty) {
DependencyProperty dp = (DependencyProperty)currentState.obj;
- writer.CreateDependencyPropertyText(reader.Value, dp.PropertyType,
- getTypeConverter(dp.PropertyType));
+ writer.CreateDependencyPropertyText(reader.Value, dp.PropertyType);
} else {
PropertyInfo prop = (PropertyInfo)currentState.obj;
- writer.CreatePropertyText(reader.Value, prop.PropertyType,
- getTypeConverter(prop.PropertyType));
+ writer.CreatePropertyText(reader.Value, prop.PropertyType);
}
}
- Type getTypeConverter(Type fromType)
- {
- // TODO: this business setting assembly is frankly
- // grotesque. It should just be something along the
- // lines of Assembly.Load("System.dll")
- Assembly assembly = null;
- foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) {
- if (a.CodeBase.EndsWith("System.dll")) {
- assembly = a;
- break;
- }
- }
-
-
- if (fromType.Namespace == "System" &&
- fromType.Name == "String")
- return null;
- string converterName = "System.ComponentModel." + fromType.Name + "Converter,System.dll";
- Type converter = assembly.GetType(converterName);
- return converter;
- // TODO: check if converter == null and do something cool
- }
-
-
void parseNormalPropertyElement(string propertyName)
{
// preconditions: currentState.Type == Object
@@ -316,7 +290,7 @@ namespace Mono.Windows.Serialization {
if (prop.PropertyType.IsSubclassOf(typeof(Delegate)))
writer.CreatePropertyDelegate(reader.Value, prop.PropertyType);
else
- writer.CreatePropertyText(reader.Value, prop.PropertyType, getTypeConverter(prop.PropertyType));
+ writer.CreatePropertyText(reader.Value, prop.PropertyType);
writer.EndProperty();
}
@@ -373,8 +347,7 @@ namespace Mono.Windows.Serialization {
DependencyProperty dp = getDependencyProperty(typeAttachedTo, propertyName);
writer.CreateDependencyProperty(typeAttachedTo, propertyName, dp.PropertyType);
- writer.CreateDependencyPropertyText(reader.Value, dp.PropertyType,
- getTypeConverter(dp.PropertyType));
+ writer.CreateDependencyPropertyText(reader.Value, dp.PropertyType);
writer.EndDependencyProperty();
}
diff --git a/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlWriter.cs b/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlWriter.cs
index 38d7170c94a..ba760e0b3de 100644
--- a/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlWriter.cs
+++ b/mcs/class/PresentationFramework/Mono.Windows.Serialization/XamlWriter.cs
@@ -38,7 +38,7 @@ namespace Mono.Windows.Serialization {
void EndObject();
void CreateProperty(PropertyInfo property);
- void CreatePropertyText(string text, Type propertyType, Type converterType);
+ void CreatePropertyText(string text, Type propertyType);
void CreatePropertyDelegate(string functionName, Type propertyType);
void EndProperty();
@@ -48,7 +48,7 @@ namespace Mono.Windows.Serialization {
void EndEvent();
void CreateDependencyProperty(Type attachedTo, string propertyName, Type propertyType);
- void CreateDependencyPropertyText(string text, Type propertyType, Type converterType);
+ void CreateDependencyPropertyText(string text, Type propertyType);
void EndDependencyProperty();
void CreateCode(string code);