/// <summary> /// Creates a new state which is based on current state and has given value for given property. /// </summary> /// <typeparam name="PropertyType">Type of value represented by property.</typeparam> /// <param name="property">Property which value will be set.</param> /// <param name="value">Value which will be set to the property.</param> /// <returns>The new dialog state.</returns> private DialogState newStateWithValue <PropertyType>(StateProperty <PropertyType> property, PropertyType value) { var propertyToValueCopy = new Dictionary <object, object>(_propertyToValue); property.SetValue(propertyToValueCopy, value); return(new DialogState(propertyToValueCopy)); }
/// <summary> /// Initialize given property reference with new property of given name. /// </summary> /// <typeparam name="PropertyType">Type of value represented by property.</typeparam> /// <param name="property">Initialized property.</param> /// <param name="propertyName">Name of initialized property.</param> private static void initialize <PropertyType>(ref StateProperty <PropertyType> property, string propertyName) { if (property != null) { throw new NotSupportedException("Cannot initialize same property twice"); } property = new StateProperty <PropertyType>(propertyName); }
/// <summary> /// Gets value that is stored by given property. /// </summary> /// <typeparam name="PropertyType">Type of value represented by property.</typeparam> /// <param name="property">Property which value is requested.</param> /// <returns>Value of the property if available <c>default</c> otherwise.</returns> private PropertyType getValue <PropertyType>(StateProperty <PropertyType> property) { return(property.GetValue(_propertyToValue)); }