SerializedElement.cs
42 lines
| 1.2 KiB
| text/x-csharp
|
CSharpLexer
|
|
r273 | using System; | |
| using System.Xml; | |||
| using System.Xml.Serialization; | |||
| namespace Implab.ServiceHost.Unity | |||
| { | |||
|
|
r274 | public class SerializedElement : AbstractRegistration, ISerializedValue { | |
|
|
r273 | [XmlAttribute("href")] | |
| public string Location { get; set; } | |||
| [XmlAttribute("serializedType")] | |||
| public string SerializedType { get; set; } | |||
| [XmlAnyElement] | |||
| public XmlElement[] Content { get; set; } | |||
|
|
r274 | ||
| string ISerializedValue.TypeName { | |||
| get { | |||
| return string.IsNullOrEmpty(SerializedType) ? RegistrationType : SerializedType; | |||
| } | |||
| } | |||
|
|
r275 | public string TypeName => throw new NotImplementedException(); | |
|
|
r274 | public override void Visit(ContainerBuilder context) { | |
|
|
r273 | context.Visit(this); | |
| } | |||
|
|
r274 | public XmlReader GetReader() { | |
| if (!string.IsNullOrEmpty(Location)) | |||
| return XmlReader.Create(Location); | |||
| if (Content != null && Content.Length > 0) | |||
| return Content[0].CreateNavigator().ReadSubtree(); | |||
|
|
r273 | ||
|
|
r274 | throw new Exception("No content found, expected XML document"); | |
|
|
r273 | } | |
|
|
r275 | ||
| public void Visit(InjectionValueBuilder builder) { | |||
| throw new NotImplementedException(); | |||
| } | |||
|
|
r273 | } | |
| } |
