Ejemplo n.º 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare a variable for the input String
            GH_ObjectWrapper dictionaryGoo = null;
            String           key           = null;
            Object           value         = null;

            // Use the DA object to retrieve the data inside the first input parameter.
            // If the retieval fails (for example if there is no data) we need to abort.
            if (!DA.GetData(0, ref dictionaryGoo))
            {
                return;
            }
            if (!DA.GetData(1, ref key))
            {
                return;
            }
            if (!DA.GetData(2, ref value))
            {
                return;
            }

            Dictionary <String, Object> dictionary = dictionaryGoo.Value as Dictionary <String, Object>;

            if (dictionary != null)
            {
                dictionary = GhToNetConverter.ConvertDictionary(dictionary);
            }
            else
            {
                Dictionary <Object, Object> ooDictionary = dictionaryGoo.Value as Dictionary <Object, Object>;

                dictionary = GhToNetConverter.ConvertDictionary(ooDictionary);
            }

            // If the retrieved data is Nothing, we need to abort.
            // We're also going to abort on a zero-length String.
            if (key == null)
            {
                return;
            }
            if (value == null)
            {
                return;
            }
            //if (data.Length == 0) { return; }

            // Convert the String to a character array.
            //char[] chars = data.ToCharArray();


            Dictionary <String, Object> newDictionary = Topologic.Dictionary.SetValueAtKey(dictionary, key, value);

            IGH_Goo newDictionaryGoo = new GH_ObjectWrapper(newDictionary);

            DA.SetData(0, newDictionaryGoo);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare a variable for the input String
            Topologic.Topology topology      = null;
            GH_ObjectWrapper   dictionaryGoo = null;

            // Use the DA object to retrieve the data inside the first input parameter.
            // If the retieval fails (for example if there is no data) we need to abort.
            if (!DA.GetData(0, ref topology))
            {
                return;
            }
            if (!DA.GetData(1, ref dictionaryGoo))
            {
                return;
            }

            Dictionary <String, Object> dictionary = dictionaryGoo.Value as Dictionary <String, Object>;

            if (dictionary != null)
            {
                dictionary = GhToNetConverter.ConvertDictionary(dictionary);
            }
            else
            {
                Dictionary <Object, Object> ooDictionary = dictionaryGoo.Value as Dictionary <Object, Object>;

                dictionary = GhToNetConverter.ConvertDictionary(ooDictionary);
            }


            // If the retrieved data is Nothing, we need to abort.
            // We're also going to abort on a zero-length String.
            if (topology == null)
            {
                return;
            }
            if (dictionary == null)
            {
                return;
            }
            //if (data.Length == 0) { return; }

            // Convert the String to a character array.
            //char[] chars = data.ToCharArray();


            Topologic.Topology topologyWithDictionary = topology.SetDictionary(dictionary);

            // Use the DA object to assign a new String to the first output parameter.
            DA.SetData(0, topologyWithDictionary);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare a variable for the input String
            List <String> keys   = new List <string>();
            List <Object> values = new List <Object>();

            // Use the DA object to retrieve the data inside the first input parameter.
            // If the retieval fails (for example if there is no data) we need to abort.
            if (!DA.GetDataList(0, keys))
            {
                return;
            }
            if (!DA.GetDataList(1, values))
            {
                return;
            }

            // If the retrieved data is Nothing, we need to abort.
            // We're also going to abort on a zero-length String.
            if (keys == null)
            {
                return;
            }
            if (values == null)
            {
                return;
            }
            //if (data.Length == 0) { return; }

            // Convert the String to a character array.
            //char[] chars = data.ToCharArray();

            List <Object> finalValues = GhToNetConverter.ConvertList(values);

            Dictionary <String, Object> dictionary = Topologic.Dictionary.ByKeysValues(keys, finalValues);

            IGH_Goo dictionaryGoo = new GH_ObjectWrapper(dictionary);

            DA.SetData(0, dictionaryGoo);
        }