Browse Source

Bugfix: Whitespace fixes

pull/584/head
jkuehner 11 years ago
parent
commit
e2b5f6fa26
  1. 98
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs
  2. 86
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

98
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

@ -280,7 +280,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -280,7 +280,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
continue;
}
ParseObjectAttribute(obj, attribute);
}
@ -328,52 +328,52 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -328,52 +328,52 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
if (collectionType != null && collectionInstance == null && elementChildNodes.Count() == 1)
{
var firstChild = elementChildNodes.First() as XmlElement;
if (ObjectChildElementIsCollectionInstance(firstChild, collectionType))
{
collectionInstance = ParseObject(firstChild);
collectionProperty.PropertyValue = (XamlPropertyValue) collectionInstance;
}
else
{
throw new XamlLoadException("Collection Instance is null");
}
}
if (collectionType != null && collectionInstance == null && elementChildNodes.Count() == 1)
{
var firstChild = elementChildNodes.First() as XmlElement;
if (ObjectChildElementIsCollectionInstance(firstChild, collectionType))
{
collectionInstance = ParseObject(firstChild);
collectionProperty.PropertyValue = (XamlPropertyValue) collectionInstance;
}
else
{
throw new XamlLoadException("Collection Instance is null");
}
}
else
{
foreach (XmlNode childNode in elementChildNodes) {
XmlElement childElement = childNode as XmlElement;
if (childElement != null) {
if (childElement.NamespaceURI == XamlConstants.XamlNamespace)
continue;
if (ObjectChildElementIsPropertyElement(childElement)) {
ParseObjectChildElementAsPropertyElement(obj, childElement, defaultProperty);
continue;
}
}
if (initializeFromTextValueInsteadOfConstructor != null)
continue;
XamlPropertyValue childValue = ParseValue(childNode);
if (childValue != null) {
if (collectionProperty != null) {
collectionProperty.ParserAddCollectionElement(collectionPropertyElement, childValue);
CollectionSupport.AddToCollection(collectionType, collectionInstance, childValue);
} else {
if (defaultProperty == null)
throw new XamlLoadException("This element does not have a default value, cannot assign to it");
if (isDefaultValueSet)
throw new XamlLoadException("default property may have only one value assigned");
{
foreach (XmlNode childNode in elementChildNodes) {
XmlElement childElement = childNode as XmlElement;
if (childElement != null) {
if (childElement.NamespaceURI == XamlConstants.XamlNamespace)
continue;
obj.AddProperty(new XamlProperty(obj, defaultProperty, childValue));
isDefaultValueSet = true;
}
}
}
}
if (ObjectChildElementIsPropertyElement(childElement)) {
ParseObjectChildElementAsPropertyElement(obj, childElement, defaultProperty);
continue;
}
}
if (initializeFromTextValueInsteadOfConstructor != null)
continue;
XamlPropertyValue childValue = ParseValue(childNode);
if (childValue != null) {
if (collectionProperty != null) {
collectionProperty.ParserAddCollectionElement(collectionPropertyElement, childValue);
CollectionSupport.AddToCollection(collectionType, collectionInstance, childValue);
} else {
if (defaultProperty == null)
throw new XamlLoadException("This element does not have a default value, cannot assign to it");
if (isDefaultValueSet)
throw new XamlLoadException("default property may have only one value assigned");
obj.AddProperty(new XamlProperty(obj, defaultProperty, childValue));
isDefaultValueSet = true;
}
}
}
}
}
IEnumerable<XmlNode> GetNormalizedChildNodes(XmlElement element)
@ -599,10 +599,10 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -599,10 +599,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
return element.LocalName.Contains(".");
}
static bool ObjectChildElementIsCollectionInstance(XmlElement element, Type collectionType)
{
return element.Name == collectionType.Name;
}
static bool ObjectChildElementIsCollectionInstance(XmlElement element, Type collectionType)
{
return element.Name == collectionType.Name;
}
static bool IsElementChildACollectionForProperty(XamlTypeFinder typeFinder, XmlElement element, XamlPropertyInfo propertyInfo)
{

86
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

@ -26,10 +26,10 @@ using System.Windows; @@ -26,10 +26,10 @@ using System.Windows;
namespace ICSharpCode.WpfDesign.XamlDom
{
/// <summary>
/// Describes a property on a <see cref="XamlObject"/>.
/// </summary>
[DebuggerDisplay("XamlProperty: {PropertyName}")]
/// <summary>
/// Describes a property on a <see cref="XamlObject"/>.
/// </summary>
[DebuggerDisplay("XamlProperty: {PropertyName}")]
public sealed class XamlProperty
{
XamlObject parentObject;
@ -137,7 +137,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -137,7 +137,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
/// <summary>
/// Gets if the property represents the FrameworkElement.Resources property that holds a locally-defined resource dictionary.
/// Gets if the property represents the FrameworkElement.Resources property that holds a locally-defined resource dictionary.
/// </summary>
public bool IsResources {
get { return isResources; }
@ -262,7 +262,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -262,7 +262,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
propertyValue = null;
}
if (_propertyElement != null) {
Debug.Assert(!isExplicitCollection || _propertyElement.ParentNode == null);
Debug.Assert(!isExplicitCollection || _propertyElement.ParentNode == null);
if (!isExplicitCollection) {
_propertyElement.ParentNode.RemoveChild(_propertyElement);
@ -315,44 +315,44 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -315,44 +315,44 @@ namespace ICSharpCode.WpfDesign.XamlDom
static XmlNode FindChildNode(XmlNode node, Type elementType, string propertyName, XamlDocument xamlDocument)
{
var localName = elementType.Name + "." + propertyName;
var namespaceURI = xamlDocument.GetNamespaceFor(elementType);
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == localName && childNode.NamespaceURI == namespaceURI)
{
return childNode;
}
}
var type = elementType.BaseType;
namespaceURI = xamlDocument.GetNamespaceFor(type);
while (type != typeof(object))
{
if (type.GetProperty(propertyName) == null)
break;
localName = type.Name + "." + propertyName;
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == localName && childNode.NamespaceURI == namespaceURI)
{
return childNode;
}
}
type = type.BaseType;
}
var localName = elementType.Name + "." + propertyName;
var namespaceURI = xamlDocument.GetNamespaceFor(elementType);
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == localName && childNode.NamespaceURI == namespaceURI)
{
return childNode;
}
}
var type = elementType.BaseType;
namespaceURI = xamlDocument.GetNamespaceFor(type);
while (type != typeof(object))
{
if (type.GetProperty(propertyName) == null)
break;
localName = type.Name + "." + propertyName;
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == localName && childNode.NamespaceURI == namespaceURI)
{
return childNode;
}
}
type = type.BaseType;
}
return null;
}
bool IsNodeCollectionForThisProperty(XmlNode node)
{
//Remove the commented check! This is Possible: BeginStoryboard=>The COntent Property is Storyboard, and the Content Element is also Storyboard!
//Remove the commented check! This is Possible: BeginStoryboard=>The COntent Property is Storyboard, and the Content Element is also Storyboard!
return _propertyElement == null /* && this.PropertyName != this.ParentObject.ContentPropertyName */ && this.ReturnType.IsAssignableFrom(this.ParentObject.OwnerDocument.TypeFinder.GetType(node.NamespaceURI, node.LocalName));
}
@ -410,7 +410,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -410,7 +410,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (collection == null) {
if (collectionElements.Count == 0 && this.PropertyName != this.ParentObject.ContentPropertyName) {
// we have to create the collection element
_propertyElement = CreatePropertyElement();
_propertyElement = CreatePropertyElement();
if (this.IsResources) {
parentObject.XmlElement.PrependChild(_propertyElement);
@ -449,11 +449,11 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -449,11 +449,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
name = PropertyTargetType.Name + "." + PropertyName;
string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType);
string prefix = element.GetPrefixOfNamespace(ns);
string prefix = element.GetPrefixOfNamespace(ns);
if (String.IsNullOrEmpty(prefix)) {
prefix = ParentObject.OwnerDocument.GetPrefixForNamespace(ns);
}
prefix = ParentObject.OwnerDocument.GetPrefixForNamespace(ns);
}
if (!string.IsNullOrEmpty(prefix)) {
element.SetAttribute(name, ns, value);

Loading…
Cancel
Save