protected ServiceModelCodeGenerator(IDirectory directory, CodeGenerationOptions options)
        {
            this.Options = options;
            this.directory = directory;

            directory.Create(true);
        }
        protected ServiceModelCodeGenerator(TextWriter writer, CodeGenerationOptions options)
        {
            this.Options = options;
            this.writer = new TextWriterWrapper(writer);

            if (writer == Console.Out)
            {
                this.writer.NewLine = "\n";
            }
        }
        public static ServiceModelCodeGenerator GetCodeGenerator(string language, object param, CodeGenerationOptions options)
        {
            var types = typeof(ServiceModelCodeGenerator).Assembly.GetTypes();
            var serviceModelCodeGeneratorTypes = types.Where(c => typeof(ServiceModelCodeGenerator).IsAssignableFrom(c));

            var generatorType = serviceModelCodeGeneratorTypes.FirstOrDefault(delegate(Type type)
            {
                if (Regex.Match(type.Name, language + "ServiceModelCodeGenerator$", RegexOptions.IgnoreCase).Success)
                {
                    return true;
                }

                var attribute = type.GetFirstCustomAttribute<ServiceModelCodeGeneratorAttribute>(true);

                return attribute != null && attribute.Aliases.FirstOrDefault(c => c.Equals(language, StringComparison.InvariantCultureIgnoreCase)) != null;
            });

            if (generatorType != null)
            {
                return (ServiceModelCodeGenerator)Activator.CreateInstance(generatorType, param, options);
            }

            return null;
        }
示例#4
0
 public CodeGenerationContext(ServiceModel serviceModel, CodeGenerationOptions options)
 {
     this.Options = options;
     this.ServiceModel = serviceModel;
 }
 public static ServiceModelCodeGenerator GetCodeGenerator(string language, TextWriter writer, CodeGenerationOptions options)
 {
     return GetCodeGenerator(language, (object)writer, options);
 }
 public static ServiceModelCodeGenerator GetCodeGenerator(string language, IFile file, CodeGenerationOptions options)
 {
     return GetCodeGenerator(language, (object)file, options);
 }
 public static ServiceModelCodeGenerator GetCodeGenerator(string language, IDirectory directory, CodeGenerationOptions options)
 {
     return GetCodeGenerator(language, (object)directory, options);
 }
 protected ServiceModelCodeGenerator(IFile file, CodeGenerationOptions options)
     : this(file.GetContent().GetWriter(), options)
 {
 }