コード例 #1
0
 public void AddItemsToCart()
 {
     JavaField.SendKeys("1" + Keys.Enter);
     RubyField.SendKeys("2");
     PythonField.SendKeys("1");
     AddButton.Click();
 }
コード例 #2
0
        public static void MapAttributesToGraph(PythonGraph pythonGraph, AttributeWalker projectAttributes)
        {
            var typeDictionary = new CsPyMapperDictionary();

            // Add core Python types

            AddCorePythonTypes(pythonGraph, typeDictionary);

            // Add custom Python types

            foreach (var entry in projectAttributes.ClassAttributes)
            {
                var target    = entry.Key;
                var attribute = entry.Value;

                var pythonClass = pythonGraph.GetOrAddModule(attribute.ModuleName).GetOrAddClass(attribute.ClassName);
                typeDictionary[target] = pythonClass;
            }

            // Add fields

            foreach (var entry in projectAttributes.FieldAttributes)
            {
                var target    = entry.Key;
                var attribute = entry.Value;

                var pythonClass = typeDictionary[target.ContainingType];
                var fieldName   = attribute.Name ?? target.Name;
                var fieldType   = typeDictionary.GetPythonType(target.Type);

                var pythonField = PythonField.Create(fieldName, fieldType);
                pythonClass.Children.Add(fieldName, pythonField);
            }

            // Add methods

            foreach (var entry in projectAttributes.MethodAttributes)
            {
                var target    = entry.Key;
                var attribute = entry.Value;

                MapPythonFunction(target, attribute.Function, typeDictionary);
            }

            // Add operators

            foreach (var entry in projectAttributes.OperatorAttributes)
            {
                var target    = entry.Key;
                var attribute = entry.Value;

                MapPythonFunction(target, $"@operator.{attribute.Operator}", typeDictionary);
            }

            // Add properties

            foreach (var entry in projectAttributes.PropertyAttributes)
            {
                var target    = entry.Key;
                var attribute = entry.Value;

                var pythonClass  = typeDictionary[target.ContainingType];
                var propertyName = attribute.Name ?? target.Name;
                var propertyType = typeDictionary.GetPythonType(target.Type);

                var pythonProperty = PythonProperty.Create(propertyName, propertyType);

                if (target.GetMethod != null)
                {
                    var getterName = attribute.GetterFunction ?? propertyName;
                    var parameters = new[] { new PythonParameter("self", new PythonType(pythonClass)) };
                    pythonProperty.GetterFunction = PythonFunction.Create(getterName, propertyType, parameters);
                }

                if (target.SetMethod != null)
                {
                    var setterName = attribute.SetterFunction ?? propertyName;
                    var parameters = new[] { new PythonParameter("self", new PythonType(pythonClass)),
                                             new PythonParameter("value", propertyType) };
                    pythonProperty.SetterFunction = PythonFunction.Create(setterName, PythonTypes.None, parameters);
                }

                pythonClass.Children.Add(propertyName, pythonProperty);
            }
        }
コード例 #3
0
 public void clearFields()
 {
     JavaField.Clear();
     RubyField.Clear();
     PythonField.Clear();
 }