Пример #1
0
        //public override IObject GetReturnType(IObject myWorkingBase, DBTypeManager myTypeManager)
        //{
        //    return base.GetReturnType(myWorkingBase, myTypeManager);
        //}
        /// <summary>
        /// Calls a webservice to get the current currency conversion ratio of the two given currencies and returns the calling value times the ratio.
        /// This method contains the entire logic of the function.
        /// </summary>
        /// <param name="dbContext">The current DBContext.</param>
        /// <param name="myParams">The parameters for the function. Must be two strings, that contains the currency codes. <see cref="CurrencyConverterFunction"/></param>
        /// <returns>The currency converted value</returns>
        public override Exceptional<FuncParameter> ExecFunc(DBContext dbContext, params FuncParameter[] myParams)
        {
            var resolvingEdge = (myParams[0].Value as DBTypeAttribute).GetValue();
            var source = (CallingObject as IReferenceEdge);

            var returningEdge = new EdgeTypeSetOfReferences();

            foreach(var dbStream in source.GetAllEdgeDestinations(dbContext.DBObjectCache))
            {

                if (dbStream.Failed())
                {
                    return new Exceptional<FuncParameter>(dbStream);
                }

                var hyperEdge = dbStream.Value.GetAttribute(resolvingEdge, resolvingEdge.GetDBType(dbContext.DBTypeManager), dbContext);
                if (hyperEdge.Value == null)
                {
                    return new Exceptional<FuncParameter>(new FuncParameter(null));
                }
                if (hyperEdge.Failed())
                {
                    return new Exceptional<FuncParameter>(hyperEdge);
                }

                returningEdge.AddRange((hyperEdge.Value as IReferenceEdge).GetAllReferenceIDs(), resolvingEdge.DBTypeUUID);

            }

            return new Exceptional<FuncParameter>(new FuncParameter(returningEdge, resolvingEdge));
        }
Пример #2
0
 private void Serialize(ref SerializationWriter mySerializationWriter, EdgeTypeSetOfReferences myValue)
 {
     mySerializationWriter.WriteInt32(myValue._ObjectUUIDs.Count);
     foreach (var obj in myValue._ObjectUUIDs)
     {
         obj.Value.Serialize(ref mySerializationWriter);
     }
 }
Пример #3
0
        private object Deserialize(ref SerializationReader mySerializationReader, EdgeTypeSetOfReferences myValue)
        {
            var count = mySerializationReader.ReadInt32();
            for (Int32 i = 0; i < count; i++)
            {
                Reference aRef = new Reference();
                aRef.Deserialize(ref mySerializationReader);
                myValue._ObjectUUIDs.Add(aRef.ObjectUUID, aRef);
            }

            CalcEstimatedSize(myValue);

            return myValue;
        }
Пример #4
0
        private void CalcEstimatedSize(EdgeTypeSetOfReferences myTypeAttribute)
        {
            //Dictionary<ObjectUUID, Reference> + base size
            _estimatedSize = base.GetBaseSize();

            if (_ObjectUUIDs != null)
            {
                _estimatedSize += EstimatedSizeConstants.Dictionary;

                foreach (var aKV in _ObjectUUIDs)
                {
                    //key
                    _estimatedSize += EstimatedSizeConstants.CalcUUIDSize(aKV.Key);

                    //Value
                    _estimatedSize += aKV.Value.GetEstimatedSize();
                }
            }
        }
Пример #5
0
        public override IReferenceEdge GetNewInstance(IEnumerable<Exceptional<DBObjectStream>> iEnumerable)
        {
            var newEdge = new EdgeTypeSetOfReferences();

            foreach (var aDBO in iEnumerable)
            {
                newEdge.Add(aDBO.Value.ObjectUUID, aDBO.Value.TypeUUID);
            }

            return newEdge;
        }
Пример #6
0
        private Edge GetNotResolvedBackwardEdgeReferenceAttributeValue(DBObjectStream myDBObject, TypeAttribute myTypeAttribute, EdgeKey edgeKey, EdgeList currentEdgeList, Boolean myUsingGraph, DBContext _DBContext)
        {

            IObject attrValue = null;

            if (myUsingGraph)
            {
                var interestingLevelKey = new LevelKey((currentEdgeList + new EdgeKey(myTypeAttribute.RelatedGraphDBTypeUUID, myTypeAttribute.UUID)).Edges, _DBContext.DBTypeManager);

                attrValue = new EdgeTypeSetOfReferences(_ExpressionGraph.SelectUUIDs(interestingLevelKey, myDBObject), myTypeAttribute.DBTypeUUID);
            }

            else
            {
                var attrValueException = myDBObject.GetBackwardEdges(edgeKey, _DBContext, _DBContext.DBObjectCache, myTypeAttribute.GetDBType(_DBContext.DBTypeManager));
                if (attrValueException.Failed())
                {
                    throw new GraphDBException(attrValueException.IErrors);
                }

                attrValue = attrValueException.Value;
            }

            if (attrValue == null)
            {
                return null;
            }

            else if (!(attrValue is IReferenceEdge))
            {
                throw new GraphDBException(new Error_InvalidEdgeType(attrValue.GetType(), typeof(IReferenceEdge)));
            }

            var readouts = new List<Vertex>();
            var typeName = _DBContext.DBTypeManager.GetTypeByUUID(edgeKey.TypeUUID).Name;

            foreach (var reference in (attrValue as IReferenceEdge).GetAllReferenceIDs())
            {
                var specialAttributes = new Dictionary<string, object>();
                specialAttributes.Add(SpecialTypeAttribute_UUID.AttributeName, reference);
                specialAttributes.Add(SpecialTypeAttribute_TYPE.AttributeName, typeName);

                readouts.Add(new Vertex(specialAttributes));
            }

            return new Edge(null, readouts, _DBContext.DBTypeManager.GetTypeAttributeByEdge(edgeKey).GetDBType(_DBContext.DBTypeManager).Name);

        }