private static CompilationSettings GetCompilationSettings(
     ICompilerOptionsProvider compilerOptionsProvider,
     IProjectContext projectContext)
 {
     return compilerOptionsProvider.GetCompilerOptions(projectContext.Name,
                                                       projectContext.TargetFramework,
                                                       projectContext.Configuration)
                                   .ToCompilationSettings(projectContext.TargetFramework);
 }
 public void AddProjectReference(IProjectContext project, MetadataReferenceProperties properties)
 {
     // AbstractProject and ProjectTracker track project references using the project bin output path.
     // Setting the command line arguments should have already set the output file name and folder.
     // We fetch this output path to add the reference.
     var referencedProject = this.ProjectTracker.GetProject(project.Id);
     var binPathOpt = referencedProject.TryGetBinOutputPath();
     if (!string.IsNullOrEmpty(binPathOpt))
     {
         AddMetadataReferenceAndTryConvertingToProjectReferenceIfPossible(binPathOpt, properties);
     }
 }
示例#3
0
 public static string GetHubName(this IProjectContext projectContext)
 => projectContext is null ? throw new ArgumentNullException(nameof(projectContext)) : GetHubName(projectContext.ProjectId);
        public EntityFrameworkServices(
            IProjectContext projectContext,
            IApplicationInfo applicationInfo,
            ICodeGenAssemblyLoadContext loader,
            IModelTypesLocator modelTypesLocator,
            IDbContextEditorServices dbContextEditorServices,
            IPackageInstaller packageInstaller,
            IServiceProvider serviceProvider,
            Workspace workspace,
            IFileSystem fileSystem,
            ILogger logger)
        {
            if (projectContext == null)
            {
                throw new ArgumentNullException(nameof(projectContext));
            }

            if (applicationInfo == null)
            {
                throw new ArgumentNullException(nameof(applicationInfo));
            }

            if (loader == null)
            {
                throw new ArgumentNullException(nameof(loader));
            }

            if (modelTypesLocator == null)
            {
                throw new ArgumentNullException(nameof(modelTypesLocator));
            }

            if (dbContextEditorServices == null)
            {
                throw new ArgumentNullException(nameof(dbContextEditorServices));
            }

            if (packageInstaller == null)
            {
                throw new ArgumentNullException(nameof(packageInstaller));
            }

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (workspace == null)
            {
                throw new ArgumentNullException(nameof(workspace));
            }

            if (fileSystem == null)
            {
                throw new ArgumentNullException(nameof(fileSystem));
            }

            _projectContext          = projectContext;
            _applicationInfo         = applicationInfo;
            _loader                  = loader;
            _modelTypesLocator       = modelTypesLocator;
            _dbContextEditorServices = dbContextEditorServices;
            _packageInstaller        = packageInstaller;
            _serviceProvider         = serviceProvider;
            _logger                  = logger;
            _workspace               = workspace;
            _fileSystem              = fileSystem;
        }
 public void OnProjectCreated(IProjectContext projectContext)
 {
 }
        public static DocumentNode GetParsedOrSniffedRootNode(IProjectItem projectItem, IProjectContext projectContext)
        {
            if (projectItem.Document != null)
            {
                SceneDocument sceneDocument = projectItem.Document as SceneDocument;
                if (sceneDocument != null && sceneDocument.DocumentRoot != null)
                {
                    return(sceneDocument.DocumentRoot.RootNode);
                }
            }
            DocumentContext documentContext = DocumentContextHelper.CreateDocumentContext((IProject)projectContext.GetService(typeof(IProject)), projectContext, DocumentReferenceLocator.GetDocumentLocator(projectItem.DocumentReference));
            IType           type            = DocumentContextHelper.SniffRootNodeType(projectItem, documentContext);

            if (type != null && type.RuntimeType != (Type)null)
            {
                return((DocumentNode)documentContext.CreateNode((ITypeId)type));
            }
            return((DocumentNode)null);
        }
 private IAnnotationPluginData GetPluginData(IProjectContext projectContext)
 {
     return(_pluginDataService.GetPluginData(projectContext, PLUGIN_ID) as IAnnotationPluginData);
 }
        private IAnnotationData GetAnnotationData(IProjectContext projectContext, IModelElement element)
        {
            var pluginData = GetPluginData(projectContext);

            return(pluginData?.Annotations.SingleOrDefault(ad => Equals(ad.Element, element)));
        }
示例#9
0
 public IAttachedPropertiesMetadata Create(IProjectContext projectContext, IPlatformService platformService, IAssemblyService assemblyService)
 {
     return((IAttachedPropertiesMetadata) new AttachedPropertiesMetadata(projectContext, platformService, assemblyService));
 }
示例#10
0
 private void StatePickerEditor_Unloaded(object sender, RoutedEventArgs e)
 {
     this.EditingProperty      = (SceneNodeProperty)null;
     this.ActiveProjectContext = (IProjectContext)null;
 }
 public SelectProjectController(IProjectContext projectContext)
 {
     _db = projectContext;
 }
 public TypeReflectingProjectContext(IProjectContext actualProjectContext)
 {
     this.actualProjectContext = actualProjectContext;
 }
