Ejemplo n.º 1
0
        internal static IPropertyId RefineDataContextProperty(SceneNode target, IPropertyId targetProperty, DocumentNode dataNode)
        {
            if (targetProperty.MemberType == MemberType.DesignTimeProperty || !DataContextHelper.IsDataContextProperty(target.DocumentNode, targetProperty))
            {
                return(targetProperty);
            }
            SampleNonBasicType sampleNonBasicType = dataNode.Type as SampleNonBasicType;

            if (sampleNonBasicType != null)
            {
                if (!sampleNonBasicType.DeclaringDataSet.IsEnabledAtRuntime)
                {
                    return(DesignTimeProperties.DesignDataContextProperty);
                }
                if (((DocumentCompositeNode)target.DocumentNode).Properties[targetProperty] != null)
                {
                    DataContextInfo dataContextInfo = new DataContextEvaluator().Evaluate(target, targetProperty, true);
                    if (dataContextInfo.DataSource != null && !(dataContextInfo.DataSource.DataSourceType is SampleNonBasicType))
                    {
                        return(DesignTimeProperties.DesignDataContextProperty);
                    }
                }
                return(targetProperty);
            }
            if (PlatformTypes.IsExpressionInteractiveType(dataNode.Type.RuntimeType))
            {
                return(DesignTimeProperties.DesignDataContextProperty);
            }
            return(targetProperty);
        }
Ejemplo n.º 2
0
        public void MakeHierarchicalCollection()
        {
            if (!this.schemaItem.Schema.DataSource.IsSampleDataSource)
            {
                return;
            }
            SampleDataSet       sampleData    = this.schemaItem.Schema.DataSource.SampleData;
            SampleCompositeType effectiveType = this.DataSchemaNode.EffectiveType;

            if (effectiveType == null)
            {
                return;
            }
            this.model.SelectionContext.Clear();
            SampleNonBasicType sampleNonBasicType   = (SampleNonBasicType)this.DataSchemaNode.SampleType;
            string             uniquePropertyName1  = effectiveType.GetUniquePropertyName(this.DataSchemaNode.PathName);
            SampleProperty     hierarchicalProperty = effectiveType.AddProperty(uniquePropertyName1, (SampleType)sampleNonBasicType);
            SampleProperty     sampleProperty       = this.DataSchemaNode.EffectiveParentType.GetSampleProperty(this.DataSchemaNode.PathName);
            string             uniquePropertyName2  = DataSchemaItem.GetUniquePropertyName(sampleProperty, hierarchicalProperty, uniquePropertyName1);
            string             schemaNodePath       = DataSchemaItem.ProvideNodePathForPendingEdit(this, uniquePropertyName2, sampleProperty, hierarchicalProperty);

            sampleProperty.Rename(uniquePropertyName2);
            hierarchicalProperty.Rename(uniquePropertyName2);
            this.model.RenameSampleDataSchemaItemUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath);
            this.model.ExtendSelectionUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath);
            this.IsExpanded = true;
            using (TemporaryCursor.SetWaitCursor())
                sampleData.CommitChanges(this.ViewModel.DesignerContext.MessageDisplayService);
        }
Ejemplo n.º 3
0
        private static void RenamePropertyAndType(SampleProperty property, string propertyName, string typeName)
        {
            if (propertyName == property.Name)
            {
                return;
            }
            property.Rename(propertyName);
            SampleNonBasicType sampleNonBasicType1 = property.PropertySampleType as SampleNonBasicType;

            if (sampleNonBasicType1 == null)
            {
                return;
            }
            string uniqueTypeName1 = sampleNonBasicType1.DeclaringDataSet.GetUniqueTypeName(typeName, sampleNonBasicType1.Name);

            if (string.IsNullOrEmpty(uniqueTypeName1))
            {
                return;
            }
            sampleNonBasicType1.Rename(uniqueTypeName1);
            SampleCollectionType sampleCollectionType = sampleNonBasicType1 as SampleCollectionType;
            SampleNonBasicType   sampleNonBasicType2  = sampleCollectionType != null ? sampleCollectionType.ItemSampleType as SampleNonBasicType : (SampleNonBasicType)null;

            if (sampleNonBasicType2 == null || sampleNonBasicType2 == sampleNonBasicType1)
            {
                return;
            }
            string uniqueTypeName2 = sampleNonBasicType2.DeclaringDataSet.GetUniqueTypeName(typeName + "Item", sampleNonBasicType2.Name);

            if (string.IsNullOrEmpty(uniqueTypeName2))
            {
                return;
            }
            sampleNonBasicType2.Rename(uniqueTypeName2);
        }
Ejemplo n.º 4
0
        private static SampleCompositeType CalculateEffectiveType(Type type)
        {
            SampleNonBasicType sampleNonBasicType = SampleDataSet.SampleDataTypeFromType(type);

            if (sampleNonBasicType != null)
            {
                SampleCollectionType sampleCollectionType;
                while ((sampleCollectionType = sampleNonBasicType as SampleCollectionType) != null)
                {
                    sampleNonBasicType = sampleCollectionType.ItemType as SampleNonBasicType;
                }
            }
            return(sampleNonBasicType as SampleCompositeType);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public void Refresh(SampleDataSet changedSampleData)
        {
            List <IProjectItem> list = new List <IProjectItem>();

            foreach (KeyValuePair <IProjectItem, DesignDataSchemaManager.SchemaAndOpenState> keyValuePair in this.designDataCache)
            {
                ClrObjectSchema clrObjectSchema = keyValuePair.Value.Schema as ClrObjectSchema;
                bool            flag            = false;
                if (clrObjectSchema != null)
                {
                    DocumentNode rootDesignDataNode = DesignDataHelper.GetRootDesignDataNode(keyValuePair.Key, (IProjectContext)clrObjectSchema.DataSource.DocumentNode.TypeResolver);
                    if (rootDesignDataNode == null || rootDesignDataNode != clrObjectSchema.DataSource.DocumentNode)
                    {
                        flag = true;
                    }
                    else if (changedSampleData != null)
                    {
                        SampleNonBasicType sampleNonBasicType = rootDesignDataNode.Type as SampleNonBasicType;
                        if (sampleNonBasicType != null && sampleNonBasicType.DeclaringDataSet == changedSampleData)
                        {
                            flag = true;
                        }
                    }
                }
                else
                {
                    flag = true;
                }
                if (flag)
                {
                    list.Add(keyValuePair.Key);
                }
            }
            foreach (IProjectItem key in list)
            {
                this.designDataCache.Remove(key);
            }
        }
Ejemplo n.º 7
0
 public SampleTypeDeleted(SampleNonBasicType sampleType)
     : base(sampleType)
 {
 }
Ejemplo n.º 8
0
 public SampleTypeCreated(SampleNonBasicType sampleType)
     : base(sampleType)
 {
 }
Ejemplo n.º 9
0
 public SampleTypeRenamed(SampleNonBasicType sampleType, string oldName)
     : base(sampleType)
 {
     this.OldName = oldName;
     this.NewName = sampleType.Name;
 }
Ejemplo n.º 10
0
 protected SampleTypeChange(SampleNonBasicType sampleType)
     : base((object)sampleType)
 {
 }