示例#1
0
        public void AddTest()
        {
            BigInt  xE = new BigInt("35220081ee207cc2b5b7b40bbd947eaa7ebe25227a4baa74b5a20b9eb5f2cc9b36cb7db24e6788d062b7a918f7d15f7c37242ddc8e1a1866e7f13bee0f6cd679", 16);
            BigInt  yE = new BigInt("5dbc39aeb9c97ace09e0dd7e0ee7716696d174bef72ec3d92d56122a4bbafe3fe6cf8a4606ebecde9ee2037b1e5e3b10cdb8422cf2453c8eb1c214d9fa791ac1", 16);
            Complex e  = new Complex(field, xE, yE);

            Assert.AreEqual(e, f.Add(a, b));
        }
示例#2
0
        private static ComplexField ElementToComplexField(XmlElement fieldElm, string fieldId, string fieldName)
        {
            if (fieldElm == null)
            {
                return(null);
            }
            ComplexField complexField = (ComplexField)SchemaFactory.CreateField(FieldTypeEnum.COMPLEX);

            complexField.Id   = fieldId;
            complexField.Name = fieldName;
            XmlElement fieldsEle = XmlUtils.GetChildElement(fieldElm, "fields");

            if (fieldsEle != null)
            {
                List <XmlElement> fieldEleList = XmlUtils.GetChildElements(fieldsEle, "field");
                foreach (XmlElement subFieldEle in fieldEleList)
                {
                    Field fieldFromEle = ElementToField(subFieldEle);
                    complexField.Add(fieldFromEle);
                }
            }
            //rules
            XmlElement rulesEle = XmlUtils.GetChildElement(fieldElm, "rules");

            if (rulesEle != null)
            {
                List <XmlElement> ruleEleList = XmlUtils.GetChildElements(rulesEle, "rule");
                foreach (XmlElement ruleEle in ruleEleList)
                {
                    Rule rule = ElementToRule(ruleEle, complexField.Id);
                    complexField.Add(rule);
                }
            }
            //property
            XmlElement propertiesEle = XmlUtils.GetChildElement(fieldElm, "properties");

            if (propertiesEle != null)
            {
                List <XmlElement> propertyEleList = XmlUtils.GetChildElements(propertiesEle, "property");
                foreach (XmlElement propertyEle in propertyEleList)
                {
                    Property.Property property = ElementToProperty(propertyEle, complexField.Id);
                    complexField.Add(property);
                }
            }
            //default-complex-value
            XmlElement defaultComplexValueEle = XmlUtils.GetChildElement(fieldElm, "default-complex-values");

            if (defaultComplexValueEle != null)
            {
                List <XmlElement> defaultValuesSubFieldList = XmlUtils.GetChildElements(defaultComplexValueEle, "field");
                ComplexValue      defaultCvalue             = new ComplexValue();
                foreach (XmlElement subFiledValueEle in defaultValuesSubFieldList)
                {
                    Field field = ElementToField(subFiledValueEle);
                    defaultCvalue.Put(field);
                }
                complexField.SetDefaultValue(defaultCvalue);
            }
            //complex-value
            XmlElement complexValueEle = XmlUtils.GetChildElement(fieldElm, "complex-values");

            if (complexValueEle != null)
            {
                List <XmlElement> valuesSubFieldList = XmlUtils.GetChildElements(complexValueEle, "field");
                ComplexValue      cvalue             = new ComplexValue();
                foreach (XmlElement subFiledValueEle in valuesSubFieldList)
                {
                    Field field = ElementToField(subFiledValueEle);
                    cvalue.Put(field);
                }
                complexField.SetComplexValue(cvalue);
            }
            return(complexField);
        }