コード例 #1
0
        private void ValidateRootXPath()
        {
            DocumentNode node = ((DocumentCompositeNode)this.DataSource.DocumentNode).Properties[XmlDataProviderSceneNode.XPathProperty];

            if (node == null)
            {
                return;
            }
            string valueAsString = DocumentPrimitiveNode.GetValueAsString(node);

            if (string.IsNullOrEmpty(valueAsString))
            {
                return;
            }
            DataSchemaNode dataSchemaNode = (DataSchemaNode)null;

            if ((int)valueAsString[0] == 47)
            {
                dataSchemaNode = this.GetNodeFromPath(valueAsString);
            }
            if (dataSchemaNode != null)
            {
                return;
            }
            this.invalidRootXPath = true;
        }
コード例 #2
0
        public int GetCollectionDepth(DataSchemaNode endNode)
        {
            if (this.root == null)
            {
                return(0);
            }
            int num = endNode.IsCollection ? true : false;

            if (endNode == this.root)
            {
                return(num);
            }
            for (DataSchemaNode parent = endNode.Parent; parent != this.root; parent = parent.Parent)
            {
                if (parent == null)
                {
                    return(-1);
                }
                if (parent.IsCollection)
                {
                    ++num;
                }
            }
            return(num);
        }
コード例 #3
0
        public SampleDataEditorModel(DataSchemaNodePath schemaPath, IMessageDisplayService messageService)
        {
            this.messageService = messageService;
            SampleType     sampleType         = schemaPath.Node.SampleType;
            DataSchemaNode collectionItemNode = schemaPath.EffectiveCollectionItemNode;

            this.editingSchemaPath    = new DataSchemaNodePath(schemaPath.Schema, collectionItemNode.Parent);
            this.sampleCompositeType  = (SampleCompositeType)collectionItemNode.SampleType;
            this.ValueBuilder         = new SampleDataValueBuilderBase(this.SampleDataSet, this.SampleDataSet.RootNode.Context);
            this.SampleDataProperties = (IList <SampleDataProperty>) new List <SampleDataProperty>();
            foreach (SampleProperty sampleProperty in (IEnumerable <SampleProperty>) this.sampleCompositeType.SampleProperties)
            {
                if (sampleProperty.IsBasicType)
                {
                    this.SampleDataProperties.Add(new SampleDataProperty(sampleProperty, this));
                }
            }
            ((List <SampleDataProperty>) this.SampleDataProperties).Sort((Comparison <SampleDataProperty>)((a, b) => StringLogicalComparer.Instance.Compare(a.SampleProperty.Name, b.SampleProperty.Name)));
            this.sourceCollectionNode = this.GetCollectionNode(this.SampleDataSet.RootNode, false);
            this.ValueBuilder.InitCollectionDepth(this.editingSchemaPath);
            List <SampleDataRow> rows = new List <SampleDataRow>();

            if (this.sourceCollectionNode != null)
            {
                int count = this.sourceCollectionNode.Children.Count;
                for (int rowNumber = 0; rowNumber < count; ++rowNumber)
                {
                    rows.Add(new SampleDataRow(this, rowNumber));
                }
            }
            this.SampleDataRows = (ObservableCollection <SampleDataRow>) new SampleDataEditorModel.SampleDataRowCollection(rows);
        }
コード例 #4
0
ファイル: DataSchemaNode.cs プロジェクト: radtek/Shopdrawing
 public void AddChild(DataSchemaNode child)
 {
     this.Children.Add(child);
     child.parent = this;
     this.OnPropertyChanged("Children");
     this.OnPropertyChanged("HasChildren");
 }
コード例 #5
0
ファイル: DataSchemaNode.cs プロジェクト: radtek/Shopdrawing
 public void RemoveChild(DataSchemaNode child)
 {
     this.Children.Remove(child);
     child.parent = (DataSchemaNode)null;
     this.OnPropertyChanged("Children");
     this.OnPropertyChanged("HasChildren");
 }
