private static CompositionGetValueStatus TryGetValue <T>( T source, Dictionary <T, KeyValuePair <CompositionPropertySet, Dictionary <string, ExpressionAnimation> > > dictionary, string propertyName, CompositionPropertyType type, out object value) { value = null; if (source == null || string.IsNullOrWhiteSpace(propertyName)) { throw new ArgumentException(); } CompositionPropertySet propertySet = null; Dictionary <string, ExpressionAnimation> expressionAnimations = null; ExpressionAnimation expressionAnimation = null; string propertySetPropertyName = null; GetExpressionAnimation <T>( source, propertyName, dictionary, out propertySet, out expressionAnimations, out expressionAnimation, out propertySetPropertyName); if (propertySet != null) { propertySet.StopAnimation(propertySetPropertyName); CompositionGetValueStatus status = CompositionGetValueStatus.TypeMismatch; switch (type) { case CompositionPropertyType.Boolean: bool boolValue; status = propertySet.TryGetBoolean(propertySetPropertyName, out boolValue); value = boolValue; break; case CompositionPropertyType.Float: float floatValue; status = propertySet.TryGetScalar(propertySetPropertyName, out floatValue); value = floatValue; break; case CompositionPropertyType.Vector2: Vector2 vector2Value; status = propertySet.TryGetVector2(propertySetPropertyName, out vector2Value); value = vector2Value; break; case CompositionPropertyType.Vector3: Vector3 vector3Value; status = propertySet.TryGetVector3(propertySetPropertyName, out vector3Value); value = vector3Value; break; // Insert new case for any property type that is being added. } if (expressionAnimation != null) { propertySet.StartAnimation(propertySetPropertyName, expressionAnimation); } return(status); } return(CompositionGetValueStatus.NotFound); }
private static CompositionGetValueStatus TryGetPropertyValue(CompositionObject sourceObject, string propertyName, CompositionPropertyType type, out object value) { return(TryGetValue <CompositionObject>(sourceObject, s_objectsDictionary, propertyName, type, out value)); }