Beispiel #1
0
        private static void GenerateConfigTypes()
        {
            var types = new List<ResourceType>();
            var typesBySchema = new Dictionary<string, IEnumerable<ResourceType>>();

            //create structureMap type
            var structureMapTypeConstraints = new List<IResourceTypeConstraint>();
            structureMapTypeConstraints.Add(new XmlConfigTypeConstraint("StructureMap"));
            var structureMapConfigType = new ResourceType(typeof(StructureMapConfigurationComponent), structureMapTypeConstraints);

            //create dotnet type
            var netConfigTypeConstraints = new List<IResourceTypeConstraint>();
            netConfigTypeConstraints.Add(new XmlConfigTypeConstraint("configuration"));

            var constraint = ("[filename]".AsHasSiblingConstraint().Or(
                              "(.*)/web.config$".AsUriRegexConstraint())).And("^((?!vshost).)*$".AsUriRegexConstraint());

            netConfigTypeConstraints.Add(constraint);
            var netConfigConfigType = new ResourceType(typeof(DotNetConfigurationComponent), netConfigTypeConstraints);

            //add types
            AddTypeToLists(types, typesBySchema, structureMapConfigType);
            AddTypeToLists(types, typesBySchema, netConfigConfigType);

            _resourceTypes = types;
            _resourceTypesBySchema = typesBySchema;
        }
Beispiel #2
0
        private static void AddTypeToLists(List<ResourceType> types, Dictionary<string, IEnumerable<ResourceType>> typesBySchema, ResourceType structureMapConfigType)
        {
            types.Add(structureMapConfigType);

            IEnumerable<ResourceType> typesForSchema = null;
            if (!typesBySchema.TryGetValue(structureMapConfigType.UriSchema, out typesForSchema))
                typesBySchema[structureMapConfigType.UriSchema] = new List<ResourceType>();

            (typesBySchema[structureMapConfigType.UriSchema] as List<ResourceType>).Add(structureMapConfigType);
        }
Beispiel #3
0
 public static bool IsOfType(this ResourceId id, ResourceType type)
 {
     return type.IsOfType(id);
 }