Esempio n. 1
0
 /// <summary>
 /// A single parameter
 /// </summary>
 /// <param name="myParameterName">The name of the parameter. Currently this is not used.</param>
 /// <param name="myParameterDBType">The DBType of the parameter</param>
 /// <param name="myVariableNumOfParams">True if this parameter occurs 1 or more time. This have to be the last parameter!</param>
 public ParameterValue(String myParameterName, ADBBaseObject myParameterDBType, Boolean myVariableNumOfParams)
     : this()
 {
     Name                = myParameterName;
     DBType              = myParameterDBType;
     VariableNumOfParams = myVariableNumOfParams;
 }
Esempio n. 2
0
        public override IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            IndexKey lookup = new IndexKey(myAttributeUUID, myOperationValue, myIndex.IndexKeyDefinition);
            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            var result = myIndex.Contains(lookup, currentType, dbContext);
            if (result.Value)
            {
                var interestingUUIDs = myIndex.GetValues(lookup, currentType, dbContext);

                foreach (var aIndexValue in myIndex.GetAllValues(currentType, dbContext))
                {
                    foreach (var aUUID in aIndexValue)
                    {
                        if (!interestingUUIDs.Contains(aUUID))
                        {
                            yield return aUUID;
                        }
                    }
                }
            }
            else
            {
                foreach (var aIndexValue in myIndex.GetKeyValues(currentType, dbContext).Select(kv => kv.Value))
                {
                    foreach (var aUUID in aIndexValue)
                    {
                        yield return aUUID;
                    }
                }
            }

            yield break;
        }
Esempio n. 3
0
        public SetRefDefinition(Structures.TupleDefinition tupleDefinition, ADBBaseObject[] myParameters)
        {
            System.Diagnostics.Debug.Assert(tupleDefinition != null);

            this.TupleDefinition = tupleDefinition;
            this.Parameters = myParameters;
        }
Esempio n. 4
0
 /// <summary>
 /// A single parameter
 /// </summary>
 /// <param name="myParameterName">The name of the parameter. Currently this is not used.</param>
 /// <param name="myParameterDBType">The DBType of the parameter</param>
 public ParameterValue(String myParameterName, ADBBaseObject myParameterDBType)
     : this()
 {
     Name                = myParameterName;
     DBType              = myParameterDBType;
     VariableNumOfParams = false;
 }
Esempio n. 5
0
 public ADBSettingsBase(ADBSettingsBase myCopy)
 {
     Name        = myCopy.Name;
     Description = myCopy.Description;
     OwnerID     = myCopy.OwnerID;
     Type        = myCopy.Type;
     Default     = myCopy.Default;
     _Value      = myCopy._Value;
 }
Esempio n. 6
0
 public ADBSettingsBase(String myName, String myDescription, EntityUUID myOwnerID, TypeUUID myType, ADBBaseObject myDefault, ADBBaseObject myValue)
 {
     Name        = myName;
     Description = myDescription;
     OwnerID     = myOwnerID;
     Type        = myType;
     Default     = myDefault;
     _Value      = myValue;
 }
Esempio n. 7
0
 /// <summary>
 /// Adds a single ADBBaseObject to the IndexKex
 /// </summary>
 /// <param name="myAttributeUUID">AttributeUUID corresponding to the ADBBaseObject</param>
 /// <param name="myIndexKeyPayload">The ADBBaseObject that is going to be added</param>
 /// <param name="myIndexDefinition">The corresponding IndexKeyDefinition</param>
 public IndexKey(AttributeUUID myAttributeUUID, ADBBaseObject myIndexKeyPayload, IndexKeyDefinition myIndexDefinition)
 {
     if (!myIndexDefinition.IndexKeyAttributeUUIDs.Contains(myAttributeUUID))
     {
         throw new GraphDBException(new Error_IndexKeyCreationError(myAttributeUUID, myIndexKeyPayload, myIndexDefinition));
     }
     else
     {
         AddAAKey(myAttributeUUID, myIndexKeyPayload);
     }
 }
Esempio n. 8
0
        public override IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            var myIndeyKey = new IndexKey(myAttributeUUID, myOperationValue, myIndex.IndexKeyDefinition);
            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            if (myIndex.Contains(myIndeyKey, currentType, dbContext))
            {
                foreach (var aUUID in myIndex.GetValues(myIndeyKey, currentType, dbContext))
                {
                    yield return aUUID;
                }
            }

            yield break;
        }
