예제 #1
0
        /// SpeckleCore does not currently support dictionaries, therefore avoiding the canonical ToSpeckle
        public static Dictionary <string, object> ToSpeckleX(this DesignScript.Builtin.Dictionary dict)
        {
            if (dict == null)
            {
                return(null);
            }

            var speckleDict = new Dictionary <string, object>();

            foreach (var key in dict.Keys)
            {
                object value = dict.ValueAtKey(key);
                if (value is DesignScript.Builtin.Dictionary)
                {
                    value = (value as DesignScript.Builtin.Dictionary).ToSpeckleX();
                }

                //TODO:
                //else if (value is Geometry)
                //{
                //  value = Converter.Serialise(value);
                //}
                speckleDict.Add(key, value);
            }

            return(speckleDict);
        }
예제 #2
0
        /// <summary>
        /// Returns the value of dictionary at a given key.
        /// </summary>
        /// <param name="dictionary">Dictionary exposing all available values</param>
        /// <param name="key">The key of the value to retrieve</param>
        /// <returns>The value retrieved from the dictionary at the given key</returns>
        public static object UnPackOutputByKey(DesignScript.Builtin.Dictionary dictionary, string key)
        {
            if (dictionary == null)
            {
                return(null);
            }

            return(dictionary.ValueAtKey(key));
        }
예제 #3
0
        private Base DictionaryToBase(DesignScript.Builtin.Dictionary dsDic)
        {
            var @base = new Base();

            foreach (var key in dsDic.Keys)
            {
                @base[key] = RecurseTreeToSpeckle(dsDic.ValueAtKey(key));
            }

            return(@base);
        }