예제 #1
0
        private void DoProperty(Property tag, ValueStack stack, System.Xml.XmlNode node, System.Xml.XmlWriter w)
        {
            String s = tag.Value;

            if (s.StartsWith("$"))
            {
                object value = stack.Evaluate(s);
                if (value == null)
                {
                    s = "";
                }
                else
                {
                    s = value.ToString();
                }
            }
            w.WriteString(s);
        }
예제 #2
0
        private IContainer DoPush(Push tag, IContainer parent, ValueStack.ValueStack stack, object newObject = null)
        {
            object expr = newObject;
            if (expr == null)
            {
                Type type = null;
                if (!String.IsNullOrEmpty(tag.Type))
                    type = GetType().Assembly.GetType(tag.Type, false, true);
                /*
                if (!String.IsNullOrEmpty(tag.Value))
                    if (!tag.Value.StartsWith("$")) //TODO
                        throw new ArgumentException(String.Format("Invalid Push expression '{0}'. Should start with '$'", tag.Value));
                */
                expr = stack.Evaluate(tag.Value, type);
            }

            stack.Push(tag.Id, expr);
            return parent;
        }
예제 #3
0
        private IContainer DoIterator(Iterator tag, IContainer parent, XmlNode node, ValueStack.ValueStack stack)
        {
            var collection = (IEnumerable)stack.Evaluate(tag.Value, null, false);

            var status = new IteratorStatus();
            if (!String.IsNullOrEmpty(tag.Status))
                stack.Push(tag.Status, status); //push status variable

            var list = new ArrayList();
            var reader = collection as IDataReader;
            if (reader != null)
            {
                while (reader.Read())
                {
                    stack.Push(tag.Id, reader);
                    ProcessChildren(parent, node, stack);
                    status.Inc();
                }
            }
            else
            {
                foreach (var item in collection)
                    list.Add(item);

                foreach (var item in list)
                {
                    stack.Push(tag.Id, item);
                    ProcessChildren(parent, node, stack);
                    status.Inc();
                }
            }

            if (!String.IsNullOrEmpty(tag.Status))
                stack.Values.Remove(tag.Status); //remove status variable

            return parent;
        }
예제 #4
0
        private static void SetProperties(XmlNode node, ValueStack.ValueStack stack, object obj)
        {
            foreach (XmlAttribute a in node.Attributes)
            {
                if (String.IsNullOrEmpty(a.Prefix))
                {
                    PropertyInfo prop = obj.GetType()
                        .GetProperty(a.Name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
                    if (prop == null)
                        throw new Exception(String.Format("Property '{0}' is not found in type '{1}'", a.Name,
                            obj.GetType().Name));

					String aValue = ApplicationContext.Context.DAL.TranslateString(a.Value.Trim());

                    if (prop.PropertyType == typeof(DataBinder))
                    {
                        object bindedObject;
                        String propertyName;
                        stack.Evaluate(aValue, out bindedObject, out propertyName);

                        var binder = new DataBinder(obj, a.Name, bindedObject, propertyName);
                        prop.SetValue(obj, binder, null);
                    }
                    else if (prop.PropertyType == typeof(ActionHandler))
                    {
                        var handler = new ActionHandler(aValue, stack);
                        prop.SetValue(obj, handler, null);
                    }
                    else if (prop.PropertyType == typeof(ActionHandlerEx))
                    {
                        var handler = new ActionHandlerEx(aValue, stack, obj);
                        prop.SetValue(obj, handler, null);
                    }
                    else
                    {
                        object mexpr = stack.Evaluate(aValue, prop.PropertyType);
                        prop.SetValue(obj, mexpr, null);
                    }
                }
            }
        }
예제 #5
0
        private static string InitObjectId(XmlNode node, ValueStack.ValueStack stack, object obj)
        {
            foreach (XmlAttribute a in node.Attributes)
            {
                if (string.IsNullOrEmpty(a.Prefix) && a.Name.ToLower().Equals("id"))
                {
					string aValue = ApplicationContext.Context.DAL.TranslateString (a.Value);
                    string id = stack.Evaluate(aValue).ToString();
                    stack.Push(id, obj);
                    return id;
                }
            }
            return null;
        }
예제 #6
0
        private void DoIterator(Iterator tag, ValueStack stack, System.Xml.XmlNode node, System.Xml.XmlWriter w)
        {
            System.Collections.IEnumerable collection = (System.Collections.IEnumerable)stack.Evaluate(tag.Value, null, false);

            if (collection is System.Data.IDataReader)
            {
                while (((System.Data.IDataReader)collection).Read())
                {
                    stack.Push(tag.Id, collection as System.Data.IDataRecord);
                    ProcessChildren(stack, node, w);
                }
            }
            else
            {
                System.Collections.IEnumerator enumerator = collection.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    stack.Push(tag.Id, enumerator.Current);
                    ProcessChildren(stack, node, w);
                }
            }
        }
예제 #7
0
 private void DoProperty(Property tag, ValueStack stack, System.Xml.XmlNode node, System.Xml.XmlWriter w)
 {
     String s = tag.Value;
     if (s.StartsWith("$"))
     {
         object value = stack.Evaluate(s);
         if (value == null)
             s = "";
         else
             s = value.ToString();
     }
     w.WriteString(s);
 }
예제 #8
0
        private void DoIterator(Iterator tag, ValueStack stack, System.Xml.XmlNode node, System.Xml.XmlWriter w)
        {
            System.Collections.IEnumerable collection = (System.Collections.IEnumerable)stack.Evaluate(tag.Value, null, false);

            if (collection is System.Data.IDataReader)
            {
                while (((System.Data.IDataReader)collection).Read())
                {
                    stack.Push(tag.Id, collection as System.Data.IDataRecord);
                    ProcessChildren(stack, node, w);
                }
            }
            else
            {
                System.Collections.IEnumerator enumerator = collection.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    stack.Push(tag.Id, enumerator.Current);
                    ProcessChildren(stack, node, w);
                }
            }
        }