Esempio n. 9
0
        public override void ApplyParams(params EdgeTypeParamDefinition[] myParams)
        {
            if (myParams.Count() == 0)
                throw new GraphDBException(new Error_EdgeParameterCountMismatch(EdgeTypeName, 0, 1));

            // The first parameter has to be the type
            if (myParams[0].Type != ParamType.GraphType)
            {
                throw new GraphDBException(new Error_DataTypeDoesNotMatch(myParams[0].Type.ToString(), "BaseType like 'Integer', 'Double, etc"));
            }
            else
            {
                _CountBy = myParams[0].Param as ADBBaseObject;
            }

            _Count = _CountBy.Clone();
            _Count.SetValue(DBObjectInitializeType.Default);

            #region Get default node if exists

            if (myParams.Any(p => p.Type == ParamType.DefaultValueDef))
            {
                var def = (from p in myParams where p.Type == ParamType.DefaultValueDef select p).First();
                if (_CountBy.IsValidValue(def.Param))
                {
                    _CountBy.SetValue(def.Param);
                }
                else
                {
                    throw new GraphDBException(new Error_DataTypeDoesNotMatch(_CountBy.ObjectName, def.Param.GetType().Name));
                }
            }
            else
            {
                _CountBy.SetValue(1);
            }

            #endregion

            CalcEstimatedSize(this);
        }
Esempio n. 10
0
        public virtual IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            foreach (var keyValPair in myIndex.GetKeyValues(dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID), dbContext))
            {
                var res = Compare(keyValPair.Key.IndexKeyValues[0], myOperationValue);

                if (res.Failed())
                {
                    throw new GraphDBException(res.PushIError(new Error_InvalidIndexOperation(myIndex.IndexName, keyValPair.Key.IndexKeyValues[0].Value, myOperationValue.Value)).IErrors);
                }

                if (res.Value)
                {
                    foreach (var aUUID in keyValPair.Value)
                    {
                        yield return aUUID;
                    }
                }
            }

            yield break;
        }
Esempio n. 11
0
File: DBType.cs Progetto: ipbi/sones
 public override void Sub(ADBBaseObject myGraphObject)
 {
 }
Esempio n. 12
0
File: DBType.cs Progetto: ipbi/sones
 public override ADBBaseObject Sub(ADBBaseObject myGraphObjectA, ADBBaseObject myGraphObjectB)
 {
     return myGraphObjectA;
 }
Esempio n. 13
0
 /// <summary>
 /// Check for a containing element
 /// </summary>
 /// <param name="myValue"></param>
 /// <returns></returns>
 public override bool Contains(ADBBaseObject myValue)
 {
     return _Objects.Contains((ADBBaseObject)myValue);
 }
Esempio n. 14
0
 /// <summary>
 /// Adds a new value with some optional parameters
 /// </summary>
 /// <param name="myValue"></param>
 /// <param name="myParameters"></param>
 public override void Add(ADBBaseObject myValue, params ADBBaseObject[] myParameters)
 {
     _Objects.Add(myValue);
 }
Esempio n. 15
0
 /// <summary>
 /// Remove a value
 /// </summary>
 /// <param name="myValue"></param>
 /// <returns></returns>
 public override Boolean Remove(ADBBaseObject myValue)
 {
     return _Objects.Remove((ADBBaseObject)myValue);
 }
