Example #1
0
        public static RootConfig CreateFromAssembly(AssemblyCache cache, string assembly, GenerateContractMode mode, bool internalVisibility)
        {
            RootConfig root = new RootConfig(cache)
            {
                Contracts = new List<ProxyConfig>()
            };

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

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

            return root;
        }
Example #2
0
 public RootConfig(AssemblyCache cache)
 {
     Contracts = new List<ProxyConfig>();
     AssemblyCache = cache;
     Generators = new List<GeneratorConfig>();
     Assemblies = new List<string>();
 }
Example #3
0
        public static RootConfig CreateFromConfig(AssemblyCache cache, string outputDirectory, string content)
        {
            var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Include, Formatting = Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver() };

            RootConfig config = JsonConvert.DeserializeObject<RootConfig>(content, settings);
            config.OutputDirectory = outputDirectory;
            config.AssemblyCache = cache;

            foreach (ProxyConfig contract in config.Contracts)
            {
                contract.Parent = config;
            }

            if (config.Generators != null)
            {
                foreach (GeneratorConfig generator in config.Generators)
                {
                    generator.Parent = config;
                }
            }

            return config;
        }
Example #4
0
 public static RootConfig CreateFromConfig(AssemblyCache cache, string file)
 {
     file = Path.GetFullPath(file);
     string content = File.ReadAllText(file);
     return CreateFromConfig(cache, Path.GetDirectoryName(file), content);
 }
Example #5
0
        private static RootConfig CreateSampleConfiguration(AssemblyCache cache)
        {
            RootConfig rootConfig = new RootConfig(cache);
            rootConfig.Modifier = "<public|internal>";
            rootConfig.Assemblies = new List<string> { "<AssemblyPath>", "<AssemblyPath>", "<AssemblyPath>" };
            rootConfig.Generators = new List<GeneratorConfig>
                                        {
                                            new GeneratorConfig
                                                {
                                                    Name = "<GeneratorName>",
                                                    Type = "<FullTypeName>",
                                                    Properties =
                                                        new Dictionary<string, string>
                                                            {
                                                                {
                                                                    "<Name>",
                                                                    "<Value>"
                                                                }
                                                            }
                                                }
                                        };

            rootConfig.Contracts = new List<ProxyConfig>();
            rootConfig.Contracts.Add(
                new ProxyConfig
                    {
                        Contract = "<Type>",
                        Modifier = "<public|internal>",
                        Context = "<Context> // passed to user code generators",
                        Excluded = new List<string> { "<FullTypeName>", "<FullTypeName>" },
                        ForceAsync = true,
                        Generator = "<GeneratorName>",
                        Output = "<Path>",
                        Suffix = "<Suffix> // suffix for generated client proxy, defaults to 'Proxy'",
                        Namespace = "<Namespace> // namespace of generated proxy, defaults to contract namespace if null",
                        Name = "<ProxyName> // name of generated proxy, defaults to 'ContractName + Suffix' if null",
                        ExcludedInterfaces = new List<string> { "<FullTypeName>", "<FullTypeName>" }
                    });

            return rootConfig;
        }
Example #6
0
 public Program(ILibraryManager manager, IAssemblyLoadContextAccessor accessor, IAssemblyLoaderContainer container, IApplicationEnvironment environment)
 {
     _cache = new AssemblyCache(manager, accessor, container, environment);
 }