예제 #1
0
        public override IGeneratorCommandResult Run()
        {
            IDependencyResolver attributeResolver = this.resolver.CloneForCommands();
            Options             options           = attributeResolver.Get <Options>();
            IOptions            attributeOptions  = options.Current;

            attributeOptions.Language = this.Parameters.Language?.Name?.Equals(nameof(OutputLanguage.Csharp), StringComparison.CurrentCultureIgnoreCase) ?? false
                                            ? this.resolver.Get <CsharpLanguage>()
                                            : this.resolver.Get <TypeScriptLanguage>();

            if (attributeOptions.Language.IsTypeScript())
            {
                attributeOptions.SkipNamespace      = true;
                attributeOptions.PropertiesToFields = true;
            }
            attributeOptions.SetFromParameter(this.Parameters);

            ReflectionReadConfiguration readConfiguration = new();

            readConfiguration.Name         = this.Parameters.Name;
            readConfiguration.Namespace    = this.Parameters.Namespace;
            readConfiguration.Assembly     = this.Parameters.Assembly;
            readConfiguration.OnlySubTypes = this.Parameters.OnlySubTypes;

            attributeResolver.Create <ReflectionReader>().Read(readConfiguration, attributeOptions);
            attributeResolver.Get <IOutput>().DeleteAllRelatedFiles(this.Parameters.RelativePath);
            ReflectionWriter writer = attributeResolver.Create <ReflectionWriter>();

            writer.FormatNames();
            writer.Write(this.Parameters.RelativePath);

            this.resolver.Get <IEnvironment>().TransferObjects.AddIfNotExists(attributeResolver.Get <List <ITransferObject> >());

            return(this.Success());
        }
예제 #2
0
        public override IGeneratorCommandResult Run()
        {
            IOptions options = this.resolver.Get <Options>().Current;

            options.SetFromParameter(this.Parameters);
            options.Language = this.resolver.Get <CsharpLanguage>();
            ReflectionWriter writer = this.resolver.Create <ReflectionWriter>();

            writer.FormatNames();
            this.resolver.Get <IOutput>().DeleteAllRelatedFiles(this.Parameters.RelativePath);
            writer.Write(this.Parameters.RelativePath);

            return(this.Success());
        }