Beispiel #1
0
        private bool RenameProperty(string rawName)
        {
            SampleCompositeType effectiveParentType1 = this.DataSchemaNode.EffectiveParentType;
            SampleProperty      sampleProperty1      = effectiveParentType1.GetSampleProperty(this.DataSchemaNode.PathName);
            SampleProperty      propertyToRename1    = DataSchemaItem.GetHierarchicalPropertyToRename(sampleProperty1);

            if (propertyToRename1 == null || propertyToRename1 != sampleProperty1)
            {
                return(this.RenamePropertyInternal(sampleProperty1, propertyToRename1, rawName));
            }
            for (DataSchemaItem dataSchemaItem = this.Parent as DataSchemaItem; dataSchemaItem != null; dataSchemaItem = dataSchemaItem.Parent as DataSchemaItem)
            {
                SampleCompositeType effectiveParentType2 = dataSchemaItem.DataSchemaNode.EffectiveParentType;
                if (effectiveParentType2 != effectiveParentType1)
                {
                    SampleProperty sampleProperty2 = effectiveParentType2 != null?effectiveParentType2.GetSampleProperty(dataSchemaItem.DataSchemaNode.PathName) : (SampleProperty)null;

                    if (sampleProperty2 == null)
                    {
                        return(this.RenamePropertyInternal(sampleProperty1, (SampleProperty)null, rawName));
                    }
                    SampleProperty propertyToRename2 = DataSchemaItem.GetHierarchicalPropertyToRename(sampleProperty2);
                    if (propertyToRename2 != sampleProperty1)
                    {
                        return(this.RenamePropertyInternal(sampleProperty1, (SampleProperty)null, rawName));
                    }
                    return(dataSchemaItem.RenamePropertyInternal(sampleProperty2, propertyToRename2, rawName));
                }
            }
            return(this.RenamePropertyInternal(sampleProperty1, (SampleProperty)null, rawName));
        }
Beispiel #2
0
        private void ChangeEffectivePropertyIfValid(DataSchemaItem.ModifySamplePropertyOperation operation)
        {
            SampleCompositeType effectiveParentType = this.DataSchemaNode.EffectiveParentType;

            if (effectiveParentType == null)
            {
                return;
            }
            SampleDataSet  declaringDataSet = effectiveParentType.DeclaringDataSet;
            SampleProperty sampleProperty   = effectiveParentType.GetSampleProperty(this.DataSchemaNode.PathName);

            if (sampleProperty == null)
            {
                return;
            }
            operation(effectiveParentType, sampleProperty);
            using (TemporaryCursor.SetWaitCursor())
                declaringDataSet.CommitChanges(this.ViewModel.DesignerContext.MessageDisplayService);
        }
Beispiel #3
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);
        }