public ConfigFactoryElementReader(DynamicElementAttribute attr,
                                   ObjectPropertyInfo info, string modelName)
 {
     fModelName      = modelName;
     fObjectInfo     = info;
     fConfigData     = attr.PlugInFactory.ConfigData;
     fOrder          = attr.Order;
     fMultiple       = attr.IsMultiple;
     fCollectionType = attr.CollectionType;
     fRequired       = attr.Required;
     PropertyName    = info.PropertyName;
     fUseJsonObject  = attr.UseJsonObject;
 }
示例#2
0
        internal ObjectElementAttribute ConvertTo(string localName, Type objectType,
                                                  DynamicElementAttribute dynamic)
        {
            ObjectElementAttribute attr = new ObjectElementAttribute(NamespaceType)
            {
                LocalName      = localName,
                ObjectType     = objectType,
                UseConstructor = UseConstructor,
                Order          = dynamic.Order,
                IsMultiple     = dynamic.IsMultiple,
                CollectionType = dynamic.CollectionType
            };

            if (NamespaceType == NamespaceType.Namespace)
            {
                attr.NamespaceUri = NamespaceUri;
            }

            return(attr);
        }
示例#3
0
        internal void ReadElementAttribute(Type type, PropertyInfo property, string modelName,
                                           object[] propertyAttributes)
        {
            object dynamicAttribute = (from attr in propertyAttributes
                                       where attr is DynamicElementAttribute
                                       select attr).FirstOrDefault();

            if (dynamicAttribute != null)
            {
                DynamicElementAttribute attribute = dynamicAttribute as DynamicElementAttribute;
                BaseXmlConfigFactory    factory   = attribute.PlugInFactory;
                if (fXmlConfigFactories == null)
                {
                    fXmlConfigFactories = new Dictionary <string, BaseXmlConfigFactory>();
                }
                if (!fXmlConfigFactories.ContainsKey(factory.Name))
                {
                    fXmlConfigFactories.Add(factory.Name, factory);
                }
                //factory.AddElements(this, type, property, modelName, attribute);
                ReflectorObjectPropertyInfo objInfo = new ReflectorObjectPropertyInfo(property, attribute, modelName);
                var dyn = new ConfigFactoryElementReader(attribute, objInfo, modelName);
                fMultiElements.Add(dyn);
                fElementWriter.Add(dyn);
            }
            else
            {
                //foreach (var attr in propertyAttributes)
                //{
                //    if (attr is BaseDictionaryAttribute)
                //        InternalAdd(type, property, attr as NamedAttribute, modelName);
                //    else
                //    {
                //        SimpleElementAttribute eleAttr = attr as SimpleElementAttribute;
                //        if (eleAttr != null)
                //            AddAttribute(eleAttr, type, property, modelName);
                //    }
                //}

                var objElemAttrs = (from item in propertyAttributes
                                    where item is ObjectElementAttribute
                                    select(ObjectElementAttribute) item).ToArray();
                if (objElemAttrs.Length == 0)
                {
                    foreach (var attr in propertyAttributes)
                    {
                        if (attr is BaseDictionaryAttribute)
                        {
                            AddSingleAttrible(type, property, attr as NamedAttribute, modelName);
                        }
                        else
                        {
                            SimpleElementAttribute eleAttr = attr as SimpleElementAttribute;
                            if (eleAttr != null)
                            {
                                AddSingleAttrible(type, property, eleAttr, modelName);
                            }
                        }
                    }
                }
                else if (objElemAttrs.Length == 1)
                {
                    AddSingleAttrible(type, property, objElemAttrs[0], modelName);
                }
                else
                {
                    var multi = new MultipleElementReader(property, modelName, objElemAttrs);
                    fMultiElements.Add(multi);
                    fElementWriter.Add(multi);
                }
            }
        }