Exemplo n.º 1
0
        internal static void WriteTypeScript(IEnumerable <IntellisenseObject> objects, StringBuilder sb, string file = null)
        {
            bool          extraLineFeed = false;
            StringBuilder references    = new StringBuilder();

            foreach (var ns in objects.GroupBy(o => o.Namespace))
            {
                sb.AppendFormat("declare module {0} {{\r\n", ns.Key);

                foreach (IntellisenseObject io in ns)
                {
                    if (!string.IsNullOrEmpty(io.Summary))
                    {
                        sb.AppendLine("\t/** " + whitespaceTrimmer.Replace(io.Summary, "") + " */");
                    }
                    if (io.IsEnum)
                    {
                        sb.AppendLine("\tenum " + CamelCaseClassName(io.Name) + " {");
                        foreach (var p in io.Properties)
                        {
                            WriteTypeScriptComment(p, sb);
                            if (p.InitExpression != null)
                            {
                                sb.AppendLine("\t\t" + CamelCasePropertyName(p.Name) + " = " + CleanEnumInitValue(p.InitExpression) + ",");
                            }
                            else
                            {
                                sb.AppendLine("\t\t" + CamelCasePropertyName(p.Name) + ",");
                            }
                        }
                        sb.AppendLine("\t}");
                    }
                    else
                    {
                        sb.Append("\tinterface ").Append(CamelCaseClassName(io.Name)).Append(" ");
                        WriteTSInterfaceDefinition(sb, "\t", io.Properties);
                        sb.AppendLine();

                        if (file != null)
                        {
                            foreach (var reference in io.References.SkipWhile(r => r == file))
                            {
                                references.Insert(0, string.Format(CultureInfo.InvariantCulture, "/// <reference path=\"{0}\" />\r\n", FileHelpers.RelativePath(file, reference)));
                            }

                            if (references.Length > 0)
                            {
                                if (!extraLineFeed)
                                {
                                    references.AppendLine();
                                    extraLineFeed = true;
                                }

                                sb.Insert(0, references);
                                references.Clear();
                            }
                        }
                    }
                }

                sb.AppendLine("}");
            }
        }
Exemplo n.º 2
0
 // Overridden to work around SASS bug
 // TODO: Remove when https://github.com/hcatlin/libsass/issues/242 is fixed
 protected async virtual Task <string> ReadMapFile(string sourceMapFileName)
 {
     return(await FileHelpers.ReadAllTextRetry(sourceMapFileName));
 }