Example #1
0
        private static void EmitProcessAndEncodeDirect(IEmittingContext emittingContext, HandlerParameterCodec[] responseParameterCodecs, Type retvalType)
        {
            var il = emittingContext.IL;

            EmitEncodeDirect(emittingContext, responseParameterCodecs, retvalType);
            il.Call(TaskMethods.FromResult(typeof(byte[])));
        }
Example #2
0
            // Copy the contents of this dictionary to an array.
            public void CopyTo(Array array, int index)
            {
                int count;

                if (array == null)
                {
                    throw new ArgumentNullException("array");
                }
                if (index < 0)
                {
                    throw new ArgumentOutOfRangeException
                              ("index", _("ArgRange_Array"));
                }
                if (array.Rank != 1)
                {
                    throw new ArgumentException(_("Arg_RankMustBe1"));
                }
                count = TaskMethods.GetEnvironmentCount();
                if (index >= array.Length ||
                    count > (array.Length - index))
                {
                    throw new ArgumentException
                              (_("Arg_InvalidArrayIndex"));
                }
                int posn;

                for (posn = 0; posn < count; ++posn)
                {
                    array.SetValue(new DictionaryEntry
                                       (TaskMethods.GetEnvironmentKey(posn),
                                       TaskMethods.GetEnvironmentValue(posn)),
                                   index + posn);
                }
            }
Example #3
0
        public void TestMethodEvenLastCifra()
        {
            TaskMethods task = new TaskMethods();

            Assert.AreEqual(true, task.EvenLastCifra(34));
            Assert.AreEqual(false, task.EvenLastCifra(31));
        }
Example #4
0
        //Событие, в котором рассчитывается сумма 3 чисел, если они больше 5.
        private void GetAnswer_Click(object sender, EventArgs e)
        {
            int[]       mass = new int[] { (int)firstNumber.Value, (int)secondNumber.Value, (int)thridNumber.Value };
            TaskMethods task = new TaskMethods();

            answer.Text = task.SummThreeNumbers(mass).ToString();
        }
Example #5
0
        private MethodInfo CreateDecodeDeferredMethod(ProxyClassBuildingContext classContext, string parentMethodName, IReadOnlyList <Type> genericTypeArguments, Type pureRetvalType)
        {
            var methodBuilder = classContext.Builder.DefineMethod("__rpc_decode_deferred_" + parentMethodName,
                                                                  MethodAttributes.Private | MethodAttributes.HideBySig);

            var genericTypeParameterBuilders = genericTypeArguments.Any()
                ? methodBuilder.DefineGenericParameters(genericTypeArguments.Select(x => x.Name).ToArray())
                : new GenericTypeParameterBuilder[0];
            var genericArgumentMap = genericTypeParameterBuilders.ToDictionary(x => x.Name, x => (Type)x);

            var retvalType = pureRetvalType.DeepSubstituteGenerics(genericArgumentMap);

            methodBuilder.SetParameters(DecodeDeferredParameterTypes);
            methodBuilder.SetReturnType(retvalType);
            methodBuilder.SetImplementationFlags(MethodImplAttributes.Managed);

            var il = new MyILGenerator(methodBuilder.GetILGenerator());
            var emittingContext = new ProxyMethodEmittingContext(il, classContext.Fields);

            il.Ldarg(1);
            il.Call(TaskMethods.GetResult(typeof(byte[])));
            EmitPrepareToDecode(emittingContext);

            var retvalCodec = new ProxyMethodRetvalCodec(retvalType);

            retvalCodec.EmitDecode(emittingContext);
            il.Ret();

            return(methodBuilder);
        }
