private ModelToViewsTuple[] InitModelViewRelation()
        {
            ModelToViewsTuple[]         modelsToViews = new ModelToViewsTuple[1];
            Dictionary <String, String> descriptions  = new Dictionary <String, String>();

            descriptions.Add("en", "This view opens the values in a SQLViewer.");
            descriptions.Add("de", "Dieses Tool öffnet die Werte in einem SQLViewer.");
            OpenEngSBCore.XLinkConnectorView[] views = new OpenEngSBCore.XLinkConnectorView[1];
            views[0] = new OpenEngSBCore.XLinkConnectorView()
            {
                name         = "SQLView",
                viewId       = "SQL Viewer",
                descriptions = descriptions.ConvertMap <OpenEngSBCore.string2stringMapEntry>()
            };
            modelsToViews[0] =
                new ModelToViewsTuple()
            {
                description = new ModelDescription()
                {
                    modelClassName = "org.openengsb.domain.SQLCode.model.SQLCreate", versionString = "3.0.0.SNAPSHOT"
                },
                views = views
            };
            return(modelsToViews);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            serializer.NullValueHandling = NullValueHandling.Ignore;
            if (IsMapType(objectType))
            {
                IDictionary list = new Dictionary <Object, Object>();
                serializer.Populate(reader, list);
                return(list.ConvertMap(objectType));
            }
            else if (IsException(objectType))
            {
                Object exceptionObject = Activator.CreateInstance(HelpMethods.ImplementTypeDynamicly(objectType, typeof(IJavaException)));
                serializer.Populate(reader, exceptionObject);
                return(exceptionObject);
            }

            Type typeWithIOpenEngSBModel;

            if (alreadyExtendedTypes.ContainsKey(objectType.Name))
            {
                typeWithIOpenEngSBModel = alreadyExtendedTypes[objectType.Name];
            }
            else
            {
                typeWithIOpenEngSBModel = HelpMethods.ImplementTypeDynamicly(objectType, typeof(IOpenEngSBModel));
                alreadyExtendedTypes.Add(objectType.Name, typeWithIOpenEngSBModel);
            }

            Object modelWithOpenEngsbModelTail = Activator.CreateInstance(typeWithIOpenEngSBModel);

            serializer.Populate(reader, modelWithOpenEngsbModelTail);
            return(modelWithOpenEngsbModelTail);
        }
Exemple #3
0
        public void TestConvertIDictionaryToMap()
        {
            IDictionary result = new Dictionary <String, int>();

            result.Add("Test", 123);
            Entry1[] arrays = (Entry1[])result.ConvertMap(typeof(Entry1[]));
        }
        /// <summary>
        /// Creates the Array of Model/View relations, offered by the Tool, for XLink
        /// </summary>
        private ModelToViewsTuple[] initModelViewRelation()
        {
            ModelToViewsTuple[] modelsToViews
                = new ModelToViewsTuple[1];
            Dictionary <String, String> descriptions = new Dictionary <String, String>();

            descriptions.Add("en", "This view opens the values in a C# SourceCode viewer.");
            descriptions.Add("de", "Dieses Tool öffnet die Werte in einem C# SourceCode viewer.");

            OpenEngSBCore.XLinkConnectorView[] views = new OpenEngSBCore.XLinkConnectorView[1];
            views[0]         = (new OpenEngSBCore.XLinkConnectorView()
            {
                name = "C# SourceCode View", viewId = Program.viewId, descriptions = descriptions.ConvertMap <entry3>()
            });
            modelsToViews[0] =
                new ModelToViewsTuple()
            {
                description = new ModelDescription()
                {
                    modelClassName = classNameOfOpenEngSBModel, versionString = "3.0.0.SNAPSHOT"
                },
                views = views
            };
            return(modelsToViews);
        }
Exemple #5
0
        public void TestConvertingWithExtendedMethodDictionaryToEntry1()
        {
            Dictionary <Object, Object> test = new Dictionary <Object, Object>();

            test.Add("1", 11);
            test.Add("21", 111);
            Entry1[] result = test.ConvertMap <Entry1>();
            foreach (Entry1 e1 in result)
            {
                Assert.IsTrue(test.ContainsKey(e1.key));
                Assert.AreEqual <Object>(test[e1.key], e1.value);
            }
        }
