示例#1
0
        public ValueField Clone()
        {
            ValueField f = new ValueField();

            if (f.attributes != null)
            {
                f.attributes = attributes.Clone();
            }

            f.valueType        = valueType;
            f.Name             = Name;
            f.CustomColumnName = CustomPrivateName;
            f.CustomColumnName = CustomColumnName;

            f.length            = length;
            f.defaultFormat     = defaultFormat;
            f.defaultValue      = defaultValue;
            f.Caption           = Caption;
            f.Description       = Description;
            f.validatorError    = validatorError;
            f.validatorRegEx    = validatorRegEx;
            f.validatorRequired = validatorRequired;
            f.isIndexed         = isIndexed;
            f.isNullable        = isNullable;
            f.isUnique          = isUnique;
            f.group             = group;

            return(f);
        }
        public void Remove(ValueField value)
        {
            int index = IndexOf(value);

            if (index == -1)
            {
                throw(new Exception("FieldEntry not found in collection."));
            }
            RemoveAt(index);
        }
 public int IndexOf(ValueField value)
 {
     for (int x = 0; x < itemCount; x++)
     {
         if (FieldEntryArray[x].Equals(value))
         {
             return(x);
         }
     }
     return(-1);
 }
 public void Insert(int index, ValueField value)
 {
     itemCount++;
     if (itemCount > FieldEntryArray.Length)
     {
         for (int x = index + 1; x == itemCount - 2; x++)
         {
             FieldEntryArray[x] = FieldEntryArray[x - 1];
         }
     }
     FieldEntryArray[index] = value;
 }
 public int Add(ValueField value)
 {
     itemCount++;
     if (itemCount > FieldEntryArray.GetUpperBound(0) + 1)
     {
         ValueField[] tempFieldEntryArray = new ValueField[itemCount * 2];
         for (int x = 0; x <= FieldEntryArray.GetUpperBound(0); x++)
         {
             tempFieldEntryArray[x] = FieldEntryArray[x];
         }
         FieldEntryArray = tempFieldEntryArray;
     }
     FieldEntryArray[itemCount - 1] = value;
     return(itemCount - 1);
 }
        public void MoveDown(ValueField f)
        {
            int i = IndexOf(f);

            // Don't do anything if this field is already on bottom
            if (i == this.Count - 1)
            {
                return;
            }

            ValueField swap = FieldEntryArray[i + 1];

            FieldEntryArray[i + 1] = f;
            FieldEntryArray[i]     = swap;
        }
        public void MoveUp(ValueField f)
        {
            int i = IndexOf(f);

            // Don't do anything if this field is already on top
            if (i == 0)
            {
                return;
            }

            ValueField swap = FieldEntryArray[i - 1];

            FieldEntryArray[i - 1] = f;
            FieldEntryArray[i]     = swap;
        }
示例#8
0
 public int CompareTo(ValueField x)
 {
     return(Name.CompareTo(x.Name));
 }
示例#9
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();
        }
示例#10
0
        public ClassFolder(XmlTextReader r, string version) : this()
        {
            if (r.Name != "ClassFolder")
            {
                throw new Exception(string.Format("Source file does not match NitroCast DTD; " +
                                                  "expected 'ClassModel', found '{0}'.", r.Name));
            }

            base.ParseXml(r);

            if (r.Name == "Builder")
            {
                ClassFolderBuilder.Builders.TryGetValue(r.ReadElementString("Builder"), out builder);
            }

            _isExpanded         = bool.Parse(r.ReadElementString("IsExpanded"));
            _isItemListExpanded = bool.Parse(r.ReadElementString("IsItemListExpanded"));

            if (r.Name == "IsReadOnly")
            {
                _isReadOnly = bool.Parse(r.ReadElementString("IsReadOnly"));
            }
            else
            {
                _isReadOnly = false;
            }

            if (r.Name == "IsBrowsable")
            {
                _isBrowsable = bool.Parse(r.ReadElementString("IsBrowsable"));
            }
            else
            {
                _isBrowsable = true;
            }

            if (r.Name == "IsPartition")
            {
                _isPartition = bool.Parse(r.ReadElementString("IsPartition"));
            }
            else
            {
                _isPartition = false;
            }

            if (r.Name == "DataMode")
            {
                _dataMode = (ClassFolderDataMode)Enum.Parse(typeof(ClassFolderDataMode), r.ReadElementString("DataMode"), true);
            }
            else
            {
                _dataMode = ClassFolderDataMode.Integrated;
            }

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

                    while ((r.Name == "FieldEntry" |
                            r.Name == "ChildEntry" |
                            r.Name == "EnumField"))
                    {
                        //r.Read();
                        switch (r.LocalName)
                        {
                        case "FieldEntry":
                            ValueField vf = new ValueField(r, version);
                            vf.ParentFolder = this;
                            items.Add(vf);
                            break;

                        case "ChildEntry":
                            ReferenceField rf = new ReferenceField(r, version);
                            rf.ParentFolder = this;
                            items.Add(rf);
                            break;

                        case "EnumField":
                            EnumField ef = new EnumField(r, version);
                            ef.ParentFolder = this;
                            items.Add(ef);
                            break;
                        }
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

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

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

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

            r.ReadEndElement();
        }
示例#11
0
 public bool Contains(ValueField value)
 {
     return(IndexOf(value) != -1);
 }