private static ObjectAPI Convert(Type type, String externalId, object source, List <ValueElementIdReferenceAPI> valueElementIdReferences)
        {
            ObjectAPI objectAPI = null;

            if (source != null)
            {
                // If we have a value element identifier, we need to translate it over
                if (type.Name.Equals("ValueElementIdAPI", StringComparison.OrdinalIgnoreCase) == true)
                {
                    type = new ValueElementIdReferenceAPI().GetType();
                }

                objectAPI = new ObjectAPI();
                objectAPI.developerName = GetCleanObjectName(type.Name);
                objectAPI.externalId    = externalId;
                objectAPI.properties    = new List <PropertyAPI>();

                foreach (PropertyInfo propertyInfo in type.GetRuntimeProperties())
                {
                    PropertyAPI propertyAPI = Convert(source, propertyInfo, valueElementIdReferences);
                    if (propertyAPI != null)
                    {
                        objectAPI.properties.Add(propertyAPI);
                    }
                }
            }

            return(objectAPI);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Cand lista de propietati este updatata, toate propietatile sunt luate din
 /// baza de date si descrierea lor afisata.
 /// </summary>
 private void UpdatePropertyList()
 {
     propertyView.Items.Clear();
     Properties = PropertyAPI.GetAllProperties();
     foreach (var property in Properties)
     {
         propertyView.Items.Add(new ListViewItem(new string[] { property.Id.ToString(), property.Description }));
     }
 }
        /// <summary>
        /// Utility method for creating new properties.
        /// </summary>
        public static PropertyAPI CreateProperty(String developerName, String contentValue)
        {
            PropertyAPI propertyAPI = null;

            propertyAPI = new PropertyAPI();
            propertyAPI.developerName = developerName;
            propertyAPI.contentValue = contentValue;

            return propertyAPI;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Cand butonul de stergere de propietati e apasat, propietatile selectate
        /// vor fi sterse.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void propertyDeleteButton_Click(object sender, EventArgs e)
        {
            List <int> propertiesToRemove = new List <int>();
            var        propertyIndices    = propertyView.CheckedIndices.Cast <int>();

            foreach (int property in propertyIndices)
            {
                propertiesToRemove.Add(Properties[property].Id);
            }
            PropertyAPI.DeleteProperties(propertiesToRemove);
            UpdatePropertyList();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Daca descrierea propietatii nu este goala, propietatea cu acea descriere
        /// va fi adaugata in baza de date. De asemenea, lista de propietati va fi updatata.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void propertyDescButton_Click(object sender, EventArgs e)
        {
            string propertyDescription = textBox1.Text;

            if (propertyDescription == null || propertyDescription.Length == 0)
            {
                return;
            }
            PropertyAPI.AddProperty(propertyDescription);
            textBox1.Text = "";
            UpdatePropertyList();
        }
Exemplo n.º 6
0
        private static PropertyAPI GetPropertyAPIFromDictionary(object source, PropertyInfo propertyInfo, List <ValueElementIdReferenceAPI> valueElementIdReferences)
        {
            PropertyAPI propertyAPI = null;
            IDictionary value       = (IDictionary)propertyInfo.GetValue(source, null);

            if (value != null)
            {
                var values = value as IDictionary <string, string>;
                if (values != null && values.Count > 0)
                {
                    // Add a new list of "Object: String" type objects
                    propertyAPI = new PropertyAPI();

                    if (propertyInfo.Name.EqualsIgnoreCase("properties"))
                    {
                        propertyAPI.developerName = "Properties";
                    }
                    else
                    {
                        propertyAPI.developerName = "Attributes";
                    }

                    // For each keypair, create a new "Object: String" object
                    propertyAPI.objectData = new List <ObjectAPI>();

                    foreach (var attribute in values)
                    {
                        propertyAPI.objectData.Add(new ObjectAPI
                        {
                            developerName = "KeyPair",
                            externalId    = Fuid.NewGuid().ToString(),
                            properties    = new List <PropertyAPI>
                            {
                                new PropertyAPI {
                                    developerName = "Key", contentValue = attribute.Key
                                },
                                new PropertyAPI {
                                    developerName = "Value", contentValue = attribute.Value
                                }
                            }
                        });
                    }
                }
            }

            return(propertyAPI);
        }
        public static ObjectAPI CreateAttributeObject(String label, String value)
        {
            ObjectAPI attributeObject = null;
            PropertyAPI attributeProperty = null;

            attributeObject = new ObjectAPI();
            attributeObject.externalId = value;
            attributeObject.developerName = ManyWhoConstants.AUTHENTICATION_AUTHENTICATION_ATTRIBUTE_OBJECT_DEVELOPER_NAME;
            attributeObject.properties = new List<PropertyAPI>();

            attributeProperty = new PropertyAPI();
            attributeProperty.developerName = ManyWhoConstants.AUTHENTICATION_ATTRIBUTE_LABEL;
            attributeProperty.contentValue = label;

            attributeObject.properties.Add(attributeProperty);

            attributeProperty = new PropertyAPI();
            attributeProperty.developerName = ManyWhoConstants.AUTHENTICATION_ATTRIBUTE_VALUE;
            attributeProperty.contentValue = value;

            attributeObject.properties.Add(attributeProperty);

            return attributeObject;
        }
        public static ObjectAPI CreateAttributeObject(String label, String value)
        {
            ObjectAPI   attributeObject   = null;
            PropertyAPI attributeProperty = null;

            attributeObject               = new ObjectAPI();
            attributeObject.externalId    = value;
            attributeObject.developerName = ManyWhoConstants.AUTHENTICATION_AUTHENTICATION_ATTRIBUTE_OBJECT_DEVELOPER_NAME;
            attributeObject.properties    = new List <PropertyAPI>();

            attributeProperty = new PropertyAPI();
            attributeProperty.developerName = ManyWhoConstants.AUTHENTICATION_ATTRIBUTE_LABEL;
            attributeProperty.contentValue  = label;

            attributeObject.properties.Add(attributeProperty);

            attributeProperty = new PropertyAPI();
            attributeProperty.developerName = ManyWhoConstants.AUTHENTICATION_ATTRIBUTE_VALUE;
            attributeProperty.contentValue  = value;

            attributeObject.properties.Add(attributeProperty);

            return(attributeObject);
        }
 /// <summary>
 /// Aceasta metoda permite obtinerea tuturor propietatilor din baza de date.
 /// </summary>
 /// <returns>Lista cu obiecte de tip propietate ce reprezinta
 /// toate propietatile din baza de date.</returns>
 List <Property> IProperty.GetAllProperties()
 {
     return(PropertyAPI.GetAllProperties());
 }
Exemplo n.º 10
0
 /// <summary>
 /// Aceasta metoda permite stergerea de propietati.
 /// </summary>
 /// <param name="propertyIndices">Lista cu id-uri pentru propietatile ce doresc a fi sterse.</param>
 /// <returns>Un boolean care spune daca adaugarea a fost realizata cu succes.</returns>
 bool IProperty.DeleteProperties(List <int> propertyIndices)
 {
     return(PropertyAPI.DeleteProperties(propertyIndices));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Aceasta metoda permite adaugarea unei propietati in baza de date.
 /// </summary>
 /// <param name="description">Descrierea propietatii.</param>
 /// <returns>Un boolean care spune daca adaugarea a fost realizata cu succes.</returns>
 bool IProperty.AddProperty(string description)
 {
     return(PropertyAPI.AddProperty(description));
 }