當前位置: 首頁>>代碼示例>>C#>>正文


C# GraphDBType.RemoveAttribute方法代碼示例

本文整理匯總了C#中sones.GraphDB.TypeManagement.GraphDBType.RemoveAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# GraphDBType.RemoveAttribute方法的具體用法?C# GraphDBType.RemoveAttribute怎麽用?C# GraphDBType.RemoveAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sones.GraphDB.TypeManagement.GraphDBType的用法示例。


在下文中一共展示了GraphDBType.RemoveAttribute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RemoveAttributeOfType

        /// <summary>
        /// Removes an attribute of the given type.
        /// </summary>
        /// <param name="aUserType">The target type.</param>
        /// <param name="attributeUUID">The attribute uuid, referencing the deprecated attribute.</param>
        /// <returns></returns>
        private Exceptional<ResultType> RemoveAttributeOfType(GraphDBType aUserType, AttributeUUID attributeUUID)
        {
            #region INPUT EXCEPTIONS

            if (aUserType == null)
            {
                return new Exceptional<ResultType>(new Error_ArgumentNullOrEmpty("aUserType"));
            }

            #endregion

            #region remove attribute from type

            TypeAttribute typeAttribute = aUserType.Attributes[attributeUUID];

            if (typeAttribute != null)
            {

                aUserType.RemoveAttribute(typeAttribute.UUID);

                var FlushExcept = FlushType(aUserType);

                if (FlushExcept.Failed())
                {
                    aUserType.AddAttribute(typeAttribute, this, false);

                    return new Exceptional<ResultType>(FlushExcept);
                }

                #region update lookup tables ob sub-classes

                foreach (var aSubType in GetAllSubtypes(aUserType).Where(aType => aType != aUserType))
                {
                    //delete from lookuptable
                    aSubType.RemoveAttributeFromLookupTable(typeAttribute.UUID);
                }

                #endregion

            }
            else
            {
                return new Exceptional<ResultType>(new Error_AttributeIsNotDefined(aUserType.Name, typeAttribute.Name));
            }

            #endregion

            return new Exceptional<ResultType>(ResultType.Successful);
        }
開發者ID:TheByte,項目名稱:sones,代碼行數:55,代碼來源:DBTypeManager.cs

示例2: Execute

        public override Exceptional Execute(DBContext dbContext, GraphDBType graphDBType)
        {
            var listOfTypeAttrs = new List<TypeAttribute>();
            var retExcept = new Exceptional();

            foreach (var attr in _ListOfAttributes)
            {

                var typeAttr = graphDBType.GetTypeAttributeByName(attr);

                if (typeAttr == null)
                {
                    return new Exceptional(new Error_AttributeIsNotDefined(attr));
                }

                var attrType = dbContext.DBTypeManager.GetTypeByUUID(typeAttr.DBTypeUUID);

                if (attrType == null)
                    return new Exceptional(new Error_TypeDoesNotExist(""));

                if (attrType.IsUserDefined)
                    return new Exceptional(new Error_InvalidReferenceAssignmentOfUndefAttr());

                listOfTypeAttrs.Add(typeAttr);

            }

            var dbobjects = dbContext.DBObjectCache.SelectDBObjectsForLevelKey(new LevelKey(graphDBType, dbContext.DBTypeManager), dbContext);

            foreach (var item in dbobjects)
            {

                if (!item.Success())
                {
                    retExcept.PushIExceptional(item);
                }

                else
                {
                    foreach (var attr in listOfTypeAttrs)
                    {
                        if (item.Value.HasAttribute(attr.UUID, graphDBType))
                        {
                            var attrVal = item.Value.GetAttribute(attr.UUID);

                            var addExcept = item.Value.AddUndefinedAttribute(attr.Name, attrVal, dbContext.DBObjectManager);

                            if (!addExcept.Success())
                                retExcept.PushIExceptional(addExcept);

                            item.Value.RemoveAttribute(attr.UUID);

                            var saveExcept = dbContext.DBObjectManager.FlushDBObject(item.Value);

                            if (!saveExcept.Success())
                                retExcept.PushIExceptional(saveExcept);
                        }
                    }
                }
            }

            var indices = graphDBType.GetAllAttributeIndices();
            List<AAttributeIndex> idxToDelete = new List<AAttributeIndex>();

            //remove attributes from type
            foreach (var attr in listOfTypeAttrs)
            {

                foreach (var item in indices)
                {
                    var index = item.IndexKeyDefinition.IndexKeyAttributeUUIDs.Find(idx => idx == attr.UUID);

                    if (index != null && item.IndexKeyDefinition.IndexKeyAttributeUUIDs.Count == 1)
                    {
                        idxToDelete.Add(item);
                    }
                }

                //remove indices
                foreach (var idx in idxToDelete)
                {
                    var remExcept = graphDBType.RemoveIndex(idx.IndexName, idx.IndexEdition, dbContext.DBTypeManager);

                    if (!remExcept.Success())
                    {
                        retExcept.PushIExceptional(remExcept);
                    }
                }

                idxToDelete.Clear();
                graphDBType.RemoveAttribute(attr.UUID);

                var flushExcept = dbContext.DBTypeManager.FlushType(graphDBType);

                if (!flushExcept.Success())
                {
                    retExcept.PushIExceptional(flushExcept);
                }
            }

//.........這裏部分代碼省略.........
開發者ID:TheByte,項目名稱:sones,代碼行數:101,代碼來源:AlterType_UndefineAttributes.cs


注:本文中的sones.GraphDB.TypeManagement.GraphDBType.RemoveAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。