Example #1
0
 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());");
 }
Example #2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Field"/> class.
		/// </summary>
		/// <param name="fieldDefinition">The field definition.</param>
		public Field (FieldDefinition fieldDefinition, Class type, Class _class, InternalType internalType)
		{
			this.type = type;
			this.internalType = internalType;
			this.fieldDefinition = fieldDefinition;
			this._class = _class;
		}
        private static void HandleMissingOperatorOverloadPair(Class @class, CXXOperatorKind op1,
            CXXOperatorKind op2)
        {
            foreach (var op in @class.Operators.Where(
                o => o.OperatorKind == op1 || o.OperatorKind == op2).ToList())
            {
                int index;
                var missingKind = CheckMissingOperatorOverloadPair(@class, out index, op1, op2,
                    op.Parameters.First().Type, op.Parameters.Last().Type);

                if (missingKind == CXXOperatorKind.None || !op.IsGenerated)
                    continue;

                var method = new Method()
                    {
                        Name = Operators.GetOperatorIdentifier(missingKind),
                        Namespace = @class,
                        SynthKind = FunctionSynthKind.ComplementOperator,
                        Kind = CXXMethodKind.Operator,
                        OperatorKind = missingKind,
                        ReturnType = op.ReturnType,
                        Parameters = op.Parameters
                    };

                @class.Methods.Insert(index, method);
            }
        }
Example #4
0
        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);
            }
        }
Example #5
0
 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;
     }
 }
        public override bool VisitClassDecl(Class @class)
        {
            if (@class.CompleteDeclaration != null)
                return VisitClassDecl(@class.CompleteDeclaration as Class);

            if (!VisitDeclarationContext(@class))
                return false;

            // Check for C++ operators that cannot be represented in C#.
            CheckInvalidOperators(@class);

            if (Driver.Options.IsCSharpGenerator)
            {
                // The comparison operators, if overloaded, must be overloaded in pairs;
                // that is, if == is overloaded, != must also be overloaded. The reverse
                // is also true, and similar for < and >, and for <= and >=.

                HandleMissingOperatorOverloadPair(@class, CXXOperatorKind.EqualEqual,
                                                  CXXOperatorKind.ExclaimEqual);

                HandleMissingOperatorOverloadPair(@class, CXXOperatorKind.Less,
                                                  CXXOperatorKind.Greater);

                HandleMissingOperatorOverloadPair(@class, CXXOperatorKind.LessEqual,
                                                  CXXOperatorKind.GreaterEqual);
            }

            return false;
        }
        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;
        }
Example #8
0
 public void TestCloneNewRoot()
 {
     var obj1 = new Class { ClassMember = new Class(), ListMember = { new Class(), new Class(), new Class() } };
     var obj2 = new Class { ClassMember = new Class(), ListMember = { new Class(), new Class(), new Class() } };
     var nodeContainer = new NodeContainer();
     var newRoot = nodeContainer.GetOrCreateNode(obj2);
     var path1 = new GraphNodePath(nodeContainer.GetOrCreateNode(obj1));
     var clone = path1.Clone(newRoot);
     Assert.AreNotEqual(newRoot, path1.RootNode);
     Assert.AreEqual(newRoot, clone.RootNode);
     Assert.AreEqual(path1.IsValid, clone.IsValid);
     Assert.AreEqual(path1.IsEmpty, clone.IsEmpty);
     var path2 = path1.PushMember(nameof(Class.ClassMember)).PushTarget().PushMember(nameof(Class.IntMember));
     clone = path2.Clone(newRoot);
     Assert.AreNotEqual(newRoot, path2.RootNode);
     Assert.AreEqual(newRoot, clone.RootNode);
     Assert.AreEqual(path2.IsValid, clone.IsValid);
     Assert.AreEqual(path2.IsEmpty, clone.IsEmpty);
     var path3 = path1.PushMember(nameof(Class.ListMember)).PushIndex(new Index(1)).PushMember(nameof(Class.IntMember));
     clone = path3.Clone(newRoot);
     Assert.AreNotEqual(newRoot, path3.RootNode);
     Assert.AreEqual(newRoot, clone.RootNode);
     Assert.AreEqual(path3.IsValid, clone.IsValid);
     Assert.AreEqual(path3.IsEmpty, clone.IsEmpty);
 }
