예제 #1
0
        public override bool TryParse(string value, ref object obj)
        {
            TextCollection  tc      = (TextCollection)obj;
            MatchCollection matches = Regex.Matches(value, @"[^\\](,)");

            Values.Clear();

            int i = 0;

            foreach (Match match in matches)
            {
                if (match.Success)
                {
                    tc.Values.Add(new Text(value.Substring(i, match.Index - i + 1)));
                    i = match.Index + 2;
                }
                else
                {
                    return(false);
                }
            }

            if (i < value.Length)
            {
                tc.Values.Add(new Text(value.Substring(i, value.Length - i)));
            }

            return(true);
        }
예제 #2
0
        public override void CopyFrom(object obj)
        {
            if (obj is TextCollection)
            {
                TextCollection tc    = (TextCollection)obj;
                Text[]         array = new Text[tc.Values.Count];
                tc.CopyTo(array, 0);

                Values.Clear();
                Values.AddRange(array);
            }
            base.CopyFrom(obj);
        }
예제 #3
0
 public override bool Equals(object obj)
 {
     if (obj is TextCollection)
     {
         TextCollection tc = (TextCollection)obj;
         for (int i = 0; i < Values.Count; i++)
         {
             if (!Values[i].Equals(tc.Values[i]))
             {
                 return(false);
             }
         }
         return(true);
     }
     else if (obj is Text)
     {
         if (Values.Count == 1 && Values[0].Equals(obj))
         {
             return(true);
         }
     }
     return(base.Equals(obj));
 }
예제 #4
0
        virtual public void AddCategory(string categoryName)
        {
            Text cn = categoryName;
            if (Categories != null)
            {
                foreach (TextCollection tc in Categories)
                {
                    if (tc.Values.Contains(cn))
                    {
                        return;
                    }
                }
            }

            if (Categories == null ||
                Categories.Length == 0)
            {
                Categories = new TextCollection[1] { new TextCollection(categoryName) };
                Categories[0].Name = "CATEGORIES";
            }
            else
            {
                Categories[0].Values.Add(cn);
            }
        }
 public TextCollectionSerializer(TextCollection tc)
     : base(tc)
 {
     this.m_TC = tc;
 }
예제 #6
0
        virtual public void AddResource(string resource)
        {
            Text r = resource;
            if (Resources != null)
            {
                foreach (TextCollection tc in Resources)
                {
                    if (tc.Values.Contains(r))
                    {
                        return;
                    }
                }
            }

            if (Resources == null ||
                Resources.Length == 0)
            {
                Resources = new TextCollection[1] { new TextCollection(resource) };
                Resources[0].Name = "RESOURCES";
            }
            else
            {
                Resources[0].Values.Add(r);
            }
        }