当前位置: 首页>>代码示例>>C#>>正文


C# Class类代码示例

本文整理汇总了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);
        }
开发者ID:jijamw,项目名称:CppSharp,代码行数:25,代码来源:ResolveIncompleteDeclsPass.cs

示例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;
        }
开发者ID:fhchina,项目名称:CppSharp,代码行数:26,代码来源:CheckOperatorsOverloads.cs

示例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;
     }
 }
开发者ID:eng7miky,项目名称:GradSys,代码行数:25,代码来源:ClassDAO.cs

示例4: VisitClassDecl

        public override bool VisitClassDecl(Class @class)
        {
            if (@class.CompleteDeclaration != null)
                return VisitClassDecl(@class.CompleteDeclaration as Class);

            return base.VisitClassDecl(@class);
        }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:7,代码来源:FieldToPropertyPass.cs

示例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);
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:20,代码来源:DefaultMatcher.cs

示例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;
 }
开发者ID:grbd,项目名称:QtSharp,代码行数:32,代码来源:GetCommentsFromQtDocsPass.cs

示例7: ComputeClassPath

        public static List<BaseClassSpecifier> ComputeClassPath(Class from, Class to)
        {
            var path = new List<BaseClassSpecifier>();

            ComputeClassPath(from, to, path);
            return path;
        }
开发者ID:xistoso,项目名称:CppSharp,代码行数:7,代码来源:MultipleInheritancePass.cs

示例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);
            }
        }
开发者ID:xistoso,项目名称:CppSharp,代码行数:31,代码来源:MultipleInheritancePass.cs

示例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'.
 }
开发者ID:leijiancd,项目名称:fixie,代码行数:7,代码来源:ClassLifecycleTests.cs

示例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;
        }
    }
开发者ID:afrog33k,项目名称:mobjc,代码行数:26,代码来源:ExceptionTests.cs

示例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);
            }
        }
开发者ID:hieuntp2,项目名称:TruongChuyen,代码行数:33,代码来源:ClientInfor.cs

示例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;
        }
开发者ID:fengweijp,项目名称:higlabo,代码行数:30,代码来源:JsonParser.cs

示例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;
        }
开发者ID:tritao,项目名称:CppSharp,代码行数:26,代码来源:TrimSpecializationsPass.cs

示例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;
        }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:29,代码来源:DelegatesPass.cs

示例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());");
 }
开发者ID:tritao,项目名称:CppSharp,代码行数:7,代码来源:ObjectOverridesPass.cs


注:本文中的Class类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。