예제 #1
0
        /// <summary>
        /// Creates a DataSource in the user account
        /// </summary>
        /// <param name="Name">The name of the DataSource</param>
        /// <param name="Context">The context of the DataSource</param>
        /// <param name="Tags">The tags of the DataSource</param>
        /// <returns>The newly created DataSource</returns>
        public DataSource CreateDataSource(string Name,
                                           Dictionary <string, string> Context, string[] Tags)
        {
            if (Name == null)
            {
                throw new ArgumentNullException();
            }

            Dictionary <string, object> Data = new Dictionary <string, object>();

            Data.Add("name", Name);

            if (Context != null)
            {
                Data.Add("context", Context);
            }

            if (Tags != null)
            {
                Data.Add("tags", Tags);
            }

            string Json = Bridge.Post("datasources/",
                                      JsonConvert.SerializeObject(Data));

            DataSource Var = new DataSource(JsonConvert.DeserializeObject <Dictionary <string, object> >(Json), this);

            return(Var);
        }
예제 #2
0
        /// <summary>
        /// Creates a DataSource in the user account
        /// </summary>
        /// <param name="Name">The name of the DataSource</param>
        /// <param name="Context">The context of the DataSource</param>
        /// <param name="Tags">The tags of the DataSource</param>
        /// <returns>The newly created DataSource</returns>
        public IEnumerator CreateDataSource(string Name, Dictionary <string, string> Context, string[] Tags, System.Action <DataSource> values)
        {
            var outputMessage = "";

            if (Name == null)
            {
                throw new ArgumentNullException();
            }

            Dictionary <string, object> Data = new Dictionary <string, object>();

            Data.Add("name", Name);

            if (Context != null)
            {
                Data.Add("context", Context);
            }

            if (Tags != null)
            {
                Data.Add("tags", Tags);
            }

            yield return(Extender.Instance.StartCoroutine(Bridge.Post("datasources/", JsonUtility.ToJson(Data), result => outputMessage = result)));

            DataSource Var = new DataSource(JsonUtility.FromJson <ServerBridge.JsonData>(outputMessage), this);

            values(Var);
        }