public void Constructs_ok([Column(0, 123)] int index) { var comment = new NodeContent(index, 123, " Jack Burton "); Assert.AreEqual(index, comment.Index); Assert.IsEmpty(comment.Children); Assert.AreEqual(" Jack Burton ", comment.Text); }
public void Search_ShouldReturnPopulatedFacetGroupOption() { var content = new NodeContent(); var filterOptions = new FilterOptionViewModel { FacetGroups = new List<FacetGroupOption>() }; var result = _subject.Search(content, filterOptions); var facetGroupOption = result.FacetGroups.First(); var expected = new FacetGroupOption { GroupName = "FacetGroupName", GroupFieldName = "FacetGroupFieldName", Facets = new List<FacetOption> { new FacetOption { Name = _facet.Name, Key = _facet.Key, Selected = _facet.IsSelected, Count = _facet.Count } } }; facetGroupOption.ShouldBeEquivalentTo(expected); }
public void Diff_equal_with_different_index() { var actual = new NodeContent(123, 123, "Text"); var expected = new NodeContent(456, 123, "Text"); var diff = actual.Diff(expected, XmlPathRoot.Strict.Empty, XmlPathRoot.Strict.Empty, XmlOptions.Strict.Value); Assert.IsTrue(diff.IsEmpty); }
public ContentReference Update(NodeContent nodeContent, Node node, SaveAction saveAction) { if (string.IsNullOrEmpty(node.urlSegment) == false) { nodeContent.RouteSegment = node.urlSegment; } else { nodeContent.RouteSegment = node.code.ToLowerInvariant(); } //Set the Name nodeContent.Name = node.name; nodeContent.DisplayName = node.name; // Override with language var displayName = GetPropertyValue(node, RootCatalog.DefaultLanguage, "DisplayName"); if (string.IsNullOrEmpty(displayName) == false) { nodeContent.DisplayName = displayName; } //Publish the new content and return its ContentReference. return _contentRepository.Save(nodeContent, saveAction, AccessLevel.NoAccess); }
public void Search_WhenFilterOptionsIsNull_ShouldReturnEmptyResult() { var content = new NodeContent(); var result = _subject.Search(content, null); result.ProductViewModels.Should().BeEmpty(); result.FacetGroups.Should().BeEmpty(); result.SearchResult.FacetGroups.Should().BeEmpty(); }
public void Search_ShouldReturnSameSearchResult() { var content = new NodeContent(); var filterOptions = new FilterOptionViewModel { FacetGroups = new List<FacetGroupOption>() }; var result = _subject.Search(content, filterOptions); result.SearchResult.ShouldBeEquivalentTo(_searchResultsMock.Object); }
protected string GetDisplayName(NodeContent content) { if (content == null) { return string.Empty; } return WebStringHelper.EncodeForWebString(content.DisplayName ?? content.Name); }
public void Index_WhenCallingViewModelFactory_ShouldPassAlongNodeContent() { // Arrange var nodeContent = new NodeContent(); // Act var result = (PartialViewResult)_subject.Index(nodeContent); // Assert _viewModelFactoryMock.Verify(v => v.Create(nodeContent, It.IsAny<FilterOptionFormModel>())); }
protected string GetDisplayName(NodeContent content, bool toUpper) { if (content == null) { return string.Empty; } var displayName = content.DisplayName ?? content.Name; if (!toUpper) { return WebStringHelper.EncodeForWebString(displayName); } return WebStringHelper.EncodeForWebString(displayName.ToUpper()); }
/// <summary> /// The function to process a model from original content into model content for export /// </summary> /// <param name="input"></param> /// <param name="context"></param> /// <returns></returns> public override ModelContent Process(NodeContent input, ContentProcessorContext context) { // Process the skeleton for skinned character animation BoneContent skeleton = ProcessSkeleton(input); SwapSkinnedMaterial(input); model = base.Process(input, context); ProcessAnimations(model, input, context); // Add the extra content to the model model.Tag = modelExtra; return(model); }
static void AddAnimationNodes(List <string> animationNames, NodeContent node) { foreach (NodeContent childNode in node.Children) { // If this node doesn't have keyframes for this animation we should just skip it foreach (string key in childNode.Animations.Keys) { if (!animationNames.Contains(key)) { animationNames.Add(key); } } AddAnimationNodes(animationNames, childNode); } }
/// <summary> /// Recursively adds calculated tangent frames to all meshes. /// </summary> void CalculateTangentFrames(NodeContent input, ContentProcessorContext context) { MeshContent inputMesh = input as MeshContent; if (inputMesh != null) { MeshHelper.CalculateTangentFrames(inputMesh, VertexChannelNames.TextureCoordinate(0), VertexChannelNames.Tangent(0), null); } foreach (NodeContent childNode in input.Children) { CalculateTangentFrames(childNode, context); } }
/// <summary> /// Process the model /// </summary> /// <param name="input">Input data</param> /// <param name="context">Context for logging</param> /// <returns>Model content</returns> public override ModelContent Process( NodeContent input, ContentProcessorContext context) { // First generate tangent data because x files don't store them GenerateTangents(input, context); // Use the name of the bone for our mesh name if it is not set UseParentBoneNameIfMeshNameIsNotSet(input); // Store the current selected technique and if the texture uses alpha // into the mesh name for each mesh part. StoreEffectTechniqueInMeshName(input, context); // And let the rest be processed by the default model processor return(base.Process(input, context)); }
protected override NodeContent GetContent(NodeBase node, NodeContentParameters contentParameters) { var callPath = $"{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}"; try { if (!node.Exists()) { return(NodeContent.CreateDelayedWriteContent(new MemoryStream())); } using (var scope = _factory.CreateScope()) { if (node.NodeType == NodeType.File) { var conf = scope.ServiceProvider.GetRequiredService <IConfiguration>(); var uow = scope.ServiceProvider.GetRequiredService <IUnitOfWork>(); var folderEntity = CompositeFileSystemHelper.FolderPathToEntity(uow, _userEntity, node.Parent.Path.StringPath); var fileEntity = uow.UserFiles.Get(QueryExpressionFactory.GetQueryExpression <tbl_UserFile>() .Where(x => x.IdentityId == _userEntity.IdentityId && x.FolderId == folderEntity.Id && x.VirtualName == node.Name).ToLambda()) .Single(); var file = new FileInfo(conf["Storage:UnstructuredDataPath"] + Path.DirectorySeparatorChar + fileEntity.RealPath + Path.DirectorySeparatorChar + fileEntity.RealFileName); fileEntity.LastAccessed = DateTime.UtcNow; uow.UserFiles.Update(fileEntity); uow.Commit(); return(NodeContent.CreateDelayedWriteContent(File.Open(file.FullName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))); } else { throw new NotImplementedException(); } } } catch (Exception ex) { Log.Error(ex.ToString()); throw; } }
protected override NodeBase SaveContent(NodeBase node, NodeContent content) { var callPath = $"{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}"; DirectoryInfo folder = null; FileInfo file = null; try { if (!node.Exists()) { return(node); } if (node.NodeType == NodeType.File) { WindowsIdentity.RunImpersonated(_userToken, () => { folder = SmbFileSystemHelper.FolderPathToCIFS(_userMount + node.Parent.Path.StringPath); if (!folder.Exists) { folder.Create(); } file = SmbFileSystemHelper.FilePathToCIFS(_userMount + node.Path.StringPath); using (var fs = new FileStream(file.FullName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) content.GetStream().CopyTo(fs); Log.Information($"'{callPath}' '{_userEntity.IdentityAlias}' file '{node.Path}' to '{file.FullName}'" + $" run as '{WindowsIdentity.GetCurrent().Name}'"); }); } else { throw new NotImplementedException(); } return(node); } catch (Exception ex) { Log.Error(ex.ToString()); throw; } }
/// <summary> /// The main Process method converts an intermediate format content pipeline /// NodeContent tree to a ModelContent object with embedded animation data. /// </summary> /// <param name="input">NodeContent input</param> /// <param name="context">ContentProcessorContext input</param> /// <returns>Model Content</returns> public override ModelContent Process(NodeContent input, ContentProcessorContext context) { ValidateMesh(input, context, null); // Find the skeleton. BoneContent skeleton = MeshHelper.FindSkeleton(input); if (skeleton == null) { throw new InvalidContentException("Input skeleton not found."); } // We don't want to have to worry about different parts of the model being // in different local coordinate systems, so let's just bake everything. FlattenTransforms(input, skeleton); // Read the bind pose and skeleton hierarchy data. IList <BoneContent> bones = MeshHelper.FlattenSkeleton(skeleton); if (bones.Count > SkinnedEffect.MaxBones) { throw new InvalidContentException( string.Format( "Skeleton has {0} bones, but the maximum supported is {1}.", bones.Count, SkinnedEffect.MaxBones)); } List <Matrix> bindPose = new List <Matrix>(); List <Matrix> inverseBindPose = new List <Matrix>(); List <int> skeletonHierarchy = new List <int>(); foreach (BoneContent bone in bones) { bindPose.Add(bone.Transform); inverseBindPose.Add(Matrix.Invert(bone.AbsoluteTransform)); skeletonHierarchy.Add(bones.IndexOf(bone.Parent as BoneContent)); } // Chain to the base ModelProcessor class so it can convert the model data. ModelContent model = base.Process(input, context); // Store our custom animation data in the Tag property of the model. model.Tag = new SkinningData(bindPose, inverseBindPose, skeletonHierarchy); return(model); }
//ModelContent modelContent = null; //static bool m_First = true; public override ModelContent Process(NodeContent input, ContentProcessorContext context) { bool collapsed = BokuPipeline.MaterialsGroup.PreProcess(input); // stash our model content so that we can use it to look up meshes // ModelContent model = base.Process(input, context); FindBBoxesRecurse(input, model); BokuPipeline.MaterialsGroup.TagMeshParts(model, collapsed); /* * // Just debug foo, nothing to see here. * foreach (ModelMeshContent mesh in model.Meshes) * { * foreach (ModelMeshPartContent part in mesh.MeshParts) * { * MaterialContent mat = part.Material; * float alpha = mat.OpaqueData.GetValue<float>("Alpha", -1.0f); * Vector3 diffuse = mat.OpaqueData.GetValue<Vector3>("DiffuseColor", -Vector3.One); * if(alpha != 1.0f) * { * } * } * } */ return(model); //NodeContentCollection ncc = input.Children; //parseChildren(ncc); //ModelContent mc2 = base.Process(input, context); //mc2.Meshes[0].MeshParts[0]; //int nMeshes = mc2.Meshes.Count; //BoundingBox[] boxes = new BoundingBox[nMeshes]; //for(int i = 0; i < nMeshes; i++) //{ // boxes[i] = GetBoundingBox(mc2.Meshes[i]); //} //return m_ModelContent; }
/// <summary> /// The main Process method converts an intermediate format content pipeline /// NodeContent tree to a ModelContent object with embedded animation data. /// </summary> public SkinningData Process(NodeContent input, ContentProcessorContext context) { SkinnedModelHelper.ValidateMesh(input, context, null); // Find the skeleton. BoneContent skeleton = MeshHelper.FindSkeleton(input); if (skeleton == null) { return(null); } // We don't want to have to worry about different parts of the model being // in different local coordinate systems, so let's just bake everything. SkinnedModelHelper.FlattenTransforms(input, skeleton); // Read the bind pose and skeleton hierarchy data. IList <BoneContent> bones = MeshHelper.FlattenSkeleton(skeleton); if (bones.Count > MaxBones) { throw new InvalidContentException(string.Format( "Skeleton has {0} bones, but the maximum supported is {1}.", bones.Count, MaxBones)); } List <Matrix> bindPose = new List <Matrix>(); List <Matrix> inverseBindPose = new List <Matrix>(); List <int> skeletonHierarchy = new List <int>(); foreach (BoneContent bone in bones) { bindPose.Add(bone.Transform); inverseBindPose.Add(Matrix.Invert(bone.AbsoluteTransform)); skeletonHierarchy.Add(bones.IndexOf(bone.Parent as BoneContent)); } // Convert animation data to our runtime format. Dictionary <string, AnimationClip> animationClips; animationClips = SkinnedModelHelper.ProcessAnimations(skeleton.Animations, bones); // Store our custom animation data in the Tag property of the model. return(new SkinningData(animationClips, bindPose, inverseBindPose, skeletonHierarchy)); }
public override ModelContent Process(Texture2DContent input, ContentProcessorContext context) { if (input == null) { throw new ArgumentNullException("input"); } PixelBitmapContent <Color> bmpInput = (PixelBitmapContent <Color>)input.Mipmaps[0]; NodeContent nodeContent = new NodeContent(); nodeContent.Children.Add(buildFloorMesh(bmpInput)); nodeContent.Children.Add(buildWallMesh(bmpInput)); nodeContent.Children.Add(buildBlackMesh(bmpInput)); return(context.Convert <NodeContent, ModelContent>(nodeContent, typeof(LightPrePassProcessor).Name)); }
public override ModelContent Process(NodeContent input, ContentProcessorContext context) { foundSkinning_ = false; if (!forceShader_.Equals("") || !forceSkinnedShader_.Equals("")) { ReplaceShaders(input, context, input.Identity); } ModelContent ret = base.Process(input, context); if (ret.Tag == null) { ret.Tag = new Dictionary <string, object>(); } SetTexturePaths(ret); CalculateBoundingBoxes(ret, context.TargetPlatform); return(ret); }
/// <summary> /// Checks whether the imported model matches the model description. /// </summary> /// <param name="input">The root node content.</param> /// <param name="context">Contains any required custom process parameters.</param> public void Validate(NodeContent input, ContentProcessorContext context) { foreach (var meshDescription in Meshes) { // Check if there is a mesh for this mesh name. if (!string.IsNullOrEmpty(meshDescription.Name) && TreeHelper.GetSubtree(input, n => n.Children) .OfType <MeshContent>() .All(mc => mc.Name != meshDescription.Name)) { context.Logger.LogWarning( null, input.Identity, "Model description (.drmdl file) contains description for mesh '{0}' which was not found in the asset.", meshDescription.Name); } } }
public override ModelContent Process(NodeContent input, ContentProcessorContext context) { List <Vector3> lowestPoints = new List <Vector3>(); lowestPoints = FindLowestPoints(input, lowestPoints); ModelContent model = base.Process(input, context); int i = 0; foreach (ModelMeshContent mesh in model.Meshes) { mesh.Tag = lowestPoints[i++]; } return(model); }
public override ModelContent Process(NodeContent input, ContentProcessorContext context) { ModelContent model = base.Process(input, context); foreach (ModelMeshContent mm in model.Meshes) { sphereList.Add(mm.BoundingSphere); } foreach (BoundingSphere bs in sphereList) { master = BoundingSphere.CreateMerged(master, bs); } sphereList.Insert(0, master); model.Tag = sphereList; return(model); }
private void TraverseGeometryContents(NodeContent node) { MeshContent mesh = node as MeshContent; if (mesh != null) { foreach (GeometryContent geometry in mesh.Geometry) { // In case we want to do some processing here. } } foreach (NodeContent child in node.Children) { TraverseGeometryContents(child); } }
public SearchFilter GetSearchFilterForNode(NodeContent nodeContent) { var configFilter = new SearchFilter { field = BaseCatalogIndexBuilder.FieldConstants.Node, Descriptions = new Descriptions { defaultLocale = _preferredCulture.Name }, Values = new SearchFilterValues() }; var desc = new Description { locale = "en", Value = _localizationService.GetString("/Facet/Category") }; configFilter.Descriptions.Description = new[] { desc }; var nodes = _contentLoader.GetChildren<NodeContent>(nodeContent.ContentLink).ToList(); var nodeValues = new SimpleValue[nodes.Count]; var index = 0; foreach (var node in nodes) { var val = new SimpleValue { key = node.Code, value = node.Code, Descriptions = new Descriptions { defaultLocale = _preferredCulture.Name } }; var desc2 = new Description { locale = _preferredCulture.Name, Value = node.DisplayName }; val.Descriptions.Description = new[] { desc2 }; nodeValues[index] = val; index++; } configFilter.Values.SimpleValue = nodeValues; return configFilter; }
public static void CalculateBoundingBox(NodeContent node, ref BoundingBox box) { if (node is MeshContent) { MeshContent mc = node as MeshContent; Vector3[] pts = new Vector3[mc.Positions.Count]; Fill(pts, mc.Positions); Matrix mat = mc.AbsoluteTransform; Vector3.Transform(pts, ref mat, pts); BoundingBox b2 = BoundingBox.CreateFromPoints(pts); box = BoundingBox.CreateMerged(box, b2); } foreach (NodeContent cld in node.Children) { CalculateBoundingBox(cld, ref box); } }
void AddPointsTo(NodeContent dataHolder, List <Vector3> list) { //iterate through and get positions if (dataHolder != null) { for (int i = dataHolder.Children.Count - 1; i >= 0; --i) { MeshContent spherePoint = dataHolder.Children[i] as MeshContent; if (spherePoint != null) { BoundingSphere sphere = BoundingSphere.CreateFromPoints(spherePoint.Positions); list.Add(Vector3.Transform(sphere.Center, spherePoint.AbsoluteTransform)); } } dataHolder.Parent.Children.Remove(dataHolder); } }
public override RewardDescription Evaluate(IOrderForm orderForm, BuyXFromCategoryGetProductForFree promotionData, PromotionProcessorContext context) { IEnumerable <ILineItem> items = GetLineItemsInOrder(orderForm); List <AffectedItem> affectedItems = new List <AffectedItem>(); var lineItemCategories = items.Select(i => new { Quantity = i.Quantity, NodesForEntry = GetNodesForEntry(i.Code), Code = i.Code, LineItem = i }); decimal numberOfItemsInPromotionCategory = 0; NodeContent category = _contentLoader.Get <NodeContent>(promotionData.Category); foreach (var lineItemCategory in lineItemCategories) { if (lineItemCategory.NodesForEntry.Contains(category.Code)) { numberOfItemsInPromotionCategory += lineItemCategory.Quantity; // TODO: This has not yet been implemented //affectedItems.Add( // new AffectedItem( // _referenceConverter.GetContentLink(lineItemCategory.Code), // lineItemCategory.LineItem, // lineItemCategory.Quantity)); } } FulfillmentStatus fulfillment = this.GetFulfillment(numberOfItemsInPromotionCategory, promotionData.Threshold); // context.OrderGroup //if(fulfillment == FulfillmentStatus.Fulfilled) //{ // affectedItems.Add( // new AffectedItem( // promotionData // _referenceConverter.GetContentLink(lineItemCategory.Code), // lineItemCategory.LineItem, // lineItemCategory.Quantity)); //} return(RewardDescription.CreateFreeItemReward(fulfillment, affectedItems, promotionData, "Got something for free")); // return new RewardDescription(fulfillment, affectedItems, promotionData, 0, 0, RewardType.Free, "Got something for free"); }
/// <summary> /// Bakes unwanted transforms into the model geometry, /// so everything ends up in the same coordinate system. /// </summary> void FlattenTransforms(NodeContent node, BoneContent skeleton) { foreach (NodeContent child in node.Children) { // Don't process the skeleton, because that is special. if (child == skeleton) { continue; } // This is important: Don't bake in the transforms except // for geometry that is part of a skinned mesh if (IsSkinned(child)) { FlattenAllTransforms(child); } } }
private void CalculateTangentFrames( NodeContent input, ContentProcessorContext context ) { MeshContent mesh = input as MeshContent; if (mesh != null && !IsCollisionNode(input)) { MeshHelper.CalculateTangentFrames(mesh, "TextureCoordinate0", "Tangent0", "Binormal0"); } // Go through all children foreach (NodeContent child in input.Children) { CalculateTangentFrames(child, context); } }
public override ModelContent Process(NodeContent input, ContentProcessorContext context) { if (input == null) { throw new ArgumentNullException("input"); } // We always want to Generate tangent frames GenerateTangentFrames = true; MeshHelper.TransformScene(input, input.Transform); input.Transform = Matrix.Identity; MergeTransforms(input); directory = Path.GetDirectoryName(input.Identity.SourceFilename); LookUpTextures(input); return(base.Process(input, context)); }
private static void AddToListWithSort(List <NodeContent> list, NodeContent newNode) { bool greatest = true; for (int i = 0; i < list.Count; i++) { if (list[i].CompareTo(newNode) >= 0) { list.Insert(i, newNode); greatest = false; break; } } if (greatest) { list.Add(newNode); } }
public override AnimatedModelIntermediateType Import(string filename, ContentImporterContext context) { AnimatedModelInfo animatedModelInfo = JsonConvert.DeserializeObject <AnimatedModelInfo>(File.ReadAllText(filename)); string root = Path.GetDirectoryName(filename); string extension = "fbx"; string modelFilename = Path.ChangeExtension(Path.Combine(root, animatedModelInfo.model), extension); NodeContent nodeContent = fbxImporter.Import(modelFilename, context); AnimatedModelClipContent[] clipContent = new AnimatedModelClipContent[animatedModelInfo.clips.Length]; for (int i = 0; i < animatedModelInfo.clips.Length; i++) { AnimatedModelClipInfo clipInfo = animatedModelInfo.clips[i]; clipContent[i] = new AnimatedModelClipContent(clipInfo.name, clipInfo.startFrame, clipInfo.endFrame); } return(new AnimatedModelIntermediateType(nodeContent, animatedModelInfo.totalFrames, clipContent)); }
private CategoryItemViewModel ToViewModel(NodeContent model) { var children = _contentLoader.GetChildren <NodeContent>(model.ContentLink); return(new CategoryItemViewModel { Name = model.DisplayName, ImageUrl = model.DefaultImageUrl(), Uri = _urlResolver.GetUrl(model.ContentLink), ChildLinks = children.Select( x => new CategoryChildLinkViewModel { Text = x.DisplayName, Uri = _urlResolver.GetUrl(x.ContentLink) }) .ToList() }); }
private static void MergeAnimation(string animationFile, AnimationContentDictionary animationDictionary, ContentIdentity contentIdentity, ContentProcessorContext context) { if (string.IsNullOrEmpty(animationFile)) { return; } if (animationDictionary == null) { throw new ArgumentNullException("animationDictionary"); } if (context == null) { throw new ArgumentNullException("context"); } // Use content pipeline to build the asset. animationFile = ContentHelper.FindFile(animationFile, contentIdentity); NodeContent mergeModel = context.BuildAndLoadAsset <NodeContent, NodeContent>(new ExternalReference <NodeContent>(animationFile), null); // Find the skeleton. BoneContent mergeRoot = MeshHelper.FindSkeleton(mergeModel); if (mergeRoot == null) { context.Logger.LogWarning(null, contentIdentity, "Animation model file '{0}' has no root bone. Cannot merge animations.", animationFile); return; } // Merge all animations of the skeleton root node. foreach (string animationName in mergeRoot.Animations.Keys) { if (animationDictionary.ContainsKey(animationName)) { context.Logger.LogWarning(null, contentIdentity, "Replacing animation '{0}' with merged animation from '{1}'.", animationName, animationFile); animationDictionary[animationName] = mergeRoot.Animations[animationName]; } else { context.Logger.LogImportantMessage("Merging animation '{0}' from '{1}'.", animationName, animationFile); animationDictionary.Add(animationName, mergeRoot.Animations[animationName]); } } }
private void AnimationDataImport(ModelContent model, NodeContent input, ContentProcessorContext context) { for (int i = 0; i < model.Bones.Count; i++) { bones[model.Bones[i].Name] = i; } boneTransforms = new Matrix[model.Bones.Count]; AnimationDataImportRec(input); if (animationData.Clips.Count == 0) { Clip clip = new Clip(); animationData.Clips.Add(clip); string clipName = "Take 001"; clips[clipName] = clip; clip.Name = clipName; foreach (ModelBoneContent bone in model.Bones) { Clip.Bone clipBone = new Clip.Bone(); clipBone.Name = bone.Name; clip.Bones.Add(clipBone); } } foreach (Clip clip in animationData.Clips) { for (int b = 0; b < bones.Count; b++) { List <Clip.Keyframe> keyframes = clip.Bones[b].Keyframes; if (keyframes.Count == 0 || keyframes[0].Time > 0) { Clip.Keyframe keyframe = new Clip.Keyframe(); keyframe.Time = 0; keyframe.Transform = boneTransforms[b]; keyframes.Insert(0, keyframe); } } } }
protected override NodeContent GetContent(NodeBase node, NodeContentParameters contentParameters) { //error if (!node.Exists()) { return(NodeContent.CreateDelayedWriteContent(new MemoryStream())); } var resultStream = new MemoryStream(); _store[node].Content.CopyTo(resultStream); resultStream.Position = 0; _store[node].Content.Position = 0; return(contentParameters.AccessType == NodeContentAccess.Read ? NodeContent.CreateReadOnlyContent(resultStream) : NodeContent.CreateDelayedWriteContent(resultStream)); }
public override ModelContent Process(NodeContent input, ContentProcessorContext context) { if (input is null) { throw new ArgumentNullException(nameof(input)); } if (this.ProcessTextures) { // Look up all materials and link them to the model MaterialLinker.Bind( input, Path.GetFullPath(this.NormalMapFallback), Path.GetFullPath(this.SpecularMapFallback), Path.GetFullPath(this.MaskFallback)); } return(base.Process(input, context)); }
public override ModelContent Process(NodeContent input, ContentProcessorContext context) { //uncomment this to debug the content processor //System.Diagnostics.Debugger.Launch(); LevelTagData tag = new LevelTagData(); AddPointsTo(GetDataHolder(input, "light_poles"), tag.lightPoleLocations); AddPointsTo(GetDataHolder(input, "cars"), tag.cars); AddPointsTo(GetDataHolder(input, "mailbox1"), tag.mailbox1); AddPointsTo(GetDataHolder(input, "mailbox2"), tag.mailbox2); AddPointsTo(GetDataHolder(input, "beer"), tag.beer); ModelContent retModel = base.Process(input, context); retModel.Tag = tag; return(retModel); }
public override ModelContent Process(NodeContent input, ContentProcessorContext context) { CalculateTangentFrames(input, context); // The base processor will include the tagent frames in the resulting model ModelContent modelContent = base.Process(input, context); // Copy each mesh part's material name to it's tag. Chip rendering uses the // material name to determine which texture goes on which side. foreach (ModelMeshContent modelMesh in modelContent.Meshes) { foreach (ModelMeshPartContent modelMeshPart in modelMesh.MeshParts) { modelMeshPart.Tag = modelMeshPart.Material.Name; } } return(modelContent); }
public void Search_ShouldReturnPopulatedProductViewModel() { var content = new NodeContent(); var filterOptions = new FilterOptionFormModel { FacetGroups = new List<FacetGroupOption>() }; var result = _subject.Search(content, filterOptions); var productViewModel = result.ProductViewModels.First(); var expected = new ProductViewModel { DisplayName = "DisplayName", PlacedPrice = new Money(1, _currentCurrency), ExtendedPrice = new Money(1, _currentCurrency), ImageUrl = "/image.jpg", Url = "http://domain.com", Code = "Code", Brand = "Brand" }; productViewModel.ShouldBeEquivalentTo(expected); }
public void Search_WhenQueryContainsWaveCharacter_ShouldRemoveWaveCharacterFromQuery() { const string searchQuery = "start~end"; const string expectedResult = "startend*"; var content = new NodeContent(); var filterOptions = new FilterOptionViewModel { Q = searchQuery, FacetGroups = new List<FacetGroupOption>() }; _subject.Search(content, filterOptions); _searchFacadeMock.Verify(x => x.Search(It.Is<CatalogEntrySearchCriteria>(y => y.SearchPhrase.Equals(expectedResult)))); }
/// <summary> /// <para>Add a child at the specified position and enable its flag.</para> /// </summary> /// <param name="position"></param> /// <param name="flag"></param> private void AddChild(NodeChild position, NodeContent flag) { this.EnableVertex(flag); QuadNode node = new QuadNode(this, position); this.Childs[(int)position] = node; float size = node.GetNodeSize(); switch (position) { case NodeChild.NorthWest: node.Location = this.Location + new Vector2(0, size); break; case NodeChild.NorthEast: node.Location = this.Location + new Vector2(size, size); break; case NodeChild.SouthWest: node.Location = this.Location + new Vector2(0, 0); break; default: node.Location = this.Location + new Vector2(size, 0); break; } node.InitializeNeighbors(); this.InitializeNeighbors(); node.Initialize(); switch (position) { case NodeChild.NorthWest: this.EnableVertex(NodeContent.NorthVertex, NodeVertex.North); this.EnableVertex(NodeContent.WestVertex, NodeVertex.West); break; case NodeChild.NorthEast: this.EnableVertex(NodeContent.NorthVertex, NodeVertex.North); this.EnableVertex(NodeContent.EastVertex, NodeVertex.East); break; case NodeChild.SouthWest: this.EnableVertex(NodeContent.SouthVertex, NodeVertex.South); this.EnableVertex(NodeContent.WestVertex, NodeVertex.West); break; default: this.EnableVertex(NodeContent.SouthVertex, NodeVertex.South); this.EnableVertex(NodeContent.EastVertex, NodeVertex.East); break; } }
public void Search_ShouldFilterByCurrentMarket() { var filterOptions = new FilterOptionViewModel { Q = "query", FacetGroups = new List<FacetGroupOption>() }; var content = new NodeContent(); _subject.Search(content, filterOptions); var expected = _currentMarketMock.Object.GetCurrentMarket().MarketId; _searchFacadeMock.Verify(x => x.Search(It.Is<CatalogEntrySearchCriteria>(y => y.MarketId.Equals(expected)))); }
/// <summary> /// <para>Check the specified child of the current <see cref="QuadNode"/>.</para> /// </summary> /// <param name="position">Position of the child.</param> /// <param name="flag">Flag to enable/disable.</param> /// <param name="childBox">Associated child's bounding box.</param> private void CheckChildAt(NodeChild position, NodeContent flag, float dotprod, BoundingBox childBox) { if (this.IsDisabled(flag)//if the flag is not enabled && ChildTest(dotprod, childBox, Camera.Camera.DefaultCamera.Transform.Translation))//and the child bounding box show that the child have to be enabled this.AddChild(position, flag); else if (this.IsEnabled(flag)//if the flag is enabled && this.Childs[(int)position].IsLeaf() //and the child have not childs && this.Childs[(int)position].HaveNoEdge() // and the child have no side edges && !ChildTest(dotprod, childBox, Camera.Camera.DefaultCamera.Transform.Translation)) ////and the child bounding box show that the child have to be disabled this.RemoveChild(position, flag); }
/// <summary> /// <para>Check the specified vertex of the current <see cref="QuadNode"/>.</para> /// </summary> /// <param name="position">Position of the vertex.</param> /// <param name="flag">Flag to enable/disable.</param> private void CheckVertexAt(NodeVertex position, NodeContent flag, NodeSideVertex side) { if (this.IsDisabled(flag)//if the flag is not enabled && VertexTest(this.Vertices[(int)position].Value.Position, side, Camera.Camera.DefaultCamera.Transform.Translation))//and the vertex can be enabled... this.EnableVertex(flag, position); else if (this.IsEnabled(flag)//if the flag is enabled && !VertexTest(this.Vertices[(int)position].Value.Position, side, Camera.Camera.DefaultCamera.Transform.Translation))//and the vertex have to be disabled... this.DisableVertex(flag, position); }
/// <summary> /// <para>Remove a child from the specified position and disable its flag.</para> /// </summary> private void RemoveChild(NodeChild position, NodeContent flag) { this.DisableVertex(flag); QuadNode node = this.Childs[(int)position]; switch (position) { case NodeChild.NorthWest: this.DisableVertex(NodeContent.NorthVertex, NodeVertex.North); this.DisableVertex(NodeContent.WestVertex, NodeVertex.West); break; case NodeChild.NorthEast: this.DisableVertex(NodeContent.NorthVertex, NodeVertex.North); this.DisableVertex(NodeContent.EastVertex, NodeVertex.East); break; case NodeChild.SouthWest: this.DisableVertex(NodeContent.SouthVertex, NodeVertex.South); this.DisableVertex(NodeContent.WestVertex, NodeVertex.West); break; default: this.DisableVertex(NodeContent.SouthVertex, NodeVertex.South); this.DisableVertex(NodeContent.EastVertex, NodeVertex.East); break; } this.Childs[(int)position] = null; this.InitializeNeighbors(); node.InitializeNeighbors(); node.Dispose(); }
/// <summary> /// <para>Enable the specified flag and the specified vertex.</para> /// </summary> public void EnableVertex(NodeContent flag, NodeVertex vertex) { this.EnableVertex(flag); this._vertices[(int)vertex].AddReferenceTo(this); }
private NodeContent AtNode(Node node) { if (!grid.ContainsKey (node)) { return grid [node] = new NodeContent (); } else { return grid [node]; } }
protected void WalkCategoryTree(NodeContent node, IContentRepository repository, CatalogContentLoader contentLoader, ICatalogSystem catalog, ReferenceConverter referenceConverter) { // ReSharper disable PossibleMultipleEnumeration // Get all products Stopwatch tmr = Stopwatch.StartNew(); IEnumerable<EntryContentBase> entries = repository.GetChildren<EPiServer.Commerce.Catalog.ContentTypes.EntryContentBase>(node.ContentLink); _log.Debug("Loaded {0} entries in category {1} using IContentRepository in {2}ms", entries.Count(), node.Name, tmr.ElapsedMilliseconds); // Load and cache Entry objects. Still a lot of code that uses this tmr = Stopwatch.StartNew(); foreach (EntryContentBase entryAsContent in entries) { // Load full entry int entryId = referenceConverter.GetObjectId(entryAsContent.ContentLink); // Catalog Gadget uses info //catalog.GetCatalogEntry(entryId, // new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo)); catalog.GetCatalogEntry(entryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull)); } // Prime the catalog gadget // IEnumerable<IContent> children = repository.GetChildren<IContent>(node.ContentLink, new LanguageSelector("en"), 0, int.MaxValue); // _log.Debug("Loaded {0} children", children.Count()); // .GetDescendents(node.ContentLink); tmr.Stop(); _log.Debug("Loaded {0} entries in category {1} using ICatalogSystem in {2}ms", entries.Count(), node.Name, tmr.ElapsedMilliseconds); // Get all products the way it is done in edit mode, but this does not seem to // use the cache. //int loadedEntries; //contentLoader.GetCatalogEntries(node.ContentLink, 0, int.MaxValue, out loadedEntries); //_log.Debug("Loaded {0} entries in category {1} using CatalogContentLoader", loadedEntries, node.Name); // Get child nodes the same way done by the UI IList<GetChildrenReferenceResult> catalogNodes = contentLoader.GetCatalogNodes(node.ContentLink); _log.Debug("Loaded {0} categories in category {1} using CatalogContentLoader", catalogNodes.Count, node.Name); foreach (GetChildrenReferenceResult catalogNode in catalogNodes) { NodeContent childNode = repository.Get<NodeContent>(catalogNode.ContentLink); WalkCategoryTree(childNode, repository, contentLoader, catalog, referenceConverter); } // ReSharper restore PossibleMultipleEnumeration }
public void Diff_with_items_differing_by_type() { var actual = new NodeContent(123, 123, "TEXT"); var expected = MockRepository.GenerateStub<INode>(); var diff = actual.Diff(expected, XmlPathRoot.Strict.Empty, XmlPathRoot.Strict.Empty, XmlOptions.Strict.Value); AssertDiff(diff, new Diff(DiffType.UnexpectedContent, XmlPathRoot.Strict.Empty.Element(123), DiffTargets.Actual)); }
public void Diff_with_value_differing_by_case() { var actual = new NodeContent(123, 123, "Text"); var expected = new NodeContent(123, 123, "TEXT"); var diff = actual.Diff(expected, XmlPathRoot.Strict.Empty, XmlPathRoot.Strict.Empty, XmlOptions.Strict.Value); AssertDiff(diff, new Diff(DiffType.MismatchedContent, XmlPathRoot.Strict.Empty.Element(123), DiffTargets.Both)); }
public void Diff_equal_ignoring_name_case() { var actual = new NodeContent(123, 123, "Text"); var expected = new NodeContent(123, 123, "TEXT"); var diff = actual.Diff(expected, XmlPathRoot.Strict.Empty, XmlPathRoot.Strict.Empty, Options.IgnoreElementsValueCase); Assert.IsTrue(diff.IsEmpty); }
private void AggregateContent(NodeContent node) { var output = new StringBuilder(); if (!node.IsFirst) output.Append(Ellipsis + " "); output.Append(node.Text); pendingContent = output.ToString(); }
public void Diff_with_null_pathExpected_should_throw_exception() { var actual = new NodeContent(123, 123, "Text"); var expected = new NodeContent(123, 123, "Text"); actual.Diff(expected, XmlPathRoot.Strict.Empty, null, XmlOptions.Strict.Value); }
/// <summary> /// <para>Disable the specified flag.</para> /// </summary> public void DisableVertex(NodeContent flag) { this._enabledContent &= ~flag; if (((int)this._enabledContent >> 5) == 0) { this._enabledContent &= ~NodeContent.CenterVertex; this.CenterVertex.RemoveReferenceFrom(this); } }
/// <summary> /// <para>Returns true if the specified <see cref="EnabledVertex"/> is disabled.</para> /// </summary> /// <param name="disabledVertex">Flag to analyse.</param> private bool IsDisabled(NodeContent disabledVertex) { return ((this._enabledContent & disabledVertex) == NodeContent.None); }
/// <summary> /// <para>Enable the specified flag.</para> /// </summary> public void EnableVertex(NodeContent flag) { this._enabledContent |= flag; if (((int)this._enabledContent >> 5) != 0) { this._enabledContent |= NodeContent.CenterVertex; this.CenterVertex.AddReferenceTo(this); } //if an edge is enable must enable neighbor to share the edge if (((int)flag >> 5) != 0 && (this.Parent != null)) { switch (flag) { case NodeContent.WestVertex: if (this.WestNeighbor == null) { if (this.Position == NodeChild.NorthWest) { if (this.Parent.WestNeighbor != null) if (this.Parent.WestNeighbor.NorthEastChild == null) this.Parent.WestNeighbor.AddChild(NodeChild.NorthEast, NodeContent.NorthEastChild); } else if (this.Position == NodeChild.SouthWest) { if (this.Parent.WestNeighbor != null) if (this.Parent.WestNeighbor.SouthEastChild == null) this.Parent.WestNeighbor.AddChild(NodeChild.SouthEast, NodeContent.SouthEastChild); } else if (this.Position == NodeChild.SouthEast) { if (this.Parent.SouthWestChild == null) this.Parent.AddChild(NodeChild.SouthWest, NodeContent.SouthWestChild); } else if (this.Position == NodeChild.NorthEast) { if (this.Parent.NorthWestChild == null) this.Parent.AddChild(NodeChild.NorthWest, NodeContent.NorthWestChild); } } break; case NodeContent.NorthVertex: if (this.NorthNeighbor == null) { if (this.Position == NodeChild.NorthWest) { if (this.Parent.NorthNeighbor != null) if (this.Parent.NorthNeighbor.SouthWestChild == null) this.Parent.NorthNeighbor.AddChild(NodeChild.SouthWest, NodeContent.SouthWestChild); } else if (this.Position == NodeChild.NorthEast) { if (this.Parent.NorthNeighbor != null) if (this.Parent.NorthNeighbor.SouthEastChild == null) this.Parent.NorthNeighbor.AddChild(NodeChild.SouthEast, NodeContent.SouthEastChild); } else if (this.Position == NodeChild.SouthEast) { if (this.Parent.NorthEastChild == null) this.Parent.AddChild(NodeChild.NorthEast, NodeContent.NorthEastChild); } else if (this.Position == NodeChild.SouthWest) { if (this.Parent.NorthWestChild == null) this.Parent.AddChild(NodeChild.NorthWest, NodeContent.NorthWestChild); } } break; case NodeContent.EastVertex: if (this.EastNeighbor == null) { if (this.Position == NodeChild.NorthEast) { if (this.Parent.EastNeighbor != null) if (this.Parent.EastNeighbor.NorthWestChild == null) this.Parent.EastNeighbor.AddChild(NodeChild.NorthWest, NodeContent.NorthWestChild); } else if (this.Position == NodeChild.SouthEast) { if (this.Parent.EastNeighbor != null) if (this.Parent.EastNeighbor.SouthWestChild == null) this.Parent.EastNeighbor.AddChild(NodeChild.SouthWest, NodeContent.SouthWestChild); } else if (this.Position == NodeChild.NorthWest) { if (this.Parent.NorthEastChild == null) this.Parent.AddChild(NodeChild.NorthEast, NodeContent.NorthEastChild); } else if (this.Position == NodeChild.SouthWest) { if (this.Parent.SouthEastChild == null) this.Parent.AddChild(NodeChild.SouthEast, NodeContent.SouthEastChild); } } break; case NodeContent.SouthVertex: if (this.SouthNeighbor == null) { if (this.Position == NodeChild.SouthEast) { if (this.Parent.SouthNeighbor != null) if (this.Parent.SouthNeighbor.NorthEastChild == null) this.Parent.SouthNeighbor.AddChild(NodeChild.NorthEast, NodeContent.NorthEastChild); } else if (this.Position == NodeChild.SouthWest) { if (this.Parent.SouthNeighbor != null) if (this.Parent.SouthNeighbor.NorthWestChild == null) this.Parent.SouthNeighbor.AddChild(NodeChild.NorthWest, NodeContent.NorthWestChild); } else if (this.Position == NodeChild.NorthEast) { if (this.Parent.SouthEastChild == null) this.Parent.AddChild(NodeChild.SouthEast, NodeContent.SouthEastChild); } else if (this.Position == NodeChild.NorthWest) { if (this.Parent.SouthWestChild == null) this.Parent.AddChild(NodeChild.SouthWest, NodeContent.SouthWestChild); } } break; default: break; } } }
/// <summary> /// <para>Returns true if the specified <see cref="EnabledVertex"/> is enabled.</para> /// </summary> /// <param name="enabledVertex">Flag to analyse.</param> private bool IsEnabled(NodeContent enabledVertex) { return ((this._enabledContent & enabledVertex) != NodeContent.None); }
/// <summary> /// <para>Disable the specified flag and the specified vertex.</para> /// </summary> public void DisableVertex(NodeContent flag, NodeVertex vertex) { this.DisableVertex(flag); this._vertices[(int)vertex].RemoveReferenceFrom(this); }