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:
authorAndreas N <andreas@mono-cvs.ximian.com>2003-07-02 18:54:42 +0400
committerAndreas N <andreas@mono-cvs.ximian.com>2003-07-02 18:54:42 +0400
commit52f9ed8dc05e476ba8f712ddbb1eb0a2e2bf28c1 (patch)
treef8b163123d0d34471fb49f38ed1e108fbad0cb24 /mcs/class/System/System.ComponentModel.Design.Serialization
parent93fa12d0d56f77db9344e9d2a3d7c0e258add56f (diff)
2003-06-28 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* ContextStack.cs: Redone based on a stack and completely implemented * DesignerLoader.cs: Removed unneeded members * DesignerSerializerAttribute.cs: Implemented, fixed AttributeUsage * ResolveNameEventArgs.cs: Visibility bug fixed * RootDesignerSerializerAttribute.cs: Fixed and implemented, fixed AttributeUsage * InstanceDescriptor.cs: Completely Implemented svn path=/trunk/mcs/; revision=15866
Diffstat (limited to 'mcs/class/System/System.ComponentModel.Design.Serialization')
-rw-r--r--mcs/class/System/System.ComponentModel.Design.Serialization/Changelog8
-rw-r--r--mcs/class/System/System.ComponentModel.Design.Serialization/ContextStack.cs82
-rw-r--r--mcs/class/System/System.ComponentModel.Design.Serialization/DesignerLoader.cs19
-rw-r--r--mcs/class/System/System.ComponentModel.Design.Serialization/DesignerSerializerAttribute.cs43
-rw-r--r--mcs/class/System/System.ComponentModel.Design.Serialization/InstanceDescriptor.cs125
-rw-r--r--mcs/class/System/System.ComponentModel.Design.Serialization/ResolveNameEventArgs.cs6
-rw-r--r--mcs/class/System/System.ComponentModel.Design.Serialization/RootDesignerSerializerAttribute.cs46
7 files changed, 206 insertions, 123 deletions
diff --git a/mcs/class/System/System.ComponentModel.Design.Serialization/Changelog b/mcs/class/System/System.ComponentModel.Design.Serialization/Changelog
new file mode 100644
index 00000000000..a573836fa4a
--- /dev/null
+++ b/mcs/class/System/System.ComponentModel.Design.Serialization/Changelog
@@ -0,0 +1,8 @@
+2003-06-28 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * ContextStack.cs: Redone based on a stack and completely implemented
+ * DesignerLoader.cs: Removed unneeded members
+ * DesignerSerializerAttribute.cs: Implemented, fixed AttributeUsage
+ * ResolveNameEventArgs.cs: Visibility bug fixed
+ * RootDesignerSerializerAttribute.cs: Fixed and implemented, fixed AttributeUsage
+ * InstanceDescriptor.cs: Completely Implemented \ No newline at end of file
diff --git a/mcs/class/System/System.ComponentModel.Design.Serialization/ContextStack.cs b/mcs/class/System/System.ComponentModel.Design.Serialization/ContextStack.cs
index cba0a2ba3ce..d15f3b1e2c9 100644
--- a/mcs/class/System/System.ComponentModel.Design.Serialization/ContextStack.cs
+++ b/mcs/class/System/System.ComponentModel.Design.Serialization/ContextStack.cs
@@ -1,44 +1,66 @@
+//
// System.ComponentModel.Design.Serialization.ContextStack.cs
//
// Author:
-// Alejandro Sánchez Acosta <raciel@gnome.org>
+// Alejandro Sánchez Acosta (raciel@gnome.org)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
//
using System.Collections;
namespace System.ComponentModel.Design.Serialization
{
- public sealed class ContextStack
- {
- public ArrayList list;
-
- public ContextStack () {
- list = new ArrayList ();
- }
-
- public object Current {
- get {
- if (list.Count == 0) return null;
- return list [list.Count - 1];
- }
-
- set {
- list.Add (value);
- }
- }
-
- [MonoTODO]
+ public sealed class ContextStack
+ {
+ private Stack stack;
+
+ public ContextStack ()
+ {
+ stack = new Stack ();
+ }
+
+ public object Current {
+ get {
+ try {
+ return stack.Peek ();
+ }
+ catch {
+ return null;
+ }
+ }
+ }
+
public object this[Type type] {
- get { throw new NotImplementedException ();}
- set { throw new NotImplementedException ();}
- }
-
- [MonoTODO]
- public object this[int level] {
- get { throw new NotImplementedException ();}
- set { throw new NotImplementedException ();}
- }
+ get {
+ foreach (object o in stack.ToArray())
+ if (o.GetType () == type)
+ return o;
+ return null;
+ }
+ }
+
+ public object this[int level] {
+ get {
+ if (level < 0)
+ throw new ArgumentException ("level has to be >= 0","level");
+ Array A = stack.ToArray();
+ if (level > (A.Length - 1))
+ return null;
+ return A.GetValue(level);
+ }
+ }
+
+ public object Pop ()
+ {
+ return stack.Pop ();
+ }
+
+ public void Push (object context)
+ {
+ stack.Push (context);
+ }
}
}
diff --git a/mcs/class/System/System.ComponentModel.Design.Serialization/DesignerLoader.cs b/mcs/class/System/System.ComponentModel.Design.Serialization/DesignerLoader.cs
index a6f66e740bc..c73fe3112b2 100644
--- a/mcs/class/System/System.ComponentModel.Design.Serialization/DesignerLoader.cs
+++ b/mcs/class/System/System.ComponentModel.Design.Serialization/DesignerLoader.cs
@@ -1,38 +1,33 @@
//
-// System.ComponentModel.Design.Serialization.DesignerLoader
+// System.ComponentModel.Design.Serialization.DesignerLoader.cs
//
// Authors:
-// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2003 Martin Willemoes Hansen
+// (C) 2003 Andreas Nahr
//
namespace System.ComponentModel.Design.Serialization
{
+ // This class is merely an interface with no implementation needed
public abstract class DesignerLoader
{
- [MonoTODO]
+
protected DesignerLoader()
{
}
public virtual bool Loading {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return false; }
}
public abstract void BeginLoad (IDesignerLoaderHost host);
public abstract void Dispose();
- [MonoTODO]
public virtual void Flush()
{
- throw new NotImplementedException();
- }
-
- [MonoTODO]
- ~DesignerLoader()
- {
}
}
}
diff --git a/mcs/class/System/System.ComponentModel.Design.Serialization/DesignerSerializerAttribute.cs b/mcs/class/System/System.ComponentModel.Design.Serialization/DesignerSerializerAttribute.cs
index 63bda459810..f2ae468f4c8 100644
--- a/mcs/class/System/System.ComponentModel.Design.Serialization/DesignerSerializerAttribute.cs
+++ b/mcs/class/System/System.ComponentModel.Design.Serialization/DesignerSerializerAttribute.cs
@@ -2,54 +2,49 @@
// System.ComponentModel.Design.Serialization.DesignerSerializerAttribute.cs
//
// Authors:
-// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2003 Martin Willemoes Hansen
+// (C) 2003 Andreas Nahr
//
namespace System.ComponentModel.Design.Serialization
{
- [AttributeUsage(AttributeTargets.Class |
- AttributeTargets.Interface)]
- public sealed class DesignerSerializerAttribute : Attribute
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
+ public sealed class DesignerSerializerAttribute : Attribute
{
- [MonoTODO]
+
+ private string serializerTypeName;
+ private string baseSerializerTypeName;
+
public DesignerSerializerAttribute (string serializerTypeName,
- string baseSerializerTypeName)
+ string baseSerializerTypeName)
{
+ this.serializerTypeName = serializerTypeName;
+ this.baseSerializerTypeName = baseSerializerTypeName;
}
- [MonoTODO]
- public DesignerSerializerAttribute (string serializerTypeName,
- Type baseSerializerType)
+ public DesignerSerializerAttribute (string serializerTypeName, Type baseSerializerType)
+ : this (serializerTypeName, baseSerializerType.AssemblyQualifiedName)
{
}
- [MonoTODO]
- public DesignerSerializerAttribute (Type serializerType,
- Type baseSerializerType)
+ public DesignerSerializerAttribute (Type serializerType, Type baseSerializerType)
+ : this (serializerType.AssemblyQualifiedName, baseSerializerType.AssemblyQualifiedName)
{
}
public string SerializerBaseTypeName {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return baseSerializerTypeName; }
}
public string SerializerTypeName {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return serializerTypeName; }
}
public override object TypeId {
- [MonoTODO]
- get { throw new NotImplementedException(); }
- }
-
- [MonoTODO]
- public override int GetHashCode()
- {
- throw new NotImplementedException();
+ get { return string.Concat (this.ToString(), baseSerializerTypeName); }
}
}
}
diff --git a/mcs/class/System/System.ComponentModel.Design.Serialization/InstanceDescriptor.cs b/mcs/class/System/System.ComponentModel.Design.Serialization/InstanceDescriptor.cs
index a944813a901..fc713904b6a 100644
--- a/mcs/class/System/System.ComponentModel.Design.Serialization/InstanceDescriptor.cs
+++ b/mcs/class/System/System.ComponentModel.Design.Serialization/InstanceDescriptor.cs
@@ -1,10 +1,12 @@
//
-// System.ComponentModel.Design.Serialization.InstanceDescriptor
+// System.ComponentModel.Design.Serialization.InstanceDescriptor.cs
//
// Authors:
-// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Martin Willemoes Hansen (mwh@sysrq.dk)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2003 Martin Willemoes Hansen
+// (C) 2003 Andreas Nahr
//
using System.Collections;
@@ -14,44 +16,123 @@ namespace System.ComponentModel.Design.Serialization
{
public sealed class InstanceDescriptor
{
- [MonoTODO]
- public InstanceDescriptor (MemberInfo info,
- ICollection collection)
+
+ private MemberInfo member;
+ private ICollection arguments;
+ private bool isComplete;
+
+ public InstanceDescriptor (MemberInfo member, ICollection arguments)
+ : this (member, arguments, true)
+ {
+ }
+
+ public InstanceDescriptor(MemberInfo member, ICollection arguments, bool isComplete)
{
+ this.isComplete = isComplete;
+ if (member == null)
+ throw new ArgumentNullException ("member", "MemberInfo must be valid");
+ if (!IsMemberValid (member, arguments))
+ throw new ArgumentException ("Only Constructor, Method, Field or Property members allowed", "member");
+ this.member = member;
+ this.arguments = arguments;
}
- [MonoTODO]
- public InstanceDescriptor(MemberInfo info,
- ICollection coolection,
- bool boolean)
+ private bool IsMemberValid (MemberInfo member, ICollection arguments)
{
- throw new NotImplementedException();
+ switch (member.MemberType) {
+ // According to docs only these types are allowed
+ case MemberTypes.Constructor:
+ ConstructorInfo CI = (ConstructorInfo) member;
+ if (!CI.IsStatic)
+ throw new ArgumentException ("InstanceDescriptor only describes static (VB.Net: shared) members", "member");
+ if (arguments == null) // null counts as no arguments
+ if (CI.GetParameters().Length != 0)
+ throw new ArgumentException ("Invalid number of arguments for this constructor", "arguments");
+ if (arguments.Count != CI.GetParameters().Length)
+ throw new ArgumentException ("Invalid number of arguments for this constructor", "arguments");
+ return true;
+ case MemberTypes.Method:
+ MethodInfo MI = (MethodInfo) member;
+ if (!MI.IsStatic)
+ throw new ArgumentException ("InstanceDescriptor only describes static (VB.Net: shared) members", "member");
+ if (arguments == null) // null counts as no arguments
+ if (MI.GetParameters().Length != 0)
+ throw new ArgumentException ("Invalid number of arguments for this method", "arguments");
+ if (arguments.Count != MI.GetParameters().Length)
+ throw new ArgumentException ("Invalid number of arguments for this method", "arguments");
+ return true;
+ case MemberTypes.Field:
+ FieldInfo FI = (FieldInfo) member;
+ if (!FI.IsStatic)
+ throw new ArgumentException ("InstanceDescriptor only describes static (VB.Net: shared) members", "member");
+ if (arguments == null) // null counts as no arguments
+ return true;
+ if (arguments.Count == 0)
+ throw new ArgumentException ("Field members do not take any arguments", "arguments");
+ return true;
+ case MemberTypes.Property:
+ PropertyInfo PI = (PropertyInfo) member;
+ if (!(PI.CanRead))
+ throw new ArgumentException ("That property cannot be read", "member");
+ MethodInfo PIM = PI.GetGetMethod();
+ if (!PIM.IsStatic)
+ throw new ArgumentException ("InstanceDescriptor only describes static (VB.Net: shared) members", "member");
+ if (arguments == null) // null counts as no arguments
+ if (PIM.GetParameters().Length != 0)
+ throw new ArgumentException ("Invalid number of arguments for this property", "arguments");
+ if (arguments.Count != PIM.GetParameters().Length)
+ throw new ArgumentException ("Invalid number of arguments for this property", "arguments");
+ return true;
+ }
+ return false;
}
public ICollection Arguments {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get {
+ // It seems MS does not return null even if we specified null as parameter (but does not cause an exception)
+ if (arguments == null)
+ return new object[0];
+ return arguments;
+ }
}
public bool IsComplete {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return isComplete; }
}
public MemberInfo MemberInfo {
- [MonoTODO]
- get { throw new NotImplementedException(); }
+ get { return member; }
}
- [MonoTODO]
public object Invoke()
{
- throw new NotImplementedException();
- }
+ object[] parsearguments;
+ if (arguments == null)
+ parsearguments = new object[0];
+ else {
+ parsearguments = new object[arguments.Count - 1];
+ arguments.CopyTo (parsearguments, 0);
+ }
- [MonoTODO]
- ~InstanceDescriptor()
- {
+ //MemberInfo member;
+ switch (member.MemberType) {
+ case MemberTypes.Constructor:
+ ConstructorInfo CI = (ConstructorInfo) member;
+ return CI.Invoke (parsearguments);
+
+ case MemberTypes.Method:
+ MethodInfo MI = (MethodInfo) member;
+ return MI.Invoke (null, parsearguments);
+
+ case MemberTypes.Field:
+ FieldInfo FI = (FieldInfo) member;
+ return FI.GetValue (null);
+
+ case MemberTypes.Property:
+ PropertyInfo PI = (PropertyInfo) member;
+ return PI.GetValue (null, parsearguments);
+ }
+ return null;
}
}
}
diff --git a/mcs/class/System/System.ComponentModel.Design.Serialization/ResolveNameEventArgs.cs b/mcs/class/System/System.ComponentModel.Design.Serialization/ResolveNameEventArgs.cs
index a2291995cd6..b88a5df3a11 100644
--- a/mcs/class/System/System.ComponentModel.Design.Serialization/ResolveNameEventArgs.cs
+++ b/mcs/class/System/System.ComponentModel.Design.Serialization/ResolveNameEventArgs.cs
@@ -1,7 +1,8 @@
+//
// System.ComponentModel.Design.Serialization.ResolveNameEventArgs.cs
//
// Author:
-// Alejandro Sánchez Acosta <raciel@gnome.org>
+// Alejandro Sánchez Acosta (raciel@gnome.org)
//
// (C) Alejandro Sánchez Acosta
//
@@ -10,7 +11,8 @@ namespace System.ComponentModel.Design.Serialization
{
public class ResolveNameEventArgs : EventArgs
{
- public string name;
+
+ private string name;
public ResolveNameEventArgs (string name) {
this.name = name;
diff --git a/mcs/class/System/System.ComponentModel.Design.Serialization/RootDesignerSerializerAttribute.cs b/mcs/class/System/System.ComponentModel.Design.Serialization/RootDesignerSerializerAttribute.cs
index 4f6370931b0..6a0a84d17da 100644
--- a/mcs/class/System/System.ComponentModel.Design.Serialization/RootDesignerSerializerAttribute.cs
+++ b/mcs/class/System/System.ComponentModel.Design.Serialization/RootDesignerSerializerAttribute.cs
@@ -1,20 +1,21 @@
+//
// System.ComponentModel.Design.Serialization.RootDesignerSerializerAttribute.cs
//
-// Author:
-// Alejandro Sánchez Acosta <raciel@gnome.org>
+// Authors:
+// Alejandro Sánchez Acosta (raciel@gnome.org)
+// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
//
namespace System.ComponentModel.Design.Serialization
{
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
public sealed class RootDesignerSerializerAttribute : Attribute
{
private string serializer;
private string baseserializer;
- private Type basetypeserializer;
- private Type serializertype;
private bool reload;
public RootDesignerSerializerAttribute (string serializerTypeName, string baseSerializerTypeName, bool reloadable) {
@@ -23,57 +24,36 @@ namespace System.ComponentModel.Design.Serialization
this.reload = reloadable;
}
- public RootDesignerSerializerAttribute (string serializerTypeName, Type baseSerializerType, bool reloadable) {
- this.serializer = serializerTypeName;
- this.basetypeserializer = baseSerializerType;
- this.reload = reloadable;
+ public RootDesignerSerializerAttribute (string serializerTypeName, Type baseSerializerType, bool reloadable)
+ : this (serializerTypeName, baseSerializerType.AssemblyQualifiedName, reloadable)
+ {
}
- public RootDesignerSerializerAttribute (Type serializerType, Type baseSerializerType, bool reloadable) {
- this.serializertype = serializerType;
- this.basetypeserializer = baseSerializerType;
- this.reload = reloadable;
+ public RootDesignerSerializerAttribute (Type serializerType, Type baseSerializerType, bool reloadable)
+ : this (serializerType.AssemblyQualifiedName, baseSerializerType.AssemblyQualifiedName, reloadable)
+ {
}
public bool Reloadable {
get {
return this.reload;
}
-
- set {
- this.reload = value;
- }
}
public string SerializerBaseTypeName {
get {
return this.baseserializer;
}
-
- set {
- this.baseserializer = value;
- }
}
public string SerializerTypeName {
get {
return this.serializer;
}
-
- set {
- serializer = value;
- }
}
- [MonoTODO]
public override object TypeId {
- get { throw new NotImplementedException ();}
- }
-
- [MonoTODO]
- public override int GetHashCode()
- {
- throw new NotImplementedException();
+ get { return string.Concat (this.ToString(), baseserializer);}
}
}
}