Example #6
0
        //Событие, в котором генерируестся исходная таблица, котороя сразу записывается в рич текст бокс, после записывается преобразованная таблица.
        private void GenerateAnswer_Click(object sender, EventArgs e)
        {
            tables.Clear();
            int         amountRows    = rnd.Next(3, 6);
            int         amountColumns = rnd.Next(3, 6);
            TaskMethods task          = new TaskMethods();

            double[,] matr = new double[amountRows, amountColumns];
            double[,] changeMatr;
            tables.Text += "Исходная матрица" + "\n";
            for (int i = 0; i < matr.GetLength(0); i++)
            {
                for (int j = 0; j < matr.GetLength(1); j++)
                {
                    matr[i, j]   = rnd.Next(-10, 10);
                    tables.Text += matr[i, j] + " ";
                }
                tables.Text += "\n";
            }
            task.ExchangeMaxMinRows(matr, out changeMatr);

            tables.Text += "Измененная матрица" + "\n";
            for (int i = 0; i < changeMatr.GetLength(0); i++)
            {
                for (int j = 0; j < changeMatr.GetLength(1); j++)
                {
                    tables.Text += changeMatr[i, j] + " ";
                }
                tables.Text += "\n";
            }
        }
Example #7
0
 // Get a particular environment variable.
 public static String GetEnvironmentVariable(String variable)
 {
     if (variable == null)
     {
         throw new ArgumentNullException("variable");
     }
     return(TaskMethods.GetEnvironmentVariable(variable));
 }
Example #8
0
        public void TestMethodSummThreeNumbers()
        {
            TaskMethods task = new TaskMethods();

            int[] numbers = new int[] { 6, 6, 6 };
            Assert.AreEqual(18, task.SummThreeNumbers(numbers));
            numbers = new int[] { 1, 2, 3 };
            Assert.AreEqual(0, task.SummThreeNumbers(numbers));
        }
Example #9
0
        private static void EmitProcessAndEncodeAsyncWithRetval(HandlerClassBuildingContext classContext, IEmittingContext emittingContext, Type pureRetvalType)
        {
            var encodeDeferredMethod = CreateEncodeDeferredMethod(classContext, pureRetvalType);
            var continueWithMethod   = TaskMethods.ContinueWith(pureRetvalType, typeof(byte[]));

            var il = emittingContext.IL;

            il.Ldarg(0);
            il.Ldftn(encodeDeferredMethod);
            il.Newobj(FuncMethods.Constructor(typeof(Task <>).MakeGenericType(pureRetvalType), typeof(byte[])));
            il.Callvirt(continueWithMethod);
        }
Example #10
0
 // Get the command line arguments.
 public static String[] GetCommandLineArgs()
 {
     String[] args = TaskMethods.GetCommandLineArgs();
     if (args != null)
     {
         return(args);
     }
     else
     {
         throw new NotSupportedException
                   (_("Exception_NoCmdLine"));
     }
 }
Example #11
0
            // Determine if this dictionary contains a specific key.
            public bool Contains(Object key)
            {
                String keyName = key.ToString();

                if (keyName != null)
                {
                    return(TaskMethods.GetEnvironmentVariable(keyName)
                           != null);
                }
                else
                {
                    throw new ArgumentNullException("key");
                }
            }
Example #12
0
        public JsonResult Insert_TaskDetail(TaskVM model)
        {
            string msg    = "Oops, Something went wrong.";
            bool   result = false;

            result = TaskMethods.Insert_TaskMaster(model);

            if (result)
            {
                msg = "Record Successfully Saved.";
            }

            return(Json(new { Success = result, Message = msg }, JsonRequestBehavior.AllowGet));
        }
Example #13
0
        //Событитие, в котором определяется четность или нечетность последней цифры в двузначном числе
        private void GetAnswer_Click(object sender, EventArgs e)
        {
            bool        returned;
            TaskMethods task1 = new TaskMethods();

            returned = task1.EvenLastCifra((int)number.Value);
            if (returned == true)
            {
                answer.Text = "Последняя цифра является четной";
            }
            else
            {
                answer.Text = "Последняя цифра является нечетной";
            }
        }
Example #14
0
        public void RejectionMaxMass3()
        {
            TaskMethods task = new TaskMethods();

            int[] numbers  = new int[] { -5, -4, -3, -2, -1 };
            int[] expected = new int[] { 4, 3, 2, 1, 0 };
            int   max;

            int[] reject;
            task.RejectionMaxMass(numbers, out max, out reject);
            Assert.AreEqual(-1, max);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], reject[i]);
            }
        }
