Ejemplo n.º 1
0
        private string GetPropertyPathExtension(DocumentCompositeNode documentNode, IProperty targetProperty, DataContextPropertyPathExtension pathExtension)
        {
            if (!pathExtension.IsValid)
            {
                return((string)null);
            }
            DocumentNode node = documentNode.Properties[(IPropertyId)targetProperty];

            if (node == null || !PlatformTypes.String.IsAssignableFrom((ITypeId)node.Type))
            {
                return(string.Empty);
            }
            string localPath = DocumentPrimitiveNode.GetValueAsString(node);

            if (pathExtension.IsCollectionItem)
            {
                localPath = ClrObjectSchema.CombinePaths(DataSchemaNode.IndexNodePath, localPath);
            }
            return(localPath);
        }
Ejemplo n.º 2
0
        private static string ProvideNodePathForPendingEdit(DataSchemaItem parentItem, string newPropertyName, params SampleProperty[] renamedProperties)
        {
            DataSchemaNodePath dataSchemaNodePath = parentItem.DataSchemaNodePath;
            DataSchemaNode     endNode            = (DataSchemaNode)null;

            if (dataSchemaNodePath.IsCollection)
            {
                endNode = dataSchemaNodePath.EffectiveCollectionItemNode;
            }
            if (endNode == null)
            {
                endNode = dataSchemaNodePath.Node;
            }
            if (endNode == null)
            {
                return(newPropertyName);
            }
            string inheritedPath = (string)null;

            if (renamedProperties.Length == 0)
            {
                if (endNode != dataSchemaNodePath.Node)
                {
                    dataSchemaNodePath = new DataSchemaNodePath(dataSchemaNodePath.Schema, endNode);
                }
                return(ClrObjectSchema.CombinePaths(dataSchemaNodePath.Path, newPropertyName));
            }
            List <string> list = new List <string>()
            {
                newPropertyName
            };
            string pathName = endNode.PathName;

            for (DataSchemaNode parent = endNode.Parent; parent != null; parent = parent.Parent)
            {
                SampleCompositeType sampleCompositeType = parent.SampleType as SampleCompositeType;
                if (sampleCompositeType == null)
                {
                    list.Add(pathName);
                }
                else
                {
                    string         name           = pathName;
                    SampleProperty sampleProperty = sampleCompositeType.GetSampleProperty(name);
                    if (Enumerable.FirstOrDefault <SampleProperty>((IEnumerable <SampleProperty>)renamedProperties, (Func <SampleProperty, bool>)(p => p == sampleProperty)) != null)
                    {
                        name = newPropertyName;
                    }
                    list.Add(name);
                }
                if (parent != dataSchemaNodePath.Schema.Root)
                {
                    pathName = parent.PathName;
                }
                else
                {
                    break;
                }
            }
            for (int index = list.Count - 1; index >= 0; --index)
            {
                inheritedPath = ClrObjectSchema.CombinePaths(inheritedPath, list[index]);
            }
            return(inheritedPath);
        }