Esempio n. 16
0
        private static Boolean ConvertToBestMatchingTypeReverse(ref ADBBaseObject myDBBaseObjectB, ref ADBBaseObject myDBBaseObjectA)
        {
            #region Both are not unknown

            if ((myDBBaseObjectA.Type != BasicType.Unknown) && (myDBBaseObjectB.Type != BasicType.Unknown))
            {

                #region Types matching, we can leave

                if (myDBBaseObjectA.Type == myDBBaseObjectB.Type)
                {
                    return true;
                }

                #endregion

                #region DBList and DBReference are not matchable with other types

                else if (myDBBaseObjectA is DBEdge || myDBBaseObjectA is DBReference || myDBBaseObjectB is DBEdge || myDBBaseObjectB is DBReference)
                {
                    return false;
                }

                #endregion

                #region The types does not match - so try to convert the right-handed to the left handed type

                else if (myDBBaseObjectA is DBUInt64)
                {
                    //
                    if (DBUInt64.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return true;
                    }
                    return false;
                }

                else if (myDBBaseObjectA is DBInt64)
                {
                    //
                    if (DBInt64.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return true;
                    }
                    // do not change to ConvertToBestMatchingType(ref myDBBaseObjectB, ref myDBBaseObjectA)
                    return false;
                }

                else if (myDBBaseObjectA is DBDouble)
                {
                    //
                    if (DBDouble.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return true;
                    }
                    return false;
                }

                else if (myDBBaseObjectA is DBDateTime)
                {
                    //
                    if (DBDateTime.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return true;
                    }
                    return false;
                }

                else if (myDBBaseObjectA is DBBoolean)
                {
                    //
                    if (DBDouble.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return true;
                    }
                    return false;
                }

                else if (myDBBaseObjectA is DBString)
                {
                    //
                    if (DBString.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return true;
                    }
                    return false;
                }

                #endregion

                // we couldnt find a matching type for both are not unknown
                return false;

            }

            #endregion

            #region Both are strings - thats fine

            else if (myDBBaseObjectA is DBString && myDBBaseObjectB is DBString)
            {
                return true;
            }

            #endregion

            #region only one is unknown

            else if (!(myDBBaseObjectA.Type == BasicType.Unknown && myDBBaseObjectB.Type == BasicType.Unknown))
            {

                #region myDBBaseObjectA is unknown - try to use the type of myDBBaseObjectB

                if (myDBBaseObjectA.Type == BasicType.Unknown)
                {

                    try
                    {
                        // avaoid changing a Double to Int64
                        if (myDBBaseObjectA is DBNumber
                            && (myDBBaseObjectB.Type == BasicType.Int64 || myDBBaseObjectB.Type == BasicType.UInt64))
                        {
                            if (myDBBaseObjectA.Value is Double && DBDouble.IsValid(myDBBaseObjectB.Value))
                            {
                                myDBBaseObjectA = new DBDouble(myDBBaseObjectA.Value);
                                myDBBaseObjectB = new DBDouble(myDBBaseObjectB.Value);
                                return true;
                            }
                        }

                        myDBBaseObjectA = myDBBaseObjectB.Clone(myDBBaseObjectA.Value);

                    }

                    catch
                    {
                        return false;
                    }

                }

                #endregion

                #region myDBBaseObjectB is unknown - try to use the type of myDBBaseObjectA

                else if (myDBBaseObjectB.Type == BasicType.Unknown)
                {
                    try
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                    }
                    catch
                    {
                        return false;
                    }
                }

                else
                {
                    return false;
                }

                #endregion

            }

            #endregion

            #region both are unknown

            #region One of them is expected as a Number - so try to parse both as a number

            else if (myDBBaseObjectA is DBNumber || myDBBaseObjectB is DBNumber)
            {

                if (DBInt64.IsValid(myDBBaseObjectA.Value) && DBInt64.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBInt64(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBInt64(myDBBaseObjectB.Value);
                }

                else if (DBUInt64.IsValid(myDBBaseObjectA.Value) && DBUInt64.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBUInt64(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBUInt64(myDBBaseObjectB.Value);
                }

                else if (DBDouble.IsValid(myDBBaseObjectA.Value) && DBDouble.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBDouble(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBDouble(myDBBaseObjectB.Value);
                }

                else
                {
                    return false;
                }

            }

            #endregion

            #region Try all other dataTypes

            else
            {

                // check all types beginning with the hardest and ending with string (matches all)
                if (DBDateTime.IsValid(myDBBaseObjectA.Value) && DBDateTime.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBDateTime(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBDateTime(myDBBaseObjectB.Value);
                }

                else if (DBBoolean.IsValid(myDBBaseObjectA.Value) && DBBoolean.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBBoolean(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBBoolean(myDBBaseObjectB.Value);
                }

                else if (DBEdge.IsValid(myDBBaseObjectA.Value) && DBEdge.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBEdge(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBEdge(myDBBaseObjectB.Value);
                }

                else if (DBReference.IsValid(myDBBaseObjectA.Value) && DBReference.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBReference(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBReference(myDBBaseObjectB.Value);
                }

                else if (DBString.IsValid(myDBBaseObjectA.Value) && DBString.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBString(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBString(myDBBaseObjectB.Value);
                }

                else
                {
                    return false;
                }

            }

            #endregion

            #endregion

            return true;
        }
Esempio n. 17
0
 /// <summary>
 /// Remove a value
 /// </summary>
 /// <param name="myValue"></param>
 /// <returns></returns>
 public abstract Boolean Remove(ADBBaseObject myValue);
Esempio n. 18
0
 public override ADBBaseObject Sub(ADBBaseObject myGraphObjectA, ADBBaseObject myGraphObjectB)
 {
     throw new NotImplementedException();
 }
 public Error_EdgeParameterTypeMismatch(ADBBaseObject currentType, params ADBBaseObject[] expectedTypes)
 {
     CurrentType = currentType;
     ExpectedTypes = expectedTypes;
 }
Esempio n. 20
0
 public Error_IndexKeyCreationError(AttributeUUID myAttributeUUID, ADBBaseObject myIndexKeyPayload, IndexKeyDefinition myIndexDefinition)
 {
     AttributeUUID = myAttributeUUID;
     IndexKeyPayload = myIndexKeyPayload;
     IndexDefinition = myIndexDefinition;
 }
Esempio n. 21
0
 /// <summary>
 /// Check for a containing element
 /// </summary>
 /// <param name="myValue"></param>
 /// <returns></returns>
 public abstract Boolean Contains(ADBBaseObject myValue);
Esempio n. 22
0
 /// <summary>
 /// Adds a new value with some optional parameters
 /// </summary>
 /// <param name="myValue"></param>
 /// <param name="myParameters"></param>
 public abstract void Add(ADBBaseObject myValue, params ADBBaseObject[] myParameters);
Esempio n. 23
0
 public override void Sub(ADBBaseObject myGraphObject)
 {
     _Value -= Convert.ToDouble(myGraphObject.Value);
 }
Esempio n. 24
0
        public static Exceptional<Boolean> ConvertToBestMatchingType(ref ADBBaseObject myDBBaseObjectA, ref ADBBaseObject myDBBaseObjectB)
        {
            #region Both are not unknown

            if ((myDBBaseObjectA.Type != BasicType.Unknown) && (myDBBaseObjectB.Type != BasicType.Unknown))
            {

                #region Types matching, we can leave

                if (myDBBaseObjectA.Type == myDBBaseObjectB.Type)
                {
                    return new Exceptional<Boolean>(true);
                }

                #endregion

                #region DBList and DBReference are not matchable with other types

                else if (myDBBaseObjectA is DBEdge || myDBBaseObjectB is DBEdge)
                {
                    return new Exceptional<Boolean>(false);
                }

                #endregion

                #region The types does not match - so try to convert the right-handed to the left handed type

                else if (myDBBaseObjectA is DBUInt64)
                {
                    //
                    if (DBUInt64.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return new Exceptional<Boolean>(true);
                    }
                    return new Exceptional<Boolean>(ConvertToBestMatchingTypeReverse(ref myDBBaseObjectA, ref myDBBaseObjectB));
                }

                else if (myDBBaseObjectA is DBInt64)
                {
                    //
                    if (DBInt64.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return new Exceptional<Boolean>(true);
                    }
                    return new Exceptional<Boolean>(ConvertToBestMatchingTypeReverse(ref myDBBaseObjectA, ref myDBBaseObjectB));
                }

                else if (myDBBaseObjectA is DBInt32)
                {
                    //
                    if (DBInt32.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return new Exceptional<Boolean>(true);
                    }
                    return new Exceptional<Boolean>(ConvertToBestMatchingTypeReverse(ref myDBBaseObjectA, ref myDBBaseObjectB));
                }

                else if (myDBBaseObjectA is DBDouble)
                {
                    //
                    if (DBDouble.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return new Exceptional<Boolean>(true);
                    }
                    return new Exceptional<Boolean>(ConvertToBestMatchingTypeReverse(ref myDBBaseObjectA, ref myDBBaseObjectB));
                }

                else if (myDBBaseObjectA is DBDateTime)
                {
                    //
                    if (DBDateTime.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return new Exceptional<Boolean>(true);
                    }
                    return new Exceptional<Boolean>(ConvertToBestMatchingTypeReverse(ref myDBBaseObjectA, ref myDBBaseObjectB));
                }

                else if (myDBBaseObjectA is DBBoolean)
                {
                    //
                    if (DBBoolean.IsValid(myDBBaseObjectB.Value))
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                        return new Exceptional<Boolean>(true);
                    }
                    return new Exceptional<Boolean>(ConvertToBestMatchingTypeReverse(ref myDBBaseObjectA, ref myDBBaseObjectB));
                }

                #endregion

                // we couldnt find a matching type for both are not unknown
                return new Exceptional<bool>(new Error_NotImplemented(new StackTrace(true), String.Format("no type conversion implemented for {0} and {1}", myDBBaseObjectA.GetType(), myDBBaseObjectB.GetType())));

            }

            #endregion

            #region Both are strings - thats fine

            else if (myDBBaseObjectA is DBString && myDBBaseObjectB is DBString)
            {
                return new Exceptional<Boolean>(true);
            }

            #endregion

            #region only one is unknown

            else if (!(myDBBaseObjectA.Type == BasicType.Unknown && myDBBaseObjectB.Type == BasicType.Unknown))
            {

                #region myDBBaseObjectA is unknown - try to use the type of myDBBaseObjectB

                if (myDBBaseObjectA.Type == BasicType.Unknown)
                {

                    // avoid changing a Double to Int64
                    if (myDBBaseObjectA is DBNumber
                        && (myDBBaseObjectB.Type == BasicType.Int64 || myDBBaseObjectB.Type == BasicType.UInt64))
                    {
                        if (myDBBaseObjectA.Value is Double && DBDouble.IsValid(myDBBaseObjectB.Value))
                        {
                            myDBBaseObjectA = new DBDouble(myDBBaseObjectA.Value);
                            myDBBaseObjectB = new DBDouble(myDBBaseObjectB.Value);
                            return new Exceptional<bool>(true);
                        }
                    }

                    try
                    {
                        myDBBaseObjectA = myDBBaseObjectB.Clone(myDBBaseObjectA.Value);
                    }
                    catch
                    {
                        return new Exceptional<bool>(new Error_DataTypeDoesNotMatch(myDBBaseObjectB.GetType().Name, myDBBaseObjectA.Value.GetType().Name));
                    }

                }

                #endregion

                #region myDBBaseObjectB is unknown - try to use the type of myDBBaseObjectA

                else if (myDBBaseObjectB.Type == BasicType.Unknown)
                {

                    // avoid changing a Double to Int64
                    if (myDBBaseObjectB is DBNumber
                        && (myDBBaseObjectA.Type == BasicType.Int64 || myDBBaseObjectA.Type == BasicType.UInt64))
                    {
                        if (myDBBaseObjectB.Value is Double && DBDouble.IsValid(myDBBaseObjectA.Value))
                        {
                            myDBBaseObjectA = new DBDouble(myDBBaseObjectA.Value);
                            myDBBaseObjectB = new DBDouble(myDBBaseObjectB.Value);
                            return new Exceptional<bool>(true);
                        }
                    }

                    try
                    {
                        myDBBaseObjectB = myDBBaseObjectA.Clone(myDBBaseObjectB.Value);
                    }
                    catch
                    {
                        return new Exceptional<bool>(new Error_DataTypeDoesNotMatch(myDBBaseObjectA.Value.GetType().ToString(), myDBBaseObjectB.GetType().ToString()));
                    }

                }

                else
                {
                    return new Exceptional<bool>(false);
                }

                #endregion

            }

            #endregion

            #region both are unknown

            #region One of them is expected as a Number - so try to parse both as a number

            else if (myDBBaseObjectA is DBNumber || myDBBaseObjectB is DBNumber)
            {

                if (DBInt64.IsValid(myDBBaseObjectA.Value) && DBInt64.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBInt64(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBInt64(myDBBaseObjectB.Value);
                }

                else if (DBUInt64.IsValid(myDBBaseObjectA.Value) && DBUInt64.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBUInt64(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBUInt64(myDBBaseObjectB.Value);
                }

                else if (DBDouble.IsValid(myDBBaseObjectA.Value) && DBDouble.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBDouble(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBDouble(myDBBaseObjectB.Value);
                }

                else
                {
                    return new Exceptional<Boolean>(false);
                }

            }

            #endregion

            #region Try all other dataTypes

            else
            {

                // check all types beginning with the hardest and ending with string (matches all)
                if (DBDateTime.IsValid(myDBBaseObjectA.Value) && DBDateTime.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBDateTime(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBDateTime(myDBBaseObjectB.Value);
                }

                else if (DBBoolean.IsValid(myDBBaseObjectA.Value) && DBBoolean.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBBoolean(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBBoolean(myDBBaseObjectB.Value);
                }

                else if (DBEdge.IsValid(myDBBaseObjectA.Value) && DBEdge.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBEdge(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBEdge(myDBBaseObjectB.Value);
                }

                else if (DBReference.IsValid(myDBBaseObjectA.Value) && DBReference.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBReference(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBReference(myDBBaseObjectB.Value);
                }

                else if (DBString.IsValid(myDBBaseObjectA.Value) && DBString.IsValid(myDBBaseObjectB.Value))
                {
                    myDBBaseObjectA = new DBString(myDBBaseObjectA.Value);
                    myDBBaseObjectB = new DBString(myDBBaseObjectB.Value);
                }

                else
                {
                    return new Exceptional<Boolean>(false);
                }

            }

            #endregion

            #endregion

            return new Exceptional<bool>(true);
        }
Esempio n. 25
0
        public override void ApplyParams(params EdgeTypeParamDefinition[] myParams)
        {
            if (myParams.Count() == 0)
                throw new ArgumentException("EdgeTypeWeightedList: Expected at least 1 parameter for edge type WeightedList!");

            // The first parameter has to be the type
            if (myParams[0].Type != ParamType.GraphType)
            {
                throw new ArgumentException("EdgeTypeWeightedList: The first parameter has to be the type 'Integer', 'Double, etc");
            }
            else
            {
                weightDataType = myParams[0].Param as ADBBaseObject;
            }

            #region Get default node if exists

            if (myParams.Any(p => p.Type == ParamType.DefaultValueDef))
            {
                var def = (from p in myParams where p.Type == ParamType.DefaultValueDef select p).First();
                weightDataType.SetValue(def.Param);
            }

            #endregion

            weightedSet.SetWeightedDefaultValue((DBNumber)weightDataType);

            #region Get sort if exists

            if (myParams.Any(p => p.Type == ParamType.Sort))
            {
                var sort = (from p in myParams where p.Type == ParamType.Sort select p).First();
                weightedSet.SetSortDirection((SortDirection)sort.Param);
            }

            #endregion

            CalcEstimatedSize(this);
        }
Esempio n. 26
0
        /// <summary>
        /// check for the correct type of each list item
        /// </summary>
        /// <param name="myObjects">current object in list</param>
        /// <param name="myLastObject">last object in list</param>
        /// <returns>an ADBBaseObject</returns>
        private ADBBaseObject CheckTypeOfItems(object myObjects, ADBBaseObject myLastObject)
        {
            var baseObject = GraphDBTypeMapper.GetBaseObjectFromCSharpType(myObjects);

            if (baseObject.Type == myLastObject.Type)
            {
                return baseObject;
            }
            else
            {
                throw new GraphDBException(new Error_InvalidAttrDefaultValueAssignment(baseObject.ObjectName, myLastObject.ObjectName));
            }
        }
Esempio n. 27
0
 public override int CompareTo(ADBBaseObject obj)
 {
     return CompareTo(obj.Value);
 }
Esempio n. 28
0
 protected override Exceptional<Boolean> Compare(ADBBaseObject myLeft, ADBBaseObject myRight)
 {
     if (!GraphDBTypeMapper.ConvertToBestMatchingType(ref myLeft, ref myRight).Value)
     {
         return new Exceptional<Boolean>(new Error_DataTypeDoesNotMatch(myLeft.Type.ToString(), myRight.Type.ToString()));
     }
     return new Exceptional<Boolean>(myLeft.CompareTo(myRight) == 0);
 }
Esempio n. 29
0
 public override void Sub(ADBBaseObject myGraphObject)
 {
     throw new NotImplementedException();
 }
Esempio n. 30
0
 protected abstract Exceptional<Boolean> Compare(ADBBaseObject myLeft, ADBBaseObject myRight);