本文整理汇总了C#中Class类的典型用法代码示例。如果您正苦于以下问题:C# Class类的具体用法?C# Class怎么用?C# Class使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Class类属于命名空间,在下文中一共展示了Class类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitClassDecl
public override bool VisitClassDecl(Class @class)
{
if (!VisitDeclaration(@class))
return false;
if ([email protected])
goto Out;
if (@class.CompleteDeclaration != null)
goto Out;
@class.CompleteDeclaration =
AstContext.FindCompleteClass(@class.QualifiedName);
if (@class.CompleteDeclaration == null)
{
@class.IsGenerated = false;
Driver.Diagnostics.EmitWarning(DiagnosticId.UnresolvedDeclaration,
"Unresolved declaration: {0}", @class.Name);
}
Out:
return base.VisitClassDecl(@class);
}
示例2: CheckMissingOperatorOverloadPair
static CXXOperatorKind CheckMissingOperatorOverloadPair(Class @class, out int index,
CXXOperatorKind op1, CXXOperatorKind op2, Type typeLeft, Type typeRight)
{
var first = @class.Operators.FirstOrDefault(o => o.OperatorKind == op1 &&
o.Parameters.First().Type.Equals(typeLeft) && o.Parameters.Last().Type.Equals(typeRight));
var second = @class.Operators.FirstOrDefault(o => o.OperatorKind == op2 &&
o.Parameters.First().Type.Equals(typeLeft) && o.Parameters.Last().Type.Equals(typeRight));
var hasFirst = first != null;
var hasSecond = second != null;
if (hasFirst && (!hasSecond || !second.IsGenerated))
{
index = @class.Methods.IndexOf(first);
return op2;
}
if (hasSecond && (!hasFirst || !first.IsGenerated))
{
index = @class.Methods.IndexOf(second);
return op1;
}
index = 0;
return CXXOperatorKind.None;
}
示例3: addClass
public static Boolean addClass(int cCode, int semester_id, int max_enrollment, int enrollment, DateTime Class_time, int prof_id)
{
GradingSys_DataClassesDataContext db = new GradingSys_DataClassesDataContext();
Class classObj = new Class
{
Course_code = cCode,
Semester_id = semester_id,
Max_enrollment = max_enrollment,
Enrollment = enrollment,
Class_time = Class_time,
Professor_id = prof_id
};
db.Classes.InsertOnSubmit(classObj);
// Submit the change to the database.
try
{
db.SubmitChanges();
return true;
}
catch (Exception e)
{
Console.WriteLine(e);
return false;
}
}
示例4: VisitClassDecl
public override bool VisitClassDecl(Class @class)
{
if (@class.CompleteDeclaration != null)
return VisitClassDecl(@class.CompleteDeclaration as Class);
return base.VisitClassDecl(@class);
}
示例5: Match
/// <summary>
/// This is used to match a <c>Transform</c> for the given
/// type. If a transform cannot be resolved this this will throw an
/// exception to indicate that resolution of a transform failed. A
/// transform is resolved by first searching for a transform within
/// the user specified matcher then searching the stock transforms.
/// </summary>
/// <param name="type">
/// this is the type to resolve a transform object for
/// </param>
/// <returns>
/// this returns a transform used to transform the type
/// </returns>
public Transform Match(Class type) {
Transform value = matcher.Match(type);
if(value != null) {
return value;
}
return MatchType(type);
}
示例6: VisitClassDecl
public override bool VisitClassDecl(Class @class)
{
if ([email protected] && base.VisitClassDecl(@class))
{
if (@class.IsInterface)
{
@class.Comment = @class.OriginalClass.Comment;
foreach (var method in @class.OriginalClass.Methods)
{
var interfaceMethod = @class.Methods.FirstOrDefault(m => m.OriginalPtr == method.OriginalPtr);
if (interfaceMethod != null)
{
interfaceMethod.Comment = method.Comment;
}
}
foreach (var property in @class.OriginalClass.Properties)
{
var interfaceProperty = @class.Properties.FirstOrDefault(p => p.Name == property.Name);
if (interfaceProperty != null)
{
interfaceProperty.Comment = property.Comment;
}
}
}
else
{
this.documentation.DocumentType(@class);
}
return true;
}
return false;
}
示例7: ComputeClassPath
public static List<BaseClassSpecifier> ComputeClassPath(Class from, Class to)
{
var path = new List<BaseClassSpecifier>();
ComputeClassPath(from, to, path);
return path;
}
示例8: CheckNonVirtualInheritedFunctions
public void CheckNonVirtualInheritedFunctions(Class @class, Class originalClass = null)
{
if (originalClass == null)
originalClass = @class;
foreach (BaseClassSpecifier baseSpecifier in @class.Bases)
{
var @base = baseSpecifier.Class;
if (@base.IsInterface) continue;
var nonVirtualOffset = ComputeNonVirtualBaseClassOffset(originalClass, @base);
if (nonVirtualOffset == 0)
continue;
foreach (var method in @base.Methods.Where(method =>
!method.IsVirtual && (method.Kind == CXXMethodKind.Normal)))
{
Console.WriteLine(method);
var adjustedMethod = new Method(method)
{
SynthKind = FunctionSynthKind.AdjustedMethod,
AdjustedOffset = nonVirtualOffset,
};
originalClass.Methods.Add(adjustedMethod);
}
CheckNonVirtualInheritedFunctions(@base, originalClass);
}
}
示例9: Execute
public void Execute(Class testClass, Action next)
{
//Behavior chooses not to invoke next().
//Since the test classes are never intantiated,
//their cases don't have the chance to throw exceptions,
//resulting in all 'passing'.
}
示例10: FromManaged
public void FromManaged()
{
NSObject s = new Class("Subclass1").Call("alloc").Call("init").To<NSObject>();
try
{
Managed.LogException = (e) => {};
s.Call("BadValue");
Assert.Fail("should have been an exception");
}
catch (TargetInvocationException e)
{
Assert.IsTrue(e.Message.Contains("Exception has been thrown by the (managed) target of an Objective-C method call"));
Assert.IsNotNull(e.InnerException);
ArgumentException ae = e.InnerException as ArgumentException;
Assert.IsNotNull(ae);
Assert.IsTrue(ae.Message.Contains("my error"));
Assert.IsTrue(ae.Message.Contains("alpha"));
Assert.AreEqual("alpha", ae.ParamName);
}
finally
{
Managed.LogException = null;
}
}
示例11: updateInfor
internal void updateInfor(Class.MyClient myClient, MyGroupQuestion groupQuestion)
{
lbUsername.Text = myClient.Username;
lvListQuestionAnswer.Items.Clear();
for (int i = 0; i < myClient.ListQuestionAnswereds.Count; i++)
{
ListViewItem item = new ListViewItem();
item.Text = i.ToString();
item.SubItems.Add(groupQuestion.questions[i].Question);
switch (groupQuestion.questions[i].type)
{
case MyQuestionType.MyMissingFieldQuestion:
item.SubItems.Add("Điền khuyết");
break;
case MyQuestionType.MyMultiChoiceQuestion:
item.SubItems.Add("Nhiều đáp án");
break;
case MyQuestionType.MyOneChoiceQuestion:
item.SubItems.Add("Chọn duy nhất");
break;
}
item.SubItems.Add(myClient.ListQuestionAnswereds[i]);
item.SubItems.Add(groupQuestion.questions[i].Answer);
checkClientAnswer(myClient, groupQuestion, i, item);
lvListQuestionAnswer.Items.Add(item);
}
}
示例12: Parse
public Class Parse(String json, String className)
{
Class result = new Class(AccessModifier.Public, className);
var oo = JsonConvert.DeserializeObject(json);
var c = new ClassInfo(className);
if (oo is JArray)
{
foreach (var jo in (JArray)oo)
{
if (jo is JObject)
{
SetProperties(c, (JObject)jo);
}
else if (jo is JValue)
{
var pi = new PropertyInfo();
pi.Validate(jo);
return new Class(AccessModifier.Public, pi.GetCSharpTypeName());
}
}
}
else if (oo is JObject)
{
SetProperties(c, (JObject)oo);
}
SetProperties(result, c);
return result;
}
示例13: VisitClassDecl
public override bool VisitClassDecl(Class @class)
{
if (!base.VisitClassDecl(@class) || @class.IsIncomplete || [email protected])
return false;
@class.Specializations.RemoveAll(
s => s.Fields.Any(f => f.Type.IsPrimitiveType(PrimitiveType.Void)));
if (@class.Specializations.Count == 0)
return false;
var groups = (from specialization in @class.Specializations
group specialization by specialization.Arguments.All(
a => a.Type.Type != null && a.Type.Type.IsAddress()) into @group
select @group).ToList();
foreach (var group in groups.Where(g => g.Key))
foreach (var specialization in group.Skip(1))
@class.Specializations.Remove(specialization);
for (int i = @class.Specializations.Count - 1; i >= 0; i--)
if (@class.Specializations[i] is ClassTemplatePartialSpecialization)
@class.Specializations.RemoveAt(i);
return true;
}
示例14: VisitClassDecl
public override bool VisitClassDecl(Class @class)
{
if (!base.VisitClassDecl(@class))
return false;
// dependent types with virtuals have no own virtual layouts
// so virtuals are considered different objects in template instantiations
// therefore the method itself won't be visited, so let's visit it through the v-table
if (Context.ParserOptions.IsMicrosoftAbi)
{
foreach (var method in from vfTable in @class.Layout.VFTables
from component in vfTable.Layout.Components
where component.Method != null
select component.Method)
VisitMethodDecl(method);
}
else
{
if (@class.Layout.Layout == null)
return false;
foreach (var method in from component in @class.Layout.Layout.Components
where component.Method != null
select component.Method)
VisitMethodDecl(method);
}
return true;
}
示例15: GenerateToString
void GenerateToString(Class @class, Block block, Method method)
{
needsStreamInclude = true;
block.WriteLine("std::ostringstream os;");
block.WriteLine("os << *NativePtr;");
block.Write("return clix::marshalString<clix::E_UTF8>(os.str());");
}