예제 #1
0
 public static string ConvertToTypeScript(ProjectItem sourceItem)
 {
     try
     {
         Options.ReadOptionOverrides(sourceItem);
         VSHelpers.WriteOnOutputWindow(string.Format("{0} - Started", sourceItem.Name));
         var list = IntellisenseParser.ProcessFile(sourceItem);
         // path is needed for relative paths of imports
         var sourceItemPath = sourceItem.Properties.Item("FullPath").Value as string;
         VSHelpers.WriteOnOutputWindow(string.Format("{0} - Completed", sourceItem.Name));
         return(IntellisenseWriter.WriteTypeScript(list.ToList(), sourceItemPath));
     }
     catch (Exception ex)
     {
         VSHelpers.WriteOnOutputWindow(string.Format("{0} - Failure", sourceItem.Name));
         if (ex is ExceptionForUser)
         {
             // "expected" exception, show to user instead of reporting
             VSHelpers.WriteOnOutputWindow(ex.Message);
         }
         else
         {
             Telemetry.TrackException("ParseFailure", ex);
         }
         return(null);
     }
 }
        public static string ConvertToTypeScriptEnumsOnly(ProjectItem sourceItem, ref DefinitionMapData definitionMapData, out bool isEmpty)
        {
            try
            {
                // Initialize the definition data if there was no specified
                if (definitionMapData == null)
                {
                    definitionMapData = new DefinitionMapData();
                }

                Options.ReadOptionOverrides(sourceItem);
                VSHelpers.WriteOnOutputWindow(string.Format("{0} - Started (enums only)", sourceItem.Name));
                var list = IntellisenseParser.ProcessFile(sourceItem, definitionMapData);
                VSHelpers.WriteOnOutputWindow(string.Format("{0} - Completed", sourceItem.Name));
                return(IntellisenseWriter.WriteTypeScriptEnumsOnly(list, sourceItem, out isEmpty));
            }
            catch (Exception ex)
            {
                isEmpty = true;

                VSHelpers.WriteOnOutputWindow(string.Format("{0} - Failure", sourceItem.Name));
                Telemetry.TrackException("ParseFailure", ex);
                return(null);
            }
        }
 public static string ConvertToTypeScript(ProjectItem sourceItem)
 {
     try
     {
         var list = IntellisenseParser.ProcessFile(sourceItem);
         return(IntellisenseWriter.WriteTypeScript(list));
     }
     catch (Exception ex)
     {
         Telemetry.TrackException("ParseFailure", ex);
         return(null);
     }
 }
 public static string ConvertToTypeScript(ProjectItem sourceItem)
 {
     try
     {
         Options.ReadOptionOverrides(sourceItem);
         VSHelpers.WriteOnOutputWindow(string.Format("{0} - Started", sourceItem.Name));
         var list = IntellisenseParser.ProcessFile(sourceItem);
         VSHelpers.WriteOnOutputWindow(string.Format("{0} - Completed", sourceItem.Name));
         return(IntellisenseWriter.WriteTypeScript(list));
     }
     catch (Exception ex)
     {
         VSHelpers.WriteOnOutputWindow(string.Format("{0} - Failure", sourceItem.Name));
         Telemetry.TrackException("ParseFailure", ex);
         return(null);
     }
 }