Catel.Data.PropertyDataManager.GetPropertyData C# (CSharp) Метод

GetPropertyData() публичный Метод

Gets the property data.
The is null. The is null or whitespace. Thrown when the property is not registered.
public GetPropertyData ( Type type, string name ) : PropertyData
type System.Type The type for which to get the property data.
name string The name of the property.
Результат PropertyData
        public PropertyData GetPropertyData(Type type, string name)
        {
            Argument.IsNotNull("type", type);
            Argument.IsNotNullOrWhitespace("name", name);

            lock (_propertyDataLock)
            {
                CatelTypeInfo propertyDataOfType;
                if (!_propertyData.TryGetValue(type, out propertyDataOfType))
                {
                    throw Log.ErrorAndCreateException(msg => new PropertyNotRegisteredException(name, type),
                        "Property '{0}' on type '{1}' is not registered", name, type.FullName);
                }

                return propertyDataOfType.GetPropertyData(name);
            }
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Reads the value from the XML node.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="reader"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="propertyName"/> is <c>null</c> or whitespace.</exception>
        /// <remarks>This method does not check whether the property exists. This is the responsibility of the caller.</remarks>
        private void ReadValueFromXmlNode(XmlReader reader, string propertyName)
        {
            Argument.IsNotNull("reader", reader);
            Argument.IsNotNullOrWhitespace("propertyName", propertyName);

            var propertyData = PropertyDataManager.GetPropertyData(GetType(), propertyName);

            object value = null;

            switch (reader.NodeType)
            {
            case XmlNodeType.Attribute:
                value = GetObjectFromXmlAttribute(reader, propertyData);
                break;

            case XmlNodeType.Element:
                value = GetObjectFromXmlElement(reader, propertyName);
                break;

            default:
                string error = string.Format("Xml node type '{0}' with local name '{1}' is not supported", reader.NodeType, ObjectToStringHelper.ToString(reader.LocalName));
                Log.Error(error);
                throw new NotSupportedException(error);
            }

            if (value != null)
            {
                SetValue(propertyData, value, false, false);
            }
        }
All Usage Examples Of Catel.Data.PropertyDataManager::GetPropertyData