Beispiel #1
0
 public void AddExtensions(ValueField field)
 {
     foreach (OutputExtension extension in outputExtensions.Values)
     {
         if (extension.ValueFieldExtensionType != null)
         {
             if (!field.extensions.ContainsKey(extension.ValueFieldExtensionType))
             {
                 ValueFieldExtension newExtension = (ValueFieldExtension)
                                                    Activator.CreateInstance(
                     extension.ValueFieldExtensionType);
                 field.extensions.Add(newExtension.GetType(), newExtension);
             }
         }
     }
 }
Beispiel #2
0
        public ValueField(XmlTextReader r, string version) : this()
        {
            if (r.Name != "FieldEntry")
            {
                throw new Exception(string.Format("Cannot load, expected FieldEntry, found '{0}'.",
                                                  r.Name));
            }

            r.MoveToAttribute("PropertyName");
            this.Name = r.Value;
            r.MoveToAttribute("CustomPrivateName");
            //this.customPrivateName = r.Value;
            CustomPrivateName = string.Empty;
            r.MoveToAttribute("CustomColumnName");
            //this.customColumnName = r.Value;
            CustomColumnName = string.Empty;
            r.MoveToContent();
            r.Read();

            valueType = DataTypeManager.FindFieldType(r.ReadElementString("DataType"));
            if (r.Name == "Builder")
            {
                ValueTypeBuilder.Builders.TryGetValue(r.ReadElementString("Builder"), out builder);
            }

            length            = int.Parse(r.ReadElementString("Length"));
            defaultFormat     = r.ReadElementString("DefaultFormat");
            defaultValue      = r.ReadElementString("DefaultValue");
            Caption           = r.ReadElementString("Caption");;
            Description       = r.ReadElementString("Description");
            validatorRequired = bool.Parse(r.ReadElementString("ValidatorRequired"));
            validatorRegEx    = r.ReadElementString("ValidatorRegEx");
            validatorError    = r.ReadElementString("ValidatorError");
            isNullable        = bool.Parse(r.ReadElementString("IsNullable"));
            if (r.LocalName == "NullValue")
            {
                nullValue = r.ReadElementString("NullValue");
            }
            if (r.LocalName == "UseDefaultValueOnNull")
            {
                useDefaultValueOnNull = bool.Parse(r.ReadElementString("UseDefaultValueOnNull"));
            }
            if (r.LocalName == "IsIndexed")
            {
                isIndexed = bool.Parse(r.ReadElementString("IsIndexed"));
            }
            if (r.LocalName == "IsUnique")
            {
                isUnique = bool.Parse(r.ReadElementString("IsUnique"));
            }
            if (r.LocalName == "Group")
            {
                group = r.ReadElementString("Group");
            }
            if (r.LocalName == "IsClientGridEnabled")
            {
                isClientGridEnabled = bool.Parse(r.ReadElementString("IsClientGridEnabled"));
            }
            if (r.LocalName == "IsClientEditEnabled")
            {
                isClientEditEnabled = bool.Parse(r.ReadElementString("IsClientEditEnabled"));
            }
            if (r.LocalName == "IsClientViewEnabled")
            {
                isClientViewEnabled = bool.Parse(r.ReadElementString("IsClientViewEnabled"));
            }

            if (r.Name == "MetaAttributes")
            {
                if (!r.IsEmptyElement)
                {
                    r.Read();
                    while (r.LocalName == "MetaAttribute")
                    {
                        attributes.Add(new MetaAttribute(r));
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }


            if (r.Name == "Extensions")
            {
                if (!r.IsEmptyElement)
                {
                    r.Read();

                    while (r.Name == "Extension")
                    {
                        ValueFieldExtension newExtension = (ValueFieldExtension)
                                                           ObjectExtension.Build(r, version);
                        extensions.Add(newExtension.GetType(), newExtension);
                    }

                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            r.ReadEndElement();
        }