/// <summary> /// Disconnect a Feature Extractor from a Data Type Node if the feature extracted doesn't match our expected type /// </summary> /// <typeparam name="T"></typeparam> /// <param name="node"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="expectedType"></param> /// <returns></returns> public static bool DisconnectFeatureNotSameIMLDataType <T>(this BaseDataTypeNode <T> node, NodePort from, NodePort to, IMLSpecifications.DataTypes expectedType) { // Make sure that the feature connected is matching our type bool disconnect = false; // If it is a feature... if (from.node is IFeatureIML featureConnected) { // If it is a feature... if (featureConnected != null) { // Check that dataType is the same as the expected one if (featureConnected.FeatureValues.DataType != expectedType) { from.Disconnect(to); disconnect = true; } } } return(disconnect); }
/// <summary> /// Disconnect two IML Data Types if they are not equal /// </summary> /// <typeparam name="T"></typeparam> /// <param name="node"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="expectedType"></param> /// <returns></returns> public static bool DisconnectIfNotSameIMLDataType <T>(this BaseDataTypeNode <T> node, NodePort from, NodePort to, IMLSpecifications.DataTypes expectedType) { // Make sure that the IMLDataType connected is matching our type bool disconnect = false; // If it is a IMLDataType, check that it is the exact same one if (from.node.GetType().Equals(typeof(IMLBaseDataType))) { var featureConnected = from.node as IFeatureIML; // If it is a feature... if (featureConnected != null) { // Check that dataType is the same as the expected one if (featureConnected.FeatureValues.DataType != expectedType) { from.Disconnect(to); disconnect = true; } } } return(disconnect); }
/// <summary> /// Disconnects two nodes if two Data Type Nodes are not exactly the same /// </summary> /// <typeparam name="T"></typeparam> /// <param name="node"></param> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> public static bool DisconnectIfNotSameDataTypeNode <T> (this BaseDataTypeNode <T> node, NodePort from, NodePort to) { bool disconnect = false; // Check if types are matching Type nodeConnectedType = from.node.GetType(); // Check if the from node is a dataType var isDataType = ReusableMethods.Types.IsSubclassOfRawGeneric(typeof(BaseDataTypeNode <>), nodeConnectedType); // If it is a dataType... if (isDataType) { // Check if both from and to are the same dataType var isSameType = nodeConnectedType.Equals(node.GetType()); // If not (i.e. a float vs a Vector3) if (!isSameType) { // We disconnect the nodes from.Disconnect(to); disconnect = true; } } return(disconnect); }