public string Map(object o)
        {
            DictionaryEntry entry = (DictionaryEntry)o;
            string          value = "(" + entry.Value + ")";

            return(ASPMapperHelper.getInstance().buildMapping((string)entry.Key, '^', value));
        }
        public string getASPRepresentation(SimpleSensor s)
        {
            String sensorMapping = "";

            foreach (string p in s.properties.Distinct())
            {
                if (s.operationPerProperty.ContainsKey(p))
                {
                    sensorMapping += "%";
                    string keyWithoutDotsAndSpaces = p.Replace(".", "");
                    keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace(" ", "");
                    keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace("_", "");
                    string sensorNameNotCapital = char.ToLower(s.sensorName[0]) + s.sensorName.Substring(1);
                    //MyDebugger.MyDebug("goname " + s.gOName);
                    string goNameNotCapital = "";
                    if (s.gOName.Length > 0)
                    {
                        goNameNotCapital = char.ToLower(s.gOName[0]) + s.gOName.Substring(1);
                    }

                    sensorMapping += sensorNameNotCapital + "(";
                    if (!s.gOName.Equals(""))
                    {
                        sensorMapping += goNameNotCapital + "(";
                    }
                    sensorMapping += ASPMapperHelper.getInstance().buildMapping(keyWithoutDotsAndSpaces, '^', "(X)") + ")";
                    if (!s.gOName.Equals(""))
                    {
                        sensorMapping += ").";
                    }
                    sensorMapping += Environment.NewLine;
                }
            }
            return(sensorMapping);
        }
 public static ASPMapperHelper getInstance()
 {
     if (instance == null)
     {
         instance = new ASPMapperHelper();
     }
     return(instance);
 }
        public string getASPRepresentation(AdvancedSensor s)
        {
            MappingManager manager = MappingManager.getInstance();
            string         rep     = ((ASPSimpleSensorMapper)manager.getMapper(typeof(SimpleSensor))).getASPRepresentation(s);

            foreach (string p in s.advancedConf.Keys.Distinct())
            {
                List <string> elementConf             = s.advancedConf[p].toSave;
                string        keyWithoutDotsAndSpaces = p.Replace(".", "");
                keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace(" ", "");
                keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace("_", "");
                string sensorNameNotCapital = char.ToLower(s.sensorName[0]) + s.sensorName.Substring(1);
                //Debug.Log("goname " + s.gOName);
                string goNameNotCapital = "";
                if (s.gOName.Length > 0)
                {
                    goNameNotCapital = char.ToLower(s.gOName[0]) + s.gOName.Substring(1);
                }

                foreach (string p2 in elementConf)
                {
                    rep += "%" + sensorNameNotCapital + "(";
                    if (!s.gOName.Equals(""))
                    {
                        rep += goNameNotCapital + "(";
                    }
                    string elemType = s.advancedConf[p].name;
                    elemType = Char.ToLower(elemType[0]) + elemType.Substring(1);
                    string partial = elemType + "(" + ASPMapperHelper.getInstance().buildMapping(p2, '^', "(V)") + ")";
                    //Debug.Log("Advanced conf " + p);
                    if (s.matrixProperties.Count > 0)
                    {
                        //Debug.Log("matrix " + s.matrixProperties.First());
                    }
                    if (s.listProperties.Count > 0)
                    {
                        //Debug.Log("list " + s.listProperties.First());
                    }
                    if (s.matrixProperties.ContainsKey(p))
                    {
                        //Debug.Log("is a matrix");
                        rep += ASPMapperHelper.getInstance().buildMapping(keyWithoutDotsAndSpaces, '^', "(X,Y," + partial + ")") + ")";//TODO: improve whene map other types
                    }
                    else if (s.listProperties.ContainsKey(p))
                    {
                        //Debug.Log("is a list");
                        rep += ASPMapperHelper.getInstance().buildMapping(keyWithoutDotsAndSpaces, '^', "(X," + partial + ")") + ")";//TODO: improve whene map other types
                    }
                    if (!s.gOName.Equals(""))
                    {
                        rep += ").";
                    }
                    rep += Environment.NewLine;
                }
            }
            return(rep);
        }
        internal Dictionary <string, List <string> > getTemplateASPRepresentation(SimpleSensor s)
        {
            Dictionary <string, List <string> > sensorMapping = new Dictionary <string, List <string> >();

            foreach (string p in s.properties.Distinct())
            {
                sensorMapping.Add(p, new List <string>());
                if (s.operationPerProperty.ContainsKey(p))
                {
                    string keyWithoutDotsAndSpaces = p.Replace(".", "");
                    keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace(" ", "");
                    keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace("_", "");
                    string sensorNameNotCapital = char.ToLower(s.sensorName[0]) + s.sensorName.Substring(1);
                    //MyDebugger.MyDebug("goname " + s.gOName);
                    string goNameNotCapital = "";
                    if (s.gOName.Length > 0)
                    {
                        goNameNotCapital = char.ToLower(s.gOName[0]) + s.gOName.Substring(1);
                    }

                    sensorMapping[p].Add(sensorNameNotCapital + "(");
                    if (!s.gOName.Equals(""))
                    {
                        sensorMapping[p][0] += goNameNotCapital + "(";
                    }
                    List <string> temp = ASPMapperHelper.getInstance().buildTemplateMapping(keyWithoutDotsAndSpaces, '^');
                    sensorMapping[p][0] += temp[0];
                    sensorMapping[p].Add("");
                    sensorMapping[p].Add(temp[temp.Count - 1] + ")");
                    if (!s.gOName.Equals(""))
                    {
                        sensorMapping[p][2] += ").";
                    }
                }
            }
            return(sensorMapping);
        }
        public Dictionary <string, List <string> > getTemplateASPRepresentation(AdvancedSensor s)
        {
            MappingManager manager = MappingManager.getInstance();
            Dictionary <string, List <string> > rep = ((ASPSimpleSensorMapper)manager.getMapper(typeof(SimpleSensor))).getTemplateASPRepresentation(s);

            foreach (string p in s.advancedConf.Keys.Distinct())
            {
                List <string> elementConf             = s.advancedConf[p].toSave;
                string        keyWithoutDotsAndSpaces = p.Replace(".", "");
                keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace(" ", "");
                keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace("_", "");
                string sensorNameNotCapital = char.ToLower(s.sensorName[0]) + s.sensorName.Substring(1);
                //Debug.Log("goname " + s.gOName);
                string goNameNotCapital = "";
                if (s.gOName.Length > 0)
                {
                    goNameNotCapital = char.ToLower(s.gOName[0]) + s.gOName.Substring(1);
                }

                foreach (string p2 in elementConf)
                {
                    rep.Add(p + "$" + p2, new List <string>()); //each property of the inner element is referred as propertyName$elementPropertyName
                    List <string> partial = rep[p + "$" + p2];
                    partial.Add(sensorNameNotCapital + "(");
                    if (!s.gOName.Equals(""))
                    {
                        partial[0] += goNameNotCapital + "(";
                    }
                    string elemType = s.advancedConf[p].name;
                    elemType = Char.ToLower(elemType[0]) + elemType.Substring(1);

                    List <string> inner = ASPMapperHelper.getInstance().buildTemplateMapping(p2, '^');
                    inner[0] = elemType + "(" + inner[0];
                    inner[inner.Count - 1] += ")";

                    List <string> temp = ASPMapperHelper.getInstance().buildTemplateMapping(keyWithoutDotsAndSpaces, '^');
                    partial[0] = partial[0] + temp[0] + "(";
                    partial.Add(inner[0]);
                    partial.Add(inner[inner.Count - 1] + temp[temp.Count - 1] + "))");

                    /*Debug.Log("Advanced conf " + p);
                     * if (s.matrixProperties.Count > 0)
                     * {
                     *  //Debug.Log("matrix " + s.matrixProperties.First());
                     * }
                     * if (s.listProperties.Count > 0)
                     * {
                     *  //Debug.Log("list " + s.listProperties.First());
                     * }
                     * if (s.matrixProperties.ContainsKey(p))
                     * {
                     *  //Debug.Log("is a matrix");
                     *  List<string> temp= ASPMapperHelper.getInstance().buildTemplateMapping(keyWithoutDotsAndSpaces, '^');//TODO: improve whene map other types
                     *  partial[0] = partial[0] + temp[0]+"(" + inner[0];
                     *  partial.Add("");
                     *  partial.Add(inner[inner.Count - 1] + temp[temp.Count - 1] + "))");
                     *
                     * }
                     * else if (s.listProperties.ContainsKey(p))
                     * {
                     *  //Debug.Log("is a list");
                     *  rep += ASPMapperHelper.getInstance().buildMapping(keyWithoutDotsAndSpaces, '^', "(X," + partial + ")") + ")";//TODO: improve whene map other types
                     *
                     * }*/
                    if (!s.gOName.Equals(""))
                    {
                        partial[partial.Count - 1] += ").";
                    }
                }
            }
            return(rep);
        }