Exemple #6
0
        public void TestConvertingWithExtendedMethodDictionaryToEntry1WhereTheReturnTypeIsIndicatedAsType()
        {
            Dictionary <Object, Object> test = new Dictionary <Object, Object>();

            test.Add("1", 11);
            test.Add("21", 111);

            Entry1[] result = (Entry1[])test.ConvertMap(typeof(Entry1));

            foreach (Entry1 e1 in result)
            {
                Assert.IsTrue(test.ContainsKey(e1.key));
                Assert.AreEqual(test[e1.key], e1.value);
            }
        }
Exemple #7
0
        public void TestIfMapIsRecognizedAndIfVariablesAreDetectedCorrectlyAndCorrectConvertedFromJsonToObject()
        {
            IDictionary result = new Dictionary <String, String>();

            Entry1[] entry = new Entry1[]
            {
                new Entry1()
                {
                    key = "Test", value = 123
                }
            };
            result.Add("123", new JsonMarshaller().MarshallObject(entry));
            EntryWithEntryParameter[] arrays = (EntryWithEntryParameter[])result.ConvertMap(typeof(EntryWithEntryParameter));
            Assert.IsTrue(arrays[0].key.Equals("123"));
            Assert.IsTrue(arrays[0].value[0].key.Equals("Test"));
        }
Exemple #8
0
        public void TestConvertDictionaryToEntry1WithParameterTypeAreEntry1AndInJsonFormat()
        {
            // This Test case checks if an object that is not an array is not recognized as Map and converted correctly
            IDictionary result   = new Dictionary <String, String>();
            Entry1      keyEntry = new Entry1 {
                key = "Test", value = 123
            };
            Entry1 valueEntry = new Entry1 {
                key = "ValueTest", value = 111
            };

            result.Add(marshaller.MarshallObject(keyEntry), marshaller.MarshallObject(valueEntry));

            EntryWithAllEntryParameter[] arrays = (EntryWithAllEntryParameter[])result.ConvertMap(typeof(EntryWithAllEntryParameter));

            Assert.AreEqual <String>(arrays[0].key.key, keyEntry.key);
            Assert.AreEqual <int>(arrays[0].key.value, keyEntry.value);
            Assert.AreEqual <String>(arrays[0].value.key, valueEntry.key);
            Assert.AreEqual <int>(arrays[0].value.value, valueEntry.value);
        }
 private ModelToViewsTuple[] InitModelViewRelation()
 {
     ModelToViewsTuple[] modelsToViews = new ModelToViewsTuple[1];
     Dictionary<String, String> descriptions = new Dictionary<String, String>();
     descriptions.Add("en", "This view opens the values in a SQLViewer.");
     descriptions.Add("de", "Dieses Tool öffnet die Werte in einem SQLViewer.");
     XLinkConnectorView[] views = new XLinkConnectorView[1];
     views[0] = new XLinkConnectorView()
     {
         name = "SQLView",
         viewId = "SQL Viewer",
         descriptions = descriptions.ConvertMap<string2stringMapEntry>()
     };
     modelsToViews[0] =
         new ModelToViewsTuple()
     {
         description = new ModelDescription() { modelClassName = "org.openengsb.domain.SQLCode.model.SQLCreate", versionString = "3.0.0.SNAPSHOT" },
         views = views
     };
     return modelsToViews;
 }
        /// <summary>
        /// Creates the Array of Model/View relations, offered by the Tool, for XLink
        /// </summary>
        private ModelToViewsTuple[] initModelViewRelation()
        {
            ModelToViewsTuple[] modelsToViews
                = new ModelToViewsTuple[1];
            Dictionary<String, String> descriptions = new Dictionary<String, String>();
            descriptions.Add("en", "This view opens the values in a C# SourceCode viewer.");
            descriptions.Add("de", "Dieses Tool öffnet die Werte in einem C# SourceCode viewer.");

            OpenEngSBCore.XLinkConnectorView[] views = new OpenEngSBCore.XLinkConnectorView[1];
            views[0] = (new OpenEngSBCore.XLinkConnectorView() { name = "C# SourceCode View", viewId = Program.viewId, descriptions = descriptions.ConvertMap<entry3>() });
            modelsToViews[0] =
                    new ModelToViewsTuple()
                    {
                        description = new ModelDescription() { modelClassName = classNameOfOpenEngSBModel, versionString = "3.0.0.SNAPSHOT" },
                        views = views
                    };
            return modelsToViews;
        }