예제 #1
0
        public override string ToString()
        {
            Type          type          = this.GetType();
            SampleDataSet sampleDataSet = SampleDataSet.SampleDataSetFromType(type);

            return(sampleDataSet == null ? type.Name : sampleDataSet.ClrNamespace + "." + type.Name);
        }
        private IEnumerable <DataStoreReferenceEntry> FindDataStoreReferenceDictionary(SceneDocument document)
        {
            List <DataStoreReferenceEntry>    list = (List <DataStoreReferenceEntry>)null;
            ResourceDictionaryContentProvider dictionaryContentProvider = this.GetResourceDictionaryContentProvider(document);

            if (dictionaryContentProvider != null)
            {
                foreach (DocumentNode documentNode1 in dictionaryContentProvider.Items)
                {
                    DocumentCompositeNode documentCompositeNode = documentNode1 as DocumentCompositeNode;
                    if (documentCompositeNode != null)
                    {
                        DocumentNode documentNode2 = documentCompositeNode.Properties[DictionaryEntryNode.ValueProperty];
                        if (documentNode2 != null)
                        {
                            SampleDataSet sampleDataSet = SampleDataSet.SampleDataSetFromType(documentNode2.Type.RuntimeType);
                            if (sampleDataSet != null && sampleDataSet.Context == DataSetContext.DataStore)
                            {
                                if (list == null)
                                {
                                    list = new List <DataStoreReferenceEntry>();
                                }
                                DataStoreReferenceEntry storeReferenceEntry = new DataStoreReferenceEntry()
                                {
                                    DataStore           = sampleDataSet,
                                    DictionaryEntryNode = documentCompositeNode
                                };
                                list.Add(storeReferenceEntry);
                            }
                        }
                    }
                }
            }
            return((IEnumerable <DataStoreReferenceEntry>)list);
        }
        public override void OnViewNodeInvalidating(IInstanceBuilderContext context, ViewNode target, ViewNode child, ref bool doesInvalidRootsContainTarget, List <ViewNode> invalidRoots)
        {
            base.OnViewNodeInvalidating(context, target, child, ref doesInvalidRootsContainTarget, invalidRoots);
            DocumentCompositeNode fromXamlDocument = SampleDataSet.SampleDataSetFromType(target.DocumentNode.Type.RuntimeType).ValidRootNodeFromXamlDocument;

            if (fromXamlDocument == null || !this.IsSampleDataXamlContext(context, fromXamlDocument.DocumentRoot))
            {
                return;
            }
            InstanceBuilderOperations.SetInvalid(context, target, ref doesInvalidRootsContainTarget, invalidRoots);
        }
        public override bool Instantiate(IInstanceBuilderContext context, ViewNode viewNode)
        {
            bool flag = viewNode.Instance != null;

            base.Instantiate(context, viewNode);
            if (flag)
            {
                return(false);
            }
            SampleDataSet sampleDataSet = SampleDataSet.SampleDataSetFromType(viewNode.DocumentNode.Type.RuntimeType);

            if (sampleDataSet == null)
            {
                return(!flag);
            }
            DocumentCompositeNode documentCompositeNode = sampleDataSet != null ? sampleDataSet.ValidRootNodeFromXamlDocument : (DocumentCompositeNode)null;

            if (documentCompositeNode == null || !PlatformTypes.PlatformsCompatible((IPlatformMetadata)context.Platform.Metadata, documentCompositeNode.PlatformMetadata) || (this.IsSampleDataXamlContext(context, documentCompositeNode.DocumentRoot) || DesignDataHelper.GetDesignDataFile(viewNode.DocumentNode) != null))
            {
                return(!flag);
            }
            using (StandaloneInstanceBuilderContext instanceBuilderContext = new StandaloneInstanceBuilderContext(context.DocumentContext, context))
            {
                using (instanceBuilderContext.ChangeSerializationContext(context.SerializationContext))
                {
                    ViewNode viewNode1 = this.GetViewNode((IInstanceBuilderContext)instanceBuilderContext, (DocumentNode)documentCompositeNode);
                    viewNode1.Instance = viewNode.Instance;
                    this.Initialize((IInstanceBuilderContext)instanceBuilderContext, viewNode1, true);
                    viewNode1.Instance     = (object)null;
                    viewNode.InstanceState = InstanceState.Valid;
                }
            }
            context.DocumentRootResolver.GetDocumentRoot(documentCompositeNode.DocumentRoot.DocumentContext.DocumentUrl);
            IProperty index           = context.DocumentContext.TypeResolver.ResolveProperty(DesignTimeProperties.SampleDataTagProperty);
            ViewNode  referenceSource = new ViewNode(context.ViewNodeManager, (DocumentNode)documentCompositeNode);

            viewNode.Properties[index] = referenceSource;
            context.ViewNodeManager.AddRelatedDocumentRoot(referenceSource, documentCompositeNode.DocumentRoot);
            return(!flag);
        }