##// END OF EJS Templates
Working on Unity container xml configuration
Working on Unity container xml configuration

File last commit:

r270:ade80d94dfb5 v3
r270:ade80d94dfb5 v3
Show More
ConfigurationContext.cs
63 lines | 1.7 KiB | text/x-csharp | CSharpLexer
cin
Implemented typereference parser
r268 using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Implab.Diagnostics;
namespace Implab.ServiceHost.Unity {
using System.Linq;
cin
Working on Unity container xml configuration
r269 using System.Reflection;
cin
Implemented typereference parser
r268 using System.Text;
cin
Working on Unity container xml configuration
r269 using global::Unity;
cin
Working on Unity container xml configuration
r270 using Implab.Xml;
cin
Implemented typereference parser
r268 using static Trace<ConfigurationContext>;
public class ConfigurationContext {
cin
Working on Unity container xml configuration
r270 readonly TypeResolver m_resolver;
cin
Implemented typereference parser
r268
cin
Working on Unity container xml configuration
r269 readonly UnityContainer m_container;
cin
Working on Unity container xml configuration
r270
cin
Working on Unity container xml configuration
r269 public ConfigurationContext(UnityContainer container) {
m_container = container ?? new UnityContainer();
cin
Working on Unity container xml configuration
r270 m_resolver = new TypeResolver();
cin
Implemented typereference parser
r268 }
cin
Working on Unity container xml configuration
r270 public Type Resolve(string typeReference) {
return m_resolver.Resolve(TypeReference.Parse(typeReference));
cin
Implemented typereference parser
r268 }
cin
Working on Unity container xml configuration
r270 internal void Visit(AbstractRegistration descriptor) {
cin
Working on Unity container xml configuration
r269
}
cin
Working on Unity container xml configuration
r270 internal void Visit(NamespaceElement namespaceElement) {
m_resolver.AddNamespace(namespaceElement.Name);
}
internal void Visit(AssemblyElement assemblyElement) {
Assembly.Load(assemblyElement.AssemblyName);
}
internal void Visit(IncludeElement includeElement) {
Include(includeElement.Href);
}
cin
Working on Unity container xml configuration
r269 public void Include(string file) {
cin
Working on Unity container xml configuration
r270 var includeContext = new ConfigurationContext(m_container);
includeContext.LoadConfig(file);
}
cin
Implemented typereference parser
r268
cin
Working on Unity container xml configuration
r270 public void LoadConfig(string file) {
var config = SerializationHelpers.DeserializeFromFile<ContainerElement>(file);
Visit(config);
}
public void Visit(ContainerElement containerElement) {
foreach (var item in containerElement.Items)
item.Visit(this);
cin
Implemented typereference parser
r268 }
}
}