public List <string> GetTags()
        {
            RestClient  client  = new RestClient(urlCowaboo);
            RestRequest request = new RestRequest("tags", Method.GET);

            IRestResponse response = client.Execute(request);

            if (!response.IsSuccessful || string.IsNullOrEmpty(response.Content))
            {
                return(new List <string>());
            }

            RootTags root = JsonConvert.DeserializeObject <RootTags>(response.Content);

            return(root.TagList.List.Keys.ToList());
        }
Пример #2
0
        public CalTag AddTag(string tagName)
        {
            foreach (var item in RootTags)
            {
                if (item.TagName == tagName)
                {
                    System.Windows.Forms.MessageBox.Show("相同目录下已有此标签:" + tagName);
                    break;
                }
            }
            CalTag tag = new CalTag();

            tag.EID     = Guid.NewGuid().ToString();
            tag.TagName = tagName;
            tag.MyModel = this;
            AllCalTags.Add(tag);
            RootTags.Add(tag);
            return(tag);
        }
Пример #3
0
        /// <summary>
        /// Parses the Token-Queue and returns an equivalent IActivity representation
        /// </summary>
        /// <exception cref="System.NullReferenceException">Thrown when ModuleFactory or Token-Queue is null</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when Token-Queue is empty, but another token was expected</exception>
        /// <exception cref="WF2oWFN.API.ParseException">Thrown when an error occurs while parsing the Xaml tokens</exception>
        /// <returns>IActivity containing all parsed Activities</returns>
        public IActivity Parse()
        {
            // Activity AST
            IActivity activity = null;

            if (this.moduleFactory == null)
            {
                throw new NullReferenceException("No ModuleFactory was found");
            }
            if (this.tokens == null)
            {
                throw new NullReferenceException("No Token-Queue was found");
            }

            try
            {
                // [Start] Root Element
                IXamlElement startRoot = tokens.Dequeue();

                if (!RootTags.Contains(startRoot.QName))
                {
                    ParseException e = new ParseException(String.Format("No {0} or {1} was found", this.xaml, this.xamlx));
                    e.ElementNumber = initialTokenCount - tokens.Count;
                    e.Activity      = "Root";
                    throw e;
                }
                else
                {
                    // Inner activity
                    activity = moduleFactory.CreateActivity(tokens.Peek().QName);

                    if (activity == null)
                    {
                        ParseException e = new ParseException(String.Format("No Module found for activity '{0}'", tokens.Peek().QName));
                        e.ElementNumber = initialTokenCount - tokens.Count;
                        throw e;
                    }
                    else
                    {
                        // Parse inner activity
                        activity = activity.Parse(tokens);
                    }
                }

                // [End] Root Element
                if (tokens.Count == 1)
                {
                    IXamlElement endRoot = tokens.Dequeue();

                    if (!RootTags.Contains(endRoot.QName))
                    {
                        throw new ParseException(String.Format("No {0} or {1} end tag was found", this.xaml, this.xamlx), initialTokenCount, "Root");
                    }
                }
                else
                {
                    throw new ParseException(String.Format("Expected end tag, but still too many tokens in queue '{0}'", tokens.Count), initialTokenCount - tokens.Count, "Root");
                }

                return(activity);
            }
            catch (InvalidOperationException)
            {
                throw new ParseException("Expected token, but queue is empty", 1, "Root");
            }
        }
Пример #4
0
 public void RemoveTag(CalTag tag)
 {
     RootTags.Remove(tag);
     AllCalTags.Remove(tag);
 }