当前位置: 首页>>代码示例>>C#>>正文


C# DBObjectStream.HasAttribute方法代码示例

本文整理汇总了C#中DBObjectStream.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# DBObjectStream.HasAttribute方法的具体用法?C# DBObjectStream.HasAttribute怎么用?C# DBObjectStream.HasAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBObjectStream的用法示例。


在下文中一共展示了DBObjectStream.HasAttribute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update


//.........这里部分代码省略.........
                {
                    (elementsToBeAdded as IBaseEdge).Add(GraphDBTypeMapper.GetGraphObjectFromTypeName(attrDef.GetDBType(myDBContext.DBTypeManager).Name, (tupleElem.Value as ValueDefinition).Value.Value), tupleElem.Parameters.ToArray());
                }

                #endregion
            }
            else
            {
                #region References

                if (CollectionDefinition.CollectionType == CollectionType.SetOfUUIDs)
                {
                    var result = CollectionDefinition.TupleDefinition.GetAsUUIDEdge(myDBContext, attrDef);
                    if (result.Failed())
                    {
                        return new Exceptional<Dictionary<String, Tuple<TypeAttribute, IObject>>>(result);
                    }
                    elementsToBeAdded = (IEdgeType)result.Value;
                }
                else
                {
                    if (AttributeIDChain.LastAttribute.EdgeType == null)
                    {
                        return new Exceptional<Dictionary<String, Tuple<TypeAttribute, IObject>>>(new Error_InvalidEdgeType(AttributeIDChain.LastAttribute.GetType()));
                    }

                    var result = CollectionDefinition.TupleDefinition.GetCorrespondigDBObjectUUIDAsList(myGraphDBType, myDBContext, AttributeIDChain.LastAttribute.EdgeType.GetNewInstance(), AttributeIDChain.LastAttribute.GetDBType(myDBContext.DBTypeManager));
                    if (result.Failed())
                    {
                        return new Exceptional<Dictionary<String, Tuple<TypeAttribute, IObject>>>(result);
                    }
                    elementsToBeAdded = (IEdgeType)result.Value;
                }

                #endregion

            }

            #region add elements

            if (elementsToBeAdded == null)
            {
                return new Exceptional<Dictionary<String, Tuple<TypeAttribute, IObject>>>(new Error_UpdateAttributeNoElements(AttributeIDChain.LastAttribute));
            }

            if (myDBObjectStream.HasAttribute(AttributeIDChain.LastAttribute.UUID, attrDef.GetRelatedType(myDBContext.DBTypeManager)))
            {
                if (Assign)
                {

                    if (elementsToBeAdded is IReferenceEdge)
                    {
                        var oldEdge = ((IListOrSetEdgeType)myDBObjectStream.GetAttribute(AttributeIDChain.LastAttribute.UUID));
                        var removeRefExcept = RemoveBackwardEdgesOnReferences(this, (IReferenceEdge)oldEdge, myDBObjectStream, myDBContext);

                        if (!removeRefExcept.Success())
                        {
                            return new Exceptional<Dictionary<string,Tuple<TypeAttribute,IObject>>>(removeRefExcept.IErrors.First());
                        }
                    }

                    var alterResult = myDBObjectStream.AlterAttribute(AttributeIDChain.LastAttribute.UUID, elementsToBeAdded);
                    if (alterResult.Failed())
                    {
                        return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(alterResult);
                    }
                }
                else
                {
                    ((IListOrSetEdgeType)myDBObjectStream.GetAttribute(AttributeIDChain.LastAttribute.UUID)).UnionWith((IListOrSetEdgeType)elementsToBeAdded);
                }
            }
            else
            {
                myDBObjectStream.AddAttribute(AttributeIDChain.LastAttribute.UUID, elementsToBeAdded);
            }

            #region add backward edges

            if (AttributeIDChain.LastAttribute.GetDBType(myDBContext.DBTypeManager).IsUserDefined)
            {
                Dictionary<AttributeUUID, IObject> userdefinedAttributes = new Dictionary<AttributeUUID, IObject>();
                userdefinedAttributes.Add(AttributeIDChain.LastAttribute.UUID, elementsToBeAdded);

                var omm = new ObjectManipulationManager();
                var setBackEdgesExcept = omm.SetBackwardEdges(myGraphDBType, userdefinedAttributes, myDBObjectStream.ObjectUUID, myDBContext);

                if (setBackEdgesExcept.Failed())
                    return new Exceptional<Dictionary<String, Tuple<TypeAttribute, IObject>>>(setBackEdgesExcept);
            }

            #endregion

            attrsForResult.Add(AttributeIDChain.LastAttribute.Name, new Tuple<TypeAttribute, IObject>(AttributeIDChain.LastAttribute, elementsToBeAdded));
            return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(attrsForResult);

            #endregion

            #endregion
        }