Example #9
0
        public override bool VisitClassDecl(Class @class)
        {
            if (@class.CompleteDeclaration != null)
                return VisitClassDecl(@class.CompleteDeclaration as Class);

            return base.VisitClassDecl(@class);
        }
Example #10
0
 /// <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;
 }
Example #11
0
 public static Schema.KRPC.Services GetServices()
 {
     var services = new Schema.KRPC.Services ();
     foreach (var serviceSignature in Services.Instance.Signatures.Values) {
         var service = new Schema.KRPC.Service ();
         service.Name = serviceSignature.Name;
         foreach (var procedureSignature in serviceSignature.Procedures.Values) {
             var procedure = new Procedure ();
             procedure.Name = procedureSignature.Name;
             if (procedureSignature.HasReturnType)
             {
                 procedure.HasReturnType = true;
                 procedure.ReturnType = TypeUtils.GetTypeName (procedureSignature.ReturnType);
             }
             foreach (var parameterSignature in procedureSignature.Parameters) {
                 var parameter = new Parameter ();
                 parameter.Name = parameterSignature.Name;
                 parameter.Type = TypeUtils.GetTypeName (parameterSignature.Type);
                 if (parameterSignature.HasDefaultArgument)
                 {
                     parameter.HasDefaultArgument = true;
                     parameter.DefaultArgument = parameterSignature.DefaultArgument;
                 }
                 procedure.Parameters.Add (parameter);
             }
             foreach (var attribute in procedureSignature.Attributes) {
                 procedure.Attributes.Add (attribute);
             }
             if (procedureSignature.Documentation != "")
                 procedure.Documentation = procedureSignature.Documentation;
             service.Procedures.Add (procedure);
         }
         foreach (var clsSignature in serviceSignature.Classes.Values) {
             var cls = new Class ();
             cls.Name = clsSignature.Name;
             if (clsSignature.Documentation != "")
                 cls.Documentation = clsSignature.Documentation;
             service.Classes.Add (cls);
         }
         foreach (var enmSignature in serviceSignature.Enumerations.Values) {
             var enm = new Enumeration ();
             enm.Name = enmSignature.Name;
             if (enmSignature.Documentation != "")
                 enm.Documentation = enmSignature.Documentation;
             foreach (var enmValueSignature in enmSignature.Values) {
                 var enmValue = new EnumerationValue ();
                 enmValue.Name = enmValueSignature.Name;
                 enmValue.Value = enmValueSignature.Value;
                 if (enmValueSignature.Documentation != "")
                     enmValue.Documentation = enmValueSignature.Documentation;
                 enm.Values.Add (enmValue);
             }
             service.Enumerations.Add (enm);
         }
         if (serviceSignature.Documentation != "")
             service.Documentation = serviceSignature.Documentation;
         services.Services_.Add (service);
     }
     return services;
 }
