//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public static ElementWindowPrms DisableIfTriggerInitialize(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEdittable) /// /// \brief Disables if trigger initialize. /// /// \par Description. /// - This method is activated to set for the GUI the display parameters: /// - If the trigger is Initialize - disable the field /// - Else enable the fields /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 09/05/2018 /// /// \param attribute (Attribute) - The attribute. /// \param key (dynamic) - The key. /// \param mainNetworkElement (NetworkElement) - The main network element. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. /// \param inputWindow (InputWindows) - The input window. /// \param windowEdittable (bool) - true if window edittable. /// /// \return The ElementWindowPrms. //////////////////////////////////////////////////////////////////////////////////////////////////// public static ElementWindowPrms DisableIfTriggerInitialize(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEdittable) { ElementWindowPrms prms = new ElementWindowPrms(); attribute.DefaultNewValueFieldData(ref prms, mainNetworkElement, mainDictionary, dictionary, inputWindow, windowEdittable, attribute.Editable); if (((AttributeDictionary)attribute.Parent)[Comps.Trigger] == EventTriggerType.Initialize) { prms.newValueControlPrms.enable = false; } else { prms.newValueControlPrms.enable = true; } return(prms); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public Permissions(Permissions permissions) /// /// \brief Constructor. /// /// \par Description. /// Copy constructor. /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 25/07/2017 /// /// \param permissions (Permissions) - The permissions. //////////////////////////////////////////////////////////////////////////////////////////////////// public Permissions(Permissions permissions) { this.permissions = new bool[numPhases, numPermitionTypes]; this.dictionary = permissions.dictionary; Set(permissions); Set(MainWindow.ActivationPhases.Temp, true); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public void AttributeReport(dynamic key, Attribute newAttribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) /// /// \brief Attribute report. /// /// \par Description. /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 28/12/2017 /// /// \param key (dynamic) - The key. /// \param newAttribute (Attribute) - The new attribute. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. //////////////////////////////////////////////////////////////////////////////////////////////////// public void AttributeReport(dynamic key, Attribute newAttribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) { // If we are in a status of skipping (means that we are scanning an attribute // that does not exist in the existing) we exit if (skipAttribute != null) { return; } Attribute existingAttribute = GetExistingChildAttribute(key, newAttribute); if (existingAttribute != null) { // If the attribute exists in the existing and it's value was changed during network build // copy the value from the exists to the new if (existingAttribute.Changed) { newAttribute.Value = existingAttribute.Value; } return; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public override bool ScanCondition(dynamic key, Attribute attribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) /// /// \brief Scans a condition. /// /// \par Description. /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 01/11/2017 /// /// \param key (dynamic) - The key. /// \param attribute (Attribute) - The attribute. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. /// /// \return True if it succeeds, false if it fails. //////////////////////////////////////////////////////////////////////////////////////////////////// public override bool ScanCondition(dynamic key, Attribute attribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) { return(dictionary == NetworkElement.ElementDictionaries.PrivateAttributes); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public bool ScanCondition(dynamic key, Attribute newAttribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) /// /// \brief Scans a condition. /// /// \par Description. /// Scan all the NetworkElement /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 28/12/2017 /// /// \param key (dynamic) - The key. /// \param newAttribute (Attribute) - The new attribute. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. /// /// \return True if it succeeds, false if it fails. //////////////////////////////////////////////////////////////////////////////////////////////////// public bool ScanCondition(dynamic key, Attribute newAttribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) { return(true); }
/**********************************************************************************************//** * Closes complex attribute. * * \author Ilan Hindy * \date 29/09/2016 * * \param attribute The attribute. * \param key The key. * \param name The name. * \param dictionary The dictionary. * **************************************************************************************************/ public void CloseComplexAttribute(dynamic key, Attribute attribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) { if (((Attribute)attribute).Value is Breakpoint) { string s = ((Breakpoint)((Attribute)attribute).Value).or[brp.ork.Name]; breakpointsLabelStringIndent = breakpointsLabelStringIndent.Substring(0, breakpointsLabelStringIndent.Length - 1); } }
/**********************************************************************************************//** * Opens complex attribute. * * \author Ilan Hindy * \date 29/09/2016 * * \param attribute The attribute. * \param key The key. * \param name The name. * \param dictionary The dictionary. * **************************************************************************************************/ public void OpenComplexAttribute(dynamic key, Attribute attribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) { if (((Attribute)attribute).Value is Breakpoint) { string s = ((Breakpoint)((Attribute)attribute).Value).ea[brp.ork.Name]; AddBreakpointToLabel((Breakpoint)((Attribute)attribute).Value); breakpointsLabelStringIndent += "\t"; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public static ElementWindowPrms InternalEventPrms(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEditable) /// /// \brief Internal event prms. /// /// \par Description. /// - This method sets the parameters of this class representation in the GUI /// - It meant mainly to set the CreateDefaultEvent as the method to be activated /// When the Add button is pressed (When the Add button is pressed a new event /// with default values will be inserted) /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 09/05/2018 /// /// \param attribute (Attribute) - The attribute. /// \param key (dynamic) - The key. /// \param mainNetworkElement (NetworkElement) - The main network element. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. /// \param inputWindow (InputWindows) - The input window. /// \param windowEditable (bool) - true if window editable. /// /// \return The ElementWindowPrms. //////////////////////////////////////////////////////////////////////////////////////////////////// public static ElementWindowPrms InternalEventPrms(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEditable) { ElementWindowPrms elementWindowPrms = new ElementWindowPrms(); elementWindowPrms.newValueControlPrms.inputFieldType = InputFieldsType.AddRemovePanel; elementWindowPrms.newValueControlPrms.addAttributeMethod = CreateDefaultEvent; return(elementWindowPrms); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public static ElementWindowPrms IntListPrms(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEditable) /// /// \brief Int list prms. /// /// \par Description. /// - This method is meant to set the GUI parameters for the field Targets of the messages /// - Each message contains a list of ints which are target for the message /// - This method is added to each possible target of the message /// - The purpose of this message is to assign a check that the target entered (a process id) /// exists in the network been designed /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 09/05/2018 /// /// \param attribute (Attribute) - The attribute. /// \param key (dynamic) - The key. /// \param mainNetworkElement (NetworkElement) - The main network element. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. /// \param inputWindow (InputWindows) - The input window. /// \param windowEditable (bool) - true if window editable. /// /// \return The ElementWindowPrms. //////////////////////////////////////////////////////////////////////////////////////////////////// public static ElementWindowPrms IntListPrms(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEditable) { ElementWindowPrms prms = new ElementWindowPrms(); prms.newValueControlPrms.inputFieldType = InputFieldsType.AddRemovePanel; prms.newValueControlPrms.addAttributeMethod = CreateProcessIdAttribute; return(prms); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public static ElementWindowPrms MessageListPrms(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEditable) /// /// \brief Message list prms. /// /// \par Description. /// - The BaseAlgorithmMessages is part of an event in the BaseAlgorithmHandler list /// - This method is used by the BaseAlgorithmHandler to set the GUI presentation /// parameters /// - The purpose of this method is to set the EmptyMessagesData as the method that will /// Create a new entry in the list (When pressing the Add button of the messages list (this object) the EmptyMessageData /// will be activated in order to create a new empty message) /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 09/05/2018 /// /// \param attribute (Attribute) - The attribute. /// \param key (dynamic) - The key. /// \param mainNetworkElement (NetworkElement) - The main network element. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. /// \param inputWindow (InputWindows) - The input window. /// \param windowEditable (bool) - true if window editable. /// /// \return The ElementWindowPrms. //////////////////////////////////////////////////////////////////////////////////////////////////// public static ElementWindowPrms MessageListPrms(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEditable) { ElementWindowPrms prms = new ElementWindowPrms(); attribute.DefaultNewValueFieldData(ref prms, mainNetworkElement, mainDictionary, dictionary, inputWindow, true, true); prms.newValueControlPrms.addAttributeMethod = EmptyMessageData; return(prms); }
/**********************************************************************************************//** * Scans a condition. * * \author Ilan Hindy * \date 29/09/2016 * * \param key The key. * \param attribute The attribute. * \param dictionaryKey The dictionary key. * * \return true if it succeeds, false if it fails. * . **************************************************************************************************/ public bool ScanCondition(dynamic key, Attribute attribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) { if (attribute.Value is Breakpoint || TypesUtility.GetKeyToString(key) == TypesUtility.GetKeyToString(brp.ork.Parameters)) { return(true); } else { return(false); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public override bool ScanCondition(dynamic key, Attribute attribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) /// /// \brief Scans a condition. /// /// \par Description. /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 04/07/2017 /// /// \param key (dynamic) - The key. /// \param attribute (Attribute) - The attribute. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. /// /// \return True if it succeeds, false if it fails. //////////////////////////////////////////////////////////////////////////////////////////////////// public override bool ScanCondition(dynamic key, Attribute attribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) { if (mainDictionary == NetworkElement.ElementDictionaries.PresentationParametersBackup) { return(false); } if (mainDictionary == NetworkElement.ElementDictionaries.OperationResultsBackup) { return(false); } return(true); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public static ElementWindowPrms MethodComboBoxPrms(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEditable) /// /// \brief Method combo box prms. /// /// \par Description. /// - This method is used to set the parameters for a method field in the GUI /// - The purpose of this method is to set the options for the ComboBox as all the /// messages which has the delegate signature /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 09/05/2018 /// /// \param attribute (Attribute) - The attribute. /// \param key (dynamic) - The key. /// \param mainNetworkElement (NetworkElement) - The main network element. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. /// \param inputWindow (InputWindows) - The input window. /// \param windowEditable (bool) - true if window editable. /// /// \return The ElementWindowPrms. //////////////////////////////////////////////////////////////////////////////////////////////////// public static ElementWindowPrms MethodComboBoxPrms(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEditable) { ElementWindowPrms elementWindowPrms = new ElementWindowPrms(); elementWindowPrms.newValueControlPrms.inputFieldType = InputFieldsType.ComboBox; string[] options = TypesUtility.GetInternalEventMethods().ToArray(); elementWindowPrms.newValueControlPrms.options = options; elementWindowPrms.newValueControlPrms.Value = options[0]; return(elementWindowPrms); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public static ElementWindowPrms MessageTypePrms(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEdittable) /// /// \brief Message type prms. /// /// \par Description. /// - This method is activated to set for the GUI the display parameters for the MessageType field /// - The purpose of the message is to set the values for the ComboBox /// All the message type of the algorithm + all the message types of the Base Algorithm /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 09/05/2018 /// /// \param attribute (Attribute) - The attribute. /// \param key (dynamic) - The key. /// \param mainNetworkElement (NetworkElement) - The main network element. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. /// \param inputWindow (InputWindows) - The input window. /// \param windowEdittable (bool) - true if window edittable. /// /// \return The ElementWindowPrms. //////////////////////////////////////////////////////////////////////////////////////////////////// public static ElementWindowPrms MessageTypePrms(Attribute attribute, dynamic key, NetworkElement mainNetworkElement, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary, InputWindows inputWindow, bool windowEdittable) { ElementWindowPrms prms = new ElementWindowPrms(); prms.newValueControlPrms.inputFieldType = InputFieldsType.ComboBox; prms.newValueControlPrms.options = TypesUtility.GetEnumKeysToStrings(attribute.Value.GetType().ToString()).ToArray(); prms.newValueControlPrms.enable = true; // List<string> baseMessagesTypes = TypesUtility.GetEnumKeysToStrings(typeof(bm.MessageTypes).ToString()); // prms.newValueControlPrms.options = messagesTypes.Concat(baseMessagesTypes).ToArray(); prms.newValueControlPrms.Value = TypesUtility.GetKeyToString(attribute.Value); return(prms); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public void CloseComplexAttribute(dynamic key, Attribute newAttribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) /// /// \brief Closes complex attribute. /// /// \par Description. /// - If we are in skip mode and the attribute is not the root of the skipping - exit /// - If we are in skip mode and the attribute is the root of skipping - cancel the skipping mode /// - If we are not in skip mode pop the head of the stack /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 28/12/2017 /// /// \param key (dynamic) - The key. /// \param newAttribute (Attribute) - The new attribute. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. //////////////////////////////////////////////////////////////////////////////////////////////////// public void CloseComplexAttribute(dynamic key, Attribute newAttribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) { // If we are scanning an attribute that does not exist in the existing we skip the // Operation (This process will continue until we get the new attribute from then // we continue regularly (pop the item) if (skipAttribute != null) { if (skipAttribute == newAttribute) { skipAttribute = null; } } complexAttributes.Pop(); Report("End of CloseComplexItem"); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public void OpenComplexAttribute(dynamic key, Attribute newAttribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) /// /// \brief Opens complex attribute. /// /// \par Description. /// A complex attribute arrived. /// - If we are in a skip mode (The exists network does not have a corresponding attributes for the new) - return /// - If the attribute does not exists in the exists network - enter to skip mode /// - Else - Start a merge process /// - Push the attribute to the stack /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 28/12/2017 /// /// \param key (dynamic) - The key. /// \param newAttribute (Attribute) - The new attribute. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// \param dictionary (ElementDictionaries) - The dictionary. //////////////////////////////////////////////////////////////////////////////////////////////////// public void OpenComplexAttribute(dynamic key, Attribute newAttribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) { Report("Start of OpenComplexItem newAttribute is " + newAttribute.Parent.GetChildKey(newAttribute).ToString() + " IdInList is " + newAttribute.IdInList.ToString()); //Report("Start of OpenComplexItem"); // If we are in a status of skipping (means that we are scanning an attribute // that does not exist in the existing if (skipAttribute != null) { return; } Attribute existingAttribute = GetExistingChildAttribute(key, newAttribute); if (existingAttribute == null) { skipAttribute = newAttribute; return; } switch (Attribute.GetValueCategory(newAttribute)) { case Attribute.AttributeCategory.ListOfAttributes: MergeLists(existingAttribute, newAttribute); break; case Attribute.AttributeCategory.AttributeDictionary: MergeDictionaries(existingAttribute, newAttribute); break; default: break; } complexAttributes.Push(existingAttribute); Report("End of OpenComplexItem newAttribute is " + newAttribute.Parent.GetChildKey(newAttribute).ToString()); }
/**********************************************************************************************//** * Attribute report. * * \author Ilan Hindy * \date 29/09/2016 * * \param attribute The attribute. * \param key The key. * \param name The name. * \param dictionary The dictionary. * **************************************************************************************************/ public void AttributeReport(dynamic key, Attribute attribute, NetworkElement.ElementDictionaries mainDictionary, NetworkElement.ElementDictionaries dictionary) { }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public static bool CheckIfBelongsToBaseAlgorithmEnum(this IValueHolder valueHolder, NetworkElement networkElement, NetworkElement.ElementDictionaries mainDictionary) /// /// \brief An IValueHolder extension method that determine if belongs to base algorithm enum. /// /// \par Description. /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 29/10/2017 /// /// \param valueHolder The valueHolder to act on. /// \param networkElement (NetworkElement) - The network element. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// /// \return True if the value holder belongs to the base network element. //////////////////////////////////////////////////////////////////////////////////////////////////// public static bool BelongsToBaseAlgorithmEnum(this IValueHolder valueHolder, NetworkElement networkElement, NetworkElement.ElementDictionaries mainDictionary) { // If the value holder is not attribute get the attribute of the value holder Attribute attribute; if (!(valueHolder is Attribute)) { attribute = (Attribute)valueHolder.Parent; } else { attribute = (Attribute)valueHolder; } // The condition is that the attribute which is the ancestor of our attribute // which is in the main dictionary belongs to the base class // Find the ancestor. // The parent sequence is ending in the following way // null <- networkElement <- Attribute <- mainDictionary <- Attribute // We have to find the last element in the chain described below // We do it with a loop that advances 2 parameters: The attribute and the chain end // The chain end is 4 times the parent of the attribute // Get the first chain end (If we cannot end the chain that means that the valueHolder is // one of the value holders at the middle of the chain hence they are not attributes in the // base classes main dictionary IValueHolder chainEnd = attribute; for (int idx = 0; idx < 4; idx++) { chainEnd = chainEnd.Parent; if (chainEnd == null && idx != 3) { return(false); } } // Find the ancestor while (chainEnd != null) { chainEnd = chainEnd.Parent.Parent; attribute = (Attribute)attribute.Parent.Parent; } // Decide if the attribute is part of the main dictionary if (!((AttributeDictionary)networkElement[mainDictionary]).Values.Any(a => a == attribute)) { return(false); } // Get the key of the attribute dynamic key = attribute.Parent.GetChildKey(attribute); if (TypesUtility.CompareDynamics(key, bn.ork.SingleStepStatus)) { int x = 1; } // Get the base NetworkElement Type baseNetworkElementType = networkElement.GetType().BaseType; NetworkElement baseNetworkElement = (NetworkElement)TypesUtility.CreateObjectFromTypeString(baseNetworkElementType.ToString()); baseNetworkElement.Init(0); // Check if the key is found in the base network element's dictionary return(((AttributeDictionary)baseNetworkElement[mainDictionary]).Keys.Any(k => TypesUtility.CompareDynamics(k, key))); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn public static bool AddAlgorithmWindowAttributeEditable(this IValueHolder valueHolder, NetworkElement networkElement, NetworkElement.ElementDictionaries mainDictionary) /// /// \brief An IValueHolder extension method that decides whether an attribute is editable in AddAlgorithmWindow /// /// \par Description. /// /// \par Algorithm. /// /// \par Usage Notes. /// /// \author Ilanh /// \date 29/10/2017 /// /// \param valueHolder The valueHolder to act on. /// \param networkElement (NetworkElement) - The network element. /// \param mainDictionary (ElementDictionaries) - Dictionary of mains. /// /// \return True if it succeeds, false if it fails. //////////////////////////////////////////////////////////////////////////////////////////////////// public static bool AddAlgorithmWindowAttributeEditable(this IValueHolder valueHolder, NetworkElement networkElement, NetworkElement.ElementDictionaries mainDictionary) { // In AddAlgorithm window the ElementAttributes should be disabled because this window // is for adding new keys for a new algorithm and the ElementAttributes dictionary is for // the base types only if (mainDictionary == NetworkElement.ElementDictionaries.ElementAttributes) { return(false); } // For other dictionaries if the AttributeDictionary belongs to the base class it should // be disabled because the window is allowed to change only attributes that belongs // to the Algorithm and not the base algorithm // This rule is not applied to the messages NetworkElement because all the messages // should be changeable (The base class is empty anyway) else { if (networkElement.GetType().Equals(typeof(NetworkElement))) { return(true); } else { return(!valueHolder.BelongsToBaseAlgorithmEnum(networkElement, mainDictionary)); } } }