Beispiel #1
0
        public override void Write(SerializationContext serializationContext, ModelElement element, XmlWriter writer,
                                   RootElementSettings rootElementSettings)
        {
            #region Check Parameters

            Debug.Assert(element != null);
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            #endregion

            // On ne serialise que si ce n'est pas la valeur par défaut
            DependencyProperty  instanceOfDependencyProperty = element as DependencyProperty;
            IDependencyProperty dp =
                DependencyPropertyRegistry.Instance.FindDependencyProperty(instanceOfDependencyProperty.StrategyId,
                                                                           instanceOfDependencyProperty.Name);

            object defaultValue = dp != null?dp.GetDefaultValue() : null;

            string defaultValueAsString = defaultValue != null?defaultValue.ToString() : String.Empty;

            if (instanceOfDependencyProperty.Value != null && dp != null &&
                !Utils.StringCompareEquals(instanceOfDependencyProperty.Value.ToString(), defaultValueAsString))
            {
                base.Write(serializationContext, element, writer, rootElementSettings);
            }
        }