internal static string GenerateInspectedReferences(this FilesOperations fileOps, Type element,
                                                           HashSet <Type> alltypes)
        {
            var inspectedTypes = InspectReferences(element, alltypes);
            var references     = new HashSet <string>();
            var types          = ConfigurationRepository.Instance.ReferencesForType(element);

            if (types != null)
            {
                foreach (var attr in types)
                {
                    if (attr.Type != element)
                    {
                        var path = attr.Type != null?fileOps.GetRelativePathForType(attr.Type, element) : attr.RawPath;

                        if (!string.IsNullOrEmpty(path))
                        {
                            references.AddIfNotExists(path);
                        }
                    }
                }
            }
            foreach (var inspectedType in inspectedTypes)
            {
                if (inspectedType != element)
                {
                    var path = fileOps.GetRelativePathForType(inspectedType, element);
                    if (!string.IsNullOrEmpty(path))
                    {
                        references.AddIfNotExists(path);
                    }
                }
            }
            var sb = new StringBuilder();

            foreach (var reference in references)
            {
                if (!string.IsNullOrEmpty(reference))
                {
                    sb.AppendLine(string.Format("/// <reference path=\"{0}\"/>", reference));
                }
            }

            return(sb.ToString().Trim());
        }
Exemple #2
0
 /// <summary>
 ///     Constructs new instance of TypeScript exporter
 /// </summary>
 /// <param name="context"></param>
 public TsExporter(ExportContext context)
 {
     _context = context;
     _fileOps = new FilesOperations(context);
 }
 /// <summary>
 ///     Constructs new instance of TypeScript exporter
 /// </summary>
 /// <param name="settings"></param>
 public TsExporter(ExportSettings settings)
 {
     _settings = settings;
     _fileOps  = new FilesOperations(settings);
 }