コード例 #1
0
ファイル: RefactorManager.cs プロジェクト: spolnik/ndatabase
        public void AddField(Type type, Type fieldType, string fieldName)
        {
            var classInfo = _metaModel.GetClassInfo(type, true);

            // The real attribute id (-1) will be set in the ci.addAttribute
            var fullClassName = OdbClassNameResolver.GetFullName(fieldType);
            var attributeInfo = new ClassAttributeInfo(-1, fieldName, fullClassName, classInfo);
            classInfo.AddAttribute(attributeInfo);

            _objectWriter.UpdateClassInfo(classInfo, true);
        }
コード例 #2
0
ファイル: ClassInfo.cs プロジェクト: spolnik/ndatabase
 internal void AddAttribute(ClassAttributeInfo cai)
 {
     cai.SetId(MaxAttributeId++);
     _attributes.Add(cai);
     _attributesCache.AttributesByName.Add(cai.GetName(), cai);
 }
コード例 #3
0
ファイル: ClassInfo.cs プロジェクト: spolnik/ndatabase
 internal void RemoveAttribute(ClassAttributeInfo cai)
 {
     _attributes.Remove(cai);
     _attributesCache.AttributesByName.Remove(cai.GetName());
 }
コード例 #4
0
ファイル: FileSystemWriter.cs プロジェクト: spolnik/ndatabase
        /// <summary>
        ///   Writes a class attribute info, an attribute of a class
        /// </summary>
        public void WriteClassAttributeInfo(IStorageEngine storageEngine, ClassAttributeInfo cai, bool writeInTransaction)
        {
            FileSystemInterface.WriteInt(cai.GetId(), writeInTransaction);
            FileSystemInterface.WriteBoolean(cai.IsNative(), writeInTransaction);

            if (cai.IsNative())
            {
                FileSystemInterface.WriteInt(cai.GetAttributeType().Id, writeInTransaction);
                if (cai.GetAttributeType().IsArray())
                {
                    FileSystemInterface.WriteInt(cai.GetAttributeType().SubType.Id, writeInTransaction);
                    // when the attribute is not native, then write its class info position
                    if (cai.GetAttributeType().SubType.IsNonNative())
                    {
                        FileSystemInterface.WriteLong(
                            storageEngine.GetSession().GetMetaModel().GetClassInfo(
                                cai.GetAttributeType().SubType.Name, true).ClassInfoId.ObjectId,
                            writeInTransaction); // class info id of array subtype
                    }
                }
                // For enum, we write the class info id of the enum class
                if (cai.GetAttributeType().IsEnum())
                {
                    FileSystemInterface.WriteLong(
                        storageEngine.GetSession().GetMetaModel().GetClassInfo(cai.GetFullClassname(), true).ClassInfoId
                            .ObjectId, writeInTransaction); // class info id
                }
            }
            else
            {
                FileSystemInterface.WriteLong(
                    storageEngine.GetSession().GetMetaModel().GetClassInfo(cai.GetFullClassname(), true).ClassInfoId.
                        ObjectId, writeInTransaction); // class info id
            }

            FileSystemInterface.WriteString(cai.GetName(), writeInTransaction);
            FileSystemInterface.WriteBoolean(cai.IsIndex(), writeInTransaction);
        }
コード例 #5
0
ファイル: ClassInfo.cs プロジェクト: mrdotnet/NDatabase
 internal void AddAttribute(ClassAttributeInfo cai)
 {
     cai.SetId(MaxAttributeId++);
     _attributes.Add(cai);
     _attributesCache.AttributesByName.Add(cai.GetName(), cai);
 }
コード例 #6
0
ファイル: ClassInfo.cs プロジェクト: mrdotnet/NDatabase
 internal void RemoveAttribute(ClassAttributeInfo cai)
 {
     _attributes.Remove(cai);
     _attributesCache.AttributesByName.Remove(cai.GetName());
 }