public override bool Execute() { Log.LogMessage($"Retargeting UWP assets to {TargetPlatform}."); Func <ResourceCandidate, string> resourceToTargetPath; Func <string, string> pathEncoder; switch (TargetPlatform) { case "ios": resourceToTargetPath = resource => iOSResourceConverter.Convert(resource, DefaultLanguage); pathEncoder = p => p; break; case "android": resourceToTargetPath = resource => AndroidResourceConverter.Convert(resource, DefaultLanguage); pathEncoder = AndroidResourceNameEncoder.EncodeFileSystemPath; break; default: Log.LogMessage($"Skipping unknown platform {TargetPlatform}"); return(true); } Assets = ContentItems.ToArray(); RetargetedAssets = Assets .Select((Func <ITaskItem, TaskItem>)(asset => ProcessContentItem(asset, resourceToTargetPath, pathEncoder))) .Where(a => a != null) .ToArray(); return(true); }
/// <summary> /// Add a content item to the collection /// </summary> /// <param name="key"></param> /// <param name="type"></param> /// <param name="path"></param> public void Add <T>(string key, string path) { if (Loaded) { throw new InvalidOperationException("Cannot add content while the ContentCollection is loaded"); } if (key is null) { throw new ArgumentNullException(nameof(key)); } if (key.Length == 0) { throw new ArgumentException("key.Length must be > 0", nameof(key)); } if (path is null) { throw new ArgumentNullException(nameof(path)); } if (path.Length == 0) { throw new ArgumentException("path.Length must be > 0", nameof(path)); } if (!(ContentItems.FirstOrDefault(e => e.Key == key).Key is null)) { throw new ArgumentException("Content with given key already exists", nameof(key)); } ContentItems.Add(new ContentItem { Key = key, Type = typeof(T), Path = path }); }
public virtual void Patch(DynamicContentPublishingGroupEntity target) { if (target == null) { throw new NullReferenceException(nameof(target)); } target.Description = Description; target.Name = Name; target.Priority = Priority; target.IsActive = IsActive; target.StoreId = StoreId; target.StartDate = StartDate; target.EndDate = EndDate; target.ConditionExpression = ConditionExpression; target.PredicateVisualTreeSerialized = PredicateVisualTreeSerialized; if (!ContentItems.IsNullCollection()) { var itemComparer = AnonymousComparer.Create((PublishingGroupContentItemEntity x) => x.DynamicContentItemId); ContentItems.Patch(target.ContentItems, itemComparer, (sourceProperty, targetProperty) => { }); } if (!ContentPlaces.IsNullCollection()) { var itemComparer = AnonymousComparer.Create((PublishingGroupContentPlaceEntity x) => x.DynamicContentPlaceId); ContentPlaces.Patch(target.ContentPlaces, itemComparer, (sourceProperty, targetProperty) => { }); } }
public void AddPropertyFields(string headerText = null) { if (DataObject == null) return; ContentItems.Clear(); var ps = DataObject.GetPropertiesWithAttribute<InspectorProperty>().ToArray(); if (ps.Length < 1) return; if (!string.IsNullOrEmpty(headerText)) ContentItems.Add(new SectionHeaderViewModel() { Name = headerText, }); var data = DataObject; foreach (var property in ps) { PropertyInfo property1 = property.Key; var vm = new PropertyFieldViewModel() { Type = property.Key.PropertyType, Name = property.Key.Name, InspectorType = property.Value.InspectorType, CustomDrawerType = property.Value.CustomDrawerType, Getter = () => property1.GetValue(data, null), DataObject = data, Setter = (d,v) => { property1.SetValue(d, v, null); } }; ContentItems.Add(vm); } IsDirty = true; }
public void AddContentItem(ContentItem item) { if (item.ItemConstruct.ItemCode == ConstructConfig.NEW_FILE_DEFAULT_ID_CODE) { _IDItem = item; Name = _IDItem.Value; } else if (item.ItemConstruct.ItemCode == ConstructConfig.NEW_FILE_DEFAULT_NAME_CODE) { _NameItem = item; //默认的 id的初始化在name之前 if (_IDItem != null) { if (ContentConfig.IsContentIDInvalid(_IDItem.Value)) { Name = _IDItem.Value + "." + _NameItem.Value; } else { Name = _IDItem.Value; } } } else if (item.ItemConstruct.ItemCode == ConstructConfig.NEW_FILE_DEFAULT_DESC_CODE) { _DescItem = item; } ContentItems.AddNewItem(item); }
public override bool Execute() { LogExtensionPoint.AmbientLoggerFactory.AddProvider(new TaskLoggerProvider(Log)); this.Log().Info($"Retargeting UWP assets to {TargetPlatform}."); Func <ResourceCandidate, string> resourceToTargetPath; Func <string, string> pathEncoder; switch (TargetPlatform) { case "ios": resourceToTargetPath = resource => iOSResourceConverter.Convert(resource, DefaultLanguage); pathEncoder = p => p; break; case "android": resourceToTargetPath = resource => AndroidResourceConverter.Convert(resource, DefaultLanguage); pathEncoder = AndroidResourceNameEncoder.EncodeFileSystemPath; break; default: this.Log().Info($"Skipping unknown platform {TargetPlatform}"); return(true); } Assets = ContentItems.ToArray(); RetargetedAssets = Assets .Select((Func <ITaskItem, TaskItem>)(asset => ProcessContentItem(asset, resourceToTargetPath, pathEncoder))) .Trim() .ToArray(); return(true); }
public override string ToString() { string ans = Environment.NewLine + "Relationship Type: " + RelationShipType + Environment.NewLine + "Value Type: " + ValueType + Environment.NewLine + "Concept --> " + ConceptNameCodeSequence.ToString(); if (ConceptCodeSequence != null) { ans = ans + ConceptCodeSequence.ToString(); } if (ValueType == Value.TEXT) { ans = ans + Environment.NewLine + "Value: " + TextValue; } if (DateTimeValue.HasValue) { ans = ans + Environment.NewLine + "Value: " + DateTimeValue.Value.ToString(); } if (ValueType == Value.NUM) { ans = ans + Environment.NewLine + MeasuredValueSequence.ToString(); } if (ContentItems.Any()) { foreach (var c in ContentItems) { ans = ans + Environment.NewLine + "Content Item-->" + c.ToString(); } } return(ans); }
public virtual DynamicContentPublication ToModel(DynamicContentPublication publication) { if (publication == null) { throw new NullReferenceException(nameof(publication)); } publication.Id = Id; publication.CreatedBy = CreatedBy; publication.CreatedDate = CreatedDate; publication.Description = Description; publication.ModifiedBy = ModifiedBy; publication.ModifiedDate = ModifiedDate; publication.Name = Name; publication.Priority = Priority; publication.IsActive = IsActive; publication.StoreId = StoreId; publication.StartDate = StartDate; publication.EndDate = EndDate; publication.PredicateSerialized = ConditionExpression; publication.PredicateVisualTreeSerialized = PredicateVisualTreeSerialized; if (ContentItems != null) { //TODO publication.ContentItems = ContentItems.Where(ci => ci.ContentItem != null).Select(x => x.ContentItem.ToModel(AbstractTypeFactory <DynamicContentItem> .TryCreateInstance())).ToList(); } if (ContentPlaces != null) { //TODO publication.ContentPlaces = ContentPlaces.Where(ci => ci.ContentPlace != null).Select(x => x.ContentPlace.ToModel(AbstractTypeFactory <DynamicContentPlace> .TryCreateInstance())).ToList(); } return(publication); }
public Task <bool> DeleteContentItem(string path) { var existingItem = ContentItems.FirstOrDefault(p => p.Path == path); if (existingItem != null) { Remove(existingItem); } var steps = path.Split('/'); if (steps.Length > 2) { var themePath = string.Join("/", steps[0], steps[1]); var theme = Themes.FirstOrDefault(t => t.Id == themePath); if (theme != null) { theme.ModifiedDate = DateTime.UtcNow; Update(theme); } } UnitOfWork.Commit(); return(Task.FromResult(true)); }
private async Task ExecuteLoadDocumentsCommand() { if (IsBusy) { return; } IsBusy = true; try { ContentItems.Clear(); var contentItems = await DataStore.GetContentItemsAsync(true); ContentItems.ReplaceRange(contentItems); } catch (Exception ex) { Debug.WriteLine(ex); MessagingCenter.Send(new MessagingCenterAlert { Title = "Error", Message = "Unable to load content items.", Cancel = "OK" }, "message"); } finally { IsBusy = false; } }
private void AddOutput(NodeInputConfig inputConfig, GenericNode node = null) { if (!IsVisible(inputConfig.Visibility)) { return; } var nodeToUse = node ?? GraphItem; var header = new InputOutputViewModel(); header.Name = inputConfig.Name.GetValue(node); header.DataObject = inputConfig.IsAlias ? DataObject : inputConfig.GetDataObject(nodeToUse); header.OutputConnectorType = inputConfig.SourceType; header.IsInput = false; header.IsOutput = true; if (inputConfig.AttributeInfo != null) { header.IsNewLine = inputConfig.AttributeInfo.IsNewRow; } else { header.IsNewLine = true; } ContentItems.Add(header); ApplyOutputConfiguration(inputConfig, header.DataObject as IGraphItem, header.OutputConnector, true); if (header.InputConnector != null) { header.OutputConnector.Configuration = inputConfig; } }
public void GetCurrentDocuments_IgnoresDotRazorFiles() { // Arrange ContentItems.Item("Index.razor", new Dictionary <string, string>() { [ItemReference.LinkPropertyName] = "NewIndex.razor", [ItemReference.FullPathPropertyName] = "C:\\From\\Index.razor", }); NoneItems.Item("About.razor", new Dictionary <string, string>() { [ItemReference.LinkPropertyName] = "NewAbout.razor", [ItemReference.FullPathPropertyName] = "C:\\From\\About.razor", }); var services = new TestProjectSystemServices("C:\\To\\Test.csproj"); var host = new TestFallbackRazorProjectHost(services, Workspace, ProjectManager); var changes = new TestProjectChangeDescription[] { ContentItems.ToChange(), NoneItems.ToChange(), }; var update = services.CreateUpdate(changes).Value; // Act var result = host.GetCurrentDocuments(update); // Assert Assert.Empty(result); }
public async Task OnProjectChanged_UpdateProject_Succeeds() { // Arrange ReferenceItems.Item("c:\\nuget\\Microsoft.AspNetCore.Mvc.razor.dll"); var afterChangeContentItems = new ItemCollection(ManagedProjectSystemSchema.ContentItem.SchemaName); ContentItems.Item("Index.cshtml", new Dictionary <string, string>() { [ItemReference.FullPathPropertyName] = "C:\\Path\\Index.cshtml", }); var initialChanges = new TestProjectChangeDescription[] { ReferenceItems.ToChange(), ContentItems.ToChange(), }; var changes = new TestProjectChangeDescription[] { ReferenceItems.ToChange(), afterChangeContentItems.ToChange(ContentItems.ToSnapshot()), }; var services = new TestProjectSystemServices("C:\\Path\\Test.csproj"); var host = new TestFallbackRazorProjectHost(services, Workspace, ProjectManager) { AssemblyVersion = new Version(2, 0), }; await Task.Run(async() => await host.LoadAsync()); Assert.Empty(ProjectManager.Projects); // Act - 1 await Task.Run(async() => await host.OnProjectChanged(services.CreateUpdate(initialChanges))); // Assert - 1 var snapshot = Assert.Single(ProjectManager.Projects); Assert.Equal("C:\\Path\\Test.csproj", snapshot.FilePath); Assert.Same(FallbackRazorConfiguration.MVC_2_0, snapshot.Configuration); var filePath = Assert.Single(snapshot.DocumentFilePaths); Assert.Equal("C:\\Path\\Index.cshtml", filePath); // Act - 2 host.AssemblyVersion = new Version(1, 0); await Task.Run(async() => await host.OnProjectChanged(services.CreateUpdate(changes))); // Assert - 2 snapshot = Assert.Single(ProjectManager.Projects); Assert.Equal("C:\\Path\\Test.csproj", snapshot.FilePath); Assert.Same(FallbackRazorConfiguration.MVC_1_0, snapshot.Configuration); Assert.Empty(snapshot.DocumentFilePaths); await Task.Run(async() => await host.DisposeAsync()); Assert.Empty(ProjectManager.Projects); }
/// <summary> /// Remove all content from the collection /// </summary> public void Clear() { if (Loaded) { throw new InvalidOperationException("Cannot clear content while the ContentCollection is loaded"); } ContentItems.Clear(); }
/// <summary> /// Clear the collection /// </summary> public void Clear() { if (ContentItems != null && FilteredItems != null) { ContentItems.Clear(); FilteredItems.Clear(); } }
internal void AddContentItem(Item item, float assignedQuantity) { ContentItem contentItem = new ContentItem(); contentItem.OriginalItem = item; contentItem.Quantity = assignedQuantity; ContentItems.Add(contentItem); item.Quantity -= assignedQuantity; }
/*========================================================================================================================== | GET TECHNICAL PAPERS \-------------------------------------------------------------------------------------------------------------------------*/ /// <summary> /// Provides a helper function for retrieving a list of <see cref="TechnicalPaperTopicViewModel"/>s based on a category /// key. /// </summary> public TopicViewModelCollection<TechnicalPaperTopicViewModel> GetTechnicalPapers(string category) => new TopicViewModelCollection<TechnicalPaperTopicViewModel>( ContentItems .Where(t => (t.Category ?? "") .Equals(category)) .Cast<TechnicalPaperTopicViewModel>() .OrderByDescending(p => p.PublicationDate) .AsEnumerable() );
public override bool Execute() { LogExtensionPoint.AmbientLoggerFactory.AddProvider(new TaskLoggerProvider(Log)); this.Log().Info($"Retargeting UWP assets to {TargetPlatform}."); Func<ResourceCandidate, string> resourceToTargetPath; switch (TargetPlatform) { case "ios": resourceToTargetPath = resource => iOSResourceConverter.Convert(resource, DefaultLanguage); break; case "android": resourceToTargetPath = resource => AndroidResourceConverter.Convert(resource, DefaultLanguage); break; default: this.Log().Info($"Skipping unknown platform {TargetPlatform}"); return true; } Assets = ContentItems.Where(content => IsAsset(content.ItemSpec)).ToArray(); RetargetedAssets = Assets .Select(asset => { if (!asset.MetadataNames.Contains("Link")) { this.Log().Info($"Skipping '{asset.ItemSpec}' because 'Link' metadata is not set."); return null; } var fullPath = asset.GetMetadata("FullPath"); var relativePath = asset.GetMetadata("Link"); var resourceCandidate = ResourceCandidate.Parse(fullPath, relativePath); if (!UseHighDPIResources && int.TryParse(resourceCandidate.GetQualifierValue("scale"), out var scale) && scale > HighDPIThresholdScale) { this.Log().Info($"Skipping '{asset.ItemSpec}' of scale {scale} because {nameof(UseHighDPIResources)} is false."); return null; } var targetPath = resourceToTargetPath(resourceCandidate); if (targetPath == null) { this.Log().Info($"Skipping '{asset.ItemSpec}' as it's not supported on {TargetPlatform}."); return null; } this.Log().Info($"Retargeting '{asset.ItemSpec}' to '{targetPath}'."); return new TaskItem(asset.ItemSpec, new Dictionary<string, string>() { { "LogicalName", targetPath } }); }) .Trim() .ToArray(); return true; }
private static void AddYmlItems(this Db db, List <DbItem> items, List <DbTemplate> templates, bool merge = false) { if (items != null && items.Count > 0) { db.AddRange(LayoutItems.Get(items), merge); db.AddRange(SystemItems.Get(items), merge); db.AddRange(MediaItems.Get(items), merge); db.AddRange(ContentItems.Get(items, templates), merge); } }
public Task <IEnumerable <ContentItem> > GetContentItems(string path, GetThemeAssetsCriteria criteria) { var query = ContentItems.Where(i => i.Path.StartsWith(path)); if (criteria != null && criteria.LastUpdateDate.HasValue) { query = query.Where(i => (i.ModifiedDate.HasValue && criteria.LastUpdateDate.Value < i.ModifiedDate.Value) || (criteria.LastUpdateDate.Value < i.CreatedDate)); } return(Task.FromResult(query.AsEnumerable())); }
protected override void CreateContent() { base.CreateContent(); if (Action.Meta == null) { ContentItems.Add(new SectionHeaderViewModel() { Name = "Please Save And Compile", IsNewLine = true }); } }
public void Load() { ContentItems.ClearAndLoad(_sessionRepository.LoadContentItems().OrderBy(x => x.Name)); ContentItemsByTypeGroups.Clear(); foreach (var type in ContentItems.GroupBy(x => x.ContentType.Content).OrderBy(x => x.Key)) { var contentItemsByTypeGroup = new ContentItemsByTypeGroup(type.Key, type.OrderBy(x => x.Name)); ContentItemsByTypeGroups.Add(contentItemsByTypeGroup); } }
/// <inheritdoc /> public override void Remove(IEnumerable <string> contentItemIds) { foreach (var item in GetMultipleById(contentItemIds)) { if (item != null) { ContentItems.Remove(item); _cache.RemoveItem(item); } } _dataContext.SaveChanges(); }
public async Task OnProjectChanged_ReadsProperties_InitializesProject() { // Arrange ReferenceItems.Item("c:\\nuget\\Microsoft.AspNetCore.Mvc.razor.dll"); ContentItems.Item("Index.cshtml", new Dictionary <string, string>() { [ItemReference.FullPathPropertyName] = "C:\\Path\\Index.cshtml", }); NoneItems.Item("About.cshtml", new Dictionary <string, string>() { [ItemReference.FullPathPropertyName] = "C:\\Path\\About.cshtml", }); var changes = new TestProjectChangeDescription[] { ReferenceItems.ToChange(), ContentItems.ToChange(), NoneItems.ToChange(), }; var services = new TestProjectSystemServices("C:\\Path\\Test.csproj"); var host = new TestFallbackRazorProjectHost(services, Workspace, ProjectManager) { AssemblyVersion = new Version(2, 0), // Mock for reading the assembly's version }; await Task.Run(async() => await host.LoadAsync()); Assert.Empty(ProjectManager.Projects); // Act await Task.Run(async() => await host.OnProjectChanged(services.CreateUpdate(changes))); // Assert var snapshot = Assert.Single(ProjectManager.Projects); Assert.Equal("C:\\Path\\Test.csproj", snapshot.FilePath); Assert.Same(FallbackRazorConfiguration.MVC_2_0, snapshot.Configuration); Assert.Collection( snapshot.DocumentFilePaths, filePath => Assert.Equal("C:\\Path\\Index.cshtml", filePath), filePath => Assert.Equal("C:\\Path\\About.cshtml", filePath)); await Task.Run(async() => await host.DisposeAsync()); Assert.Empty(ProjectManager.Projects); }
// Deletes every content item and reference from exhibit with given guid. public void DeleteExhibit(Guid id) { var exhibitsIDs = GetChildContentItemsIds(id); // list of ids of content items // delete content items while (exhibitsIDs.Count != 0) { var e = ContentItems.Find(exhibitsIDs.First()); ContentItems.Remove(e); exhibitsIDs.RemoveAt(0); } Exhibit deleteExhibit = Exhibits.Find(id); Exhibits.Remove(deleteExhibit); }
public void DeleteTheme(string path) { var existingTheme = Themes.FirstOrDefault(t => t.Id == path); if (existingTheme != null) { Remove(existingTheme); var contentItems = ContentItems.Where(c => c.Path.StartsWith(path)); foreach (var item in contentItems) { Remove(item); } UnitOfWork.Commit(); } }
private void CreateOutput(ShellNodeConfigOutput output, object dataObject) { var vm = new InputOutputViewModel() { IsInput = false, IsOutput = true, DiagramViewModel = this.DiagramViewModel, Name = output.Name, DataObject = dataObject, Column = output.Column, ColumnSpan = output.ColumnSpan, IsNewLine = output.IsNewRow }; ContentItems.Add(vm); }
private void CreateHeader(ShellNodeConfigSection item, object dataObject) { var sectionViewModel = new GenericItemHeaderViewModel() { Name = item.Name, AddCommand = item.AllowAdding ? new LambdaCommand("", () => {}) : null, DataObject = dataObject, NodeViewModel = this, AllowConnections = true, Column = item.Column, ColumnSpan = item.ColumnSpan, IsNewLine = item.IsNewRow }; ContentItems.Add(sectionViewModel); }
private void OnScan(Session obj) { if (!obj.Encounters.Any()) { ScannedContentItems.Clear(); return; } var trie = new Trie(ContentItems.Select(x => x.Name).ToArray()); var sessionTrieIterator = new SessionTrieIterator(obj, ContentItems); trie.Iterate(sessionTrieIterator); ScannedContentItems.ClearAndLoad(sessionTrieIterator); }
protected override void CreateContent() { base.CreateContent(); if (IsVisible(SectionVisibility.WhenNodeIsNotFilter)) { var propertySelection = new InputOutputViewModel() { DataObject = PropertyChangedNode.CollectionIn, Name = "Collection", IsInput = true, IsOutput = false, IsNewLine = true, AllowSelection = true }; ContentItems.Add(propertySelection); AddPropertyFields(); } }