[Mediaportal-svn] SF.net SVN: mediaportal: [19232] trunk/MP-II/Presentation/SkinEngine
Turn your PC into a very advanced MediaCenter/HTPC
Brought to you by:
gereonheitmann,
morpheus_xx
From: <alb...@us...> - 2008-05-31 16:42:50
|
Revision: 19232 http://mediaportal.svn.sourceforge.net/mediaportal/?rev=19232&view=rev Author: albert1978 Date: 2008-05-31 09:42:46 -0700 (Sat, 31 May 2008) Log Message: ----------- Moved remotely Added Paths: ----------- trunk/MP-II/Presentation/SkinEngine/MpfElements/MpfNamespaceHandler.cs Removed Paths: ------------- trunk/MP-II/Presentation/SkinEngine/Loader/MpfNamespaceHandler.cs Deleted: trunk/MP-II/Presentation/SkinEngine/Loader/MpfNamespaceHandler.cs =================================================================== --- trunk/MP-II/Presentation/SkinEngine/Loader/MpfNamespaceHandler.cs 2008-05-31 15:44:06 UTC (rev 19231) +++ trunk/MP-II/Presentation/SkinEngine/Loader/MpfNamespaceHandler.cs 2008-05-31 16:42:46 UTC (rev 19232) @@ -1,118 +0,0 @@ -#region Copyright (C) 2007-2008 Team MediaPortal - -/* - Copyright (C) 2007-2008 Team MediaPortal - http://www.team-mediaportal.com - - This file is part of MediaPortal II - - MediaPortal II is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - MediaPortal II is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with MediaPortal II. If not, see <http://www.gnu.org/licenses/>. -*/ - -#endregion - -using System; -using System.Collections.Generic; -using System.Reflection; -using Presentation.SkinEngine.XamlParser; -using Presentation.SkinEngine.MpfElements; - -namespace Presentation.SkinEngine.Loader -{ - public class MpfNamespaceHandler: INamespaceHandler - { - #region Protected methods - - internal IDataDescriptor GetAttachedProperty(string propertyProvider, - string propertyName, object targetObject) - { - return new MpfAttachedPropertyDataDescriptor(this, targetObject, propertyProvider, propertyName); - } - - internal static MethodInfo GetAttachedPropertyGetter(string propertyProvider, - string propertyName) - { - Type type = GetElementType(propertyProvider); - return type.GetMethod("Get" + propertyName + "AttachedProperty", - BindingFlags.Public | BindingFlags.Static); - } - - internal static Type GetElementType(string typeName) - { - try - { - return MseElements.ObjectClassRegistrations[typeName]; - } - catch - { - throw new XamlParserException("Element type '{0}' is not present in MpfNamespaceHandler", - typeName); - } - } - - internal static bool HasAttachedProperty(string propertyProvider, - string propertyName, object targetObject) - { - return GetAttachedPropertyGetter(propertyProvider, propertyName) != null; - } - - #endregion - - #region INamespaceHandler implementation - - public object InstantiateElement(IParserContext context, string typeName, string namespaceURI, - IList<object> parameters) - { - try - { - Type t = GetElementType(typeName, namespaceURI); - object[] parameterObjects = new object[parameters.Count]; - parameters.CopyTo(parameterObjects, 0); - return Activator.CreateInstance(t, parameterObjects); - } - catch (Exception e) - { - if (e is XamlParserException) - throw; - throw new XamlParserException("Error creating element type '{0}' in namespace '{1}'", - e, typeName, namespaceURI); - } - } - - public Type GetElementType(string typeName, string namespaceURI) - { - return GetElementType(typeName); - } - - public bool HasAttachedProperty(string propertyProvider, - string propertyName, object targetObject, string namespaceURI) - { - return GetAttachedPropertyGetter(propertyProvider, propertyName) != null; - } - - public IDataDescriptor GetAttachedProperty(string propertyProvider, - string propertyName, object targetObject, string namespaceURI) - { - MpfAttachedPropertyDataDescriptor result; - if (!MpfAttachedPropertyDataDescriptor.CreateAttachedPropertyDataDescriptor( - this, targetObject, propertyProvider, propertyName, out result)) - throw new InvalidOperationException(string.Format( - "Attached property '{0}.{1}' is not available on target object '{2}'", - propertyProvider, propertyName, targetObject)); - return result; - } - - #endregion - } -} Copied: trunk/MP-II/Presentation/SkinEngine/MpfElements/MpfNamespaceHandler.cs (from rev 19231, trunk/MP-II/Presentation/SkinEngine/Loader/MpfNamespaceHandler.cs) =================================================================== --- trunk/MP-II/Presentation/SkinEngine/MpfElements/MpfNamespaceHandler.cs (rev 0) +++ trunk/MP-II/Presentation/SkinEngine/MpfElements/MpfNamespaceHandler.cs 2008-05-31 16:42:46 UTC (rev 19232) @@ -0,0 +1,118 @@ +#region Copyright (C) 2007-2008 Team MediaPortal + +/* + Copyright (C) 2007-2008 Team MediaPortal + http://www.team-mediaportal.com + + This file is part of MediaPortal II + + MediaPortal II is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + MediaPortal II is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with MediaPortal II. If not, see <http://www.gnu.org/licenses/>. +*/ + +#endregion + +using System; +using System.Collections.Generic; +using System.Reflection; +using Presentation.SkinEngine.XamlParser; +using Presentation.SkinEngine.MpfElements; + +namespace Presentation.SkinEngine.Loader +{ + public class MpfNamespaceHandler: INamespaceHandler + { + #region Protected methods + + internal IDataDescriptor GetAttachedProperty(string propertyProvider, + string propertyName, object targetObject) + { + return new MpfAttachedPropertyDataDescriptor(this, targetObject, propertyProvider, propertyName); + } + + internal static MethodInfo GetAttachedPropertyGetter(string propertyProvider, + string propertyName) + { + Type type = GetElementType(propertyProvider); + return type.GetMethod("Get" + propertyName + "AttachedProperty", + BindingFlags.Public | BindingFlags.Static); + } + + internal static Type GetElementType(string typeName) + { + try + { + return MseElements.ObjectClassRegistrations[typeName]; + } + catch + { + throw new XamlParserException("Element type '{0}' is not present in MpfNamespaceHandler", + typeName); + } + } + + internal static bool HasAttachedProperty(string propertyProvider, + string propertyName, object targetObject) + { + return GetAttachedPropertyGetter(propertyProvider, propertyName) != null; + } + + #endregion + + #region INamespaceHandler implementation + + public object InstantiateElement(IParserContext context, string typeName, string namespaceURI, + IList<object> parameters) + { + try + { + Type t = GetElementType(typeName, namespaceURI); + object[] parameterObjects = new object[parameters.Count]; + parameters.CopyTo(parameterObjects, 0); + return Activator.CreateInstance(t, parameterObjects); + } + catch (Exception e) + { + if (e is XamlParserException) + throw; + throw new XamlParserException("Error creating element type '{0}' in namespace '{1}'", + e, typeName, namespaceURI); + } + } + + public Type GetElementType(string typeName, string namespaceURI) + { + return GetElementType(typeName); + } + + public bool HasAttachedProperty(string propertyProvider, + string propertyName, object targetObject, string namespaceURI) + { + return GetAttachedPropertyGetter(propertyProvider, propertyName) != null; + } + + public IDataDescriptor GetAttachedProperty(string propertyProvider, + string propertyName, object targetObject, string namespaceURI) + { + MpfAttachedPropertyDataDescriptor result; + if (!MpfAttachedPropertyDataDescriptor.CreateAttachedPropertyDataDescriptor( + this, targetObject, propertyProvider, propertyName, out result)) + throw new InvalidOperationException(string.Format( + "Attached property '{0}.{1}' is not available on target object '{2}'", + propertyProvider, propertyName, targetObject)); + return result; + } + + #endregion + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |