Exemple #1
0
        private void CreateMethodFiles()
        {
            foreach (var nameSpace in _repository.GetAllNamespaces())
            {
                foreach (var type in nameSpace.Types)
                {
                    var sdType = _repository.GetTypeByIdentifier(type.Identifier);

                    var constructorsIndexHtmlFile = Path.Combine(_tmpFilepath, sdType.Guid + "-Constructors.html");
                    var constructorsTemplate = new ConstructorsTemplate { ProjectInfo = _repository.ProjectInfo, SDNamespace = nameSpace, SDType = sdType, CurrentLanguage = _currentLanguage, Strings = _strings };
                    File.WriteAllText(constructorsIndexHtmlFile, constructorsTemplate.TransformText());

                    var methodsIndexHtmlFile = Path.Combine(_tmpFilepath, sdType.Guid + "-Methods.html");
                    var methodsTemplate = new MethodsTemplate { ProjectInfo = _repository.ProjectInfo, SDNamespace = nameSpace, SDType = sdType, CurrentLanguage = _currentLanguage, Strings = _strings };
                    File.WriteAllText(methodsIndexHtmlFile, methodsTemplate.TransformText());

                    foreach (var method in sdType.Methods)
                    {
                        var methodHtmlFile = Path.Combine(_tmpFilepath, method.Guid + ".html");
                        var template = new MethodTemplate { ProjectInfo = _repository.ProjectInfo, SDNamespace = nameSpace, SDMethod = method, SDType = sdType, CurrentLanguage = _currentLanguage, Strings = _strings };

                        if (!method.IsSequenceDiagramEmpty())
                        {
                            method.GetSequenceDiagram(_repository.GetAllTypes()).ToPng(Path.Combine(_tmpFilepath, "diagrams", method.Guid + ".png"));
                        }

                        File.WriteAllText(methodHtmlFile, template.TransformText());
                    }

                    foreach (var constructor in sdType.Constructors)
                    {
                        var constructorHtmlFile = Path.Combine(_tmpFilepath, constructor.Guid + ".html");
                        var template = new MethodTemplate { ProjectInfo = _repository.ProjectInfo, SDNamespace = nameSpace, SDMethod = constructor, SDType = sdType, CurrentLanguage = _currentLanguage, Strings = _strings };

                        if (!constructor.IsSequenceDiagramEmpty())
                        {
                            constructor.GetSequenceDiagram(_repository.GetAllTypes()).ToPng(Path.Combine(_tmpFilepath, "diagrams", constructor.Guid + ".png"));
                        }

                        File.WriteAllText(constructorHtmlFile, template.TransformText());
                    }
                }
            }
        }
        private void CreateApiIndexFiles()
        {
            foreach(var solution in StepInput.SDProject.Solutions.Values)
            {
                var sdRepository = solution.Repositories.SingleOrDefault(r => r.TargetFx.Identifier == StepInput.CurrentTargetFx.Identifier);
                if(sdRepository != null)
                {
                    foreach (var sdNamespace in sdRepository.GetAllNamespaces())
                    {
                        ExecuteOnStepMessage(string.Format("{0}: {1}", StepInput.ChmStrings.CreateIndexFilesFor, sdNamespace.Fullname));

                        var namespaceHtmlFile = Path.Combine(StepInput.TmpPath, sdNamespace.Guid + ".html");
                        var template = new NamespaceTemplate { SDNamespace = sdNamespace };
                        File.WriteAllText(namespaceHtmlFile, template.TransformText());

                        foreach (var sdType in sdNamespace.Types)
                        {
                            var fieldsIndexHtmlFile = Path.Combine(StepInput.TmpPath, sdType.Guid + "-Fields.html");
                            var fieldsTemplate = new FieldsTemplate { SDType = sdType };
                            File.WriteAllText(fieldsIndexHtmlFile, fieldsTemplate.TransformText());

                            var eveIndexHtmlFile = Path.Combine(StepInput.TmpPath, sdType.Guid + "-Events.html");
                            var eventsTemplate = new EventsTemplate { SDType = sdType };
                            File.WriteAllText(eveIndexHtmlFile, eventsTemplate.TransformText());

                            var propertiesIndexHtmlFile = Path.Combine(StepInput.TmpPath, sdType.Guid + "-Properties.html");
                            var propertiesTemplate = new PropertiesTemplate { SDType = sdType };
                            File.WriteAllText(propertiesIndexHtmlFile, propertiesTemplate.TransformText());

                            var constructorsIndexHtmlFile = Path.Combine(StepInput.TmpPath, sdType.Guid + "-Constructors.html");
                            var constructorsTemplate = new ConstructorsTemplate { SDType = sdType };
                            File.WriteAllText(constructorsIndexHtmlFile, constructorsTemplate.TransformText());

                            var methodsIndexHtmlFile = Path.Combine(StepInput.TmpPath, sdType.Guid + "-Methods.html");
                            var methodsTemplate = new MethodsTemplate { SDType = sdType };
                            File.WriteAllText(methodsIndexHtmlFile, methodsTemplate.TransformText());
                        }
                    }
                }
            }
        }