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

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

Returns whether a specific property is registered.
The is null. The is null or whitespace.
public IsPropertyRegistered ( Type type, string name ) : bool
type System.Type The type for which to check whether the property is registered.
name string The name of the property.
Результат bool
        public bool IsPropertyRegistered(Type type, string name)
        {
            Argument.IsNotNull("type", type);
            Argument.IsNotNullOrWhitespace("name", name);

            lock (_propertyDataLock)
            {
                CatelTypeInfo propertyDataOfType;
                if (!_propertyData.TryGetValue(type, out propertyDataOfType))
                {
                    return false;
                }

                return propertyDataOfType.IsPropertyRegistered(name);
            }
        }

Usage Example

Пример #1
0
            /// <summary>
            /// Restores the backup to the object.
            /// </summary>
            public void RestoreBackup()
            {
                Dictionary <string, object> oldPropertyValues = null;

                using (var stream = new MemoryStream(_propertyValuesBackup))
                {
                    try
                    {
                        var serializer = SerializationFactory.GetXmlSerializer();
                        var properties = serializer.DeserializeMembers(_object.GetType(), stream);

                        oldPropertyValues = properties.ToDictionary(property => property.Name, property => property.Value);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Failed to deserialize the data for backup, which is weird. However, for Silverlight, Windows Phone and Windows 8 there is no other option");
                    }
                }

                if (oldPropertyValues == null)
                {
                    return;
                }

                foreach (KeyValuePair <string, object> propertyValue in oldPropertyValues)
                {
                    if (PropertyDataManager.IsPropertyRegistered(_object.GetType(), propertyValue.Key))
                    {
                        // Set value so the PropertyChanged event is invoked
                        _object.SetValue(propertyValue.Key, propertyValue.Value);
                    }
                }

                _object.IsDirty = (bool)_objectValuesBackup[IsDirty];
            }
All Usage Examples Of Catel.Data.PropertyDataManager::IsPropertyRegistered