• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Class类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Class的典型用法代码示例。如果您正苦于以下问题:C# Class类的具体用法?C# Class怎么用?C# Class使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Class类属于命名空间,在下文中一共展示了Class类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: App

    public App(string nibName)
    {
        NSObject app = (NSObject) new Class("NSApplication").Call("sharedApplication");

        // Load our nib. This will instantiate all of the native objects and wire them together.
        // The C# SimpleLayoutView will be created the first time Objective-C calls one of the
        // methods SimpleLayoutView added or overrode.
        NSObject dict = new Class("NSMutableDictionary").Call("alloc").Call("init").To<NSObject>();
        NSObject key = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("NSOwner")).To<NSObject>();
        dict.Call("setObject:forKey:", app, key);

        NSObject bundle = new Class("NSBundle").Call("mainBundle").To<NSObject>();

        NSObject nib = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto(nibName)).To<NSObject>();
        sbyte loaded = (sbyte) bundle.Call("loadNibFile:externalNameTable:withZone:", nib, dict, null);
        if (loaded != 1)
            throw new InvalidOperationException("Couldn't load the nib file");

        // We need an NSAutoreleasePool to do Native.Call, but we don't want to have one
        // hanging around while we're in the main event loop because that may hide bugs.
        // So, we'll instantiate a Native instance here and call Invoke later which can
        // be done without an NSAutoreleasePool.
        m_run = new Native(app, new Selector("run"));

        dict.release();
    }
开发者ID:afrog33k,项目名称:mobjc,代码行数:26,代码来源:NSApplication.cs


示例17: Main

        public static void Main(string[] args)
        {
            var trung = new Student() {
                Name = "Trung",
                ID = 5
            };

            var c1203l = new Class() {
                ID = 1,
                Name = "C1203L",
                Teacher = "NhatNK"
            };

            var lab1 = new Room() {
                Name = "Lab1"
            };

            var late = new TimeSlot() {
                StartTime = DateTime.MinValue.AddDays(4).AddHours(17).AddMinutes(30),
                EndTime = DateTime.MinValue.AddDays(4).AddHours(19).AddMinutes(30)
            };

            var m = new Manager();
            m.Students.Add(trung);
            m.Classes.Add(c1203l);
            m.TimeSlots.Add(late);
            m.Rooms.Add(lab1);
            m.RegisterStudentWithClass(trung, c1203l);
            m.RegisterClassRoomTimeSlot(c1203l, lab1, late);

            foreach (var a in m.Allocation)
            {
                Console.WriteLine("{0} {1} {2}", a.Item1.Name, a.Item2.Name, a.Item3.StartTime.DayOfWeek);
            }
        }
开发者ID:nhim175,项目名称:CSharpAssignment,代码行数:35,代码来源:Main.cs


示例18: Main

    static void Main()
    {
        Discipline math = new Discipline("Math", 15, 15);
        Discipline biology = new Discipline("Biology", 10, 10);
        Discipline history = new Discipline("History", 5, 5);
        history.Comment = "Optional comment"; // add comment

        Student firstStudent = new Student("Borislav Borislavov", 2);
        firstStudent.Comment = "Optional comment"; // add comment

        Student secondStudent = new Student("Vasil Vasilev", 4);

        Teacher firstTeacher = new Teacher("Ivan Ivanov");
        firstTeacher.AddDicipline(math);

        Teacher secondTeacher = new Teacher("Peter Petrov");
        secondTeacher.AddDicipline(biology);
        secondTeacher.AddDicipline(history);
        secondTeacher.Comment = "Optional comment"; // add comment

        Class firstClass = new Class("12B");
        firstClass.Comment = "Optional comment"; // add comment

        firstClass.AddStudent(firstStudent);
        firstClass.AddStudent(secondStudent);

        firstClass.AddTeacher(firstTeacher);
        firstClass.AddTeacher(secondTeacher);

        Console.WriteLine(firstClass);
    }
开发者ID:hristian-dimov,项目名称:TelerikAcademy,代码行数:31,代码来源:SchoolTest.cs


示例19: Lookup

 /// <summary>
 /// This is used to acquire a <c>Converter</c> instance from
 /// this binder. All instances are cached to reduce the overhead
 /// of lookups during the serialization process. Converters are
 /// lazily instantiated and so are only created if demanded.
 /// </summary>
 /// <param name="type">
 /// this is the type to find the converter for
 /// </param>
 /// <returns>
 /// this returns the converter instance for the type
 /// </returns>
 public Converter Lookup(Class type) {
    Class result = cache.fetch(type);
    if(result != null) {
       return Create(result);
    }
    return null;
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:19,代码来源:RegistryBinder.cs


示例20: Match

 /// <summary>
 /// This method is used to match the specified type to primitive
 /// transform implementations. If this is given a primitive then
 /// it will always return a suitable <c>Transform</c>. If
 /// however it is given an object type an exception is thrown.
 /// </summary>
 /// <param name="type">
 /// this is the primitive type to be transformed
 /// </param>
 /// <returns>
 /// this returns a stock transform for the primitive
 /// </returns>
 public Transform Match(Class type) {
    if(type == int.class) {
       return new IntegerTransform();
    }
    if(type == bool.class) {
       return new BooleanTransform();
    }
    if(type == long.class) {
       return new LongTransform();
    }
    if(type == double.class) {
       return new DoubleTransform();
    }
    if(type == float.class) {
       return new FloatTransform();
    }
    if(type == short.class) {
       return new ShortTransform();
    }
    if(type == byte.class) {
       return new ByteTransform();
    }
    if(type == char.class) {
       return new CharacterTransform();
    }
    return null;
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:39,代码来源:PrimitiveMatcher.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Class1类代码示例发布时间:2022-05-24
下一篇:
C# ClangParser类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap