none
Reusing extensions in FIM RRS feed

  • Question

  • Can anybody say, how I can make reusable extension in FIM?

    I have 3 functions to replace chars (diacritics) in First Name, Last Name and Initials.

    For example (part of code):

    case "LASTEN":
    
    if (csentry["LAST"].IsPresent)
      {
       string LAST = csentry["LAST"].Value;
       string LAST_EN;
       LAST_EN = Regex.Replace(LAST, "[Б]", "B");
       LAST_EN = Regex.Replace(LAST, "[Ж]", "Zh");
       LAST_EN = Regex.Replace(LAST, "[Ю]", "Yu");
       LAST_EN = Regex.Replace(LAST, "[П]", "P");
    
    mventry["lastNameEN"].Value = LAST_EN;
                        }

    I want to use this code for 3 times First Name, Last Name and Initials, how I can do it without using 3 "tables" of changing chars?

    Thanks!


    1


    • Edited by alexiszp Friday, September 2, 2016 2:54 PM
    Friday, September 2, 2016 2:50 PM

Answers

  • you can create a method called Replace(), and then call the method for each attribute

    public static replaceChars(string inputAttribute)

    {

    //Do the work here

    }

    Then your code will look like this

    case "LASTEN":

    if (csentry["LAST"].IsPresent)
     
    {
      
    replaceChars(csentry["LAST"].Value);
    mventry
    ["lastNameEN"].Value = LAST_EN;
                       
    }


    Nosh Mernacaj, Identity Management Specialist

    • Marked as answer by alexiszp Wednesday, September 14, 2016 10:06 AM
    Friday, September 2, 2016 4:39 PM

All replies

  • you can create a method called Replace(), and then call the method for each attribute

    public static replaceChars(string inputAttribute)

    {

    //Do the work here

    }

    Then your code will look like this

    case "LASTEN":

    if (csentry["LAST"].IsPresent)
     
    {
      
    replaceChars(csentry["LAST"].Value);
    mventry
    ["lastNameEN"].Value = LAST_EN;
                       
    }


    Nosh Mernacaj, Identity Management Specialist

    • Marked as answer by alexiszp Wednesday, September 14, 2016 10:06 AM
    Friday, September 2, 2016 4:39 PM
  • When I try to use this method I getting an error, what method must have a return type.

    As I understand I need to do something like this:

    1. Somewhere in this block:

    public class MAExtensionObject : IMASynchronization
    {}
    I need to declare 

    public static replaceChar(string inputAttribute)
    {
       string FIELD_RU = inputAttribute;
       string FIELD_EN;
       FIELD_EN = Regex.Replace(FIELD_RU, "[Б]", "B");
       FIELD_EN = Regex.Replace(FIELD_RU, "[Ж]", "Zh");
       FIELD_EN = Regex.Replace(FIELD_RU, "[Ю]", "Yu");
       FIELD_EN = Regex.Replace(FIELD_RU, "[П]", "P");
    }
       
    And using will be like 

    case "LASTEN":
    {
    if (csentry["LAST"].IsPresent)
      {
      replaceChars(csentry["LAST"].Value); 
      mventry["lastNameEN"].Value = LAST_EN;
            }

    case "FIRSTEN":
    {
    if (csentry["FIRST"].IsPresent)
      {
      replaceChars(csentry["FIRST"].Value); 
      mventry["firstNameEN"].Value = FIRST_EN;
            }

    So, I can't understand where is error causing "method must have a return type" ?
    Thanks!


    • Edited by alexiszp Monday, September 5, 2016 10:33 AM
    Monday, September 5, 2016 9:12 AM
  • 1.this was a sudo code, not a finished ready to use.

    2- Static, does not retun anything, so change to public string

    3- Place the method at the end of your code, no need to add any libraries


    Nosh Mernacaj, Identity Management Specialist

    Monday, September 5, 2016 11:50 AM