Example #12
0
 static void Main()
 {
     //Student test
     //Console.WriteLine("Student test");
     List<Student> studentsList = new List<Student>();
     studentsList.Add(new Student("Vesi", 1231532));
     studentsList.Add(new Student("Natalia", 462346));
     studentsList.Add(new Student("Mitko", 0982374));
     //Console.WriteLine(studentsList.Print());
     //Teacher test
     //Console.WriteLine("Teacher test");
     List<Teacher> teachersList = new List<Teacher>();
     teachersList.Add(new Teacher("prof. Petrov"));
     teachersList.Add(new Teacher("doc. Hristov"));
     teachersList.Add(new Teacher("as. Doneva"));
     teachersList[0].AddDiscipline("Computer sciense", 4, 5);
     teachersList[0].AddDiscipline("Hardware basics", 3, 2);
     teachersList[1].AddDiscipline("C# Basics", 4, 4);
     teachersList[1].AddDiscipline("C# OOP", 5, 5);
     teachersList[2].AddDiscipline("Operating Systems", 3, 2);
     //Console.WriteLine(teachersList.Print());
     //Class test
     //Console.WriteLine("Class test");
     Class classA = new Class('A', teachersList, studentsList);
     //Console.WriteLine(classA.ToString());
     Class classB = new Class('B', teachersList, studentsList);
     classB.Comments = "This is class B";
     //School test
     Console.WriteLine("School test:");
     School TUES = new School();
     TUES.AddClass(classA);
     TUES.AddClass(classB);
     Console.WriteLine(TUES.ToString());
 }
Example #13
0
        public static TsType CreateClass(TsType parent, Type type)
        {
            var name = type.Name;

            var newClass = new Class(parent, name);

            if (type.IsGenericType)
            {
                var genericWartIndex = name.IndexOf("`");
                if (genericWartIndex > 0)
                {
                    newClass.Name = name.Substring(0, genericWartIndex);
                }

                var generics = type.GetGenericArguments();

                foreach (var generic in generics)
                {
                    newClass.Generics.Add(new GenericDefinition(generic.Name));
                }
            }

            AddConstructors(type, newClass);

            AddFields(type, newClass);

            AddProperties(type, newClass);

            AddMethods(type, newClass);

            return newClass;
        }
Example #14
0
 /// <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;
 }
Example #15
0
 /// <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);
 }
Example #16
0
 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;
 }
Example #17
0
    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;
        }
    }
Example #18
0
        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;
        }
Example #19
0
        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);
            }
        }
Example #20
0
 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'.
 }
Example #21
0
        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;
        }
        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;
        }
        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);
        }
Example #24
0
        public IJavaProxy CreateProxy(Type expectedProxyType, Class clazz, IntPtr nativePtr)
        {
            Debug.Assert(expectedProxyType != null);
            Debug.Assert(clazz != null);

            if (nativePtr == IntPtr.Zero)
                return null;

            IJavaProxy result;

            if (WrapperHelpers.IsObjectArrayClass(clazz.InternalClassName))
            {
                result = NonAbstractProxyActivator.Instance.CreateInstance(expectedProxyType);
            }
            else
            {
                if (!TryActivateProxy(clazz, expectedProxyType, out result))
                {
                    var expectedClazz = _jniEnvWrapper.Classes.FindClass(expectedProxyType);
                    if (!TryActivateProxy(expectedClazz, expectedProxyType, out result))
                        throw new InvalidJavaProxyException(expectedProxyType);
                }
            }

            result.ProxyState = new JavaProxyState(nativePtr, clazz);
            return result;
        }
        public static List<BaseClassSpecifier> ComputeClassPath(Class from, Class to)
        {
            var path = new List<BaseClassSpecifier>();

            ComputeClassPath(from, to, path);
            return path;
        }
Example #26
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Argument"/> class.
		/// </summary>
		/// <param name="index">The index.</param>
		/// <param name="type">The type.</param>
		/// <param name="internalType">Type of the internal.</param>
		public Argument (int index, Class type, InternalType internalType)
			: base ("Arg", index)
		{
			this.type = type;
			this.internalType = internalType;
			this.forceSpill = true;
		}
        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);
            }
        }
Example #28
0
    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();
    }
