From 83f1d3436e10afcb175187270817bdd93f5e4569 Mon Sep 17 00:00:00 2001 From: Iain McCoy Date: Sat, 2 Jul 2005 09:28:36 +0000 Subject: 2005-07-02 Iain McCoy * tools/xamlc: initial in-progress version of xaml compiler and example * class/PresentationFramework: xaml support code * class/WindowsBase: initial version of DependencyObject, mostly for DependencyProperty support svn path=/trunk/mcs/; revision=46873 --- mcs/class/WindowsBase/Assembly/AssemblyInfo.cs | 39 +++++ mcs/class/WindowsBase/ChangeLog | 4 + mcs/class/WindowsBase/Makefile | 9 ++ mcs/class/WindowsBase/System.Windows/Callbacks.cs | 36 +++++ .../WindowsBase/System.Windows/DependencyObject.cs | 138 ++++++++++++++++ .../System.Windows/DependencyObjectType.cs | 65 ++++++++ .../System.Windows/DependencyProperty.cs | 175 +++++++++++++++++++++ .../System.Windows/DependencyPropertyKey.cs | 41 +++++ .../WindowsBase/System.Windows/LocalValueEntry.cs | 48 ++++++ .../System.Windows/LocalValueEnumerator.cs | 56 +++++++ .../WindowsBase/System.Windows/PropertyMetadata.cs | 90 +++++++++++ mcs/class/WindowsBase/Test/AttachedProperties.cs | 80 ++++++++++ mcs/class/WindowsBase/WindowsBase.dll.sources | 10 ++ mcs/class/WindowsBase/WindowsBase_test.dll.sources | 1 + 14 files changed, 792 insertions(+) create mode 100644 mcs/class/WindowsBase/Assembly/AssemblyInfo.cs create mode 100644 mcs/class/WindowsBase/ChangeLog create mode 100644 mcs/class/WindowsBase/Makefile create mode 100644 mcs/class/WindowsBase/System.Windows/Callbacks.cs create mode 100644 mcs/class/WindowsBase/System.Windows/DependencyObject.cs create mode 100644 mcs/class/WindowsBase/System.Windows/DependencyObjectType.cs create mode 100644 mcs/class/WindowsBase/System.Windows/DependencyProperty.cs create mode 100644 mcs/class/WindowsBase/System.Windows/DependencyPropertyKey.cs create mode 100644 mcs/class/WindowsBase/System.Windows/LocalValueEntry.cs create mode 100644 mcs/class/WindowsBase/System.Windows/LocalValueEnumerator.cs create mode 100644 mcs/class/WindowsBase/System.Windows/PropertyMetadata.cs create mode 100644 mcs/class/WindowsBase/Test/AttachedProperties.cs create mode 100644 mcs/class/WindowsBase/WindowsBase.dll.sources create mode 100644 mcs/class/WindowsBase/WindowsBase_test.dll.sources (limited to 'mcs/class/WindowsBase') diff --git a/mcs/class/WindowsBase/Assembly/AssemblyInfo.cs b/mcs/class/WindowsBase/Assembly/AssemblyInfo.cs new file mode 100644 index 00000000000..9feda362032 --- /dev/null +++ b/mcs/class/WindowsBase/Assembly/AssemblyInfo.cs @@ -0,0 +1,39 @@ +// +// AssemblyInfo.cs +// +// Author: +// Iain McCoy (iain@mccoy.id.au) +// Andreas Nahr (ClassDevelopment@A-SoftTech.com) +// +// (C) 2003 Ximian, Inc. http://www.ximian.com +// (C) 2004 Novell (http://www.novell.com) +// +// this file based on mcs/class/Mono.Data.SqlClient/Assembly/AssemblyInfo.cs + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +#if (NET_1_0) + [assembly: AssemblyVersion ("1.0.3300.0")] +#elif (NET_2_0) + [assembly: AssemblyVersion ("2.0.3600.0")] +#elif (NET_1_1) + [assembly: AssemblyVersion ("1.0.5000.0")] +#endif + +/* TODO COMPLETE INFORMATION + +[assembly: AssemblyTitle ("")] +[assembly: AssemblyDescription ("")] + +[assembly: CLSCompliant (true)] +[assembly: AssemblyFileVersion ("0.0.0.1")] + +[assembly: ComVisible (false)] + +*/ + +[assembly: AssemblyDelaySign (true)] +[assembly: AssemblyKeyFile ("../mono.pub")] + diff --git a/mcs/class/WindowsBase/ChangeLog b/mcs/class/WindowsBase/ChangeLog new file mode 100644 index 00000000000..6c7f6e994db --- /dev/null +++ b/mcs/class/WindowsBase/ChangeLog @@ -0,0 +1,4 @@ +2005-07-02 Iain McCoy + + * whole folder: initial implementation of the DependencyProperty + system diff --git a/mcs/class/WindowsBase/Makefile b/mcs/class/WindowsBase/Makefile new file mode 100644 index 00000000000..a481d1ab78f --- /dev/null +++ b/mcs/class/WindowsBase/Makefile @@ -0,0 +1,9 @@ +thisdir = class/WindowsBase +include ../../build/rules.make + +LIBRARY = WindowsBase.dll + +LIB_MCS_FLAGS = +TEST_MCS_FLAGS = -r:WindowsBase.dll + +include ../../build/library.make diff --git a/mcs/class/WindowsBase/System.Windows/Callbacks.cs b/mcs/class/WindowsBase/System.Windows/Callbacks.cs new file mode 100644 index 00000000000..60093da8f57 --- /dev/null +++ b/mcs/class/WindowsBase/System.Windows/Callbacks.cs @@ -0,0 +1,36 @@ +// +// Callbacks.cs +// +// Author: +// Iain McCoy (iain@mccoy.id.au) +// +// (C) 2005 Iain McCoy +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + + +namespace System.Windows { + public delegate bool ValidateValueCallback(object value); + public delegate void PropertyInvalidatedCallback(DependencyObject d); + public delegate Object GetValueOverride(DependencyObject d); + public delegate Object ReadLocalValueOverride(DependencyObject d); + public delegate void WriteLocalValueOverride(DependencyObject d, Object value); +} diff --git a/mcs/class/WindowsBase/System.Windows/DependencyObject.cs b/mcs/class/WindowsBase/System.Windows/DependencyObject.cs new file mode 100644 index 00000000000..a8ded9fea98 --- /dev/null +++ b/mcs/class/WindowsBase/System.Windows/DependencyObject.cs @@ -0,0 +1,138 @@ +// +// DependencyObject.cs +// +// Author: +// Iain McCoy (iain@mccoy.id.au) +// +// (C) 2005 Iain McCoy +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System.Collections; + +namespace System.Windows { + public class DependencyObject { + private static Hashtable propertyDeclarations = new Hashtable(); + private Hashtable properties = new Hashtable(); + + private DependencyObjectType dependencyObjectType; + public DependencyObjectType DependencyObjectType { + get { return dependencyObjectType; } + } + + [MonoTODO()] + public void ClearValue(DependencyProperty dp) + { + throw new NotImplementedException("ClearValue(DependencyProperty dp)"); + } + + [MonoTODO()] + public void ClearValue(DependencyPropertyKey key) + { + throw new NotImplementedException("ClearValue(DependencyPropertyKey key)"); + } + + [MonoTODO()] + public LocalValueEnumerator GetLocalValueEnumerator() + { + throw new NotImplementedException("GetLocalValueEnumerator()"); + } + + public object GetValue(DependencyProperty dp) + { + return properties[dp]; + } + + [MonoTODO()] + public object GetValueBase(DependencyProperty dp) + { + throw new NotImplementedException("GetValueBase(DependencyProperty dp)"); + } + + [MonoTODO()] + protected virtual object GetValueCore(DependencyProperty dp, object baseValue, PropertyMetadata metadata) + { + throw new NotImplementedException("GetValueCore(DependencyProperty dp, object baseValue, PropertyMetadata metadata)"); + } + + [MonoTODO()] + public void InvalidateProperty(DependencyProperty dp) + { + throw new NotImplementedException("InvalidateProperty(DependencyProperty dp)"); + } + + [MonoTODO()] + protected virtual void OnPropertyInvalidated(DependencyProperty dp, PropertyMetadata metadata) + { + throw new NotImplementedException("OnPropertyInvalidated(DependencyProperty dp, PropertyMetadata metadata)"); + } + + [MonoTODO()] + public object ReadLocalValue(DependencyProperty dp) + { + throw new NotImplementedException("ReadLocalValue(DependencyProperty dp)"); + } + + public void SetValue(DependencyProperty dp, object value) + { + + ValidateValueCallback validate = dp.ValidateValueCallback; + if (validate != null && !validate(value)) + throw new Exception("Value does not validate"); + else + properties[dp] = value; + } + + [MonoTODO()] + public void SetValue(DependencyPropertyKey key, object value) + { + throw new NotImplementedException("SetValue(DependencyPropertyKey key, object value)"); + } + + [MonoTODO()] + public void SetValueBase(DependencyProperty dp, object value) + { + throw new NotImplementedException("SetValueBase(DependencyProperty dp, object value)"); + } + + [MonoTODO()] + public void SetValueBase(DependencyPropertyKey key, object value) + { + throw new NotImplementedException("SetValueBase(DependencyPropertyKey key, object value)"); + } + + internal static DependencyProperty lookup(Type t, string name) + { + return (DependencyProperty)((Hashtable)propertyDeclarations[t])[name]; + } + + internal static void register(Type t, DependencyProperty dp) + { + if (propertyDeclarations[t] == null) + propertyDeclarations[t] = new Hashtable(); + Hashtable typeDeclarations = (Hashtable)propertyDeclarations[t]; + if (!typeDeclarations.ContainsKey(dp.Name)) + typeDeclarations[dp.Name] = dp; + else + throw new Exception("A property named " + dp.Name + " already exists on " + t.Name); + } + } +} diff --git a/mcs/class/WindowsBase/System.Windows/DependencyObjectType.cs b/mcs/class/WindowsBase/System.Windows/DependencyObjectType.cs new file mode 100644 index 00000000000..f5b2fc67fa9 --- /dev/null +++ b/mcs/class/WindowsBase/System.Windows/DependencyObjectType.cs @@ -0,0 +1,65 @@ +// +// DependencyObjectType.cs +// +// Author: +// Iain McCoy (iain@mccoy.id.au) +// +// (C) 2005 Iain McCoy +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + + +namespace System.Windows { + public class DependencyObjectType { + private DependencyObjectType baseType; + private int id; + private string name; + private Type systemType; + + public DependencyObjectType BaseType { + get { return baseType; } + } + public int Id { + get { return id; } + } + public string Name { + get { return name; } + } + public Type SystemType { + get { return systemType; } + } + [MonoTODO()] + public static DependencyObjectType FromSystemType(Type systemType) + { + throw new NotImplementedException("FromSystemType(Type systemType)"); + } + [MonoTODO()] + public bool IsInstanceOfType(DependencyObject d) + { + throw new NotImplementedException("IsInstanceOfType(DependencyObject d)"); + } + [MonoTODO()] + public bool IsSubClassOf(DependencyObjectType dependencyObjectType) + { + throw new NotImplementedException("IsSubClassOf(DependencyObjectType dependencyObjectType)"); + } + } +} diff --git a/mcs/class/WindowsBase/System.Windows/DependencyProperty.cs b/mcs/class/WindowsBase/System.Windows/DependencyProperty.cs new file mode 100644 index 00000000000..494d6453174 --- /dev/null +++ b/mcs/class/WindowsBase/System.Windows/DependencyProperty.cs @@ -0,0 +1,175 @@ +// +// DependencyProperty.cs +// +// Author: +// Iain McCoy (iain@mccoy.id.au) +// +// (C) 2005 Iain McCoy +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace System.Windows { + public class DependencyProperty { + private PropertyMetadata defaultMetadata; + private string name; + private Type ownerType; + private Type propertyType; + private ValidateValueCallback validateValueCallback; + + private bool isAttached; + internal bool IsAttached { get { return isAttached; } } + + private DependencyProperty (bool isAttached, string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback) + { + this.isAttached = isAttached; + this.defaultMetadata = defaultMetadata; + this.name = name; + this.ownerType = ownerType; + this.propertyType = propertyType; + this.validateValueCallback = validateValueCallback; + } + + public PropertyMetadata DefaultMetadata { + get { return defaultMetadata; } + } + public string Name { + get { return name; } + } + public Type OwnerType { + get { return ownerType; } + } + public Type PropertyType { + get { return propertyType; } + } + public ValidateValueCallback ValidateValueCallback { + get { return validateValueCallback; } + } + + [MonoTODO()] + public DependencyProperty AddOwner(Type ownerType) + { + throw new NotImplementedException("AddOwner(Type ownerType)"); + } + [MonoTODO()] + public DependencyProperty AddOwner(Type ownerType, PropertyMetadata typeMetadata) + { + throw new NotImplementedException("AddOwner(Type ownerType, PropertyMetadata typeMetadata)"); + } + + [MonoTODO()] + public static DependencyProperty FromName(String name, Type ownerType) + { + return DependencyObject.lookup(ownerType, name); + } + + [MonoTODO()] + public PropertyMetadata GetMetadata(Type forType) + { + throw new NotImplementedException("GetMetadata(Type forType)"); + } + [MonoTODO()] + public PropertyMetadata GetMetadata(DependencyObject d) + { + throw new NotImplementedException("GetMetadata(DependencyObject d)"); + } + [MonoTODO()] + public PropertyMetadata GetMetadata(DependencyObjectType dependencyObjectType) + { + throw new NotImplementedException("GetMetadata(DependencyObjectType dependencyObjectType)"); + } + + [MonoTODO()] + public bool IsValidType(object value) + { + throw new NotImplementedException("IsValidType(object value)"); + } + [MonoTODO()] + public bool IsValidValue(object value) + { + throw new NotImplementedException("IsValidValue(object value)"); + } + + [MonoTODO()] + public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata) + { + throw new NotImplementedException("OverrideMetadata(Type forType, PropertyMetadata typeMetadata)"); + } + [MonoTODO()] + public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata, DependencyPropertyKey key) + { + throw new NotImplementedException("OverrideMetadata(Type forType, PropertyMetadata typeMetadata, DependencyPropertyKey key)"); + } + + public static DependencyProperty Register(string name, Type propertyType, Type ownerType) + { + return Register(name, propertyType, ownerType, null, null); + } + public static DependencyProperty Register(string name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata) + { + return Register(name, propertyType, ownerType, typeMetadata, null); + } + public static DependencyProperty Register(string name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata, ValidateValueCallback validateValueCallback) + { + DependencyProperty dp = new DependencyProperty(false, name, propertyType, ownerType, typeMetadata, validateValueCallback); + DependencyObject.register(ownerType, dp); + return dp; + } + + public static DependencyProperty RegisterAttached(string name, Type propertyType, Type ownerType) + { + return RegisterAttached(name, propertyType, ownerType, null, null); + } + + public static DependencyProperty RegisterAttached(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata) + { + return RegisterAttached(name, propertyType, ownerType, defaultMetadata, null); + } + + public static DependencyProperty RegisterAttached(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback) + { + DependencyProperty dp = new DependencyProperty(true, name, propertyType, null, null, null); + DependencyObject.register(ownerType, dp); + return dp; + } + + [MonoTODO()] + public static DependencyPropertyKey RegisterAttachedReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata) + { + throw new NotImplementedException("RegisterAttachedReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata)"); + } + [MonoTODO()] + public static DependencyPropertyKey RegisterAttachedReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback) + { + throw new NotImplementedException("RegisterAttachedReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback)"); + } + [MonoTODO()] + public static DependencyPropertyKey RegisterReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata) + { + throw new NotImplementedException("RegisterReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata)"); + } + [MonoTODO()] + public static DependencyPropertyKey RegisterReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata, ValidateValueCallback validateValueCallback) + { + throw new NotImplementedException("RegisterReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata, ValidateValueCallback validateValueCallback)"); + } + + } +} diff --git a/mcs/class/WindowsBase/System.Windows/DependencyPropertyKey.cs b/mcs/class/WindowsBase/System.Windows/DependencyPropertyKey.cs new file mode 100644 index 00000000000..859d3731e0e --- /dev/null +++ b/mcs/class/WindowsBase/System.Windows/DependencyPropertyKey.cs @@ -0,0 +1,41 @@ +// +// DependencyPropertyKey.cs +// +// Author: +// Iain McCoy (iain@mccoy.id.au) +// +// (C) 2005 Iain McCoy +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace System.Windows { + public class DependencyPropertyKey { + private DependencyProperty dependencyProperty; + public DependencyProperty DependencyProperty { + get { return dependencyProperty; } + } + [MonoTODO()] + public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata) + { + throw new NotImplementedException("OverrideMetadata(Type forType, PropertyMetadata typeMetadata)"); + } + } +} diff --git a/mcs/class/WindowsBase/System.Windows/LocalValueEntry.cs b/mcs/class/WindowsBase/System.Windows/LocalValueEntry.cs new file mode 100644 index 00000000000..e574ed35310 --- /dev/null +++ b/mcs/class/WindowsBase/System.Windows/LocalValueEntry.cs @@ -0,0 +1,48 @@ +// +// LocalValueEntry.cs +// +// Author: +// Iain McCoy (iain@mccoy.id.au) +// +// (C) 2005 Iain McCoy +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace System.Windows { + public struct LocalValueEntry { + private DependencyProperty property; + private object value; + + public DependencyProperty Property { + get { return property; } + } + + public object Value { + get { return value; } + } + + internal LocalValueEntry(DependencyProperty property, object value) + { + this.property = property; + this.value = value; + } + } +} diff --git a/mcs/class/WindowsBase/System.Windows/LocalValueEnumerator.cs b/mcs/class/WindowsBase/System.Windows/LocalValueEnumerator.cs new file mode 100644 index 00000000000..67d040fc8e3 --- /dev/null +++ b/mcs/class/WindowsBase/System.Windows/LocalValueEnumerator.cs @@ -0,0 +1,56 @@ +// +// LocalValueEnumerator.cs +// +// Author: +// Iain McCoy (iain@mccoy.id.au) +// +// (C) 2005 Iain McCoy +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + + +using System.Collections; + +namespace System.Windows { + public struct LocalValueEnumerator : IEnumerator { + [MonoTODO()] + public int Count { + get { throw new NotImplementedException(); } + } + [MonoTODO()] + public LocalValueEntry Current { + get { throw new NotImplementedException(); } + } + object IEnumerator.Current { + get { return this.Current; } + } + [MonoTODO()] + public bool MoveNext() + { + throw new NotImplementedException(); + } + [MonoTODO()] + public void Reset() + { + throw new NotImplementedException(); + } + } +} diff --git a/mcs/class/WindowsBase/System.Windows/PropertyMetadata.cs b/mcs/class/WindowsBase/System.Windows/PropertyMetadata.cs new file mode 100644 index 00000000000..bb6786066ee --- /dev/null +++ b/mcs/class/WindowsBase/System.Windows/PropertyMetadata.cs @@ -0,0 +1,90 @@ +// +// PropertyMetadata.cs +// +// Author: +// Iain McCoy (iain@mccoy.id.au) +// +// (C) 2005 Iain McCoy +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +namespace System.Windows { + public class PropertyMetadata { + private object defaultValue; + private GetValueOverride getValueOverride; + private bool isSealed; + private PropertyInvalidatedCallback propertyInvalidatedCallback; + private ReadLocalValueOverride readLocalValueOverride; + private bool readOnly; + private WriteLocalValueOverride writeLocalValueOverride; + + public object DefaultValue { + get { return defaultValue; } + set { defaultValue = value; } + } + public GetValueOverride GetValueOverride { + get { return getValueOverride; } + set { getValueOverride = value;} + } + protected bool IsSealed { + get { return isSealed; } + } + public PropertyInvalidatedCallback PropertyInvalidatedCallback { + get { return propertyInvalidatedCallback; } + set { propertyInvalidatedCallback = value; } + } + public ReadLocalValueOverride ReadLocalValueOverride { + get { return readLocalValueOverride; } + set { readLocalValueOverride = value; } + } + public bool ReadOnly { + get { return readOnly; } + } + public WriteLocalValueOverride WriteLocalValueOverride { + get { return writeLocalValueOverride; } + set { writeLocalValueOverride = value; } + } + + [MonoTODO()] + protected void ClearCachedDefaultValue (DependencyObject owner) + { + throw new NotImplementedException("ClearCachedDefaultValue(DependencyObject owner)"); + } + + [MonoTODO()] + protected virtual object CreateDefaultValue (DependencyObject owner, DependencyProperty property) + { + throw new NotImplementedException("CreateDefaultValue(DependencyObject owner, DependencyProperty property)"); + } + + [MonoTODO()] + protected virtual void Merge (PropertyMetadata baseMetadata, DependencyProperty dp) + { + throw new NotImplementedException("Merge(PropertyMetadata baseMetadata, DependencyProperty dp)"); + } + + [MonoTODO()] + protected virtual void OnApply (DependencyProperty dp, Type targetType) + { + throw new NotImplementedException("OnApply(DependencyProperty dp, Type targetType)"); + } + } +} diff --git a/mcs/class/WindowsBase/Test/AttachedProperties.cs b/mcs/class/WindowsBase/Test/AttachedProperties.cs new file mode 100644 index 00000000000..f42f6166d44 --- /dev/null +++ b/mcs/class/WindowsBase/Test/AttachedProperties.cs @@ -0,0 +1,80 @@ +// this is a template for making NUnit version 2 tests. Text enclosed in curly +// brackets (and the brackets themselves) should be replaced by appropriate +// code. + +// DependencyObject.cs - NUnit Test Cases for attached properties +// +// Iain McCoy (iain@mccoy.id.au) +// +// (C) iain@mccoy.id.au +// + +using NUnit.Framework; +using System; +using System.Windows; + +// all test namespaces start with "MonoTests." Append the Namespace that +// contains the class you are testing, e.g. MonoTests.System.Collections +namespace MonoTests.System.Windows +{ + +class X { + public static readonly DependencyProperty AProperty = DependencyProperty.RegisterAttached("A", typeof(int), typeof(X)); + public static void SetA(DependencyObject obj, int value) + { + obj.SetValue(AProperty, value); + } + public static int GetA(DependencyObject obj) + { + return (int)obj.GetValue(AProperty); + } +} + +class Y : DependencyObject { +} + +[TestFixture] +public class DependencyObjectTest : Assertion { + + [SetUp] + public void GetReady() {} + + [TearDown] + public void Clean() {} + + [Test] + public void TestAttachedProperty() + { + Y y1 = new Y(); + X.SetA(y1, 2); + AssertEquals(2, X.GetA(y1)); + } + + [Test] + public void Test2AttachedProperties() + { + Y y1 = new Y(); + Y y2 = new Y(); + X.SetA(y1, 2); + X.SetA(y2, 3); + AssertEquals(2, X.GetA(y1)); + AssertEquals(3, X.GetA(y2)); + } + + // An nice way to test for exceptions the class under test should + // throw is: + /* + [Test] + [ExpectedException(typeof(ArgumentNullException))] + public void OnValid() { + ConcreteCollection myCollection; + myCollection = new ConcreteCollection(); + .... + AssertEquals ("#UniqueID", expected, actual); + .... + Fail ("Message"); + } + */ + +} +} diff --git a/mcs/class/WindowsBase/WindowsBase.dll.sources b/mcs/class/WindowsBase/WindowsBase.dll.sources new file mode 100644 index 00000000000..5e3ee2dc1fa --- /dev/null +++ b/mcs/class/WindowsBase/WindowsBase.dll.sources @@ -0,0 +1,10 @@ +System.Windows/Callbacks.cs +System.Windows/DependencyObject.cs +System.Windows/DependencyObjectType.cs +System.Windows/DependencyProperty.cs +System.Windows/DependencyPropertyKey.cs +System.Windows/LocalValueEntry.cs +System.Windows/LocalValueEnumerator.cs +System.Windows/PropertyMetadata.cs +../../build/common/MonoTODOAttribute.cs +Assembly/AssemblyInfo.cs diff --git a/mcs/class/WindowsBase/WindowsBase_test.dll.sources b/mcs/class/WindowsBase/WindowsBase_test.dll.sources new file mode 100644 index 00000000000..9cb90abe702 --- /dev/null +++ b/mcs/class/WindowsBase/WindowsBase_test.dll.sources @@ -0,0 +1 @@ +AttachedProperties.cs -- cgit v1.2.3