示例#13
0
 private static PropertyValueEditor GetPropertyEditorTemplate(IProjectContext projectContext, DesignerContext designerContext, IType type)
 {
     if (PlatformTypes.Double.IsAssignableFrom((ITypeId)type) || PlatformTypes.Double.IsAssignableFrom((ITypeId)type.NullableType))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"DoubleViewTemplate"]));
     }
     if (PlatformTypes.Int32.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"IntViewTemplate"]));
     }
     if (PlatformTypes.UInt32.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"UIntViewTemplate"]));
     }
     if (PlatformTypes.Byte.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"ByteViewTemplate"]));
     }
     if (PlatformTypes.Int16.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"ShortViewTemplate"]));
     }
     if (PlatformTypes.UInt16.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"UShortViewTemplate"]));
     }
     if (PlatformTypes.Single.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"FloatViewTemplate"]));
     }
     if (PlatformTypes.TextAlignment.IsAssignableFrom((ITypeId)type))
     {
         DataTemplate dataTemplate = new DataTemplate();
         dataTemplate.VisualTree = new FrameworkElementFactory(typeof(TextAlignmentValueEditor));
         return(new PropertyValueEditor(dataTemplate));
     }
     if (PlatformTypes.Enum.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor(!EnumsThatUseButtons.ShouldUseButtonsForEnum((ITypeId)type) ? (!EnumsThatUseButtons.ShouldUseToggleButtonsForEnum((ITypeId)type) ? (DataTemplate)PropertyEditorTemplateLookup.resources[(object)"ChoiceComboViewTemplate"] : (DataTemplate)PropertyEditorTemplateLookup.resources[(object)"ChoiceToggleButtonsViewTemplate"]) : (DataTemplate)PropertyEditorTemplateLookup.resources[(object)"ChoiceButtonsViewTemplate"]));
     }
     if (PlatformTypes.Boolean.IsAssignableFrom((ITypeId)type) || PlatformTypes.Boolean.IsAssignableFrom((ITypeId)type.NullableType))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"BoolViewTemplate"]));
     }
     if (PlatformTypes.String.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"StringViewTemplate"]));
     }
     if (PlatformTypes.Vector3D.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"Vector3DEditorTemplate"]));
     }
     if (PlatformTypes.Point3D.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"Point3DEditorTemplate"]));
     }
     if (PlatformTypes.Point.IsAssignableFrom((ITypeId)type) || PlatformTypes.Vector.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"Point2DEditorTemplate"]));
     }
     if (PlatformTypes.Color.IsAssignableFrom((ITypeId)type) || PlatformTypes.Color.IsAssignableFrom((ITypeId)type.NullableType))
     {
         DataTemplate dataTemplate = (DataTemplate)PropertyEditorTemplateLookup.resources[(object)"ColorViewTemplate"];
         return((PropertyValueEditor) new ExtendedPropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"ColorExtendedTemplate"], dataTemplate));
     }
     if (PlatformTypes.Brush.IsAssignableFrom((ITypeId)type))
     {
         DataTemplate dataTemplate = (DataTemplate)PropertyEditorTemplateLookup.resources[(object)"BrushViewTemplate"];
         return((PropertyValueEditor) new ExtendedPropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"BrushEditorTemplate"], dataTemplate));
     }
     if (PlatformTypes.Material.IsAssignableFrom((ITypeId)type))
     {
         DataTemplate dataTemplate1 = new DataTemplate();
         dataTemplate1.VisualTree = new FrameworkElementFactory(typeof(MaterialEditor));
         DataTemplate dataTemplate2 = (DataTemplate)PropertyEditorTemplateLookup.resources[(object)"MaterialViewTemplate"];
         return((PropertyValueEditor) new ExtendedPropertyValueEditor(dataTemplate1, dataTemplate2));
     }
     if (PlatformTypes.Transform.IsAssignableFrom((ITypeId)type) || PlatformTypes.Transform3D.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"TransformEditorTemplate"]));
     }
     if (PlatformTypes.Projection.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"ProjectionEditorTemplate"]));
     }
     if (PlatformTypes.Thickness.IsAssignableFrom((ITypeId)type))
     {
         DataTemplate dataTemplate = new DataTemplate();
         dataTemplate.VisualTree = new FrameworkElementFactory(typeof(ThicknessEditor));
         return(new PropertyValueEditor(dataTemplate));
     }
     if (PlatformTypes.GridLength.IsAssignableFrom((ITypeId)type))
     {
         DataTemplate dataTemplate = new DataTemplate();
         dataTemplate.VisualTree = new FrameworkElementFactory(typeof(GridLengthEditor));
         return(new PropertyValueEditor(dataTemplate));
     }
     if (PlatformTypes.FontFamily.IsAssignableFrom((ITypeId)type))
     {
         DataTemplate dataTemplate = new DataTemplate();
         dataTemplate.VisualTree = new FrameworkElementFactory(typeof(FontFamilyValueEditor));
         return(new PropertyValueEditor(dataTemplate));
     }
     if (PlatformTypes.DrawingImage.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"DrawingImageTemplate"]));
     }
     if (PlatformTypes.KeySpline.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"KeySplineEditorTemplate"]));
     }
     if (PlatformTypes.IEasingFunction.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"EasingFunctionEditorTemplate"]));
     }
     if (ProjectNeutralTypes.TransitionEffect.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"TransitionEffectEditorTemplate"]));
     }
     if (PlatformTypes.RepeatBehavior.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"RepeatBehaviorEditorTemplate"]));
     }
     if (ProjectNeutralTypes.GeometryEffect.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"GeometryEffectEditorTemplate"]));
     }
     if (ProjectNeutralTypes.LayoutPathCollection.IsAssignableFrom((ITypeId)type))
     {
         return(new PropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"LayoutPathCollectionEditorTemplate"]));
     }
     if (PlatformTypes.DoubleCollection.IsAssignableFrom((ITypeId)type))
     {
         return((PropertyValueEditor)null);
     }
     if (PlatformTypes.PointCollection.IsAssignableFrom((ITypeId)type))
     {
         return((PropertyValueEditor)null);
     }
     if (PropertyEditorTemplateLookup.ShouldUseCollectionEditor((ITypeId)type))
     {
         DataTemplate inlineEditorTemplate = (DataTemplate)PropertyEditorTemplateLookup.resources[(object)"CollectionDialogInlineTemplate"];
         return((PropertyValueEditor) new PropertyEditorTemplateLookup.CollectionDialogPropertyValueEditor((DataTemplate)PropertyEditorTemplateLookup.resources[(object)"CollectionDialogEditorTemplate"], inlineEditorTemplate, designerContext.MessageDisplayService));
     }
     if (PropertyEditorTemplateLookup.ShouldUseObjectEditor(type))
     {
         return(PropertyEditorTemplateLookup.ObjectEditorTemplate);
     }
     return((PropertyValueEditor)null);
 }
