Browse Source

A few fixes for better Parsing

pull/604/head
jogibear9988 12 years ago
parent
commit
d87cf6a2ca
  1. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs
  2. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignInstanceExtension.cs
  3. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs
  4. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
  5. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs

@ -82,9 +82,24 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -82,9 +82,24 @@ namespace ICSharpCode.WpfDesign.AddIn
var assembly = this.typeResolutionService.LoadAssembly(compilation.MainAssembly);
var prj = SD.ProjectService.CurrentProject;
var newUri = new Uri(("file://" + Path.Combine(prj.Directory, uri.OriginalString)).Replace("\\","/"), UriKind.RelativeOrAbsolute);
if (uri.OriginalString.Contains(";"))
{
var parts = uri.OriginalString.Split(';');
if (prj.Name == parts[0].Substring(1))
{
var newUri = new Uri(("file://" + Path.Combine(prj.Directory, parts[1].Substring("component".Length + 1))).Replace("\\", "/"), UriKind.RelativeOrAbsolute);
return newUri;
}
}
else
{
var strg = uri.OriginalString;
if (strg.StartsWith("/"))
strg = strg.Substring(1);
var newUri = new Uri(("file://" + Path.Combine(prj.Directory, strg)).Replace("\\", "/"), UriKind.RelativeOrAbsolute);
return newUri;
}
}
return uri;
}

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignInstanceExtension.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.XamlDom
{
public class DesignInstanceExtension : MarkupExtension
{
public DesignInstanceExtension(Type type)
{
this.Type = type;
}
public Type Type { get; set; }
public bool IsDesignTimeCreatable { get; set; }
public bool CreateList { get; set; }
public override object ProvideValue(IServiceProvider serviceProvider)
{
return null;
}
}
}

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs

@ -35,8 +35,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -35,8 +35,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement, XamlObject parentObject)
{
try
{
var nav = xmlElement.CreateNavigator();
var ns = new Dictionary<string, string>();
@ -52,6 +51,11 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -52,6 +51,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
break;
}
foreach (var dictentry in ns)
{
xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value);
}
var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace);
if (string.IsNullOrEmpty(keyAttrib))
@ -115,11 +119,6 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -115,11 +119,6 @@ namespace ICSharpCode.WpfDesign.XamlDom
result.Remove(rdKey);
return template;
}
catch (Exception)
{ }
return null;
}
private static Stream GenerateStreamFromString(string s)

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj

@ -69,6 +69,7 @@ @@ -69,6 +69,7 @@
<Compile Include="AssemblyInfo.cs" />
<Compile Include="CollectionElementsCollection.cs" />
<Compile Include="CollectionSupport.cs" />
<Compile Include="DesignInstanceExtension.cs" />
<Compile Include="DesignTimeProperties.cs" />
<Compile Include="IXamlErrorSink.cs" />
<Compile Include="MarkupCompatibilityProperties.cs" />

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

@ -28,6 +28,7 @@ using System.Windows; @@ -28,6 +28,7 @@ using System.Windows;
using System.Windows.Interop;
using System.Windows.Markup;
using System.Xml;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.XamlDom
{
@ -743,6 +744,13 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -743,6 +744,13 @@ namespace ICSharpCode.WpfDesign.XamlDom
internal static object CreateObjectFromAttributeText(string valueText, XamlPropertyInfo targetProperty, XamlObject scope)
{
if (targetProperty.ReturnType == typeof(Uri)) {
return scope.OwnerDocument.TypeFinder.ConvertUriToLocalUri(new Uri(valueText, UriKind.RelativeOrAbsolute));
} else if (targetProperty.ReturnType == typeof(ImageSource)) {
var uri = scope.OwnerDocument.TypeFinder.ConvertUriToLocalUri(new Uri(valueText, UriKind.RelativeOrAbsolute));
return targetProperty.TypeConverter.ConvertFromString(scope.OwnerDocument.GetTypeDescriptorContext(scope), CultureInfo.InvariantCulture, uri.ToString());
}
return targetProperty.TypeConverter.ConvertFromString(
scope.OwnerDocument.GetTypeDescriptorContext(scope),
CultureInfo.InvariantCulture, valueText);

Loading…
Cancel
Save