Example #15
0
        public void RejectionMaxMass2()
        {
            TaskMethods task = new TaskMethods();

            int[] numbers  = new int[] { 5, 4, 3, 2, 1 };
            int[] expected = new int[] { 0, 1, 2, 3, 4 };
            int   max;

            int[] reject;
            task.RejectionMaxMass(numbers, out max, out reject);
            Assert.AreEqual(5, max);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], reject[i]);
            }
        }
Example #16
0
        public JsonResult Get_TaskDetail(string TaskID)
        {
            string DealerCode = Session["DealerCode"].ToString();

            string data   = "";
            bool   result = false;

            data = TaskMethods.Get_TaskMasterDetail(TaskID, DealerCode);

            if (!string.IsNullOrEmpty(data))
            {
                result = true;
            }

            return(Json(new { Success = result, Response = data }, JsonRequestBehavior.AllowGet));
        }
Example #17
0
        private static MethodBuilder CreateEncodeDeferredMethod(HandlerClassBuildingContext classContext, Type pureRetvalType)
        {
            const int taskArgIndex = 1;

            var methodBuilder = classContext.Builder.DefineMethod("EncodeDeferred",
                                                                  MethodAttributes.Private | MethodAttributes.Final | MethodAttributes.HideBySig | MethodAttributes.NewSlot,
                                                                  typeof(byte[]), new[] { typeof(Task <>).MakeGenericType(pureRetvalType) });

            var il = new MyILGenerator(methodBuilder.GetILGenerator());
            var emittingContext = new HandlerMethodEmittingContext(il, classContext.Fields);

            il.Ldarg(taskArgIndex);
            il.Call(TaskMethods.GetResult(pureRetvalType));
            EmitEncodeDirect(emittingContext, new HandlerParameterCodec[0], pureRetvalType);
            il.Ret();
            return(methodBuilder);
        }
Example #18
0
 // Get a particular object from this dictionary.
 public Object this[Object key]
 {
     get
     {
         String keyName = key.ToString();
         if (keyName != null)
         {
             return(TaskMethods.GetEnvironmentVariable(keyName));
         }
         else
         {
             throw new ArgumentNullException("key");
         }
     }
     set
     {
         throw new NotSupportedException(_("NotSupp_ReadOnly"));
     }
 }
Example #19
0
        private void EmitProcessAsyncWithRetval(ProxyClassBuildingContext classContext, IEmittingContext emittingContext, string parameterMethodName, IReadOnlyList <Type> genericTypeArguments, Type retvalType)
        {
            var pureRetvalType       = retvalType.GetGenericArguments().Single();
            var decodeDeferredMethod = CreateDecodeDeferredMethod(classContext, parameterMethodName, genericTypeArguments, pureRetvalType);

            if (decodeDeferredMethod.IsGenericMethodDefinition)
            {
                decodeDeferredMethod = decodeDeferredMethod.MakeGenericMethod(genericTypeArguments.ToArray());
            }
            var funcConstructor    = FuncMethods.Constructor(typeof(Task <byte[]>), pureRetvalType);
            var continueWithMethod = TaskMethods.ContinueWith(typeof(byte[]), pureRetvalType);

            var il = emittingContext.IL;

            il.Callvirt(OutgoingRequestProcessorMethods.ProcessAsync);
            il.Ldarg(0);
            il.Ldftn(decodeDeferredMethod);
            il.Newobj(funcConstructor);
            il.Callvirt(continueWithMethod);
        }
Example #20
0
        public void ExchangeMaxMinRows1()
        {
            TaskMethods task = new TaskMethods();

            double[,] table = new double[, ] {
                { 0, 1, 2, 3 }, { -1, 3, 6, 3 }, { 10, 7, 5, 6 }
            };
            double[,] changedTable;
            double[,] expected = new double[, ] {
                { 0, 1, 2, 3 }, { 10, 7, 5, 6 }, { -1, 3, 6, 3 }
            };

            task.ExchangeMaxMinRows(table, out changedTable);
            for (int i = 0; i < table.GetLength(0); i++)
            {
                for (int j = 0; j < table.GetLength(1); j++)
                {
                    Assert.AreEqual(expected[i, j], changedTable[i, j]);
                }
            }
        }
