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
Пример #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];
            }
Пример #2
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 properties = new List <MemberValue>();

                        if (_serializer != null)
                        {
                            properties = _serializer.DeserializeMembers(_object.GetType(), stream, null);
                        }

                        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");
                    }
                }

                if (oldPropertyValues == null)
                {
                    return;
                }

                foreach (var 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[nameof(ModelBase.IsDirty)];
            }
Пример #3
0
 /// <summary>
 /// Returns whether a specific property is registered.
 /// </summary>
 /// <param name="type">The type of the object for which to check.</param>
 /// <param name="name">Name of the property.</param>
 /// <returns>
 /// True if the property is registered, otherwise false.
 /// </returns>
 protected static bool IsPropertyRegistered(Type type, string name)
 {
     return(PropertyDataManager.IsPropertyRegistered(type, name));
 }