本文整理汇总了C#中System.CodeDom.CodeCommentStatement类的典型用法代码示例。如果您正苦于以下问题:C# CodeCommentStatement类的具体用法?C# CodeCommentStatement怎么用?C# CodeCommentStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeCommentStatement类属于System.CodeDom命名空间,在下文中一共展示了CodeCommentStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constructor1_Deny_Unrestricted
public void Constructor1_Deny_Unrestricted ()
{
CodeComment cc = new CodeComment ("mono");
CodeCommentStatement ccs = new CodeCommentStatement (cc);
Assert.AreEqual ("mono", ccs.Comment.Text, "Comment.Text");
Assert.IsFalse (ccs.Comment.DocComment, "Comment.DocComment");
}
示例2: CodeGenUtil
private CodeGenUtil()
{
NamespaceImports = new CodeNamespaceImport[] {
new CodeNamespaceImport("System"),
new CodeNamespaceImport("System.Collections.Generic"),
new CodeNamespaceImport("System.Text"),
new CodeNamespaceImport("Avro"),
new CodeNamespaceImport("Avro.Specific") };
FileComment = new CodeCommentStatement(
@"------------------------------------------------------------------------------
<auto-generated>
Generated by " + System.AppDomain.CurrentDomain.FriendlyName + ", version " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version + @"
Changes to this file may cause incorrect behavior and will be lost if code
is regenerated
</auto-generated>
------------------------------------------------------------------------------");
// Visual Studio 2010 http://msdn.microsoft.com/en-us/library/x53a06bb.aspx
ReservedKeywords = new HashSet<string>() {
"abstract","as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class",
"const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event",
"explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if",
"implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new",
"null", "object", "operator", "out", "override", "params", "private", "protected", "public",
"readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static",
"string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong",
"unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while", "value", "partial" };
}
示例3: AddRange
/// <devdoc>
/// <para>Copies the elements of an array to the end of the <see cref='System.CodeDom.CodeCommentStatementCollection'/>.</para>
/// </devdoc>
public void AddRange(CodeCommentStatement[] value) {
if (value == null) {
throw new ArgumentNullException("value");
}
for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) {
this.Add(value[i]);
}
}
示例4: Constructor1_NullItem
public void Constructor1_NullItem ()
{
CodeCommentStatement[] statements = new CodeCommentStatement[] {
new CodeCommentStatement (), null };
CodeCommentStatementCollection coll = new CodeCommentStatementCollection (
statements);
}
示例5: Clone
public static CodeCommentStatement Clone(CodeCommentStatement codestatementcol)
{
return new CodeCommentStatement()
{
Comment = Clone(codestatementcol.Comment)
//EndDirectives =
};
}
示例6: TypescriptCommentStatement
public TypescriptCommentStatement(
IExpressionFactory expressionFactory,
CodeCommentStatement statement,
CodeGeneratorOptions options)
{
_expressionFactory = expressionFactory;
_statement = statement;
_options = options;
}
示例7: AddRange
public void AddRange (CodeCommentStatement [] value )
{
if (value == null) {
throw new ArgumentNullException ("value");
}
for (int i = 0; i < value.Length; i++) {
Add (value[i]);
}
}
示例8: EmitComment
private void EmitComment(CodeCommentStatement comment)
{
if (string.IsNullOrEmpty(comment.Comment.Text))
return;
writer.Write(Parser.SingleSpace);
writer.Write(Parser.DefaultComment);
writer.Write(Parser.SingleSpace);
writer.Write(comment.Comment.Text);
}
示例9: DefaultCodeCommentStatementTest
public void DefaultCodeCommentStatementTest ()
{
CodeCommentStatement commentStatement = new CodeCommentStatement ();
CodeComment comment = new CodeComment ();
commentStatement.Comment = comment;
statement = commentStatement;
Generate ();
Assertion.AssertEquals ("// \n", Code);
}
示例10: MultiLineCodeCommentStatementTest
public void MultiLineCodeCommentStatementTest ()
{
CodeCommentStatement commentStatement = new CodeCommentStatement ();
CodeComment comment = new CodeComment ();
comment.Text = "a\nb";
commentStatement.Comment = comment;
statement = commentStatement;
Generate ();
Assertion.AssertEquals ("// a\n//b\n", Code);
}
示例11: Constructor1
public void Constructor1 ()
{
CodeCommentStatement ccs1 = new CodeCommentStatement ();
CodeCommentStatement ccs2 = new CodeCommentStatement ();
CodeCommentStatement[] statements = new CodeCommentStatement[] { ccs1, ccs2 };
CodeCommentStatementCollection coll = new CodeCommentStatementCollection (
statements);
Assert.AreEqual (2, coll.Count, "#1");
Assert.AreEqual (0, coll.IndexOf (ccs1), "#2");
Assert.AreEqual (1, coll.IndexOf (ccs2), "#3");
}
示例12: Constructor2
public void Constructor2 ()
{
CodeCommentStatement ccs1 = new CodeCommentStatement ();
CodeCommentStatement ccs2 = new CodeCommentStatement ();
CodeCommentStatementCollection c = new CodeCommentStatementCollection ();
c.Add (ccs1);
c.Add (ccs2);
CodeCommentStatementCollection coll = new CodeCommentStatementCollection (c);
Assert.AreEqual (2, coll.Count, "#1");
Assert.AreEqual (0, coll.IndexOf (ccs1), "#2");
Assert.AreEqual (1, coll.IndexOf (ccs2), "#3");
}
示例13: CreateMember
/// <summary>
///
/// </summary>
/// <param name="member"></param>
/// <param name="inner"></param>
/// <param name="attrs"></param>
/// <returns></returns>
public CodeTypeMember CreateMember(MemberInfo member, CodeFieldReferenceExpression inner, MemberAttributes attrs)
{
Debug.Assert(member is MethodInfo);
MethodInfo method = member as MethodInfo;
CodeMemberMethod codeMethod = new CodeMemberMethod();
codeMethod.Name = method.Name;
codeMethod.ReturnType = new CodeTypeReference(method.ReturnType);
codeMethod.Attributes = attrs;
// try
CodeTryCatchFinallyStatement tryCode = new CodeTryCatchFinallyStatement();
// decleare parameters
List<CodeArgumentReferenceExpression> codeParamiteRefrs = new List<CodeArgumentReferenceExpression>();
foreach (ParameterInfo codeParameter in method.GetParameters()) {
CodeParameterDeclarationExpression codeParameterDeclare = new CodeParameterDeclarationExpression(codeParameter.ParameterType, codeParameter.Name);
codeMethod.Parameters.Add(codeParameterDeclare);
codeParamiteRefrs.Add(new CodeArgumentReferenceExpression(codeParameter.Name));
}
// invoke
CodeMethodInvokeExpression invokeMethod = new CodeMethodInvokeExpression(
inner, method.Name, codeParamiteRefrs.ToArray());
if (method.ReturnType.Name.ToLower() == "void") {
tryCode.TryStatements.Add(invokeMethod);
} else {
CodeVariableDeclarationStatement var = new CodeVariableDeclarationStatement(method.ReturnType, "returnObject", invokeMethod);
//CodeAssignStatement assign = new CodeAssignStatement(var, invokeMethod);
tryCode.TryStatements.Add(var);
CodeCommentStatement todo = new CodeCommentStatement("TODO: your code", false);
tryCode.TryStatements.Add(todo);
CodeVariableReferenceExpression varRef = new CodeVariableReferenceExpression("returnObject");
CodeMethodReturnStatement codeReturn = new CodeMethodReturnStatement(varRef);
tryCode.TryStatements.Add(codeReturn);
}
// catch
CodeTypeReference codeTypeRef = new CodeTypeReference(typeof(Exception));
CodeCatchClause catchClause = new CodeCatchClause("ex", codeTypeRef);
catchClause.Statements.Add(new CodeThrowExceptionStatement());
tryCode.CatchClauses.Add(catchClause);
codeMethod.Statements.Add(tryCode);
return codeMethod;
}
示例14: IgnoreDateTimeSerializeAsString
public static void IgnoreDateTimeSerializeAsString(CodeTypeDeclaration codeDeclTimeType)
{
// Remove "time" member codeattributes and add XmlIgnore
var valueMember = codeDeclTimeType.Members.Cast<CodeTypeMember>().Where(m => m.Name == "Value").Single();
valueMember.CustomAttributes.Clear();
valueMember.CustomAttributes.Add(new CodeAttributeDeclaration("System.Xml.Serialization.XmlIgnore"));
string commentLine = "New serialized string type is declared in file UBL-UnqualifiedDataTypes-2.1.partial.cs";
CodeCommentStatement memberCommentStatement = new CodeCommentStatement(commentLine, false);
valueMember.Comments.Add(memberCommentStatement);
// Modify class attributes. Make it possible to step into partial class with debugger
var debuggerStepThroughAttribute = codeDeclTimeType.CustomAttributes.OfType<CodeAttributeDeclaration>()
.Where(a => a.Name == "System.Diagnostics.DebuggerStepThroughAttribute").SingleOrDefault();
if (debuggerStepThroughAttribute != null)
{
codeDeclTimeType.CustomAttributes.Remove(debuggerStepThroughAttribute);
}
}
示例15: Test
/// <summary>
/// Tests this instance.
/// </summary>
/// <returns>the dumped object </returns>
public string Test()
{
//var element = "My String".ToCharArray().AsQueryable();
var element = "My String".ToCharArray().Select(e => new { e, Depp = (uint)e }).AsQueryable();
element.Dump(2);
/*ConstantExpression blockExpr = Expression.Constant(
Expression.Constant(42)
);
blockExpr.Dump(2);*/
// TestXmlSeria();
var testObject = new CodeTypeDeclaration("DeclClass");
var method = new CodeMemberMethod { Name = "MyMethod" };
testObject.Members.Add(method);
var method2 = new CodeMemberMethod { Name = "OtherMethod" };
testObject.Members.Add(method2);
var comment = new CodeCommentStatement("This is a comment");
method.Statements.Add(comment);
var prop = new CodeMemberProperty { Name = "MyProperty", Type = new CodeTypeReference(typeof(string)) };
testObject.Members.Add(prop);
testObject.Dump("The description", 5);
// var res = Extensions.Text;
return string.Empty;
/* var ms = new MemoryStream();
var writer = new StreamWriter(ms);
var swriter = new StringWriter();
ObjectDumper.Write(testObject, int.MaxValue, swriter);
//var xx = ms.ToString();
var result = swriter.ToString();*/
}