Example #29
0
    public static void Main()
    {
        Class mathClass = new Class("0013");

        Student studentKircho = new Student("Kircho", "0013");
        Student studentNasko = new Student("Nasko", "0013");

        Teacher teacherPencho = new Teacher("Pencho");
        Teacher teacherIvan = new Teacher("Ivan");

        mathClass.Teachers.Add(teacherPencho);
        mathClass.Teachers.Add(teacherIvan);
        mathClass.Students.Add(studentKircho);
        mathClass.Students.Add(studentNasko);
        mathClass.Comments = "This is a comment for the class";

        teacherPencho.Disciplines.Add(new Disciplines("Math", 3, 5));
        teacherPencho.Disciplines.Add(new Disciplines("Biology", 2, 3));
        teacherPencho.Disciplines.Add(new Disciplines("Literature", 6, 3));
        teacherPencho.Comments = "This is a comments for the teacher";

        teacherIvan.Disciplines.Add(new Disciplines("Informatics", 5, 10));
        teacherIvan.Disciplines.Add(new Disciplines("Robotics", 3, 5));
        teacherIvan.Disciplines.Add(new Disciplines("Networking", 7, 5));
    }
    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);
    }
        public Property GetProperty(string className, string propertyName, Frameworks framework, out Class @class)
        {
            @class = GetClass(className);
            if (@class == null)
            {
                return(null);
            }

            IEnumerable <Property> propertyFinder = @class.Properties
                                                    .Where(x => propertyName.Equals(x.Name, StringComparison.InvariantCultureIgnoreCase));

            if (framework == Frameworks.NotSet)
            {
                propertyFinder = propertyFinder.OrderByDescending(x => x.Frameworks);
            }
            else
            {
                propertyFinder = propertyFinder.Where(x => x.Frameworks.HasFlag(framework));
            }

            return(propertyFinder.FirstOrDefault());
        }
Example #32
0
 public void CreateNewClass(Class c)
 {
     m_classRepository.Insert(c);
     // save changes
     m_classRepository.SaveChanges();
 }
        public Method GetMethod(string className, string methodName, Frameworks framework, out Class @class, int overload)
        {
            @class = GetClass(className);
            if (@class == null)
            {
                return(null);
            }

            if (overload < 0)
            {
                return(null);
            }

            IEnumerable <Method> methodFinder = @class.Methods
                                                .Where(x => methodName.Equals(x.Name, StringComparison.InvariantCultureIgnoreCase));

            if (framework == Frameworks.NotSet)
            {
                methodFinder = methodFinder.OrderByDescending(x => x.Frameworks);
            }
            else
            {
                methodFinder = methodFinder.Where(x => x.Frameworks.HasFlag(framework));
            }

            if (overload > 0)
            {
                methodFinder = methodFinder.Skip(overload);
            }

            return(methodFinder.FirstOrDefault());
        }
Example #34
0
 public void UpdateClass(Class newClass)
 {
     this.UpdateClass(newClass);
 }
Example #35
0
 public void DeleteClass(Class c)
 {
     m_classRepository.Delete(c);
     // save changes
     m_classRepository.SaveChanges();
 }
Example #36
0
 public async System.Threading.Tasks.Task CreateNewClassAsync(Class c)
 {
     await Task.Run(() => CreateNewClass(c));
 }
Example #37
0
 public async Task UpdateClassAsync(Class newClass)
 {
     await Task.Run(() => UpdateClass(newClass));
 }
Example #38
0
 public override void FunctionalTest()
 {
     Class.Method(5).Should().Be(10);
 }
Example #39
0
 public async System.Threading.Tasks.Task DeleteClassAsync(Class c)
 {
     await Task.Run(() => DeleteClass(c));
 }
Example #40
0
        public byte GetMaxLevelByClass(Class castableClass)
        {
            var maxLevelProperty = MaxLevel.GetType().GetProperty(castableClass.ToString());

            return((byte)(maxLevelProperty != null ? maxLevelProperty.GetValue(MaxLevel, null) : 0));
        }
 public RemoveModifiersFromClassAction(Class classToChange)
 {
     ClassToChange = classToChange;
 }