本文整理汇总了C#中Bind.BindStreamWriter.Write方法的典型用法代码示例。如果您正苦于以下问题:C# BindStreamWriter.Write方法的具体用法?C# BindStreamWriter.Write怎么用?C# BindStreamWriter.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bind.BindStreamWriter
的用法示例。
在下文中一共展示了BindStreamWriter.Write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteConstants
void WriteConstants(BindStreamWriter sw, IEnumerable<Constant> constants)
{
// Make sure everything is sorted. This will avoid random changes between
// consecutive runs of the program.
constants = constants.OrderBy(c => c);
foreach (var c in constants)
{
if (!Settings.IsEnabled(Settings.Legacy.NoDocumentation))
{
sw.WriteLine("/// <summary>");
sw.WriteLine("/// Original was " + Settings.ConstantPrefix + c.OriginalName + " = " + c.Value);
sw.WriteLine("/// </summary>");
}
var str = String.Format("{0} = {1}((int){2}{3})", c.Name, c.Unchecked ? "unchecked" : "",
!String.IsNullOrEmpty(c.Reference) ? c.Reference + Settings.NamespaceSeparator : "", c.Value);
sw.Write(str);
if (!String.IsNullOrEmpty(str))
sw.WriteLine(",");
}
}
示例2: WriteDocumentation
void WriteDocumentation(BindStreamWriter sw, Function f)
{
var docs = f.Documentation;
try
{
string warning = String.Empty;
string category = String.Empty;
if (f.Deprecated)
{
warning = String.Format("[deprecated: v{0}]", f.DeprecatedVersion);
}
if (f.Extension != "Core" && !String.IsNullOrEmpty(f.Category))
{
category = String.Format("[requires: {0}]", f.Category);
}
else if (!String.IsNullOrEmpty(f.Version))
{
if (f.Category.StartsWith("VERSION"))
category = String.Format("[requires: {0}]", "v" + f.Version);
else
category = String.Format("[requires: {0}]", "v" + f.Version + " or " + f.Category);
}
// Write function summary
sw.Write("/// <summary>");
if (!String.IsNullOrEmpty(category) || !String.IsNullOrEmpty(warning))
{
sw.Write(WriteOptions.NoIndent, "{0}{1}", category, warning);
}
if (!String.IsNullOrEmpty(docs.Summary))
{
sw.WriteLine();
sw.WriteLine("/// {0}", docs.Summary);
sw.WriteLine("/// </summary>");
}
else
{
sw.WriteLine(WriteOptions.NoIndent, "</summary>");
}
// Write function parameters
for (int i = 0; i < f.Parameters.Count; i++)
{
var param = f.Parameters[i];
string length = String.Empty;
if (!String.IsNullOrEmpty(param.ComputeSize))
{
length = String.Format("[length: {0}]", param.ComputeSize);
}
// Try to match the correct parameter from documentation:
// - first by name
// - then by index
var docparam =
(docs.Parameters
.Where(p => p.Name == param.RawName)
.FirstOrDefault()) ??
(docs.Parameters.Count > i ?
docs.Parameters[i] : null);
if (docparam != null)
{
if (docparam.Name != param.RawName &&
docparam.Name != param.RawName.Substring(1)) // '@ref' -> 'ref' etc
{
Console.Error.WriteLine(
"[Warning] Parameter '{0}' in function '{1}' has incorrect doc name '{2}'",
param.RawName, f.Name, docparam.Name);
}
// Note: we use param.Name, because the documentation sometimes
// uses different names than the specification.
sw.Write("/// <param name=\"{0}\">", param.Name);
if (!String.IsNullOrEmpty(length))
{
sw.Write(WriteOptions.NoIndent, "{0}", length);
}
if (!String.IsNullOrEmpty(docparam.Documentation))
{
sw.WriteLine(WriteOptions.NoIndent, " ");
sw.WriteLine("/// {0}", docparam.Documentation);
sw.WriteLine("/// </param>");
}
else
{
sw.WriteLine(WriteOptions.NoIndent, "</param>");
}
}
else
{
Console.Error.WriteLine(
"[Warning] Parameter '{0}' in function '{1}' not found in documentation '{{{2}}}'",
param.Name, f.Name,
String.Join(",", docs.Parameters.Select(p => p.Name).ToArray()));
sw.WriteLine("/// <param name=\"{0}\">{1}</param>",
param.Name, length);
}
//.........这里部分代码省略.........
示例3: WriteDocumentation
void WriteDocumentation(BindStreamWriter sw, Function f)
{
var docs = f.Documentation;
try
{
string warning = "[deprecated: v{0}]";
string category = "[requires: {0}]";
if (f.Deprecated)
{
warning = String.Format(warning, f.DeprecatedVersion);
docs.Summary = docs.Summary.Insert(0, warning);
}
if (f.Extension != "Core" && !String.IsNullOrEmpty(f.Category))
{
category = String.Format(category, f.Category);
docs.Summary = docs.Summary.Insert(0, category);
}
else if (!String.IsNullOrEmpty(f.Version))
{
if (f.Category.StartsWith("VERSION"))
category = String.Format(category, "v" + f.Version);
else
category = String.Format(category, "v" + f.Version + " and " + f.Category);
docs.Summary = docs.Summary.Insert(0, category);
}
for (int i = 0; i < f.WrappedDelegate.Parameters.Count; i++)
{
var param = f.WrappedDelegate.Parameters[i];
if (param.ComputeSize != String.Empty)
{
docs.Parameters[i].Documentation.Insert(0,
String.Format("[length: {0}]", param.ComputeSize));
}
}
sw.Write("/// \brief ");
sw.WriteLine(docs.Summary);
foreach (var p in docs.Parameters)
{
sw.Write(@"/// \param ");
sw.Write(p.Name);
sw.WriteLine(p.Documentation);
}
}
catch (Exception e)
{
Console.WriteLine("[Warning] Error documenting function {0}: {1}", f.WrappedDelegate.Name, e.ToString());
}
}
示例4: WriteMethodBody
static void WriteMethodBody(BindStreamWriter sw, Function f)
{
//var callstring = f.Parameters.CallString()
// .Replace("String[]", "String*");
var callstring = GenerateCallString(f);
if (f.ReturnType != null && !f.ReturnType.ToString().ToLower().Contains("void"))
sw.Write("return ");
sw.WriteLine("Delegates::{0}()({1});", f.WrappedDelegate.Name, callstring);
}
示例5: WriteMethod
private static void WriteMethod(BindStreamWriter sw, Function f)
{
if (f.Deprecated && Settings.IsEnabled(Settings.Legacy.AddDeprecationWarnings))
{
sw.WriteLine("[Obsolete(\"Deprecated in OpenGL {0}\")]", f.DeprecatedVersion);
}
if (!string.IsNullOrEmpty (f.Obsolete))
sw.WriteLine("[Obsolete(\"{0}\")]", f.Obsolete);
if (!f.CLSCompliant)
{
sw.WriteLine("[System.CLSCompliant(false)]");
}
sw.WriteLine("[AutoGenerated(Category = \"{0}\", Version = \"{1}\", EntryPoint = \"{2}\")]",
f.Category, f.Version, Settings.FunctionPrefix + f.WrappedDelegate.Name);
sw.WriteLine("public static ");
sw.Write(f);
sw.WriteLine();
}
示例6: WriteMethod
private void WriteMethod(BindStreamWriter sw, Function f, EnumCollection enums)
{
CreateBody(f, enums);
if (f.Deprecated && Settings.IsEnabled(Settings.Legacy.AddDeprecationWarnings))
{
sw.WriteLine("[Obsolete(\"Deprecated in OpenGL {0}\")]", f.DeprecatedVersion);
}
if (!f.CLSCompliant)
{
sw.WriteLine("[System.CLSCompliant(false)]");
}
sw.WriteLine("[AutoGenerated(Category = \"{0}\", Version = \"{1}\", EntryPoint = \"{2}\")]",
f.Category, f.Version, Settings.FunctionPrefix + f.WrappedDelegate.EntryPoint);
sw.WriteLine("public static ");
sw.Write(GetDeclarationString(f));
sw.WriteLine();
}