示例#1
0
        public override void OnBegin()
        {
            object obj2 = base.Digester.Peek();

            foreach (string str in base.Digester.Attributes.Keys)
            {
                string       str2     = base.Digester.Attributes[str];
                PropertyInfo property = obj2.GetType().GetProperty(str, BindingFlags.Public | BindingFlags.Instance);
                if (property == null)
                {
                    string name = char.ToUpper(str[0]) + str.Substring(1);
                    property = obj2.GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance);
                }
                if (property != null)
                {
                    if (property.PropertyType.IsEnum)
                    {
                        property.SetValue(obj2, Enum.Parse(property.PropertyType, str2, true), null);
                    }
                    else
                    {
                        property.SetValue(obj2, TypeConverterUtility.ConvertTo(str2, property.PropertyType), null);
                    }
                }
            }
        }
示例#2
0
        public override void OnBegin()
        {
            ArrayList list  = new ArrayList();
            ArrayList list2 = new ArrayList();

            if (prms != null)
            {
                for (int i = 0; i < prms.Length; i += 2)
                {
                    string str2 = (string)prms[i];
                    Type   type = (Type)prms[i + 1];
                    string str3 = Digester.Attributes[str2];
                    if (str3 != null)
                    {
                        list2.Add(type);
                        list.Add(TypeConverterUtility.ConvertTo(str3, type));
                    }
                }
            }
            Type[]   types      = (Type[])list2.ToArray(typeof(Type));
            object[] parameters = list.ToArray();
            Rule     rule       = (Rule)ruleType.GetConstructor(types).Invoke(parameters);
            string   pattern    = PatternRule.Pattern;

            if (Digester.Attributes["pattern"] != null)
            {
                if (pattern.Length > 0)
                {
                    pattern = pattern + "/";
                }
                pattern = pattern + Digester.Attributes["pattern"];
            }
            configDigester.AddRule(pattern, rule);
        }
示例#3
0
        public override void OnEnd()
        {
            string propertyName = this.propertyName;

            if (propertyName == null)
            {
                propertyName = Digester.ElementName;
            }
            object       obj2     = Digester.Peek();
            PropertyInfo property = obj2.GetType().GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance);

            if (property != null)
            {
                property.SetValue(obj2, TypeConverterUtility.ConvertTo(body, property.PropertyType), null);
            }
        }
示例#4
0
        public override void OnEnd()
        {
            string[] strArray = null;
            if (paramCount < 0)
            {
                strArray = new string[0];
            }
            else if (paramCount == 0)
            {
                strArray = new string[] { body };
                if (body == null)
                {
                    return;
                }
            }
            else if (paramCount > 0)
            {
                strArray = Digester.PopParameters();
                if ((paramCount == 1) && (strArray[0] == null))
                {
                    return;
                }
            }
            object     obj2   = Digester.Peek();
            MethodInfo method = null;

            if (paramTypes != null)
            {
                method = obj2.GetType().GetMethod(methodName, paramTypes);
            }
            else
            {
                method = obj2.GetType().GetMethod(methodName, new Type[0]);
            }
            if (method != null)
            {
                ParameterInfo[] parameters = method.GetParameters();
                object[]        objArray   = new object[strArray.Length];
                for (int i = 0; i < objArray.Length; i++)
                {
                    objArray[i] = TypeConverterUtility.ConvertTo(strArray[i], parameters[i].ParameterType);
                }
                method.Invoke(obj2, objArray);
                body = null;
            }
        }
示例#5
0
        public override void OnBegin()
        {
            string name = null;
            string str2 = null;

            for (int i = 0; i < Digester.Attributes.Count; i++)
            {
                string key  = Digester.Attributes.GetKey(i);
                string str3 = Digester.Attributes[i];
                if (key == _name)
                {
                    name = str3;
                }
                else if (key == _value)
                {
                    str2 = str3;
                }
            }
            object       obj2     = Digester.Peek();
            PropertyInfo property = obj2.GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance);

            property.SetValue(obj2, TypeConverterUtility.ConvertTo(str2, property.PropertyType), null);
        }
示例#6
0
        public override void OnBegin()
        {
            object obj2         = digester.Peek();
            string symbolicName = string.Empty;

            if (obj2 is BundleData)
            {
                symbolicName = base.digester.Attributes["SymbolicName"];
            }
            else if (base.digester.Root is BundleData)
            {
                symbolicName = (base.digester.Root as BundleData).SymbolicName;
            }
            using (IEnumerator enumerator = base.digester.Attributes.Keys.GetEnumerator())
            {
Label_0071:
                if (!enumerator.MoveNext())
                {
                    return;
                }
                string       current  = (string)enumerator.Current;
                string       str3     = base.digester.Attributes[current];
                PropertyInfo property = obj2.GetType().GetProperty(current, BindingFlags.Public | BindingFlags.Instance);
                if (property == null)
                {
                    string name = char.ToUpper(current[0]) + current.Substring(1);
                    property = obj2.GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance);
                }
                if (property == null)
                {
                    goto Label_0191;
                }
                object obj3 = null;
                if (property.PropertyType.IsEnum)
                {
                    try
                    {
                        obj3 = Enum.Parse(property.PropertyType, str3, true);
                    }
                    catch (Exception exception)
                    {
                        FileLogUtility.Error(exception);
                    }
                }
                else
                {
                    try
                    {
                        obj3 = TypeConverterUtility.ConvertTo(str3, property.PropertyType);
                    }
                    catch (Exception exception2)
                    {
                        FileLogUtility.Error(exception2);
                    }
                }
                goto Label_01B2;
Label_013B:
                if (!string.IsNullOrEmpty(str3))
                {
                    FileLogUtility.Warn(string.Format(Messages.ManifestSectionInvalid, new object[] { str3, current, base.digester.ElementName, symbolicName }));
                    goto Label_0071;
                }
Label_0181:
                property.SetValue(obj2, obj3, null);
                goto Label_0071;
Label_0191:
                FileLogUtility.Warn(string.Format(Messages.ManifestSectionNotRecognized, current, base.digester.ElementName, symbolicName));
                goto Label_0071;
Label_01B2:
                if (obj3 != null)
                {
                    goto Label_0181;
                }
                goto Label_013B;
            }
        }