Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,65 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.XamlIntegration
{
using System;
using System.Collections.Generic;
using System.ServiceModel.Dispatcher;
using System.Windows.Markup;
[ContentProperty("Namespaces")]
public class XPathMessageContextMarkupExtension : MarkupExtension
{
static List<string> implicitPrefixes;
Dictionary<string, string> namespaces;
static XPathMessageContextMarkupExtension()
{
implicitPrefixes = new List<string>();
foreach (string prefix in XPathMessageContext.defaultNamespaces.Keys)
{
implicitPrefixes.Add(prefix);
}
implicitPrefixes.Add("");
implicitPrefixes.Add("xml");
implicitPrefixes.Add("xmlns");
}
public XPathMessageContextMarkupExtension()
{
this.namespaces = new Dictionary<string, string>();
}
public XPathMessageContextMarkupExtension(XPathMessageContext context)
: this()
{
foreach (string prefix in context)
{
if (!implicitPrefixes.Contains(prefix))
{
this.namespaces.Add(prefix, context.LookupNamespace(prefix));
}
}
}
public Dictionary<string, string> Namespaces
{
get { return this.namespaces; }
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
XPathMessageContext context = new XPathMessageContext();
foreach (KeyValuePair<string, string> ns in this.namespaces)
{
context.AddNamespace(ns.Key, ns.Value);
}
return context;
}
}
}

View File

@@ -0,0 +1,56 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.XamlIntegration
{
using System;
using System.ComponentModel;
using System.Globalization;
using System.ServiceModel.Dispatcher;
using System.Windows.Markup;
public class XPathMessageContextTypeConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (typeof(MarkupExtension) == sourceType)
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (typeof(MarkupExtension) == destinationType)
{
return true;
}
return base.CanConvertTo(context, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is XPathMessageContextMarkupExtension)
{
return ((MarkupExtension)value).ProvideValue(null);
}
return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
XPathMessageContext contextValue = value as XPathMessageContext;
if (contextValue != null && typeof(MarkupExtension) == destinationType)
{
return new XPathMessageContextMarkupExtension(contextValue);
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
}