Example #21
0
        //Событие, в котором генерируется массив, после чего находится максимальное значение и отклонения.
        private void GenerateAnswer_Click(object sender, EventArgs e)
        {
            originalMass.Clear();
            answer.Clear();
            TaskMethods task = new TaskMethods();

            minNumber = rnd.Next(-100, -1);
            maxNumber = rnd.Next(0, 100);
            sizeMass  = rnd.Next(3, 8);
            int[] mass = new int[sizeMass];
            for (int i = 0; i < (int)sizeMass; i++)
            {
                mass[i]            = rnd.Next((int)minNumber, (int)maxNumber);
                originalMass.Text += mass[i] + " ";
            }
            task.RejectionMaxMass(mass, out max, out rejections);
            answerMaxNumber.Text = max.ToString();
            for (int i = 0; i < sizeMass; i++)
            {
                answer.Text += rejections[i].ToString() + " ";
            }
        }
Example #22
0
    static void Main()
    {
        MatchCollection matchesData = Regex.Matches(TaskMethods.ReadFile("data/FC1155SMI.txt"), dataTypeRGXverOne, RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.CultureInvariant);

        var dataTypes = new List <DataType>();

        foreach (Match match in matchesData)
        {
            string dataTypeName = match.Groups[1].Value.RemoveSpecialCharacter();
            string typeName     = match.Groups[2].Value.RemoveSpecialCharacter();
            string typeID       = match.Groups[3].Value.RemoveSpecialCharacter();
            string visibility   = match.Groups[4].Value.RemoveSpecialCharacter();
            string parentType   = match.Groups[5].Value.RemoveSpecialCharacter();
            string restirctions = match.Groups[6].Value.RemoveSpecialCharacter();

            var dataType = new DataType()
            {
                Name       = typeName,
                Visibility = TaskMethods.ToVisibility(typeName),
                Keyword    = TaskMethods.ToKeyword(visibility)
            };
            dataTypes.Add(dataType);
        }



        MatchCollection matches = Regex.Matches(TaskMethods.ReadFile("data/MIB.txt"), rgxPro, RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.CultureInvariant);


        List <Leaf> listOfLeafs = new List <Leaf>();


        foreach (Match match in matches)
        {
            //string name = match.Groups[1].Value.Trim().Replace("\r", "").Replace("\n", "");
            //string syntax = match.Groups[2].Value.Trim().Replace("\r", "").Replace("\n", "");
            //string access = match.Groups[3].Value.Trim().Replace("\r", "").Replace("\n", "");
            //string status = match.Groups[4].Value.Trim().Replace("\r", "").Replace("\n", "");
            string name   = match.Groups[1].Value.RemoveSpecialCharacter();
            string syntax = match.Groups[2].Value.RemoveSpecialCharacter();
            string access = match.Groups[3].Value.RemoveSpecialCharacter();
            string status = match.Groups[4].Value.RemoveSpecialCharacter();

            //Descirption
            string desc = match.Groups[5].Value.RemoveSpecialCharacter();
            do
            {
                desc = desc.Replace("  ", " ");
            } while (desc.Contains("  "));



            Leaf leaf = new Leaf()
            {
                ObjectType  = name,
                Status      = TaskMethods.ToStatus(status),
                Access      = TaskMethods.ToAccess(access),
                Description = desc
            };
            listOfLeafs.Add(leaf);
            //{
            //    leafData = leafData.Replace("  ", " ");
            //}



            //for (int i = 1; i < match.Groups.Count; i++)
            //{
            //    Console.WriteLine(match.Groups[i].Value.Trim().Replace("\r", "").Replace("\n", ""));
            //}

            //{

            //}

            //string leafData = match.Value.Trim().Replace("\r", "").Replace("\n", "");
            //while(leafData.Contains("  "))
            //{
            //    leafData = leafData.Replace("  ", " ");
            //}
            //int objectEnd = leafData.IndexOf("OBJECT-TYPE");
            //string objecttype = leafData.Substring(0, leafData.IndexOf("OBJECT-TYPE")).Trim();
            //leafData = leafData.Remove(0, leafData.IndexOf("SYNTAX");
            //int syntaxPos = leafData.IndexOf("SYNTAX".Length + "SYNTAX".Length;
            //string syntax = leafData.Substring(syntaxPos, leafData.IndexOf("STATUS")-syntaxPos);
        }

        Console.ReadKey();
    }
