Пример #1
0
        public MetaAttributeCollection Clone()
        {
            MetaAttributeCollection clonedMetaAttribute = new MetaAttributeCollection(itemCount);

            foreach (MetaAttribute item in this)
            {
                clonedMetaAttribute.Add(item);
            }
            return(clonedMetaAttribute);
        }
Пример #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();
        }
Пример #3
0
        public ModelClass(XmlTextReader r, string version)
        {
            extended = new Dictionary <Type, ModelClassExtension>();

            // BE SURE TO CREATE SYSTEM FOLDER!

            if (r.Name != "ClassObject")
            {
                throw new Exception(string.Format("Source file does not match NitroCast DTD; " +
                                                  "expected 'ClassModel', found '{0}'.", r.Name));
            }

            r.MoveToAttribute("Name");
            name = r.Value;
            r.MoveToAttribute("NameSpace");
            _namespace = r.Value;
            r.MoveToContent();
            r.Read();

            outputpath = r.ReadElementString("OutputPath");
            if (r.Name == "WebOutputPath")
            {
                webOutputPath = r.ReadElementString("WebOutputPath");
            }
            defaultTableName = r.ReadElementString("DefaultTableName");
            isTableCoded     = bool.Parse(r.ReadElementString("DefaultTableNameHardCoded"));
            caption          = r.ReadElementString("Caption");
            description      = r.ReadElementString("Description");
            summary          = r.ReadElementString("Summary");

            if (r.Name == "IsCachingEnabled")
            {
                isCachingEnabled = bool.Parse(r.ReadElementString("IsCachingEnabled"));
            }
            if (r.Name == "CacheClass")
            {
                cacheClass = r.ReadElementString("CacheClass");
            }
            if (r.Name == "CacheName")
            {
                cacheName = r.ReadElementString("CacheName");
            }
            if (r.Name == "AspNetCachingEnabled")
            {
                isCachingEnabled = bool.Parse(r.ReadElementString("AspNetCachingEnabled"));
            }
            if (r.Name == "CacheLifetime")
            {
                cacheLifetime = TimeSpan.Parse(r.ReadElementString("CacheLifetime"));
            }
            if (r.Name == "IsCollectionCachingEnabled")
            {
                isCollectionCachingEnabled = bool.Parse(r.ReadElementString("IsCollectionCachingEnabled"));
            }
            if (r.Name == "CollectionCacheLifetime")
            {
                collectionCacheLifetime = TimeSpan.Parse(r.ReadElementString("CollectionCacheLifetime"));
            }
            if (r.Name == "LockType")
            {
                concurrency = (ConcurrencyType)Enum.Parse(typeof(ConcurrencyType), r.ReadElementString("LockType"), true);
            }
            if (r.Name == "Concurrency")
            {
                concurrency = (ConcurrencyType)Enum.Parse(typeof(ConcurrencyType), r.ReadElementString("Concurrency"), true);
            }
            if (r.Name == "IsThreadSafe")
            {
                isThreadSafe = bool.Parse(r.ReadElementString("IsThreadSafe"));
            }
            if (r.Name == "IsCreateDateEnabled")
            {
                r.ReadElementString("IsCreateDateEnabled");
            }
            if (r.Name == "IsModifyDateEnabled")
            {
                r.ReadElementString("IsModifyDateEnabled");
            }
            if (r.Name == "Interfaces")
            {
                interfaces = r.ReadElementString("Interfaces");
            }
            if (r.Name == "ToStringOverride")
            {
                toStringOverride = r.ReadElementString("ToStringOverride");
            }
            if (r.Name == "SimpleQueryEnabled")
            {
                simpleQueryEnabled = bool.Parse(r.ReadElementString("SimpleQueryEnabled"));
            }

            #region Obsolete Code

            // Place old version of fields data in data folder
            if (r.Name == "Fields")
            {
                // Make sure there is a default folder!
                if (folders.Count == 0)
                {
                    ClassFolder defaultFolder = new ClassFolder("Default");
                    defaultFolder.ParentClass = this;
                    folders.Add(defaultFolder);
                }

                if (!r.IsEmptyElement)
                {
                    r.Read();
                    while (r.LocalName == "FieldEntry")
                    {
                        ValueField field = new ValueField(r, version);
                        field.ParentFolder = folders[0];
                        folders[0].Items.Add(field);
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            // Place old version of children data in data folder
            if (r.Name == "Children")
            {
                // Make sure there is a default folder!
                if (folders.Count == 0)
                {
                    ClassFolder defaultFolder = new ClassFolder("Default");
                    folders.Add(defaultFolder);
                }

                if (!r.IsEmptyElement)
                {
                    r.Read();
                    while (r.LocalName == "ChildEntry")
                    {
                        ReferenceField field = new ReferenceField(r, version);
                        field.ParentFolder = folders[0];
                        folders[0].Items.Add(field);
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            #endregion

            if (r.Name == "ClassFolders")
            {
                if (!r.IsEmptyElement)
                {
                    r.Read();
                    while (r.LocalName == "ClassFolder")
                    {
                        ClassFolder folder = new ClassFolder(r, version);
                        folder.ParentClass = this;
                        folders.Add(folder);
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            if (r.Name == "OutputPlugins")
            {
                if (!r.IsEmptyElement)
                {
                    r.Read();
                    while (r.LocalName == "ClassOutputConnector")
                    {
                        outputConnectors.Add(new OutputExtensionConnector(r, this));
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            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")
                    {
                        ModelClassExtension newExtension = (ModelClassExtension)
                                                           ObjectExtension.Build(r, version);
                        extended.Add(newExtension.GetType(), newExtension);
                    }

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

            r.ReadEndElement();

            EnsureSystemFolderExists();
        }
Пример #4
0
        public ModelEnum(XmlTextReader r, string version) : this()
        {
            if (r.Name != "EnumObject")
            {
                throw new Exception(string.Format("Cannot load, expected " +
                                                  "EnumObject, found '{0}'.", r.Name));
            }

            r.MoveToAttribute("Name");
            name = r.Value;
            r.MoveToAttribute("NameSpace");
            nameSpace = r.Value;
            r.MoveToContent();
            r.Read();

            underlyingType = (ModelEnumUnderlyingType)
                             Enum.Parse(typeof(ModelEnumUnderlyingType),
                                        r.ReadElementString("UnderlyingType"));

            if (r.Name == "EnumItems" && !r.IsEmptyElement)
            {
                r.Read();
                while (r.LocalName == "EnumItem" && !r.IsEmptyElement)
                {
                    items.Add(new EnumItem(r, version));
                }
                r.ReadEndElement();
            }

            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")
                    {
                        ModelEnumExtension newExtension = (ModelEnumExtension)
                                                          ObjectExtension.Build(r, version);
                        extended.Add(newExtension.GetType(), newExtension);
                    }

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

            r.ReadEndElement();
        }
Пример #5
0
        public ReferenceField(XmlTextReader r, string version) : this()
        {
            string refTypeName;
            string refTypeNameSpace;

            if (r.Name != "ChildEntry")
            {
                throw new Exception(string.Format("Cannot load, expected ChildEntry, found '{0}'.",
                                                  r.Name));
            }

            r.MoveToAttribute("PropertyName");
            this.Name = r.Value;
            r.MoveToContent();
            r.Read();

            CustomPrivateName = string.Empty;
            r.ReadElementString("CustomPrivateName");
            CustomColumnName = string.Empty;
            r.ReadElementString("CustomColumnName");
            refTypeName = r.ReadElementString("DataType");
            if (r.Name == "Builder")
            {
                ReferenceTypeBuilder.Builders.TryGetValue(r.ReadElementString("Builder"), out builder);
            }
            refTypeNameSpace = r.ReadElementString("DataTypeNameSpace");
            if (r.LocalName == "AllowNull")
            {
                allowNull = bool.Parse(r.ReadElementString("AllowNull"));
            }
            Caption      = r.ReadElementString("Caption");
            Description  = r.ReadElementString("Description");
            isTableCoded = bool.Parse(r.ReadElementString("IsTableCoded"));
            tableName    = r.ReadElementString("TableName");
            isUnique     = bool.Parse(r.ReadElementString("IsUnique"));
            refMode      = ParseChildEntryType(r.ReadElementString("ChildEntryType"));
            if (r.LocalName == "Group")
            {
                group = r.ReadElementString("Group");
            }
            if (r.LocalName == "CascadeSaveEnabled")
            {
                cascadeSaveEnabled = bool.Parse(r.ReadElementString("CascadeSaveEnabled"));
            }
            else
            {
                cascadeSaveEnabled = true;
            }
            if (r.LocalName == "EnableCache")
            {
                enableCache = bool.Parse(r.ReadElementString("EnableCache"));
            }
            else
            {
                enableCache = false;
            }
            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.LocalName == "IsClientCollectionAddEnabled")
            {
                isClientCollectionAddEnabled = bool.Parse(r.ReadElementString("IsClientCollectionAddEnabled"));
            }
            if (r.LocalName == "IsClientCollectionDeleteEnabled")
            {
                isClientCollectionDeleteEnabled = bool.Parse(r.ReadElementString("IsClientCollectionDeleteEnabled"));
            }
            if (r.LocalName == "IsClientCollectionEditEnabled")
            {
                isClientCollectionEditEnabled = bool.Parse(r.ReadElementString("IsClientCollectionEditEnabled"));
            }

            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")
                    {
                        ReferenceFieldExtension newExtension = (ReferenceFieldExtension)
                                                               ObjectExtension.Build(r, version);
                        extensions.Add(newExtension.GetType(), newExtension);
                    }

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

            r.ReadEndElement();

            // Create datatype
            refType = new ReferenceType(refTypeName, refTypeNameSpace);
        }