public void Should_be_possible_to_define_the_object_flag_based_on_the_objects_of_set_for_the_intersection_operator() { FlagEnumeration firstObjectFlag = FlagEnumeration.error; FlagEnumeration secondObjectFlag = FlagEnumeration.complete; SetOperation operation = new IntersectionSetOperation(); FlagEnumeration result = operation.GetObjectFlag(firstObjectFlag, secondObjectFlag); Assert.AreEqual(FlagEnumeration.error, result, "the flag enumaration is not expected"); firstObjectFlag = FlagEnumeration.doesnotexist; secondObjectFlag = FlagEnumeration.notcollected; result = operation.GetObjectFlag(firstObjectFlag, secondObjectFlag); Assert.AreEqual(FlagEnumeration.doesnotexist, result, "the flag enumaration is not expected"); }
public void Should_be_possible_to_define_the_object_flag_based_on_the_objects_of_set_for_the_complement_operator() { FlagEnumeration firstObjectFlag = FlagEnumeration.incomplete; FlagEnumeration secondObjectFlag = FlagEnumeration.notapplicable; SetOperation operation = new ComplementSetOperation(); FlagEnumeration result = operation.GetObjectFlag(firstObjectFlag, secondObjectFlag); Assert.AreEqual(FlagEnumeration.error, result, "the flag enumaration is not expected"); firstObjectFlag = FlagEnumeration.notcollected; secondObjectFlag = FlagEnumeration.notcollected; result = operation.GetObjectFlag(firstObjectFlag, secondObjectFlag); Assert.AreEqual(FlagEnumeration.notcollected, result, "the flag enumaration is not expected"); }
/// <summary> /// Evaluates the setObjects in the tree. This method invokes the Evaluate method in the recursive form. /// The evaluation starts in the more deep level in the tree of objects. /// Then the upper levels will evaluated based on result of the deeper levels. /// </summary> /// <param name="setElement">The set element.</param> /// <returns></returns> private SetResult EvaluateOtherSets(set setElement) { IEnumerable <set> otherSetsElements = setElement.GetSets(); SetResult resultFirstSet = this.Evaluate(otherSetsElements.First()); SetResult resultSecondSet = new SetResult(new List <String>(), FlagEnumeration.notcollected); //the max number of set is 2 (reference: oval_definitions schema) if (otherSetsElements.Count() == MAX_NUMBER_OF_OBJECTS_IN_SET) { resultSecondSet = this.Evaluate(otherSetsElements.ElementAt(1)); } SetOperation operation = this.GetOperation(setElement.set_operator); IEnumerable <string> results = operation.Execute(resultFirstSet.Result, resultSecondSet.Result); FlagEnumeration objectFlag = operation.GetObjectFlag(resultFirstSet.ObjectFlag, resultSecondSet.ObjectFlag); return(new SetResult(results, objectFlag)); }
private SetResult ExecuteOperationForSetElement(set setElement, IEnumerable <sc.ObjectType> objectTypes) { sc.ObjectType firstObjectType = objectTypes.First(); sc.ObjectType secondObjectType = null; IEnumerable <string> firstReferenceTypes = firstObjectType.GetReferenceTypesInString(); IEnumerable <string> secondReferenceTypes = new List <string>(); FlagEnumeration firstObjectFlag = firstObjectType.flag; FlagEnumeration secondObjectFlag = FlagEnumeration.complete; if (objectTypes.Count() == MAX_NUMBER_OF_OBJECTS_IN_SET) { //the max number to the Object_Reference is 2 (reference: oval_definitions schema) secondObjectType = objectTypes.ElementAt(1); secondReferenceTypes = secondObjectType.GetReferenceTypesInString(); secondObjectFlag = secondObjectType.flag; } SetOperation operation = this.GetOperation(setElement.set_operator); IEnumerable <string> results = operation.Execute(firstReferenceTypes, secondReferenceTypes); FlagEnumeration objectFlag = operation.GetObjectFlag(firstObjectFlag, secondObjectFlag); SetResult result = new SetResult(results, objectFlag); return(result); }
public SetResult(IEnumerable <string> result, FlagEnumeration objectFlag) { this.Result = result; this.ObjectFlag = objectFlag; }
public SetResult(IEnumerable<string> result, FlagEnumeration objectFlag) { this.Result = result; this.ObjectFlag = objectFlag; }
protected String GetNameOfFlagEnumerationCombined(FlagEnumeration firstObjectFlag, FlagEnumeration secondObjectFlag) { return firstObjectFlag.ToString() + "-" + secondObjectFlag.ToString(); }
public FlagEnumeration GetObjectFlag(FlagEnumeration firstObjectFlag, FlagEnumeration secondObjectFlag) { return this.matrixOfCombinationFlags[this.GetNameOfFlagEnumerationCombined(firstObjectFlag, secondObjectFlag)]; }
public void SetEspecificObjectStatus(FlagEnumeration flag) { this.objectType.flag = flag; }
static void Main(string[] args) { ///برای اینکه یک خط بیاد پایین و جواب ها به بالا نچسبد Console.WriteLine(); //p1 ///تعریف ایندکسر //Indexerr array = new Indexerr(); //for (int i = 0; i < 5; i++) //{ // Console.Write("enter id {0} : ", i + 1); // lbl1: // string b = Console.ReadLine(); // /// ترای پارس یک رشته مانند بی را میگیرد سعی میکند درون آیدی بریزد اگر توانست صحیح اگر نتوانست // /// غلط را برمیگرداند // Boolean parsResult = int.TryParse(b, out int Id); // if (parsResult == false) // { // Console.Write("enter a nummber : "); // goto lbl1; // } // array[i] = Id; //} //Console.WriteLine("-------------------------"); //for (int i = 0; i < 5; i++) //{ // Console.WriteLine("Array {0} = {1}", i, array[i]); //} //p2 ///تعریف ایندکسر //Indexerr flag = new Indexerr(); //flag[0] = true; //flag[1] = false; //flag[2] = true; //flag[3] = true; ////... //for (int i = 0; i < 32; i++) //{ // Console.WriteLine(flag[i]); //} //---------------------------------------------------------------------------- //p3 /// Extension Method //int a = 2; //Console.WriteLine(a.Plus_5()); //string b = "mahdi"; //Console.WriteLine(b.Up()); //------------------------------------------------------------------------------ //p4 //SeasonsEnumeration happySeason = SeasonsEnumeration.spring; //Console.WriteLine(happySeason); //------------------------------------------------------------------------------- //p5 ///برای تعریف کردن اینام ان را با روزش مساوی قرار میدهیم FlagEnumeration meetingDay = FlagEnumeration.saturday | FlagEnumeration.monday; Console.WriteLine("the meeting days is : {0}", meetingDay); ///برای اضافه کردن باید نام متغیری ک تعریف کردیم را بنویسیم نماد خط را میگذاریم ///و پارامتر های دیگر را اضافه میکنیم meetingDay = meetingDay | FlagEnumeration.wednesday | FlagEnumeration.friday; Console.WriteLine("\nthe meeting days is : {0}", meetingDay); ///برای حذف کردن مانند اضافه کردن فقط نماد توان را میگذاریم ///نکته مهم ///ولی اگر موجود نباشد ان را اضافه میکند meetingDay = meetingDay ^ FlagEnumeration.friday; Console.WriteLine("\nthe meeting days is : {0}", meetingDay); ///برای چک کردن میتینگ دی bool checkmeeting = (meetingDay & FlagEnumeration.wednesday) == FlagEnumeration.wednesday; Console.WriteLine("\n" + checkmeeting); Console.ReadKey(); }
protected String GetNameOfFlagEnumerationCombined(FlagEnumeration firstObjectFlag, FlagEnumeration secondObjectFlag) { return(firstObjectFlag.ToString() + "-" + secondObjectFlag.ToString()); }
public FlagEnumeration GetObjectFlag(FlagEnumeration firstObjectFlag, FlagEnumeration secondObjectFlag) { return(this.matrixOfCombinationFlags[this.GetNameOfFlagEnumerationCombined(firstObjectFlag, secondObjectFlag)]); }