示例#14
0
 public void RemoveProjectReference(IProjectContext project)
 {
     foreach (var projectReference in GetCurrentProjectReferences())
     {
         if (projectReference.ProjectId.Equals(project.Id))
         {
             RemoveProjectReference(projectReference);
             return;
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the ProjectRepository class.
 /// This constructor creates an instance of a Project repository with the corresponding 
 /// interface as a parameter
 /// </summary>
 /// <param name="context">IProjectContext type context parameter</param>
 public ProjectRepository(IProjectContext context)
 {
     this.context = context;
 }
示例#16
0
 public ProjectRepository(IProjectContext context)
 {
     _context = context;
 }
示例#17
0
 public static bool TypeAnimationSupported(IProjectContext projectContext, Type type)
 {
     return(projectContext != null);
 }
示例#18
0
        public void Rebuild()
        {
            foreach (PropertyBase propertyBase in this.subProperties)
            {
                propertyBase.Associated = false;
            }
            PropertyDescriptorCollection descriptorCollection = (PropertyDescriptorCollection)null;
            Type         targetType = this.parentProperty.PropertyType;
            bool         isMixed;
            DocumentNode valueAsDocumentNode = this.parentProperty.GetLocalValueAsDocumentNode(true, out isMixed);

            if (valueAsDocumentNode == null || !(valueAsDocumentNode is DocumentPrimitiveNode) && !valueAsDocumentNode.Type.IsBinding)
            {
                TypeConverter converterFromAttributes = MetadataStore.GetTypeConverterFromAttributes(targetType.Assembly, this.parentProperty.Attributes);
                if (converterFromAttributes != null)
                {
                    object obj = this.parentProperty.SceneNodeObjectSet.GetValue(this.parentProperty.Reference, this.parentProperty.IsExpression ? PropertyReference.GetValueFlags.Computed : PropertyReference.GetValueFlags.Local);
                    if (obj != null && obj != MixedProperty.Mixed)
                    {
                        descriptorCollection = converterFromAttributes.GetProperties(obj);
                        targetType           = obj.GetType();
                    }
                }
                if (descriptorCollection == null)
                {
                    object component = this.parentProperty.SceneNodeObjectSet.GetValue(this.parentProperty.Reference, this.parentProperty.IsExpression ? PropertyReference.GetValueFlags.Computed : PropertyReference.GetValueFlags.Local);
                    if (component != null && component != MixedProperty.Mixed)
                    {
                        descriptorCollection = TypeUtilities.GetProperties(component);
                        targetType           = component.GetType();
                    }
                }
            }
            this.objectSet.RebuildObjects();
            IProjectContext projectContext = this.parentProperty.SceneNodeObjectSet.ProjectContext;

            if (projectContext != null && descriptorCollection != null)
            {
                SceneNode[] objects = this.objectSet.Objects;
                foreach (PropertyDescriptor propertyDescriptor in descriptorCollection)
                {
                    ReferenceStep referenceStep = PlatformTypeHelper.GetProperty((ITypeResolver)projectContext, targetType, propertyDescriptor) as ReferenceStep;
                    if (referenceStep != null)
                    {
                        TargetedReferenceStep targetedReferenceStep = new TargetedReferenceStep(referenceStep, this.objectSet.ObjectTypeId);
                        if (PropertyInspectorModel.IsPropertyBrowsable(objects, targetedReferenceStep) && PropertyInspectorModel.IsAttachedPropertyBrowsable(objects, this.objectSet.ObjectTypeId, targetedReferenceStep, (ITypeResolver)this.parentProperty.SceneNodeObjectSet.ProjectContext))
                        {
                            PropertyReference propertyReference = new PropertyReference(referenceStep);
                            SceneNodeProperty property          = this.FindProperty(propertyReference);
                            if (property == null)
                            {
                                SceneNodeProperty sceneNodeProperty = this.objectSet.CreateProperty(propertyReference, referenceStep.Attributes) as SceneNodeProperty;
                                int index = this.subProperties.BinarySearch(sceneNodeProperty, (IComparer <SceneNodeProperty>) new SceneNodePropertyCollection.PropertyNameComparer());
                                if (index < 0)
                                {
                                    index = ~index;
                                }
                                this.subProperties.Insert(index, sceneNodeProperty);
                                this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, (object)sceneNodeProperty, index));
                            }
                            else if (!property.UpdateAndRefresh(propertyReference, referenceStep.Attributes, (Type)null))
                            {
                                property.Associated = true;
                            }
                        }
                    }
                }
            }
            for (int index = this.subProperties.Count - 1; index >= 0; --index)
            {
                if (!this.subProperties[index].Associated)
                {
                    PropertyEntry propertyEntry = (PropertyEntry)this.subProperties[index];
                    this.subProperties[index].OnRemoveFromCategory();
                    this.subProperties.RemoveAt(index);
                    this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, (object)propertyEntry, index));
                }
            }
            this.OnPropertyChanged("Item[]");
        }
