示例#1
0
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="typeInfo">Type info of node.</param>
        /// <param name="name">Name of node.</param>
        protected DataNode(NodeTypeInfo typeInfo, string name)
        {
            this.typeInfo = typeInfo;
            this.name     = name;

            this.SetCachedValue(this.typeInfo.GetValue(null));
        }
 public virtual void Initialize(params Assembly[] a)
 {
     foreach (Assembly assembly in a)
     {
         NodeTypes.AddRange(from Type t in assembly.GetTypes()
                            where t.IsSubclassOf(typeof(TreeNode))
                            select t);
     }
     foreach (Type t in NodeTypes)
     {
         TypeCacheData data = new TypeCacheData
         {
             icon               = t.GetCustomAttribute <NodeIconAttribute>().Path,
             canDelete          = !t.IsDefined(typeof(CannotDeleteAttribute), false),
             canBeBanned        = !t.IsDefined(typeof(CannotBanAttribute), false),
             classNode          = t.IsDefined(typeof(ClassNodeAttribute), false),
             leaf               = t.IsDefined(typeof(LeafNodeAttribute), false),
             requireParent      = GetTypes(t.GetCustomAttribute <RequireParentAttribute>()?.ParentType),
             uniqueness         = t.IsDefined(typeof(UniquenessAttribute), false),
             ignoreValidation   = t.IsDefined(typeof(IgnoreValidationAttribute), false),
             createInvokeID     = t.GetCustomAttribute <CreateInvokeAttribute>()?.id,
             rightClickInvokeID = t.GetCustomAttribute <RCInvokeAttribute>()?.id
         };
         var attrs = t.GetCustomAttributes <RequireAncestorAttribute>();
         data.requireAncestor = null;
         if (attrs.Count() != 0)
         {
             data.requireAncestor = (from RequireAncestorAttribute at in attrs
                                     select GetTypes(at.RequiredTypes)).ToArray();
         }
         NodeTypeInfo.Add(t, data);
         StandardNode.Add(t, t.GetConstructor(new Type[] { typeof(DocumentData) }).Invoke(new object[] { null }) as TreeNode);
     }
 }
示例#3
0
        private void BuildPropertySets(DataTable table, Dictionary <int, PropertySetType> propertySetTypes)
        {
            List <NodeTypeInfo> ntiList = new List <NodeTypeInfo>();

            foreach (DataRow row in table.Rows)
            {
                int             id              = TypeConverter.ToInt32(row["PropertySetID"]);
                int             parentID        = row["ParentID"] is DBNull ? 0 : TypeConverter.ToInt32(row["ParentID"]);
                string          name            = TypeConverter.ToString(row["Name"]);
                string          className       = row["ClassName"] is DBNull ? null : TypeConverter.ToString(row["ClassName"]);
                PropertySetType propertySetType = propertySetTypes[TypeConverter.ToInt32(row["PropertySetTypeID"])];
                switch (propertySetType)
                {
                case PropertySetType.NodeType:
                    ntiList.Add(new NodeTypeInfo(id, parentID, name, className));
                    break;

                case PropertySetType.ContentListType:
                    CreateContentListType(id, name);
                    break;

                default:
                    throw new InvalidSchemaException(String.Concat(SR.Exceptions.Schema.Msg_UnknownPropertySetType, propertySetType));
                }
            }
            while (ntiList.Count > 0)
            {
                for (int i = ntiList.Count - 1; i >= 0; i--)
                {
                    NodeTypeInfo nti    = ntiList[i];
                    NodeType     parent = null;
                    if (nti.ParentId == 0 || ((parent = _nodeTypes.GetItemById(nti.ParentId)) != null))
                    {
                        CreateNodeType(nti.Id, _nodeTypes.GetItemById(nti.ParentId), nti.Name, nti.ClassName);
                        ntiList.Remove(nti);
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="typeInfo">Type info of node.</param>
        /// <param name="parentNode">Parent node.</param>
        /// <param name="name">Name of node. Usually the name of the property/field this node represents.</param>
        protected DataNode(NodeTypeInfo typeInfo, IDataNode parentNode, string name)
        {
            this.typeInfo   = typeInfo;
            this.name       = name;
            this.parentNode = parentNode;

            if (parentNode != null)
            {
                parentNode.ValueChanged += this.OnParentValueChanged;
            }

            var parentValue = parentNode != null ? parentNode.Value : null;

            if (parentValue != null)
            {
                // Create node value observer.
                this.NodeValueObserver = this.CreateNodeValueObserver(parentValue);
            }

            // Get initial value for the node.
            this.SetCachedValue(this.typeInfo.GetValue(parentValue));
        }
示例#5
0
 /// <inheritdoc />
 public BranchDataNode(NodeTypeInfo typeInfo, string name) : base(typeInfo, name)
 {
 }
示例#6
0
 /// <inheritdoc />
 public BranchDataNode(NodeTypeInfo typeInfo, IDataNode parentNode, string name) : base(typeInfo,
                                                                                        parentNode, name)
 {
 }
示例#7
0
 private DataNode(NodeTypeInfo typeInfo)
 {
     this.Children = new List<DataNode>();
     this.TypeInfo = typeInfo;
 }
示例#8
0
 private DataNode(NodeTypeInfo typeInfo)
 {
     this.Children = new List <DataNode>();
     this.TypeInfo = typeInfo;
 }
示例#9
0
 /// <inheritdoc />
 public LeafDataNode(NodeTypeInfo typeInfo, string name) : base(typeInfo, name)
 {
 }