Example #23
0
        static void Main(string[] args)
        {
            bool           exit = true;
            ConsoleKeyInfo key;

            while (exit)
            {
                Console.Clear();
                Console.WriteLine("Выберите задание");
                key = Console.ReadKey();
                Console.WriteLine();
                switch (key.KeyChar)
                {
                case '1':
                {
                    Console.WriteLine("Введите нужное количество точек:");
                    point[] point_arr = new point[Convert.ToInt32(Console.ReadLine())];
                    for (int i = 0; i < point_arr.Length; i++)
                    {
                        Console.WriteLine("Точка {0}", i + 1);
                        Console.Write("x="); point_arr[i].x_coord = Convert.ToDouble(Console.ReadLine());
                        Console.Write("y="); point_arr[i].y_coord = Convert.ToDouble(Console.ReadLine());
                    }
                    TaskMethods.MaxPointsLenght(point_arr);
                    Console.ReadKey();
                    break;
                }

                case '2':
                {
                    Console.WriteLine("Сколько слов вы хотите ввести?");
                    string[] arr_words = new string[Convert.ToInt32(Console.ReadLine())];
                    for (int i = 0; i < arr_words.Length; i++)
                    {
                        Console.Write("Введите слово {0}:", i + 1);
                        arr_words[i] = Console.ReadLine();
                    }
                    int Count;
                    Console.WriteLine("Слово с наибольшим количеством гласных {0}, их количество {1}", TaskMethods.MaxVowelCount(arr_words, out Count), Count);
                    Console.ReadKey();
                    break;
                }

                case '3':
                {
                    Console.WriteLine("Cколько чисел вы хотите ввести?");
                    Int64[] arr_numbers = new Int64[Convert.ToInt32(Console.ReadLine())];
                    for (int i = 0; i < arr_numbers.Length; i++)
                    {
                        Console.Write("Введите число {0}:", i + 1);
                        arr_numbers[i] = Convert.ToInt64(Console.ReadLine());
                    }
                    for (int i = 0; i < arr_numbers.Length; i++)
                    {
                        Console.WriteLine("Число {0} на позиции {1} имеет сумму чисел {2}", arr_numbers[i], i + 1, Task2Var.SumNumbers(arr_numbers[i]));
                    }
                    Console.ReadKey();
                    break;
                }

                case '4':
                {
                    Console.WriteLine("Введите m, n, k, a");
                    Console.WriteLine("Результат функции  {0}", TaskMethods.SolveFunction(Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), Convert.ToDouble(Console.ReadLine()), Convert.ToInt32(Console.ReadLine())));
                    Console.ReadKey();
                    break;
                }

                case '5':
                {
                    double[] points  = new double[4];
                    string   letters = "abcd";
                    for (int i = 0; i < points.Length; i++)
                    {
                        Console.WriteLine("Введите длину отрезка {0}", letters[i]);
                        points[i] = Convert.ToDouble(Console.ReadLine());
                    }
                    TaskMethods.TriangleSquare(points);
                    Console.ReadKey();
                    break;
                }

                case '6':
                {
                    Console.WriteLine("Введите число, факториал которого вы хотите найти:");
                    Console.WriteLine("Результат - {0}", TaskMethods.fact(Convert.ToInt32(Console.ReadLine())));
                    Console.ReadKey();
                    break;
                }

                default:

                    break;
                }
            }
        }
Example #24
0
 // Exit from the current process.
 public static void Exit(int exitCode)
 {
     TaskMethods.Exit(exitCode);
 }
Example #25
0
 // Constructor.
 public EnvironmentEnumerator()
 {
     posn  = -1;
     count = TaskMethods.GetEnvironmentCount();
 }