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()); }
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()); }