示例#19
0
 public TypeController(ISession dbSession, IProjectContext projectContext)
 {
     DbSession = dbSession;
     ProjectContext = projectContext;
 }
示例#20
0
 public ProjectRepository(IProjectContext collectionSettings)
 {
     _projectDatabase = collectionSettings;
 }
 public IAnnotationData GetAnnotation(IProjectContext projectContext, IModelElement element)
 {
     return(GetAnnotationData(projectContext, element));
 }
 public TestAssemblyLoadContext(IProjectContext projectDependencyProvider)
 {
     _projectContext = projectDependencyProvider;
     _defaultContext = new DefaultAssemblyLoadContext();
 }
示例#23
0
 public static DocumentContext CreateDocumentContext(IProject project, IProjectContext projectContext, IDocumentLocator documentLocator)
 {
     return(DocumentContextHelper.CreateDocumentContext(project, projectContext, documentLocator, false));
 }
示例#24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectJson"/> class.
 /// </summary>
 public ProjectJson()
 {
     this.context = new ProjectContext();
 }
 private static string GetMetadataFile(IProjectContext projectContext)
 {
     return(Path.Combine(projectContext.Location, "metadata.json"));
 }
示例#26
0
        public override void Execute()
        {
            BaseFrameworkElement selectedElement = this.SelectedElement;

            if (selectedElement == null)
            {
                return;
            }
            IType type1 = this.SceneViewModel.ProjectContext.ResolveType(PlatformTypes.Style);

            CreateResourceModel.ContextFlags contextFlags = this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles) ? CreateResourceModel.ContextFlags.CanApplyAutomatically : CreateResourceModel.ContextFlags.None;
            if (this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles))
            {
                contextFlags = CreateResourceModel.ContextFlags.CanApplyAutomatically;
            }
            CreateResourceModel createResourceModel = new CreateResourceModel(this.SceneViewModel, this.DesignerContext.ResourceManager, type1.RuntimeType, this.DefaultContainerType.RuntimeType, PlatformTypes.Style.Name, (SceneElement)null, (SceneNode)selectedElement, contextFlags);

            if (this.ShowUI)
            {
                bool?nullable = this.CreateDialog(createResourceModel).ShowDialog();
                if ((!nullable.GetValueOrDefault() ? 1 : (!nullable.HasValue ? true : false)) != 0)
                {
                    return;
                }
            }
            using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove())
            {
                using (SceneEditTransaction editTransaction1 = this.SceneViewModel.CreateEditTransaction(this.UndoString, false))
                {
                    using (this.SceneViewModel.ForceBaseValue())
                    {
                        using (this.SceneViewModel.DisableDrawIntoState())
                        {
                            this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)selectedElement);
                            this.SceneViewModel.ElementSelectionSet.Clear();
                            IDocumentContext documentContext = this.SceneViewModel.Document.DocumentContext;
                            IProjectContext  projectContext  = this.SceneViewModel.Document.ProjectContext;
                            Type             type2           = (Type)null;
                            if (createResourceModel.TargetTypeAsset != null && createResourceModel.TargetTypeAsset.EnsureTypeReferenced(this.SceneViewModel.ProjectContext as ProjectContext))
                            {
                                type2 = createResourceModel.TargetTypeAsset.Type.RuntimeType;
                            }
                            if (type2 == (Type)null)
                            {
                                type2 = createResourceModel.TargetType;
                            }
                            IType type3 = projectContext.GetType(type2);
                            DocumentCompositeNode documentCompositeNode1 = (DocumentCompositeNode)selectedElement.DocumentNode;
                            this.SceneViewModel.GetLayoutDesignerForChild((SceneElement)selectedElement, true).ClearUnusedLayoutProperties(selectedElement);
                            DocumentCompositeNode visualTreeNode            = documentContext.CreateNode((ITypeId)documentCompositeNode1.Type);
                            Dictionary <IProperty, DocumentNode> dictionary = new Dictionary <IProperty, DocumentNode>();
                            bool addRenderTransforms = false;
                            foreach (IPropertyId propertyId in this.GetLayoutProperties((SceneElement)selectedElement, addRenderTransforms))
                            {
                                IProperty property = this.DesignerContext.ActiveSceneViewModel.ProjectContext.ResolveProperty(propertyId);
                                if (property != null && documentCompositeNode1.Properties.Contains(property))
                                {
                                    dictionary.Add(property, documentCompositeNode1.Properties[(IPropertyId)property].Clone(documentContext));
                                    documentCompositeNode1.ClearValue((IPropertyId)property);
                                }
                            }
                            foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentCompositeNode1.Properties)
                            {
                                IPropertyId index = (IPropertyId)keyValuePair.Key;
                                DependencyPropertyReferenceStep propertyReferenceStep = index as DependencyPropertyReferenceStep;
                                if ((propertyReferenceStep == null || !propertyReferenceStep.IsAttachable || propertyReferenceStep.MemberType == MemberType.DesignTimeProperty) && (!index.Equals((object)BaseFrameworkElement.WidthProperty) && !index.Equals((object)BaseFrameworkElement.HeightProperty)))
                                {
                                    visualTreeNode.Properties[index] = keyValuePair.Value.Clone(documentContext);
                                }
                            }
                            if (documentCompositeNode1.SupportsChildren)
                            {
                                foreach (DocumentNode documentNode in (IEnumerable <DocumentNode>)documentCompositeNode1.Children)
                                {
                                    visualTreeNode.Children.Add(documentNode.Clone(documentContext));
                                }
                            }
                            if (!PlatformTypes.Panel.IsAssignableFrom((ITypeId)documentCompositeNode1.Type))
                            {
                                GridElement gridElement = (GridElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Grid);
                                SceneNode   sceneNode   = this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode);
                                gridElement.Children.Add(sceneNode);
                                visualTreeNode = (DocumentCompositeNode)gridElement.DocumentNode;
                            }
                            StyleNode styleNode = (StyleNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Style);
                            styleNode.StyleTargetTypeId = type3;
                            SetterSceneNode setterSceneNode = (SetterSceneNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Setter);
                            DependencyPropertyReferenceStep propertyReferenceStep1 = (DependencyPropertyReferenceStep)this.SceneViewModel.ProjectContext.ResolveProperty(ControlElement.TemplateProperty);
                            setterSceneNode.Property = propertyReferenceStep1;
                            BaseFrameworkElement  frameworkElement       = (BaseFrameworkElement)this.SceneViewModel.CreateSceneNode(type2);
                            DocumentCompositeNode documentCompositeNode2 = (DocumentCompositeNode)frameworkElement.DocumentNode;
                            this.AddPresenterIfNecessary(visualTreeNode, (SceneElement)frameworkElement);
                            ControlTemplateElement controlTemplateElement = (ControlTemplateElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.ControlTemplate);
                            controlTemplateElement.ControlTemplateTargetTypeId = (ITypeId)type3;
                            controlTemplateElement.DefaultInsertionPoint.Insert(this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode));
                            if (PlatformTypes.Button.Equals((object)type3) && controlTemplateElement.CanEditTriggers && this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
                            {
                                DocumentCompositeNode node = documentContext.CreateNode(typeof(TriggerCollection));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsFocusedProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsDefaultedProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, BaseFrameworkElement.IsMouseOverProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsPressedProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, BaseFrameworkElement.IsEnabledProperty, (object)false));
                                controlTemplateElement.SetLocalValue(ControlTemplateElement.ControlTemplateTriggersProperty, (DocumentNode)node);
                            }
                            setterSceneNode.SetValueAsSceneNode(SetterSceneNode.ValueProperty, (SceneNode)controlTemplateElement);
                            styleNode.Setters.Add((SceneNode)setterSceneNode);
                            bool useStaticResource = !JoltHelper.TypeSupported((ITypeResolver)this.SceneViewModel.ProjectContext, PlatformTypes.DynamicResource);
                            int  index1            = -1;
                            if (useStaticResource && selectedElement.DocumentContext == createResourceModel.CurrentResourceSite.DocumentContext)
                            {
                                index1 = createResourceModel.IndexInResourceSite(selectedElement.DocumentNode);
                            }
                            IList <DocumentCompositeNode> referencedResources = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindReferencedResources((DocumentNode)documentCompositeNode1);
                            foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in dictionary)
                            {
                                documentCompositeNode2.Properties[(IPropertyId)keyValuePair.Key] = keyValuePair.Value;
                            }
                            IList <SceneNode> nodes = (IList <SceneNode>) new List <SceneNode>();
                            nodes.Add((SceneNode)frameworkElement);
                            SceneNode parent           = selectedElement.Parent;
                            IProperty propertyForChild = parent.GetPropertyForChild((SceneNode)selectedElement);
                            ISceneNodeCollection <SceneNode> collectionForProperty = parent.GetCollectionForProperty((IPropertyId)propertyForChild);
                            int index2 = collectionForProperty.IndexOf((SceneNode)selectedElement);
                            collectionForProperty[index2] = (SceneNode)frameworkElement;
                            if (createResourceModel.SelectedResourceDictionary != null)
                            {
                                ResourceContainer instance = createResourceModel.SelectedResourceDictionary.Instance;
                                if (instance != null && instance.DocumentNode == documentCompositeNode1)
                                {
                                    createResourceModel = new CreateResourceModel(this.SceneViewModel, this.DesignerContext.ResourceManager, type1.RuntimeType, type2, PlatformTypes.Style.Name, (SceneElement)frameworkElement, (SceneNode)null, contextFlags);
                                }
                            }
                            if (createResourceModel.CurrentResourceSite != null && !PlatformTypes.PlatformsCompatible(createResourceModel.CurrentResourceSite.DocumentContext.TypeResolver.PlatformMetadata, styleNode.DocumentNode.PlatformMetadata))
                            {
                                editTransaction1.Cancel();
                                return;
                            }
                            DocumentCompositeNode resource = createResourceModel.CreateResource(styleNode.DocumentNode, StyleNode.TargetTypeProperty, index1);
                            if (resource == null)
                            {
                                editTransaction1.Cancel();
                                return;
                            }
                            DocumentNode            resourceReference = createResourceModel.CreateResourceReference(this.SceneViewModel.Document.DocumentContext, resource, useStaticResource);
                            DefaultTypeInstantiator typeInstantiator  = new DefaultTypeInstantiator(this.SceneView);
                            if (resourceReference != null)
                            {
                                documentCompositeNode2.Properties[BaseFrameworkElement.StyleProperty] = resourceReference;
                            }
                            foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentCompositeNode1.Properties)
                            {
                                IPropertyId index3 = (IPropertyId)keyValuePair.Key;
                                DependencyPropertyReferenceStep propertyReferenceStep2 = index3 as DependencyPropertyReferenceStep;
                                if (propertyReferenceStep2 != null && propertyReferenceStep2.IsAttachable && propertyReferenceStep2.MemberType != MemberType.DesignTimeProperty)
                                {
                                    documentCompositeNode2.Properties[index3] = keyValuePair.Value.Clone(documentContext);
                                }
                            }
                            DocumentCompositeNode hostNode  = createResourceModel.CurrentResourceSite.HostNode;
                            SceneViewModel        viewModel = this.SceneViewModel.GetViewModel(hostNode.DocumentRoot, false);
                            using (SceneEditTransaction editTransaction2 = viewModel.CreateEditTransaction(this.UndoString))
                            {
                                Microsoft.Expression.DesignSurface.Utility.ResourceHelper.CopyResourcesToNewResourceSite(referencedResources, viewModel, hostNode, resource, createResourceModel.IndexInResourceSite((DocumentNode)resource));
                                editTransaction2.Commit();
                            }
                            editTransaction1.Update();
                            if (this.SceneView.IsValid)
                            {
                                typeInstantiator.ApplyAfterInsertionDefaultsToElements(nodes, (SceneNode)null);
                            }
                            this.SceneView.CandidateEditingContainer = frameworkElement.DocumentNodePath;
                            editTransaction1.Update();
                            this.SceneViewModel.ElementSelectionSet.ExtendSelection((SceneElement)frameworkElement);
                            this.PostProcessing((SceneNode)selectedElement, (SceneNode)frameworkElement, resource);
                            if (frameworkElement.GetComputedValue(ControlElement.TemplateProperty) != null)
                            {
                                this.ActivateTemplateEditingMode((SceneElement)frameworkElement);
                            }
                            else
                            {
                                UIThreadDispatcherHelper.BeginInvoke(DispatcherPriority.ApplicationIdle, (Delegate) new Action <SceneElement>(this.ActivateTemplateEditingMode), (object)frameworkElement);
                            }
                            this.SceneView.CandidateEditingContainer = (DocumentNodePath)null;
                        }
                        editTransaction1.Commit();
                    }
                }
            }
        }
 public void OnProjectSaving(IProjectContext projectContext)
 {
 }
 public static IServiceCollection AddProjectTemplating(this IServiceCollection services, IProjectContext context)
 => services.AddProjectTemplating <RazorConfiguration>(context);
 public static WorkspaceManager Create(IProjectContext projectInformation)
 {
     return(new WorkspaceManager(new RoslynWorkspace(projectInformation), projectInformation.ProjectFullPath));
 }
 public static IServiceCollection AddProjectTemplating <TConfig>(this IServiceCollection services, IProjectContext context)
     where TConfig : RazorConfiguration
 {
     services.TryAddSingleton(context);
     services.TryAddSingleton <IApplicationInfo>(_ => new ApplicationInfo(context.AssemblyName, context.AssemblyFullPath, context.Configuration));
     services.TryAddSingleton(RazorProjectFileSystem.Create(context.ProjectFullPath));
     services.TryAddSingleton <RoslynCompilationService>();
     return(services.AddRazorTemlpate <TConfig, RazorProjectFileSystem, RoslynCompilationService>(TemplatingHelper.Register));
 }