コード例 #6
0
        public void OnDragBegin(DragBeginEventArgs e)
        {
            if (this.nodePath == null)
            {
                return;
            }
            List <DataSchemaItem> list1 = new List <DataSchemaItem>(Enumerable.OfType <DataSchemaItem>((IEnumerable)this.SelectionContext));

            if (list1.Count <= 0 || list1.Count != this.SelectionContext.Count || !list1.Contains(this))
            {
                return;
            }
            DataSchemaNode            parent         = list1[0].DataSchemaNode.Parent;
            DataSourceNode            dataSourceNode = list1[0].DataSourceNode;
            List <DataSchemaNodePath> list2          = new List <DataSchemaNodePath>();

            list2.Add(list1[0].nodePath.AbsolutePath);
            for (int index = 1; index < list1.Count; ++index)
            {
                if (parent != list1[index].DataSchemaNode.Parent || dataSourceNode != list1[index].DataSourceNode)
                {
                    return;
                }
                list2.Add(list1[index].nodePath.AbsolutePath);
            }
            DataSchemaNodePathCollection nodePathCollection = new DataSchemaNodePathCollection((IEnumerable <DataSchemaNodePath>)list2);

            using (DataBindingDragDropManager.GetDragDropToken())
            {
                int num = (int)DragSourceHelper.DoDragDrop(e.DragSource, (object)nodePathCollection, DragDropEffects.Copy | DragDropEffects.Move);
            }
        }
コード例 #7
0
 void IDataSchemaNodeDelayLoader.ProcessChildren(DataSchemaNode node)
 {
     if ((node.NodeType | SchemaNodeTypes.Method) == SchemaNodeTypes.Method)
     {
         return;
     }
     if (ClrObjectSchema.IsCollection(node.Type))
     {
         Type type = CollectionAdapterDescription.GetGenericCollectionType(node.Type);
         if (type == (Type)null)
         {
             type = typeof(object);
         }
         SchemaNodeTypes nodeType = SchemaNodeTypes.CollectionItem;
         if (ClrObjectSchema.IsCollection(type))
         {
             nodeType |= SchemaNodeTypes.CollectionItem;
         }
         DataSchemaNode dataSchemaNode = new DataSchemaNode(node.PathName, DataSchemaNode.IndexNodePath, nodeType, string.Empty, type, (IDataSchemaNodeDelayLoader)this);
         node.CollectionItem = dataSchemaNode;
     }
     else
     {
         this.AddMethodBasedChildren(node);
     }
     this.AddPropertyBasedChildren(node);
     node.Children.Sort((IComparer <DataSchemaNode>) new DataSchemaNode.PathNameComparer());
 }
コード例 #8
0
        public DataSchemaNodePath GetNodePathFromPath(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(this.CreateNodePath());
            }
            DataSchemaNode      endNode = this.root;
            IList <ClrPathPart> list    = ClrPropertyPathHelper.SplitPath(path);

            if (list == null)
            {
                return((DataSchemaNodePath)null);
            }
            for (int index = 0; index < list.Count && endNode != null; ++index)
            {
                ClrPathPart clrPathPart = list[index];
                string      pathName    = clrPathPart.Category == ClrPathPartCategory.PropertyName ? clrPathPart.Path : DataSchemaNode.IndexNodePath;
                endNode = endNode.FindChildByPathName(pathName);
            }
            if (endNode != null)
            {
                return(new DataSchemaNodePath((ISchema)this, endNode));
            }
            return((DataSchemaNodePath)null);
        }
コード例 #9
0
            public DataPaneCallback(DataSchemaItem dataSchemaItem)
            {
                DataSchemaNode node = dataSchemaItem.DataSchemaNodePath.Node;

                this.property       = ((SampleCompositeType)node.Parent.SampleType).GetSampleProperty(node.PathName);
                this.configuration  = new SampleDataPropertyConfiguration(this.property);
                this.messageService = dataSchemaItem.ViewModel.DesignerContext.MessageDisplayService;
            }
コード例 #10
0
        public ClrObjectSchema(Type type, DocumentNode dataSourceNode)
        {
            SchemaNodeTypes nodeType = ClrObjectSchema.IsCollection(type) ? SchemaNodeTypes.Collection : SchemaNodeTypes.Property;

            this.root       = new DataSchemaNode(type.Name, type.Name, nodeType, (string)null, type, (IDataSchemaNodeDelayLoader)this);
            this.dataSource = (DataSourceNode) new ClrObjectDataSourceNode(this, dataSourceNode);
            this.OnPropertyChanged("Root");
        }
