예제 #1
0
        public static RootConfiguration CreateFromAssembly(AssemblyCache cache, string assembly, bool internalVisibility)
        {
            RootConfiguration root = new RootConfiguration(cache)
            {
                Contracts = new List <InterfaceConfiguration>()
            };

            Assembly loadedAssembly = null;

            if (!string.IsNullOrEmpty(assembly) && File.Exists(assembly))
            {
                root.Assemblies = new List <string> {
                    Path.GetFullPath(assembly)
                };
                loadedAssembly = cache.Loader.Load(assembly);
            }

            if (loadedAssembly != null)
            {
                foreach (var type in root.AssemblyCache.GetTypes(loadedAssembly))
                {
                    root.AddContract(type.GetTypeInfo(), internalVisibility);
                }
            }

            return(root);
        }
예제 #2
0
        public static RootConfiguration CreateFromConfig(AssemblyCache cache, string outputDirectory, string content)
        {
            var settings = new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Include, Formatting = Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            RootConfiguration configuration = JsonConvert.DeserializeObject <RootConfiguration>(content, settings);

            configuration.OutputDirectory = outputDirectory;
            configuration.AssemblyCache   = cache;

            foreach (InterfaceConfiguration contract in configuration.Contracts)
            {
                contract.Parent = configuration;
            }

            return(configuration);
        }