private static TemplateSerial createComposite(
            Object _value, bool _isKey, String _field, bool _isComparator)
        {
            if (_isComparator)
            {
                if (_value is IComparer)
                {
                    ComparatorSerial serializableFieldBis_ = new ComparatorSerial((IComparer)_value);
                    serializableFieldBis_.setKeyOfMap(_isKey);
                    serializableFieldBis_.setField(_field);
                    return(serializableFieldBis_);
                }
                return(null);
            }
            if (_value.GetType().IsArray)
            {
                ArraySerial serializableFieldTer_ = new ArraySerial((Array)_value);
                serializableFieldTer_.setKeyOfMap(_isKey);
                serializableFieldTer_.setField(_field);
                return(serializableFieldTer_);
            }
            ObjectSerial serializableField_ = new ObjectSerial(_value);

            serializableField_.setKeyOfMap(_isKey);
            serializableField_.setField(_field);
            return(serializableField_);
        }
Exemplo n.º 2
0
        public static ObjectSerial newSerial(XmlNode _node, bool _requiredClass)
        {
            XmlNamedNodeMap map_    = _node.Attributes;
            ObjectSerial    serial_ = new ObjectSerial();

            if (_requiredClass)
            {
                XmlNode className_ = map_.GetNamedItem(CLASS);
                if (className_ != null)
                {
                    serial_.setClassName(className_.Value);
                }
            }
            XmlNode types_    = map_.GetNamedItem(TYPES);
            string  typesStr_ = "";

            if (types_ != null)
            {
                typesStr_ = types_.Value;
            }
            Type class_ = Constants.classForName(_node.Name, typesStr_);

            serial_.types = class_.GetGenericArguments();
            ConstructorInfo constr_ = class_.GetConstructor(new Type[] { });
            //		constr_.setAccessible(class_.getAnnotation(RwXml.class)!=null);
            //constr_.setAccessible(constr_.getAnnotation(RwXml.class)!=null);
            XmlNode field_ = map_.GetNamedItem(FIELD);

            if (field_ != null)
            {
                serial_.setField(field_.Value);
            }
            XmlNode keyOfMap_ = map_.GetNamedItem(KEY);

            if (keyOfMap_ != null)
            {
                serial_.setKeyOfMap(true);
            }
            try {
                serial_.value = constr_.Invoke(new object[] { });
                //} catch (IllegalArgumentException e) {
                //} catch (IllegalAccessException e) {
                //   e.printStackTrace();

                /*} catch (InstantiationException e) {
                 *      throw e;*/
            } catch (TargetInvocationException e) {
                throw e;
            }
            return(serial_);
        }