コード例 #11
0
        private DataSchemaNode MakeSchemaElement(XmlSchemaElement element)
        {
            string typeName = (string)null;
            Type   type     = (Type)null;

            if (element.ElementSchemaType != null && element.ElementSchemaType.Datatype != null)
            {
                type = element.ElementSchemaType.Datatype.ValueType;
            }
            else if (element.SchemaTypeName != (XmlQualifiedName)null && element.SchemaTypeName.Name != string.Empty)
            {
                typeName = element.SchemaTypeName.Name;
            }
            if (type != (Type)null)
            {
                type     = this.ConvertType(type);
                typeName = type.Name;
            }
            string               str               = this.ProcessQualifiedName(element.QualifiedName);
            SchemaNodeTypes      nodeType          = element.MaxOccurs > new Decimal(1) ? SchemaNodeTypes.Collection : SchemaNodeTypes.Property;
            DataSchemaNode       schemaNode        = new DataSchemaNode(str, str, nodeType, typeName, type, (IDataSchemaNodeDelayLoader)null);
            XmlSchemaComplexType schemaComplexType = element.ElementSchemaType as XmlSchemaComplexType;

            if (schemaComplexType != null)
            {
                XmlSchemaObjectCollection objectCollection = (XmlSchemaObjectCollection)null;
                if (schemaComplexType.Attributes.Count > 0)
                {
                    objectCollection = schemaComplexType.Attributes;
                }
                else
                {
                    XmlSchemaSimpleContent schemaSimpleContent = schemaComplexType.ContentModel as XmlSchemaSimpleContent;
                    if (schemaSimpleContent != null)
                    {
                        XmlSchemaSimpleContentExtension contentExtension = schemaSimpleContent.Content as XmlSchemaSimpleContentExtension;
                        if (contentExtension != null)
                        {
                            objectCollection = contentExtension.Attributes;
                        }
                    }
                }
                if (objectCollection != null)
                {
                    foreach (XmlSchemaAttribute attribute in objectCollection)
                    {
                        DataSchemaNode child = this.MakeSchemaAttribute(attribute);
                        schemaNode.AddChild(child);
                    }
                }
                XmlSchemaGroupBase xmlSchemaGroupBase = schemaComplexType.Particle as XmlSchemaGroupBase;
                if (xmlSchemaGroupBase != null)
                {
                    this.ProcessSchemaItems(schemaNode, xmlSchemaGroupBase.Items);
                }
            }
            return(schemaNode);
        }
コード例 #12
0
        private void VerifyNodesRelated(DataSchemaNode parentNode, DataSchemaNode childNode)
        {
            DataSchemaNode dataSchemaNode = childNode;

            while (dataSchemaNode != null && dataSchemaNode != parentNode)
            {
                dataSchemaNode = dataSchemaNode.Parent;
            }
        }
コード例 #13
0
            public DataPanePopupCallback(DataSchemaItem dataSchemaItem)
            {
                DataSchemaNode parent = dataSchemaItem.DataSchemaNode.Parent;

                dataSchemaItem.DataSourceNode.DocumentNode.TypeResolver.GetType(parent.Type);
                this.property           = DesignDataConfigurationButton.WritablePropertyFromSchemaItem(dataSchemaItem);
                this.designDataFile     = DesignDataHelper.GetDesignDataFile(dataSchemaItem.DataSourceNode.DocumentNode);
                this.stringConfigurator = new SampleStringConfiguration(SampleDataFormatHelper.NormalizeFormat(SampleBasicType.String, (string)null, false), (string)null);
            }
コード例 #14
0
 private XmlSchema(XmlSchema source, DataSchemaNode root)
 {
     this.root              = root;
     this.dataSource        = (DataSourceNode) new XmlDataSourceNode(this, source.dataSource.DocumentNode);
     this.invalidRootXPath  = source.invalidRootXPath;
     this.namespaceManager  = source.namespaceManager;
     this.prefixToNamespace = source.prefixToNamespace;
     this.namespaceToPrefix = source.namespaceToPrefix;
     this.targetNamespace   = source.targetNamespace;
 }