开发者ID:TheByte,项目名称:sones,代码行数:101,代码来源:AttributeAssignOrUpdateList.cs

示例2: GetIndexkeysFromDBObject

        /// <summary>
        /// Creates IndexKeys from a DBObject.
        /// </summary>
        /// <param name="myDBObject">The DBObject reference for the resulting IndexKeys</param>
        /// <param name="myTypeOfDBObject">The Type of the DBObject</param>
        /// <param name="myToken">The SessionInfos</param>
        /// <returns>A HashSet of IndexKeys</returns>
        private HashSet<IndexKey> GetIndexkeysFromDBObject(DBObjectStream myDBObject, GraphDBType myTypeOfDBObject, DBContext dbContext)
        {
            HashSet<IndexKey> result = new HashSet<IndexKey>();
            TypeAttribute currentAttribute;

            foreach (var aIndexAttributeUUID in IndexKeyDefinition.IndexKeyAttributeUUIDs)
            {
                currentAttribute = myTypeOfDBObject.GetTypeAttributeByUUID(aIndexAttributeUUID);

                if (!currentAttribute.GetDBType(dbContext.DBTypeManager).IsUserDefined)
                {
                    #region base attribute

                    if (myDBObject.HasAttribute(aIndexAttributeUUID, myTypeOfDBObject))
                    {
                        ADBBaseObject newIndexKeyItem = null;

                        switch (currentAttribute.KindOfType)
                        {
                            #region List/Set

                            case KindsOfType.ListOfNoneReferences:
                            case KindsOfType.SetOfNoneReferences:

                                var helperSet = new List<ADBBaseObject>();

                                foreach (var aBaseObject in ((IBaseEdge)myDBObject.GetAttribute(aIndexAttributeUUID, myTypeOfDBObject, dbContext)).GetBaseObjects())
                                {
                                    helperSet.Add((ADBBaseObject)aBaseObject);
                                }

                                if (result.Count != 0)
                                {
                                    #region update

                                    HashSet<IndexKey> helperResultSet = new HashSet<IndexKey>();

                                    foreach (var aNewItem in helperSet)
                                    {
                                        foreach (var aReturnVal in result)
                                        {
                                            helperResultSet.Add(new IndexKey(aReturnVal, aIndexAttributeUUID, aNewItem, this.IndexKeyDefinition));
                                        }
                                    }

                                    result = helperResultSet;

                                    #endregion
                                }
                                else
                                {
                                    #region create new

                                    foreach (var aNewItem in helperSet)
                                    {
                                        result.Add(new IndexKey(aIndexAttributeUUID, aNewItem, this.IndexKeyDefinition));
                                    }

                                    #endregion
                                }

                                break;

                            #endregion

                            #region single/special

                            case KindsOfType.SingleReference:
                            case KindsOfType.SingleNoneReference:
                            case KindsOfType.SpecialAttribute:

                                newIndexKeyItem = (ADBBaseObject)myDBObject.GetAttribute(aIndexAttributeUUID, myTypeOfDBObject, dbContext);

                                if (result.Count != 0)
                                {
                                    #region update

                                    foreach (var aResultItem in result)
                                    {
                                        aResultItem.AddAADBBAseObject(aIndexAttributeUUID, newIndexKeyItem);
                                    }

                                    #endregion
                                }
                                else
                                {
                                    #region create new

                                    result.Add(new IndexKey(aIndexAttributeUUID, newIndexKeyItem, this.IndexKeyDefinition));

                                    #endregion
                                }

//.........这里部分代码省略.........
开发者ID:ipbi,项目名称:sones,代码行数:101,代码来源:AttributeIndex.cs

示例3: ApplyAssignAttribute

        internal Exceptional<Tuple<String, TypeAttribute, IObject>> ApplyAssignAttribute(AAttributeAssignOrUpdate myAAttributeAssign, DBContext myDBContext, DBObjectStream myDBObject, GraphDBType myGraphDBType)
        {
            System.Diagnostics.Debug.Assert(myAAttributeAssign != null);

            //get value for assignement
            var aValue = myAAttributeAssign.GetValueForAttribute(myDBObject, myDBContext, myGraphDBType);
            if (aValue.Failed())
            {
                return new Exceptional<Tuple<String, TypeAttribute, IObject>>(aValue);
            }

            object oldValue = null;
            IObject newValue = aValue.Value;

            if (myDBObject.HasAttribute(myAAttributeAssign.AttributeIDChain.LastAttribute.UUID, myGraphDBType))
            {

                #region Update the value because it already exists

                oldValue = myDBObject.GetAttribute(myAAttributeAssign.AttributeIDChain.LastAttribute, myGraphDBType, myDBContext).Value;

                switch (myAAttributeAssign.AttributeIDChain.LastAttribute.KindOfType)
                {
                    case KindsOfType.SetOfReferences:
                        var typeOfCollection = ((AttributeAssignOrUpdateList)myAAttributeAssign).CollectionDefinition.CollectionType;

                        if (typeOfCollection == CollectionType.List)
                            return new Exceptional<Tuple<String, TypeAttribute, IObject>>(new Error_InvalidAssignOfSet(myAAttributeAssign.AttributeIDChain.LastAttribute.Name));

                        var removeRefExcept = RemoveBackwardEdgesOnReferences(myAAttributeAssign, (IReferenceEdge)oldValue, myDBObject, myDBContext);

                        if (!removeRefExcept.Success())
                            return new Exceptional<Tuple<String, TypeAttribute, IObject>>(removeRefExcept.IErrors.First());

                        newValue = (ASetOfReferencesEdgeType)newValue;
                        break;

                    case KindsOfType.SetOfNoneReferences:
                    case KindsOfType.ListOfNoneReferences:
                        newValue = (IBaseEdge)newValue;
                        break;

                    case KindsOfType.SingleNoneReference:
                        if (!(oldValue as ADBBaseObject).IsValidValue((newValue as ADBBaseObject).Value))
                        {
                            return new Exceptional<Tuple<string, TypeAttribute, IObject>>(new Error_DataTypeDoesNotMatch((oldValue as ADBBaseObject).ObjectName, (newValue as ADBBaseObject).ObjectName));
                        }
                        newValue = (oldValue as ADBBaseObject).Clone((newValue as ADBBaseObject).Value);
                        break;

                    case KindsOfType.SingleReference:
                        if (newValue is ASingleReferenceEdgeType)
                        {
                            removeRefExcept = RemoveBackwardEdgesOnReferences(myAAttributeAssign, (IReferenceEdge)oldValue, myDBObject, myDBContext);

                            if (!removeRefExcept.Success())
                                return new Exceptional<Tuple<String, TypeAttribute, IObject>>(removeRefExcept.IErrors.First());

                            ((ASingleReferenceEdgeType)oldValue).Merge((ASingleReferenceEdgeType)newValue);
                            newValue = (ASingleReferenceEdgeType)oldValue;
                        }
                        break;

                    case KindsOfType.SpecialAttribute: // Special attributes can't be updated currently

                        if ((newValue as DBString) != null && (newValue as DBString).CompareTo(oldValue) == 0)
                        {
                            return new Exceptional<Tuple<string, GraphDB.TypeManagement.TypeAttribute, GraphDB.TypeManagement.IObject>>(new Tuple<string, GraphDB.TypeManagement.TypeAttribute, GraphDB.TypeManagement.IObject>(myAAttributeAssign.AttributeIDChain.LastAttribute.Name, myAAttributeAssign.AttributeIDChain.LastAttribute, newValue as IObject));
                        }
                        else
                        {
                            return new Exceptional<Tuple<String, TypeAttribute, IObject>>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                        }

                        break;

                    default:
                        return new Exceptional<Tuple<String, TypeAttribute, IObject>>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                }

                #endregion

            }

            var alterExcept = myDBObject.AlterAttribute(myAAttributeAssign.AttributeIDChain.LastAttribute.UUID, newValue);

            if (alterExcept.Failed())
                return new Exceptional<Tuple<string, TypeAttribute, IObject>>(alterExcept);

            if (!alterExcept.Value)
            {
                myDBObject.AddAttribute(myAAttributeAssign.AttributeIDChain.LastAttribute.UUID, newValue);
            }

            #region add backward edges

            if (myAAttributeAssign.AttributeIDChain.LastAttribute.GetDBType(myDBContext.DBTypeManager).IsUserDefined)
            {
                Dictionary<AttributeUUID, IObject> userdefinedAttributes = new Dictionary<AttributeUUID, IObject>();
                userdefinedAttributes.Add(myAAttributeAssign.AttributeIDChain.LastAttribute.UUID, newValue);
//.........这里部分代码省略.........
开发者ID:Vadi,项目名称:sones,代码行数:101,代码来源:AAttributeAssignOrUpdate.cs

示例4: Update

        public override Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>> Update(DBContext myDBContext, DBObjectStream myDBObjectStream, GraphDBType myGraphDBType)
        {
            Dictionary<String, Tuple<TypeAttribute, IObject>> attrsForResult = new Dictionary<String, Tuple<TypeAttribute, IObject>>();

            #region AttributeRemoveList

            #region data

            Exceptional validateResult = AttributeIDChain.Validate(myDBContext, false);
            if (validateResult.Failed())
            {
                return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(validateResult);
            }

            ASetOfReferencesEdgeType _elementsToBeRemoved;
            EdgeTypeListOfBaseObjects undefAttrList;

            #endregion

            #region undefined attributes

            if (AttributeIDChain.IsUndefinedAttribute)
            {
                var loadExcept = LoadUndefAttributes(AttributeName, myDBContext, myDBObjectStream);

                if (loadExcept.Failed())
                    return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(loadExcept);

                if (!loadExcept.Value.ContainsKey(AttributeName))
                {
                    attrsForResult.Add(AttributeName, new Tuple<TypeAttribute, IObject>(AttributeIDChain.LastAttribute, null));
                    return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(attrsForResult);
                }

                if (!(loadExcept.Value[AttributeName] is EdgeTypeListOfBaseObjects))
                    return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(new Error_InvalidAttributeKind());

                undefAttrList = (EdgeTypeListOfBaseObjects)loadExcept.Value[AttributeName];

                foreach (var tuple in TupleDefinition)
                {
                    undefAttrList.Remove((tuple.Value as ValueDefinition).Value);
                }

                myDBContext.DBObjectManager.AddUndefinedAttribute(AttributeName, undefAttrList, myDBObjectStream);

                attrsForResult.Add(AttributeName, new Tuple<TypeAttribute, IObject>(AttributeIDChain.LastAttribute, null));
                return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(attrsForResult);
            }

            #endregion

            #region get elements

            if (AttributeIDChain.LastAttribute.EdgeType == null)
            {
                return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(new Error_InvalidEdgeType(AttributeIDChain.LastAttribute.GetType()));
            }

            var elements = TupleDefinition.GetCorrespondigDBObjectUUIDAsList(myGraphDBType, myDBContext, AttributeIDChain.LastAttribute.EdgeType.GetNewInstance(), AttributeIDChain.LastAttribute.GetDBType(myDBContext.DBTypeManager));

            if(!elements.Success())
            {
                return new Exceptional<Dictionary<string,Tuple<TypeAttribute,IObject>>>(elements);
            }

            _elementsToBeRemoved = (ASetOfReferencesEdgeType)elements.Value;

            #endregion

            #region remove elements from list

            if (_elementsToBeRemoved == null)
            {
                return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(new Error_UpdateAttributeNoElements(AttributeIDChain.LastAttribute));
            }

            if (myDBObjectStream.HasAttribute(AttributeIDChain.LastAttribute.UUID, AttributeIDChain.LastAttribute.GetRelatedType(myDBContext.DBTypeManager)))
            {
                ASetOfReferencesEdgeType edge = (ASetOfReferencesEdgeType)myDBObjectStream.GetAttribute(AttributeIDChain.LastAttribute.UUID);

                foreach (var aUUID in (_elementsToBeRemoved as ASetOfReferencesEdgeType).GetAllReferenceIDs())
                {
                    edge.RemoveUUID(aUUID);
                }

                #region remove backward edges

                if (AttributeIDChain.LastAttribute.GetDBType(myDBContext.DBTypeManager).IsUserDefined)
                {
                    Dictionary<AttributeUUID, object> userdefinedAttributes = new Dictionary<AttributeUUID, object>();
                    userdefinedAttributes.Add(AttributeIDChain.LastAttribute.UUID, _elementsToBeRemoved);

                    RemoveBackwardEdges(myGraphDBType.UUID, userdefinedAttributes, myDBObjectStream.ObjectUUID, myDBContext);
                }

                #endregion

                attrsForResult.Add(AttributeIDChain.LastAttribute.Name, new Tuple<TypeAttribute, IObject>(AttributeIDChain.LastAttribute, edge));
                return new Exceptional<Dictionary<string, Tuple<TypeAttribute, IObject>>>(attrsForResult);
//.........这里部分代码省略.........
开发者ID:TheByte,项目名称:sones,代码行数:101,代码来源:AttributeRemoveList.cs

示例5: IsValidDBObjectStreamForBinExpr

 private bool IsValidDBObjectStreamForBinExpr(DBObjectStream DBObjectStream, TypeAttribute myTypeAttribute, DBTypeManager myDBTypeManager)
 {
     if (DBObjectStream.HasAttribute(myTypeAttribute.UUID, myTypeAttribute.GetRelatedType(myDBTypeManager)) || myTypeAttribute.IsBackwardEdge)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
开发者ID:Vadi,项目名称:sones,代码行数:11,代码来源:ABinaryCompareOperator.cs

示例6: GetAttributeValue

        /// <summary>
        /// Extracts the attribute from <paramref name="myDBObject"/>.
        /// </summary>
        /// <param name="myType"></param>
        /// <param name="myTypeAttribute"></param>
        /// <param name="myDBObject"></param>
        /// <param name="myLevelKey"></param>
        /// <returns></returns>
        private Object GetAttributeValue(GraphDBType myType, TypeAttribute myTypeAttribute, DBObjectStream myDBObject, EdgeList myLevelKey)
        {
            if (myTypeAttribute.TypeCharacteristics.IsBackwardEdge)
            {

                #region IsBackwardEdge

                EdgeKey edgeKey = myTypeAttribute.BackwardEdgeDefinition;
                var contBackwardExcept = myDBObject.ContainsBackwardEdge(edgeKey, _DBContext, _DBContext.DBObjectCache, myType);

                if (contBackwardExcept.Failed())
                    throw new GraphDBException(contBackwardExcept.IErrors);

                if (contBackwardExcept.Value)
                {
                    var getBackwardExcept = myDBObject.GetBackwardEdges(edgeKey, _DBContext, _DBContext.DBObjectCache, myTypeAttribute.GetDBType(_DBContext.DBTypeManager));

                    if (getBackwardExcept.Failed())
                        throw new GraphDBException(getBackwardExcept.IErrors);

                    return getBackwardExcept.Value;
                }

                #endregion

            }
            else if (myDBObject.HasAttribute(myTypeAttribute.UUID, myType))
            {

                #region ELSE (!IsBackwardEdge)

                return myDBObject.GetAttribute(myTypeAttribute.UUID, myType, _DBContext);

                #endregion

            }

            return null;
        }
开发者ID:ipbi,项目名称:sones,代码行数:47,代码来源:SelectResultManager.cs

示例7: GetAttributeValueAndResolve

        /// <summary>   Gets an attribute value - references will be resolved. </summary>
        ///
        /// <remarks>   Stefan, 16.04.2010. </remarks>
        ///
        /// <param name="myType">           Type. </param>
        /// <param name="myTypeAttribute">  my type attribute. </param>
        /// <param name="myDBObject">       my database object. </param>
        /// <param name="myDepth">          Depth of my. </param>
        /// <param name="myLevelKey">       my level key. </param>
        /// <param name="reference">        The reference. </param>
        /// <param name="myUsingGraph">     true to my using graph. </param>
        /// <param name="attributeValue">   [out] The attribute value. </param>
        ///
        /// <returns>   true if it succeeds, false if the DBO does not have the attribute. </returns>
        private Boolean GetAttributeValueAndResolve(GraphDBType myType, SelectionElement mySelectionelement, DBObjectStream myDBObject, Int64 myDepth, EdgeList myLevelKey, String reference, Boolean myUsingGraph, out Object attributeValue, String myUndefAttrName = null)
        {

            var typeAttribute = mySelectionelement.Element;

            if (typeAttribute.TypeCharacteristics.IsBackwardEdge)
            {

                #region IsBackwardEdge

                EdgeKey edgeKey = typeAttribute.BackwardEdgeDefinition;
                var contBackwardExcept = myDBObject.ContainsBackwardEdge(edgeKey, _DBContext, _DBContext.DBObjectCache, myType);

                if (contBackwardExcept.Failed())
                    throw new GraphDBException(contBackwardExcept.IErrors);

                if (contBackwardExcept.Value)
                {
                    if (myDepth > 0)
                    {
                        var dbos = myDBObject.GetBackwardEdges(edgeKey, _DBContext, _DBContext.DBObjectCache, typeAttribute.GetDBType(_DBContext.DBTypeManager));

                        if (dbos.Failed())
                            throw new GraphDBException(dbos.IErrors);

                        if (dbos.Value != null)
                        {
                            attributeValue = ResolveAttributeValue(typeAttribute, dbos.Value, myDepth, myLevelKey, myDBObject, reference, myUsingGraph);
                            return true;
                        }
                    }
                    else
                    {
                        attributeValue = GetNotResolvedBackwardEdgeReferenceAttributeValue(myDBObject, typeAttribute, edgeKey, myLevelKey, myUsingGraph, _DBContext);
                        return true;

                    }
                }

                #endregion

            }
            else if (myDBObject.HasAttribute(typeAttribute, _DBContext))
            {

                #region SelectValueAssignment - kind of static assignment of selected attribute

                if (mySelectionelement.SelectValueAssignment != null && mySelectionelement.SelectValueAssignment.ValueAssignmentType == SelectValueAssignment.ValueAssignmentTypes.Always)
                {
                    // Currently the prior add SelectionElement verifies that TermDefinition is always a ValueDefinition - if others will become valid this must be changed!
                    attributeValue = (mySelectionelement.SelectValueAssignment.TermDefinition as ValueDefinition).Value.Value;
                    return true;
                }

                #endregion

                #region ELSE (!IsBackwardEdge)

                #region not a reference attribute value

                if (!typeAttribute.IsUserDefinedType(_DBContext.DBTypeManager))
                {
                    var attrVal = myDBObject.GetAttribute(typeAttribute, myType, _DBContext);

                    if (attrVal.Failed())
                    {
                        throw new GraphDBException(attrVal.IErrors);
                    }

                    // currently, we do not want to return a ADBBaseObject but the real value
                    if (attrVal.Value is ADBBaseObject)
                        attributeValue = (attrVal.Value as ADBBaseObject).GetReadoutValue();
                    else if (attrVal.Value is IBaseEdge)
                        attributeValue = (attrVal.Value as IBaseEdge).GetReadoutValues();
                    else
                        attributeValue = attrVal.Value;

                    return true;
                }

                #endregion

                #region ELSE Reference attribute value

                else
                {
//.........这里部分代码省略.........
开发者ID:ipbi,项目名称:sones,代码行数:101,代码来源:SelectResultManager.cs

示例8: AddNodeIfValid

        /// <summary>
        /// This method adds a DBOBjectStream to a Level if it is valid for a LevelKey.
        /// </summary>
        /// <param name="aDBObject">The Object that is going to be added</param>
        /// <param name="myLevelKey">The LevelKey which is needed for validation.</param>
        /// <param name="currentBackwardResolution">The current backward resolution (initially 0)</param>
        /// <param name="source">The ObjectUUID of the </param>
        /// <returns>True if it was valid or false otherwise.</returns>
        private bool AddNodeIfValid(DBObjectStream aDBObject, LevelKey myLevelKey, int currentBackwardResolution, ObjectUUID source, int backwardResolutiondepth)
        {
            #region data

            Exceptional<BackwardEdgeStream> beStream            = null;
            TypeAttribute                   tempTypeAttribute   = null;

            IEnumerable<ObjectUUID>         referenceUUIDs      = null;
            GraphDBType                     referenceType       = null;

            #endregion

            if ((myLevelKey.Level - currentBackwardResolution) > 0)
            {
                #region level > 0

                int desiredBackwardEdgeLevel = myLevelKey.Level - currentBackwardResolution - 1;

                tempTypeAttribute = _DBContext.DBTypeManager.GetTypeByUUID(myLevelKey.Edges[desiredBackwardEdgeLevel].TypeUUID).GetTypeAttributeByUUID(myLevelKey.Edges[desiredBackwardEdgeLevel].AttrUUID);

                #region get reference UUIDs

                if (tempTypeAttribute.IsBackwardEdge)
                {
                    #region backward edge handling

                    referenceType = _DBContext.DBTypeManager.GetTypeByUUID(tempTypeAttribute.BackwardEdgeDefinition.TypeUUID).GetTypeAttributeByUUID(tempTypeAttribute.BackwardEdgeDefinition.AttrUUID).GetDBType(_DBContext.DBTypeManager);

                    if (aDBObject.HasAttribute(tempTypeAttribute.BackwardEdgeDefinition.AttrUUID, _DBContext.DBTypeManager.GetTypeByUUID(tempTypeAttribute.BackwardEdgeDefinition.TypeUUID)))
                    {
                        referenceUUIDs = GetUUIDsForAttribute(aDBObject, tempTypeAttribute.BackwardEdgeDefinition.GetTypeAndAttributeInformation(_DBContext.DBTypeManager).Item2, _DBContext.DBTypeManager.GetTypeByUUID(aDBObject.TypeUUID));
                    }

                    #endregion
                }
                else
                {
                    #region forward edge handling

                    beStream = _DBObjectCache.LoadDBBackwardEdgeStream(tempTypeAttribute.GetDBType(_DBContext.DBTypeManager), aDBObject.ObjectUUID);

                    if (beStream.Failed())
                    {
                        throw new GraphDBException(new Error_CouldNotLoadBackwardEdge(aDBObject, tempTypeAttribute, beStream.IErrors));
                    }

                    var tempEdgeKey = GetBackwardEdgeKey(myLevelKey, desiredBackwardEdgeLevel, _DBContext);

                    if (!beStream.Value.ContainsBackwardEdge(tempEdgeKey))
                    {
                        return false;
                    }

                    referenceUUIDs = beStream.Value.GetBackwardEdgeUUIDs(tempEdgeKey);
                    referenceType = tempTypeAttribute.GetRelatedType(_DBContext.DBTypeManager);

                    #endregion
                }

                #endregion

                if (referenceUUIDs != null)
                {
                    #region references

                    Exceptional<DBObjectStream> tempDbo = null;
                    Dictionary<ObjectUUID, ADBBaseObject> validUUIDs = new Dictionary<ObjectUUID, ADBBaseObject>();
                    SettingInvalidReferenceHandling invalidReferenceSetting = null;

                    #region process references recursivly

                    foreach (var aReferenceUUID in referenceUUIDs)
                    {
                        tempDbo = _DBObjectCache.LoadDBObjectStream(referenceType, aReferenceUUID);

                        if (!tempDbo.Success())
                        {
                            #region error

                            if (invalidReferenceSetting == null)
                            {
                                invalidReferenceSetting = (SettingInvalidReferenceHandling)_DBContext.DBSettingsManager.GetSetting(SettingInvalidReferenceHandling.UUID, _DBContext, TypesSettingScope.ATTRIBUTE, referenceType, tempTypeAttribute).Value;
                            }

                            switch (invalidReferenceSetting.Behaviour)
                            {
                                case BehaviourOnInvalidReference.ignore:
                                    #region ignore

                                    //insert if the next lower level is 0

                                    if ((myLevelKey.Level - currentBackwardResolution) == 0)
//.........这里部分代码省略.........
开发者ID:TheByte,项目名称:sones,代码行数:101,代码来源:CommonUsageGraph.cs

示例9: ApplyRemoveAttribute

        /// <summary>
        /// Execute the remove of attributes
        /// </summary>
        /// <param name="myAttrsToRemove">The list of attributes to remove</param>
        /// <param name="myDBContext">The db context</param>
        /// <param name="myDBDBObject">The db object from which the attributes should be deleted</param>
        /// <param name="myGraphDBType">The type of the db object</param>
        /// <returns>The list of removed attributes</returns>
        private Exceptional<List<TypeAttribute>> ApplyRemoveAttribute(List<string> myAttrsToRemove, DBContext myDBContext, DBObjectStream myDBDBObject, GraphDBType myGraphDBType)
        {
            #region data

            List<TypeAttribute> removedAttributes = new List<TypeAttribute>();

            #endregion

            var MandatoryTypeAttrib = myGraphDBType.GetMandatoryAttributesUUIDs(myDBContext.DBTypeManager);
            foreach (String aAttribute in myAttrsToRemove)
            {
                TypeAttribute typeAttribute = myGraphDBType.GetTypeAttributeByName(aAttribute);

                if (myDBDBObject.HasAttribute(typeAttribute.UUID, myGraphDBType))
                {
                    if (!MandatoryTypeAttrib.Contains(typeAttribute.UUID))
                    {
                        #region remove backward edges

                        if (typeAttribute.GetDBType(myDBContext.DBTypeManager).IsUserDefined)
                        {
                            var userdefinedAttributes = new Dictionary<AttributeUUID, object>();
                            userdefinedAttributes.Add(typeAttribute.UUID, myDBDBObject.GetAttribute(typeAttribute.UUID));

                            RemoveBackwardEdges(myGraphDBType.UUID, userdefinedAttributes, myDBDBObject.ObjectUUID, myDBContext);
                        }

                        #endregion

                        myDBDBObject.RemoveAttribute(typeAttribute.UUID);
                        removedAttributes.Add(typeAttribute);
                    }
                    else
                    {
                        return new Exceptional<List<TypeAttribute>>(new Error_MandatoryConstraintViolation("Error in update statement. The attribute \"" + typeAttribute.Name + "\" is mandatory and can not be removed."));
                    }
                }
            }

            return new Exceptional<List<TypeAttribute>>(removedAttributes);
        }
开发者ID:Vadi,项目名称:sones,代码行数:49,代码来源:AttributeRemove.cs


注:本文中的DBObjectStream.HasAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。