示例#31
0
 private void ViewService_ActiveViewChanged(object sender, ViewChangedEventArgs e)
 {
     this.ActiveProjectContext = this.designerContext.ActiveProjectContext;
 }
        public IdentityGenerator(IApplicationInfo applicationInfo,
                                 IServiceProvider serviceProvider,
                                 ICodeGeneratorActionsService actionService,
                                 IProjectContext projectContext,
                                 IConnectionStringsWriter connectionStringsWriter,
                                 Workspace workspace,
                                 ICodeGenAssemblyLoadContext loader,
                                 IFileSystem fileSystem,
                                 ILogger logger)
        {
            if (applicationInfo == null)
            {
                throw new ArgumentNullException(nameof(applicationInfo));
            }

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            if (actionService == null)
            {
                throw new ArgumentNullException(nameof(actionService));
            }

            if (projectContext == null)
            {
                throw new ArgumentNullException(nameof(projectContext));
            }

            if (connectionStringsWriter == null)
            {
                throw new ArgumentNullException(nameof(connectionStringsWriter));
            }

            if (workspace == null)
            {
                throw new ArgumentNullException(nameof(workspace));
            }

            if (loader == null)
            {
                throw new ArgumentNullException(nameof(loader));
            }

            if (fileSystem == null)
            {
                throw new ArgumentNullException(nameof(fileSystem));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            _applicationInfo            = applicationInfo;
            _serviceProvider            = serviceProvider;
            _codegeneratorActionService = actionService;
            _projectContext             = projectContext;
            _connectionStringsWriter    = connectionStringsWriter;
            _workspace  = workspace;
            _loader     = loader;
            _fileSystem = fileSystem;
            _logger     = logger;
        }
示例#33
0
 public ProjectController(ISession session, IProjectContext projectContext, IExtractorHelper extractor)
 {
     DbSession = session;
     ProjectContext = projectContext;
     ExtractorHelper = extractor;
 }
示例#34
0
        private ContextMenu BuildResourceContextMenu(ReadOnlyCollection <ResourceEntryBase> selection)
        {
            ContextMenu contextMenu = new ContextMenu();

            if (selection.Count == 1)
            {
                ResourceEntryBase resourceEntryBase = selection[0];
                ResourceEntryItem resourceEntryItem = resourceEntryBase as ResourceEntryItem;
                if (resourceEntryItem != null)
                {
                    TypedResourceItem typedResourceItem = resourceEntryItem as TypedResourceItem;
                    if (typedResourceItem != null)
                    {
                        contextMenu.Items.Add((object)this.CreateItem(StringTable.ResourceItemEdit, "ResourceEntryItem_Edit", typedResourceItem.EditCommand));
                    }
                }
                ResourceDictionaryItem resourceDictionaryItem = resourceEntryBase as ResourceDictionaryItem;
                if (resourceDictionaryItem != null)
                {
                    contextMenu.Items.Add((object)this.CreateItem(StringTable.ResourceItemEdit, "ResourceDictionaryItem_Edit", resourceDictionaryItem.EditCommand));
                }
                ResourceContainer targetContainer = resourceEntryBase as ResourceContainer;
                if (resourceEntryBase == this.activeDocumentWrapper)
                {
                    targetContainer = this.resourceManager.ActiveRootContainer;
                }
                if (targetContainer != null && targetContainer.DocumentContext != null && resourceEntryBase.DocumentNode != null && (targetContainer is DocumentResourceContainer || targetContainer is NodeResourceContainer))
                {
                    IProject project = ProjectHelper.GetProject(this.DesignerContext.ProjectManager, targetContainer.DocumentContext);
                    if (project != null)
                    {
                        if (project.FindItem(targetContainer.DocumentReference).ContainsDesignTimeResources)
                        {
                            MenuItem menuItem = this.CreateItem(StringTable.DesignTimeResourcesAddDictionary, "ResourceContainer_LinkToDesignTimeResources", (ICommand) new ResourcePane.LinkToDesignTimeResourceCommand(this.DesignerContext, targetContainer));
                            contextMenu.Items.Add((object)menuItem);
                        }
                        else
                        {
                            IProjectContext projectContext = (IProjectContext)ProjectXamlContext.GetProjectContext(project);
                            if (projectContext != null)
                            {
                                MenuItem menuItem1 = this.CreateItem(StringTable.UndoUnitLinkToResourceDictionary, "ResourceContainer_LinkToResources", (ICommand)null);
                                foreach (DocumentResourceContainer resourceContainer in (Collection <DocumentResourceContainer>) this.resourceManager.DocumentResourceContainers)
                                {
                                    if (resourceContainer.DocumentReference != targetContainer.DocumentReference && resourceContainer.Document != null && (resourceContainer.Document.DocumentRoot != null && resourceContainer.Document.DocumentRoot.RootNode != null) && (resourceContainer.ProjectContext != null && !resourceContainer.ProjectItem.ContainsDesignTimeResources && PlatformTypes.ResourceDictionary.IsAssignableFrom((ITypeId)resourceContainer.Document.DocumentRoot.RootNode.Type)) && (resourceContainer.ProjectContext == projectContext || ProjectHelper.DoesProjectReferencesContainTarget(project, resourceContainer.ProjectContext)))
                                    {
                                        ResourcePane.LinkToResourcesCommand resourcesCommand = new ResourcePane.LinkToResourcesCommand(this.resourceManager, targetContainer, resourceContainer.ProjectItem);
                                        MenuItem menuItem2 = this.CreateItem(resourceContainer.Name, resourceContainer.Name, (ICommand)resourcesCommand);
                                        menuItem2.IsCheckable = true;
                                        menuItem2.SetBinding(MenuItem.IsCheckedProperty, (BindingBase) new Binding("IsChecked")
                                        {
                                            Source = (object)resourcesCommand,
                                            Mode   = BindingMode.OneTime
                                        });
                                        menuItem1.Items.Add((object)menuItem2);
                                    }
                                }
                                if (menuItem1.Items.Count == 0)
                                {
                                    MenuItem menuItem2 = this.CreateItem(StringTable.ResourcePaneNoDictionaries, (string)null, (ICommand)null);
                                    menuItem2.IsEnabled = false;
                                    menuItem1.Items.Add((object)menuItem2);
                                }
                                contextMenu.Items.Add((object)menuItem1);
                            }
                        }
                    }
                }
                if (contextMenu.Items.Count > 0)
                {
                    contextMenu.Items.Add((object)new Separator());
                }
            }
            contextMenu.Items.Add((object)this.CreateItem(StringTable.ResourceItemCut, "ResourcePane_Cut", this.CutCommand));
            contextMenu.Items.Add((object)this.CreateItem(StringTable.ResourceItemCopy, "ResourcePane_Copy", this.CopyCommand));
            contextMenu.Items.Add((object)this.CreateItem(StringTable.ResourceItemPaste, "ResourcePane_Paste", this.PasteCommand));
            contextMenu.Items.Add((object)this.CreateItem(StringTable.ResourceItemDelete, "ResourcePane_Delete", this.DeleteCommand));
            contextMenu.Items.Add((object)new Separator());
            contextMenu.Items.Add((object)this.CreateItem(StringTable.ViewXamlCommandName, "ResourcePane_ViewXaml", this.ViewXamlCommand));
            return(contextMenu);
        }
示例#35
0
 public static GridLength RoundGridLength(IProjectContext projectContext, GridLength gridLength)
 {
     return(new GridLength(JoltHelper.RoundDouble(projectContext, gridLength.Value), gridLength.GridUnitType));
 }
 public DataProviderLocator(IProjectContext projectContext, ICodeGenerationAssemblyProvider codeGenerationAssemblyProvider, IServiceProvider serviceProvider)
 {
     _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
     _projectContext  = projectContext ?? throw new ArgumentNullException(nameof(projectContext));
     _codeGenerationAssemblyProvider = codeGenerationAssemblyProvider ?? throw new ArgumentNullException(nameof(codeGenerationAssemblyProvider));
 }
示例#37
0
 public NamespaceController(ISession dbSession, IProjectContext projectContext)
 {
     DbSession = dbSession;
     ProjectContext = projectContext;
 }
 protected virtual string GetXmlFilePath( IProjectContext project )
 {
     return Path.Combine(project.ProjectDirectory, project.Name + ".xml");
 }