コード例 #15
0
        public DataSchemaNodePath GetNodePathFromPath(string path)
        {
            DataSchemaNode nodeFromPath = this.GetNodeFromPath(path);

            if (nodeFromPath != null)
            {
                return(new DataSchemaNodePath((ISchema)this, nodeFromPath));
            }
            return((DataSchemaNodePath)null);
        }
コード例 #16
0
ファイル: DataSchemaNode.cs プロジェクト: radtek/Shopdrawing
 public bool IsAncestorOf(DataSchemaNode descendant)
 {
     for (; descendant != null; descendant = descendant.Parent)
     {
         if (this == descendant)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #17
0
        private void Verify()
        {
            if (this.Schema.Root == null)
            {
                return;
            }
            bool flag = false;

            for (DataSchemaNode dataSchemaNode = this.Node; dataSchemaNode != null && !flag; dataSchemaNode = dataSchemaNode.Parent)
            {
                flag = dataSchemaNode == this.Schema.Root;
            }
        }
コード例 #18
0
        private DocumentCompositeNode GetCollectionNode(DocumentCompositeNode rootSampleDataNode, bool createMissingNodes)
        {
            DataSchemaNode        node = this.editingSchemaPath.Node;
            List <DataSchemaNode> list = new List <DataSchemaNode>();

            for (DataSchemaNode dataSchemaNode = node; dataSchemaNode.Parent != null; dataSchemaNode = dataSchemaNode.Parent)
            {
                list.Insert(0, dataSchemaNode);
            }
            DocumentCompositeNode documentNode1 = rootSampleDataNode;

            for (int index = 0; index < list.Count; ++index)
            {
                DataSchemaNode     dataSchemaNode     = list[index];
                SampleNonBasicType sampleNonBasicType = (SampleNonBasicType)documentNode1.Type;
                DocumentNode       documentNode2;
                if (sampleNonBasicType.IsCollection)
                {
                    if (documentNode1.Children.Count > 0)
                    {
                        documentNode2 = documentNode1.Children[0];
                    }
                    else
                    {
                        if (!createMissingNodes)
                        {
                            return((DocumentCompositeNode)null);
                        }
                        documentNode2 = this.ValueBuilder.CreateNode(((SampleCollectionType)sampleNonBasicType).ItemSampleType);
                        documentNode1.Children.Add(documentNode2);
                    }
                }
                else
                {
                    SampleProperty sampleProperty = ((SampleCompositeType)sampleNonBasicType).GetSampleProperty(dataSchemaNode.PathName);
                    documentNode2 = documentNode1.Properties[(IPropertyId)sampleProperty];
                    if (documentNode2 == null)
                    {
                        if (!createMissingNodes)
                        {
                            return((DocumentCompositeNode)null);
                        }
                        documentNode2 = this.ValueBuilder.CreatePropertyValue(documentNode1, sampleProperty);
                        documentNode1.Properties[(IPropertyId)sampleProperty] = documentNode2;
                    }
                }
                documentNode1 = (DocumentCompositeNode)documentNode2;
            }
            return(documentNode1);
        }
コード例 #19
0
        private DataSchemaNode GetNodeFromPath(string path)
        {
            if (this.root == null)
            {
                return((DataSchemaNode)null);
            }
            bool flag = !string.IsNullOrEmpty(path) && (int)path[0] == 47;

            if (this.invalidRootXPath && !flag)
            {
                return((DataSchemaNode)null);
            }
            if (string.IsNullOrEmpty(path))
            {
                return(this.root);
            }
            DataSchemaNode dataSchemaNode1 = flag ? this.AbsoluteRoot : this.root;

            string[] strArray = path.Split('/');
            int      num      = 0;

            if (flag)
            {
                if (string.IsNullOrEmpty(strArray[1]) && strArray.Length == 2)
                {
                    return(dataSchemaNode1);
                }
                if (dataSchemaNode1.PathName != strArray[1])
                {
                    return((DataSchemaNode)null);
                }
                num = 2;
            }
            DataSchemaNode dataSchemaNode2 = dataSchemaNode1;

            for (int index = num; index < strArray.Length && dataSchemaNode2 != null; ++index)
            {
                string pathName = strArray[index];
                if (pathName == "..")
                {
                    dataSchemaNode2 = dataSchemaNode2.Parent;
                }
                else if (pathName != ".")
                {
                    dataSchemaNode2 = dataSchemaNode2.FindChildByPathName(pathName);
                }
            }
            return(dataSchemaNode2);
        }
コード例 #20
0
        public static IProperty WritablePropertyFromSchemaItem(DataSchemaItem dataSchemaItem)
        {
            IProperty      property       = (IProperty)null;
            DataSchemaNode dataSchemaNode = dataSchemaItem.DataSchemaNode;

            if (dataSchemaNode.Parent != null && dataSchemaNode.IsProperty)
            {
                DataSchemaNode parent = dataSchemaNode.Parent;
                property = (IProperty)dataSchemaItem.DataSourceNode.DocumentNode.TypeResolver.GetType(parent.Type).GetMember(MemberType.Property, dataSchemaNode.PathName, MemberAccessTypes.All);
                if (!DesignDataGenerator.IsPropertyWritable(property, (ITypeResolver)dataSchemaItem.ViewModel.ProjectContext))
                {
                    property = (IProperty)null;
                }
            }
            return(property);
        }
コード例 #21
0
        public bool IsSubpathOf(DataSchemaNodePath superPath)
        {
            if (this.Schema.Root != superPath.Schema.Root || this.Schema.Root == null || superPath.Schema.Root == null)
            {
                return(false);
            }
            DataSchemaNode parent = superPath.Schema.Root.Parent;

            for (DataSchemaNode dataSchemaNode = superPath.Node; dataSchemaNode != parent; dataSchemaNode = dataSchemaNode.Parent)
            {
                if (dataSchemaNode == this.Node)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #22
0
        private void AddMethodBasedChildren(DataSchemaNode node)
        {
            List <MethodInfo> supportedMethods = DataBindingDragDropAddTriggerHandler.GetSupportedMethods(this.DataSource.DocumentNode.TypeResolver, node.Type);

            if (supportedMethods == null || supportedMethods.Count == 0)
            {
                return;
            }
            for (int index = 0; index < supportedMethods.Count; ++index)
            {
                MethodInfo methodInfo = supportedMethods[index];
                node.AddChild(new DataSchemaNode(methodInfo.Name, methodInfo.Name, SchemaNodeTypes.Method, (string)null, methodInfo.ReturnType, (IDataSchemaNodeDelayLoader)this)
                {
                    IsReadOnly = true
                });
            }
        }
コード例 #23
0
        public string GetPath(DataSchemaNodePath nodePath)
        {
            if (nodePath == null || nodePath.Node == this.root)
            {
                return(string.Empty);
            }
            DataSchemaNode node             = nodePath.Node;
            bool           isCollectionItem = node.IsCollectionItem;
            string         str = node.PathName;

            for (DataSchemaNode parent = node.Parent; parent != this.Root && parent != null; parent = parent.Parent)
            {
                str = isCollectionItem ? parent.PathName + str : parent.PathName + "." + str;
                isCollectionItem = parent.IsCollectionItem;
            }
            return(str);
        }
コード例 #24
0
        private string GetPathInternal(DataSchemaNode rootNode, DataSchemaNode node)
        {
            if (this.root == null)
            {
                return((string)null);
            }
            string localXPath = string.Empty;

            for (; node != rootNode; node = node.Parent)
            {
                localXPath = localXPath.Length != 0 ? node.PathName + "/" + localXPath : node.PathName;
            }
            if (rootNode.Parent == null)
            {
                localXPath = XmlSchema.CombineXPaths("/" + rootNode.PathName, localXPath);
            }
            return(localXPath);
        }
コード例 #25
0
        public ISchema MakeRelativeToNode(DataSchemaNode node)
        {
            ClrObjectSchema clrObjectSchema;

            if (node == this.Root)
            {
                clrObjectSchema = this;
            }
            else if (node != null)
            {
                clrObjectSchema = new ClrObjectSchema(node, this.DataSource.DocumentNode);
            }
            else
            {
                DataSchemaNode absoluteRoot = this.AbsoluteRoot;
                clrObjectSchema = this.Root != absoluteRoot ? new ClrObjectSchema(absoluteRoot, this.DataSource.DocumentNode) : this;
            }
            return((ISchema)clrObjectSchema);
        }
コード例 #26
0
        public ISchema MakeRelativeToNode(DataSchemaNode node)
        {
            XmlSchema xmlSchema;

            if (node == this.Root)
            {
                xmlSchema = this;
            }
            else if (node != null)
            {
                xmlSchema = new XmlSchema(this, node);
            }
            else
            {
                DataSchemaNode absoluteRoot = this.AbsoluteRoot;
                xmlSchema = this.Root != absoluteRoot ? new XmlSchema(this, absoluteRoot) : this;
            }
            return((ISchema)xmlSchema);
        }
コード例 #27
0
 private void ProcessSchemaItems(DataSchemaNode schemaNode, XmlSchemaObjectCollection items)
 {
     foreach (XmlSchemaObject xmlSchemaObject in items)
     {
         XmlSchemaElement element;
         if ((element = xmlSchemaObject as XmlSchemaElement) != null)
         {
             DataSchemaNode child = this.MakeSchemaElement(element);
             schemaNode.AddChild(child);
         }
         else
         {
             XmlSchemaChoice xmlSchemaChoice;
             if ((xmlSchemaChoice = xmlSchemaObject as XmlSchemaChoice) != null)
             {
                 this.ProcessSchemaItems(schemaNode, xmlSchemaChoice.Items);
             }
         }
     }
 }
コード例 #28
0
        public int GetCollectionDepth(DataSchemaNode endNode)
        {
            int num = endNode.IsProperty || endNode.IsMethod ? 0 : 1;

            if (endNode == this.Root)
            {
                return(num);
            }
            for (DataSchemaNode parent = endNode.Parent; parent != this.Root; parent = parent.Parent)
            {
                if (parent == null)
                {
                    return(-1);
                }
                if (parent.IsCollectionItem)
                {
                    ++num;
                }
            }
            return(num);
        }
コード例 #29
0
ファイル: SchemaItem.cs プロジェクト: radtek/Shopdrawing
 private DataSchemaItem GetItemForNode(DataSchemaItem currentItem, DataSchemaNode nextNode, out DataSchemaNode adjustedNextNode)
 {
     currentItem.EnsureChildrenExpanded();
     adjustedNextNode = nextNode;
     foreach (DataSchemaItem dataSchemaItem in Enumerable.OfType <DataSchemaItem>((IEnumerable)currentItem.Children))
     {
         if (dataSchemaItem.DataSchemaNode == nextNode)
         {
             while (adjustedNextNode.IsCollection && adjustedNextNode.CollectionItem != null && adjustedNextNode.CollectionItem.Type != typeof(object))
             {
                 adjustedNextNode = adjustedNextNode.CollectionItem;
             }
             return(dataSchemaItem);
         }
     }
     if (currentItem.DataSchemaNode.CollectionItem == nextNode)
     {
         return(currentItem);
     }
     return((DataSchemaItem)null);
 }
コード例 #30
0
ファイル: DataSchemaNode.cs プロジェクト: radtek/Shopdrawing
        public DataSchemaNode FindChildByPathName(string pathName)
        {
            DataSchemaNode dataSchemaNode1 = (DataSchemaNode)null;

            if (pathName != DataSchemaNode.IndexNodePath)
            {
                foreach (DataSchemaNode dataSchemaNode2 in this.Children)
                {
                    if (dataSchemaNode2.PathName == pathName)
                    {
                        dataSchemaNode1 = dataSchemaNode2;
                        break;
                    }
                }
            }
            else
            {
                dataSchemaNode1 = this.CollectionItem;
            }
            return(dataSchemaNode1);
        }