当前位置: 首页>>代码示例>>C#>>正文


C# IContainer.AddChild方法代码示例

本文整理汇总了C#中IContainer.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# IContainer.AddChild方法的具体用法?C# IContainer.AddChild怎么用?C# IContainer.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IContainer的用法示例。


在下文中一共展示了IContainer.AddChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Build

        object Build(IContainer parent, XmlNode node, ValueStack.ValueStack stack)
        {
            if (node is XmlComment)
                return null;

            Type t = TypeFromNode(node);

            if (t.IsSubclassOf(typeof(ValueStackTag)))
            {
                //control flow tag
                ConstructorInfo ci = t.GetConstructor(new Type[] { });
                var tag = (ValueStackTag)ci.Invoke(new object[] { });
                foreach (XmlAttribute a in node.Attributes)
                {
                    PropertyInfo pi = t.GetProperty(a.Name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
					string value = ApplicationContext.Context.DAL.TranslateString (a.Value);
					pi.SetValue(tag, Convert.ChangeType(value, pi.PropertyType), null);
                }

                if (tag is Include)
                {
                    return DoInclude((Include)tag, parent, stack);
                }

                if (tag is If)
                {
                    return DoIf((If)tag, parent, node, stack);
                }

                if (tag is Else)
                {
                    return parent;
                }

                if (tag is Iterator)
                {
                    return DoIterator((Iterator)tag, parent, node, stack);
                }

                if (tag is Push)
                {
                    object newObject = null;
                    if (node.ChildNodes.Count == 1)
                    {
                        newObject = Build(null, node.FirstChild, stack);
                    }
                    return DoPush((Push)tag, parent, stack, newObject);
                }

                throw new Exception("Unknown tag");
            }
            else
            {
                //ui control

                object obj = CreateObject(t, stack);

                string id = InitObjectId(node, stack, obj);

                SetProperties(node, stack, obj);

                if (parent != null)
                    parent.AddChild(obj);

                if (obj is IDataBind)
                    (obj as IDataBind).DataBind();

                if (id != null)
                    LoadStepState(stack, obj, id);

                if (obj is IContainer)
                    ProcessChildren((IContainer)obj, node, stack);

                return obj;
            }
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:76,代码来源:ObjectFactory.cs

示例2: Build

        public object Build(IContainer parent, XmlNode node, IValueStack stack)
        {
            if (node is XmlComment)
                return null;

            Type t = TypeFromNode(node);

            if (node.NamespaceURI == MarkupElementAttribute.ValueStackNamespace)
            {
                //control flow tag
                var tag = (IValueStackTag)CreateObject(t, stack);
                foreach (XmlAttribute a in node.Attributes)
                {
                    PropertyInfo pi = FindProperty(t, a.Name);
                    //string value = ApplicationContext.Current.Dal.TranslateString(a.Value);
                    pi.SetValue(tag, a.Value);
                }

                var push = tag as IPush;
                if (push != null)
                    return DoPush(push, parent, stack);

                var iif = tag as IIf;
                if (iif != null)
                    return DoIf(iif, parent, node, stack);

                if (tag is IElse)
                    return parent;

                var iterator = tag as IIterator;
                if (iterator != null)
                    return DoIterator(iterator, parent, node, stack);

                var include = tag as IInclude;
                if (include != null)
                    return DoInclude(include, parent, stack);

                throw new Exception("Unknown tag");
            }
            //ui control

            object obj = CreateObject(t, stack);

            SetProperties(node, stack, obj);

            string id = null;
            var layoutable = obj as ILayoutable;
            if (layoutable != null)
                id = layoutable.Id;

            if (parent != null)
                parent.AddChild(obj);

            if (obj is IDataBind)
                (obj as IDataBind).DataBind();

            if (id != null)
            {
                stack.Push(id, obj); // add current object to value stack
                LoadStepState(stack, obj, id);
            }

            var container = obj as IContainer;
            if (container != null)
                ProcessChildren(container, node, stack);

            return obj;
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:68,代码来源:ObjectFactory.cs

示例3: DoInclude

        private IContainer DoInclude(Include tag, IContainer parent, ValueStack.ValueStack stack)
        {
            var dal = ApplicationContext.Context.DAL;

            object component = CreateObject(stack, dal.GetScreenByName(tag.File));
            if (!(component is Component))
                throw new Exception("Only Component container is allowed to be included");

            object[] controls = ((IContainer)component).Controls;
            foreach (object child in controls)
                parent.AddChild(child);
            return parent;
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:13,代码来源:ObjectFactory.cs

示例4: DoInclude

        private object DoInclude(IInclude tag, IContainer parent, IValueStack stack)
        {
            var dal = ApplicationContext.Current.Dal;

            object component = CreateObject(stack, dal.GetScreenByName(tag.File));
            if (!(component is IComponent))
                throw new Exception("Only Component container is allowed to be included");

            object[] controls = ((IContainer)component).Controls;
                        
            if (parent != null)
            {
                foreach (var control in controls)
                    parent.AddChild(control);
                return parent;
            }

            // uglu hack: так как метод Build возвращает object, а нам нужно вернуть несколько объектов
            // , мы можем вернуть тут массив, но должны помнить,
            // что это массив (см. Controls/LayoutableContainerBehaviour.cs метод Inject)
            return controls;
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:22,代码来源:ObjectFactory.cs


注:本文中的IContainer.AddChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。