예제 #1
0
        public override object GetValue(ConnectorViewModel connector, object context)
        {
            switch (CastToType)
            {
            //case CastType.SByte:
            //    return (SByte)retVal;
            //case CastType.Int16:
            //    return (Int16)retVal;
            //case CastType.Int32:
            //    return (Int32)retVal;
            //case CastType.Int64:
            //    return (Int64)retVal;
            //case CastType.Byte:
            //    return (Byte)retVal;
            //case CastType.UInt16:
            //    return (UInt16)retVal;
            //case CastType.UInt32:
            //    return (UInt32)retVal;
            //case CastType.UInt64:
            //    return (UInt64)retVal;
            case CastType.Double:
                return(NodeDataNumeric.FromDouble(Value));
                //case CastType.Single:
                //    return (Single)retVal;
                //case CastType.Decimal:
                //    return (Decimal)retVal;

                //case CastType.IConvertable:
                //    return enumeration.Sum(dr => dr);
            }
            return(NodeDataNumeric.MakeZero());
        }
예제 #2
0
파일: Sum.cs 프로젝트: nanika0/NekoPuppet
        public override object GetValue(ConnectorViewModel connector, object context)
        {
            if (conInput.IsConnected)
            {
                Cache  cache;
                double retVal;
                if (context == null || !DataCache.TryGetValue(context, out cache))
                {
                    retVal = conInput.AttachedConnections.Sum(connection =>
                    {
                        object tmp = connection.SourceConnector.ParentNode.GetValue(connection.SourceConnector, context);
                        try { if (typeof(NodeDataNumeric).IsAssignableFrom(tmp.GetType()))
                              {
                                  return(((NodeDataNumeric)tmp).GetDouble());
                              }
                        } catch { }
                        return(0d);
                    });
                    DataCache.Add(context, new Cache()
                    {
                        value = retVal
                    });
                }
                else
                {
                    retVal = cache.value;
                }

                switch (CastToType)
                {
                //case CastType.SByte:
                //    return (SByte)retVal;
                //case CastType.Int16:
                //    return (Int16)retVal;
                //case CastType.Int32:
                //    return (Int32)retVal;
                //case CastType.Int64:
                //    return (Int64)retVal;
                //case CastType.Byte:
                //    return (Byte)retVal;
                //case CastType.UInt16:
                //    return (UInt16)retVal;
                //case CastType.UInt32:
                //    return (UInt32)retVal;
                //case CastType.UInt64:
                //    return (UInt64)retVal;
                case CastType.Double:
                    return(NodeDataNumeric.FromDouble(retVal));
                    //case CastType.Single:
                    //    return (Single)retVal;
                    //case CastType.Decimal:
                    //    return (Decimal)retVal;

                    //case CastType.IConvertable:
                    //    return enumeration.Sum(dr => dr);
                }
                return(NodeDataNumeric.MakeZero());
            }
            return(NodeDataNumeric.MakeZero());
        }