コード例 #1
0
        /// <summary>
        /// Yields an array of tokens for each line in an OBJ or MTL file.
        /// </summary>
        /// <remarks>
        /// OBJ and MTL files are text based formats of identical structure.
        /// Each line of a OBJ or MTL file is either an instruction or a comment.
        /// Comments begin with # and are effectively ignored.
        /// Instructions are a space dilimited list of tokens. The first token is the
        /// instruction type code. The tokens which follow, are the arguments to that
        /// instruction. The number and format of arguments vary by instruction type.
        /// </remarks>
        /// <param name="filename">Full path of file to read.</param>
        /// <param name="identity">Identity of the file being read. This is modified to
        /// include the current line number in case an exception is thrown.</param>
        /// <returns>Element 0 is the line type identifier. The remaining elements are
        /// arguments to the identifier's operation.</returns>
        private static IEnumerable <string[]> GetLineTokens(string filename,
                                                            ContentIdentity identity)
        {
            // Open the file
            using (StreamReader reader = new StreamReader(filename))
            {
                int lineNumber = 1;

                // For each line of the file
                while (!reader.EndOfStream)
                {
                    // Set the line number to report in case an exception is thrown
                    identity.FragmentIdentifier = lineNumber.ToString();

                    // Tokenize line by splitting on 1 more more whitespace character
                    string[] lineTokens = Regex.Split(reader.ReadLine().Trim(), @"\s+");

                    // Skip blank lines and comments
                    if (lineTokens.Length > 0 &&
                        lineTokens[0] != String.Empty &&
                        !lineTokens[0].StartsWith("#"))
                    {
                        // Pass off the tokens of this line to be processed
                        yield return(lineTokens);
                    }

                    // Done with this line!
                    lineNumber++;
                }


                // Clear line number from identity
                identity.FragmentIdentifier = null;
            }
        }
コード例 #2
0
    private static TextureContent Compress(Type bitmapContentType, Texture texture, ContentIdentity identity)
    {
      // Let MonoGame's BitmapContent handle the compression.
      var description = texture.Description;
      switch (description.Dimension)
      {
        case TextureDimension.Texture1D:
        case TextureDimension.Texture2D:
          {
            var textureContent = new Texture2DContent { Identity = identity };
            for (int mipIndex = 0; mipIndex < description.MipLevels; mipIndex++)
            {
              var image = texture.Images[texture.GetImageIndex(mipIndex, 0, 0)];
              var sourceBitmap = TextureHelper.ToContent(image);
              var targetBitmap = (BitmapContent)Activator.CreateInstance(bitmapContentType, image.Width, image.Height);
              BitmapContent.Copy(sourceBitmap, targetBitmap);
              textureContent.Mipmaps.Add(targetBitmap);
            }

            return textureContent;
          }
        case TextureDimension.TextureCube:
          {
            var textureContent = new TextureCubeContent { Identity = identity };
            for (int faceIndex = 0; faceIndex < 6; faceIndex++)
            {
              for (int mipIndex = 0; mipIndex < description.MipLevels; mipIndex++)
              {
                var image = texture.Images[texture.GetImageIndex(mipIndex, faceIndex, 0)];
                var sourceBitmap = TextureHelper.ToContent(image);
                var targetBitmap = (BitmapContent)Activator.CreateInstance(bitmapContentType, image.Width, image.Height);
                BitmapContent.Copy(sourceBitmap, targetBitmap);
                textureContent.Faces[faceIndex].Add(targetBitmap);
              }
            }

            return textureContent;
          }
        case TextureDimension.Texture3D:
          {
            var textureContent = new Texture3DContent { Identity = identity };
            for (int zIndex = 0; zIndex < description.Depth; zIndex++)
            {
              textureContent.Faces.Add(new MipmapChain());
              for (int mipIndex = 0; mipIndex < description.MipLevels; mipIndex++)
              {
                var image = texture.Images[texture.GetImageIndex(mipIndex, 0, zIndex)];
                var sourceBitmap = TextureHelper.ToContent(image);
                var targetBitmap = (BitmapContent)Activator.CreateInstance(bitmapContentType, image.Width, image.Height);
                BitmapContent.Copy(sourceBitmap, targetBitmap);
                textureContent.Faces[zIndex].Add(targetBitmap);
              }
            }

            return textureContent;
          }
      }

      throw new InvalidOperationException("Invalid texture dimension.");
    }
コード例 #3
0
        private static void ProcessWeightsChannel(
            GeometryContent geometry, int vertexChannelIndex, ContentIdentity identity)
        {
            // NOTE: Portions of this code is from the XNA CPU Skinning
            // sample under Ms-PL, (c) Microsoft Corporation.

            // create a map of Name->Index of the bones
            var skeleton = MeshHelper.FindSkeleton(geometry.Parent);

            if (skeleton == null)
            {
                throw new InvalidContentException(
                          "Skeleton not found. Meshes that contain a Weights vertex channel cannot " +
                          "be processed without access to the skeleton data.",
                          identity);
            }

            var boneIndices    = new Dictionary <string, byte>();
            var flattenedBones = MeshHelper.FlattenSkeleton(skeleton);

            if (flattenedBones.Count > byte.MaxValue)
            {
                throw new NotSupportedException("The flattened skeleton contains more than 255 bones.");
            }

            for (int i = 0; i < flattenedBones.Count; i++)
            {
                boneIndices.Add(flattenedBones[i].Name, (byte)i);
            }

            var vertexChannel = geometry.Vertices.Channels[vertexChannelIndex];

            if (!(vertexChannel is VertexChannel <BoneWeightCollection> inputWeights))
            {
                throw new InvalidContentException(
                          string.Format(
                              "Vertex channel \"{0}\" is the wrong type. It has element type {1}. Type {2} is expected.",
                              vertexChannel.Name, vertexChannel.ElementType.FullName, typeof(BoneWeightCollection).FullName),
                          identity);
            }
            var outputIndices = new Byte4[inputWeights.Count];
            var outputWeights = new Vector4[inputWeights.Count];

            for (var i = 0; i < inputWeights.Count; i++)
            {
                ConvertWeights(inputWeights[i], boneIndices, outputIndices, outputWeights, i);
            }

            // create our new channel names
            var usageIndex  = VertexChannelNames.DecodeUsageIndex(inputWeights.Name);
            var indicesName = VertexChannelNames.EncodeName(VertexElementUsage.BlendIndices, usageIndex);
            var weightsName = VertexChannelNames.EncodeName(VertexElementUsage.BlendWeight, usageIndex);

            // add in the index and weight channels
            geometry.Vertices.Channels.Insert(vertexChannelIndex + 1, indicesName, outputIndices);
            geometry.Vertices.Channels.Insert(vertexChannelIndex + 2, weightsName, outputWeights);

            // remove the original weights channel
            geometry.Vertices.Channels.RemoveAt(vertexChannelIndex);
        }
コード例 #4
0
        public ContentItem Get(string id) {
            var contentIdentity = new ContentIdentity(id);

            // lookup in local cache
            if (_identities.ContainsKey(contentIdentity))
                return _contentManager.Get(_identities[contentIdentity], VersionOptions.DraftRequired);

            // no result ? then check if there are some more content items to load from the db
            if(_lastIndex != int.MaxValue) {
                
                var equalityComparer = new ContentIdentity.ContentIdentityEqualityComparer();
                IEnumerable<ContentItem> block;
            
                // load identities in blocks
                while ((block = _contentManager.HqlQuery()
                    .ForVersion(VersionOptions.Latest)
                    .OrderBy(x => x.ContentItemVersion(), x => x.Asc("Id"))
                    .Slice(_lastIndex, BulkPage)).Any()) {

                        foreach (var item in block) {
                            _lastIndex++;

                            // ignore content item if it has already been imported
                            if (_contentItemIds.ContainsKey(item.Id)) {
                                continue;
                            }

                            var identity = _contentManager.GetItemMetadata(item).Identity;

                            // ignore content item if the same identity is already present
                            if (_identities.ContainsKey(identity)) {
                                continue;
                            }

                            _identities.Add(identity, item.Id);
                            _contentItemIds.Add(item.Id, identity);
                        
                            if (equalityComparer.Equals(identity, contentIdentity)) {
                                return _contentManager.Get(item.Id, VersionOptions.DraftRequired);
                            }
                        }

                    _contentManager.Flush();
                    _contentManager.Clear();
                }
            }

            _lastIndex = int.MaxValue;

            if(!_contentTypes.ContainsKey(contentIdentity)) {
                throw new ArgumentException("Unknown content type for " + id);
                
            }

            var contentItem = _contentManager.Create(_contentTypes[contentIdentity], VersionOptions.Draft);
            _identities.Add(contentIdentity, contentItem.Id);
            _contentItemIds.Add(contentItem.Id, contentIdentity);

            return contentItem;
        }
コード例 #5
0
        public void TestInit() {
            _testItemIdentity1 = new ContentIdentity("/ItemId=1");
            _testItemIdentity2 = new ContentIdentity("/ItemId=2");
            _testItemIdentity3 = new ContentIdentity("/ItemId=3");
            _testItemIdentity4 = new ContentIdentity("/ItemId=4");
            _testItemIdentity5 = new ContentIdentity("/ItemId=5");
            var draftItem = new ContentItem { VersionRecord = new ContentItemVersionRecord { Id = 1234, Published = false, Latest = true, ContentItemRecord = new ContentItemRecord { Id = 1 } } };
            var publishedItem = new ContentItem { VersionRecord = new ContentItemVersionRecord { Id = 1234, Published = true, Latest = true, ContentItemRecord = new ContentItemRecord { Id = 1 } } };

            var draftItem5 = new ContentItem { VersionRecord = new ContentItemVersionRecord { Id = 1234, Published = false, Latest = true, ContentItemRecord = new ContentItemRecord { Id = 5 } } };
            var publishedItem5 = new ContentItem { VersionRecord = new ContentItemVersionRecord { Id = 1234, Published = true, Latest = true, ContentItemRecord = new ContentItemRecord { Id = 5 } } };

            _contentManager = new Mock<IContentManager>();
            _contentManager.Setup(m => m.Get(It.Is<int>(v => v == 1), It.Is<VersionOptions>(v => v.IsDraftRequired))).Returns(draftItem);
            _contentManager.Setup(m => m.Get(It.Is<int>(v => v == 1), It.Is<VersionOptions>(v => !v.IsDraftRequired))).Returns(publishedItem);

            _contentManager.Setup(m => m.Get(It.Is<int>(v => v == 5), It.Is<VersionOptions>(v => v.IsDraftRequired))).Returns(draftItem5);
            _contentManager.Setup(m => m.Get(It.Is<int>(v => v == 5), It.Is<VersionOptions>(v => !v.IsDraftRequired))).Returns(publishedItem5);

            _contentManager.Setup(m => m.GetItemMetadata(It.Is<IContent>(c => c.Id == 1))).Returns(new ContentItemMetadata { Identity = _testItemIdentity1 });
            _contentManager.Setup(m => m.GetItemMetadata(It.Is<IContent>(c => c.Id == 5))).Returns(new ContentItemMetadata { Identity = _testItemIdentity5 });

            _contentManager.Setup(m => m.New(It.IsAny<string>())).Returns(draftItem5);

            _contentManager.Setup(m => m.ResolveIdentity(It.Is<ContentIdentity>(id => id.Get("ItemId") == "1"))).Returns(publishedItem);
        }
コード例 #6
0
 public void Store(string id, ContentItem item) {
     var contentIdentity = new ContentIdentity(id);
     if (_dictionary.ContainsKey(contentIdentity)) {
         _dictionary.Remove(contentIdentity);
     }
     _dictionary.Add(contentIdentity, item);
 }
コード例 #7
0
        /// <summary>
        /// Called by the framework when importing a game asset. This is the method called by XNA when
        /// an asset is to be imported into an object that can be recognized by the Content Pipeline.
        /// </summary>
        /// <param name="filename">Name of a game asset file.</param>
        /// <param name="context">
        /// Contains information for importing a game asset, such as a logger interface.
        /// </param>
        /// <returns>Resulting game asset.</returns>
        public override ThemeContent Import(string filename, ContentImporterContext context)
        {
            var description = XDocument.Load(filename, LoadOptions.SetLineInfo);
            var identity    = new ContentIdentity(filename);

            return(new ThemeContent(identity, description));
        }
コード例 #8
0
ファイル: ModelProcessor.cs プロジェクト: Breadmouth/Gravitas
        public override ModelContent Process(NodeContent input, ContentProcessorContext context)
        {
            _identity = input.Identity;
            _logger   = context.Logger;

            // Gather all the nodes in tree traversal order.
            var nodes = input.AsEnumerable().SelectDeep(n => n.Children).ToList();

            var meshes            = nodes.FindAll(n => n is MeshContent).Cast <MeshContent>().ToList();
            var geometries        = meshes.SelectMany(m => m.Geometry).ToList();
            var distinctMaterials = geometries.Select(g => g.Material).Distinct().ToList();

            // Loop through all distinct materials, passing them through the conversion method
            // only once, and then processing all geometries using that material.
            foreach (var inputMaterial in distinctMaterials)
            {
                var geomsWithMaterial = geometries.Where(g => g.Material == inputMaterial).ToList();
                var material          = ConvertMaterial(inputMaterial, context);

                ProcessGeometryUsingMaterial(material, geomsWithMaterial, context);
            }

            var boneList = new List <ModelBoneContent>();
            var meshList = new List <ModelMeshContent>();
            var rootNode = ProcessNode(input, null, boneList, meshList, context);

            return(new ModelContent(rootNode, boneList, meshList));
        }
コード例 #9
0
        public override void LogWarning(string helpLink, ContentIdentity contentIdentity, string message, params object[] messageArgs)
        {
            var msg      = string.Format(message, messageArgs);
            var fileName = GetCurrentFilename(contentIdentity);

            Console.WriteLine("{0}: {1}", fileName, msg);
        }
コード例 #10
0
        private void ThrowParserException(ErrorEventArgs e, FileInfo info)
        {
            string          identifier      = string.Format("{0},{1}", e.Position.Line + 1, e.Position.Column + 1);
            ContentIdentity contentIdentity = new ContentIdentity(info.FullName, ImporterName, identifier);

            throw new InvalidContentException(e.Message, contentIdentity);
        }
コード例 #11
0
        public override void LogWarning(
            string helpLink, ContentIdentity contentIdentity, string message, params object[] messageArgs)
        {
            var warning = string.Empty;

            if (contentIdentity != null && !string.IsNullOrEmpty(contentIdentity.SourceFilename))
            {
                warning = contentIdentity.SourceFilename;
                if (!string.IsNullOrEmpty(contentIdentity.FragmentIdentifier))
                {
                    warning += "(" + contentIdentity.FragmentIdentifier + ")";
                }
                warning += ": ";
            }

            if (messageArgs != null && messageArgs.Length != 0)
            {
                warning += string.Format(message, messageArgs);
            }
            else if (!string.IsNullOrEmpty(message))
            {
                warning += message;
            }

            Console.WriteLine(warning);
        }
コード例 #12
0
        protected override void Importing(CommonPart part, ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "Owner", owner => {
                var contentIdentity = new ContentIdentity(owner);

                // use the super user if the referenced one doesn't exist;
                part.Owner =
                    _membershipService.GetUser(contentIdentity.Get("User.UserName"))
                    ?? _membershipService.GetUser(Services.WorkContext.CurrentSite.SuperUser);
            });

            context.ImportAttribute(part.PartDefinition.Name, "Container", container =>
                                    part.Container = context.GetItemFromSession(container)
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "CreatedUtc", createdUtc =>
                                    part.CreatedUtc = XmlConvert.ToDateTime(createdUtc, XmlDateTimeSerializationMode.Utc)
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "PublishedUtc", publishedUtc =>
                                    part.PublishedUtc = XmlConvert.ToDateTime(publishedUtc, XmlDateTimeSerializationMode.Utc)
                                    );

            context.ImportAttribute(part.PartDefinition.Name, "ModifiedUtc", modifiedUtc =>
                                    part.ModifiedUtc = XmlConvert.ToDateTime(modifiedUtc, XmlDateTimeSerializationMode.Utc)
                                    );
        }
コード例 #13
0
        public override void LogWarning(string helpLink, ContentIdentity contentIdentity, string message, params object[] messageArgs)
        {
            var warning = new StringBuilder();

            if (!string.IsNullOrEmpty(contentIdentity?.SourceFilename))
            {
                warning.Append(contentIdentity.SourceFilename);
                if (!string.IsNullOrEmpty(contentIdentity.FragmentIdentifier))
                {
                    warning.Append(" (");
                    warning.Append(contentIdentity.FragmentIdentifier);
                    warning.Append(")");
                }

                warning.Append(": ");
            }

            if (messageArgs != null && messageArgs.Length > 0)
            {
                warning.AppendFormat(CultureInfo.InvariantCulture, message, messageArgs);
            }
            else
            {
                warning.Append(message);
            }

            _outputService.WriteLine(warning.ToString());
        }
コード例 #14
0
        /// <summary>
        /// Converts a DigitalRune <see cref="Texture"/> to an XNA <see cref="TextureContent"/>.
        /// </summary>
        /// <param name="texture">The <see cref="Texture"/>.</param>
        /// <param name="identity">The content identity.</param>
        /// <returns>The <see cref="TextureContent"/>.</returns>
        public static TextureContent ToContent(Texture texture, ContentIdentity identity)
        {
            var description = texture.Description;

            switch (description.Dimension)
            {
            case TextureDimension.Texture1D:
            case TextureDimension.Texture2D:
            {
                var textureContent = new Texture2DContent {
                    Identity = identity
                };
                for (int mipIndex = 0; mipIndex < description.MipLevels; mipIndex++)
                {
                    var image = texture.Images[texture.GetImageIndex(mipIndex, 0, 0)];
                    textureContent.Mipmaps.Add(ToContent(image));
                }

                return(textureContent);
            }

            case TextureDimension.TextureCube:
            {
                var textureContent = new TextureCubeContent {
                    Identity = identity
                };
                for (int faceIndex = 0; faceIndex < 6; faceIndex++)
                {
                    for (int mipIndex = 0; mipIndex < description.MipLevels; mipIndex++)
                    {
                        var image = texture.Images[texture.GetImageIndex(mipIndex, faceIndex, 0)];
                        textureContent.Faces[faceIndex].Add(ToContent(image));
                    }
                }

                return(textureContent);
            }

            case TextureDimension.Texture3D:
            {
                var textureContent = new Texture3DContent {
                    Identity = identity
                };
                for (int zIndex = 0; zIndex < description.Depth; zIndex++)
                {
                    textureContent.Faces.Add(new MipmapChain());
                    for (int mipIndex = 0; mipIndex < description.MipLevels; mipIndex++)
                    {
                        var image = texture.Images[texture.GetImageIndex(mipIndex, 0, zIndex)];
                        textureContent.Faces[zIndex].Add(ToContent(image));
                    }
                }

                return(textureContent);
            }
            }

            throw new InvalidOperationException("Invalid texture dimension.");
        }
コード例 #15
0
        public void ContentIdentityCanSeeFullMatchesAreEquivalent()
        {
            var identity1 = new ContentIdentity(@"/foo=bar/bar=baz/glop=glop");
            var identity2 = new ContentIdentity(@"/foo=bar/bar=baz/glop=glop");

            Assert.That(ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(identity1, identity2));
            Assert.That(ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(identity2, identity1));
        }
コード例 #16
0
        public void ContentIdentityCanSeeNonMatchesAreNotEquivalent()
        {
            var identity1 = new ContentIdentity(@"/a=b/foo=baz");
            var identity2 = new ContentIdentity(@"/foo=bar/bar=baz/glop=glop");

            Assert.IsFalse(ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(identity1, identity2));
            Assert.IsFalse(ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(identity2, identity1));
        }
コード例 #17
0
        internal InvalidContentException NewInvalidContentException(Exception innerException, string message, params object[] args)
        {
            var xmlInfo       = (IXmlLineInfo)Xml;
            var lineAndColumn = string.Format("{0},{1}", xmlInfo.LineNumber, xmlInfo.LinePosition);
            var identity      = new ContentIdentity(_filePath, string.Empty, lineAndColumn);

            return(new InvalidContentException(string.Format(message, args), identity, innerException));
        }
コード例 #18
0
        public override void LogWarning(
            string helpLink, ContentIdentity contentIdentity, string message, params object[] messageArgs)
        {
            var msg      = string.Format(message, messageArgs);
            var fileName = GetCurrentFilename(contentIdentity);

            System.Diagnostics.Trace.WriteLine(string.Format("{0}: {1}", fileName, msg), "Warning");
        }
コード例 #19
0
ファイル: TextTool.cs プロジェクト: gburca/DreamBeam
        //		public System.Drawing.Bitmap GetBitmap(int width, int height) {
        //			// TODO:  Add TextTool.GetBitmap implementation
        //			return null;
        //		}
        //
        //		public void Next() {
        //			// TODO:  Add TextTool.Next implementation
        //		}
        //
        //		public void Prev() {
        //			// TODO:  Add TextTool.Prev implementation
        //		}
        //
        //		public void ChangeBGImagePath(string newPath) {
        //			// TODO:  Add TextTool.ChangeBGImagePath implementation
        //		}
        //
        //		public string GetIdentity() {
        //			// TODO:  Add TextTool.GetIdentity implementation
        //			return null;
        //		}

        public override ContentIdentity GetIdentity()
        {
            ContentIdentity ident = new ContentIdentity();

            ident.Type        = (int)ContentType.PlainText;
            ident.Text        = this.Title + "\n\n" + this.GetLyrics(LyricsType.Verse, SongVerseSeparator.OneBlankLine);
            ident.SongStrophe = this.CurrentLyric;
            return(ident);
        }
コード例 #20
0
        public void ContentIdentitiesWithKeysAddedInDifferentOrderAreEqual() {
            var comparer = new ContentIdentity.ContentIdentityEqualityComparer();

            var identity1 = new ContentIdentity("/foo=bar");
            Assert.That(comparer.Equals(identity1, new ContentIdentity(identity1.ToString())));

            var identity2 = new ContentIdentity(@"/foo=bar/abaz=quux\/fr\\ed=foo/yarg=yiu=foo");
            Assert.That(comparer.Equals(identity2, new ContentIdentity(identity2.ToString())));
        }
コード例 #21
0
        // <Data />
        // Import Data
        public void ExecuteRecipeStep(RecipeContext recipeContext)
        {
            if (!String.Equals(recipeContext.RecipeStep.Name, "Data", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            var importContentSession = new ImportContentSession(_orchardServices.ContentManager);

            // Populate local dictionary with elements and their ids
            var elementDictionary = CreateElementDictionary(recipeContext.RecipeStep.Step);

            //Populate import session with all identities to be imported
            foreach (var identity in elementDictionary.Keys)
            {
                importContentSession.Set(identity.ToString(), elementDictionary[identity].Name.LocalName);
            }

            //Determine if the import is to be batched in multiple transactions
            var startIndex = 0;
            int batchSize  = GetBatchSizeForDataStep(recipeContext.RecipeStep.Step);

            //Run the import
            ContentIdentity nextIdentity = null;

            try {
                while (startIndex < elementDictionary.Count)
                {
                    importContentSession.InitializeBatch(startIndex, batchSize);

                    //the session determines which items are included in the current batch
                    //so that dependencies can be managed within the same transaction
                    nextIdentity = importContentSession.GetNextInBatch();
                    while (nextIdentity != null)
                    {
                        _orchardServices.ContentManager.Import(elementDictionary[nextIdentity], importContentSession);
                        nextIdentity = importContentSession.GetNextInBatch();
                    }

                    startIndex += batchSize;

                    //Create a new transaction for each batch
                    if (startIndex < elementDictionary.Count)
                    {
                        _orchardServices.ContentManager.Clear();
                        _transactionManager.RequireNew();
                    }
                }
            }
            catch (Exception) {
                //Ensure a failed batch is rolled back
                _transactionManager.Cancel();
                throw;
            }

            recipeContext.Executed = true;
        }
コード例 #22
0
        protected override FragmentContent CreateContent(FragmentParser parser, ContentIdentity identity)
        {
            FragmentNode fragmentNode = parser.Parse();

            return(new FragmentContent
            {
                FragmentNode = fragmentNode
            });
        }
コード例 #23
0
ファイル: Bible.cs プロジェクト: gburca/DreamBeam
        //		public string GetIdentity() {
        //			return this.bible.version + "\t" + this.verseIdx + " DEBUG: " + this.bible[this.verseIdx].t;
        //		}

        public ContentIdentity GetIdentity()
        {
            ContentIdentity ident = new ContentIdentity();

            ident.Type        = (int)ContentType.BibleVerseIdx;
            ident.BibleTransl = bible.version;
            ident.VerseIdx    = verseIdx;
            return(ident);
        }
コード例 #24
0
        public IdentityResolverSelectorResult GetResolver(ContentIdentity contentIdentity) {
            if (contentIdentity.Has("Layer.LayerName")) {
                return new IdentityResolverSelectorResult {
                    Priority = 0,
                    Resolve = ResolveIdentity
                };
            }

            return null;
        }
        public IdentityResolverSelectorResult GetResolver(ContentIdentity contentIdentity) {
            if (contentIdentity.Has("package-version-id")) {
                return new IdentityResolverSelectorResult {
                    Priority = 0,
                    Resolve = ResolveIdentity
                };
            }

            return null;
        }
コード例 #26
0
        public void ContentIdentitiesAreEncodedWhenOutput() {
            var identity1 = new ContentIdentity("/foo=bar");
            Assert.That(identity1.ToString(), Is.EqualTo("/foo=bar"));

            var identity2 = new ContentIdentity(@"/foo=bar/abaz=quux\/fr\\ed=foo/yarg=yiu=foo");
            Assert.That(identity2.Get("foo"), Is.EqualTo("bar"));
            Assert.That(identity2.Get("abaz"), Is.EqualTo(@"quux/fr\ed=foo"));
            Assert.That(identity2.Get("yarg"), Is.EqualTo("yiu=foo"));
            Assert.That(identity2.ToString(), Is.EqualTo(@"/abaz=quux\/fr\\ed=foo/foo=bar/yarg=yiu=foo"));
        }
コード例 #27
0
        public override void LogWarning(string helpLink, ContentIdentity contentIdentity, string message, params object[] messageArgs)
        {
            string a = "";

            for (int i = 0; i < messageArgs.Length; i++)
            {
                a += messageArgs[i] + " ";
            }
            Console.WriteLine("XNB Converter > [WARNING]" + message + " " + a);
        }
コード例 #28
0
        public IdentityResolverSelectorResult GetResolver(ContentIdentity contentIdentity) {
            if (contentIdentity.Has("Identifier")) {
                return new IdentityResolverSelectorResult {
                    Priority = 5,
                    Resolve = ResolveIdentity
                };
            }

            return null;
        }
コード例 #29
0
        public void ContentIdentityParsesIdentities() {
            var identity1 = new ContentIdentity("/foo=bar");
            Assert.That(identity1.Get("foo"), Is.EqualTo("bar"));

            var identity2 = new ContentIdentity("/foo=");
            Assert.That(identity2.Get("foo"), Is.EqualTo(String.Empty));

            var identity3 = new ContentIdentity("foo");
            Assert.That(identity3.Get("foo"), Is.Null);
        }
コード例 #30
0
        public void TestInit()
        {
            _testItemIdentity1 = new ContentIdentity("/ItemId=1");
            _testItemIdentity2 = new ContentIdentity("/ItemId=2");
            _testItemIdentity3 = new ContentIdentity("/ItemId=3");
            _testItemIdentity4 = new ContentIdentity("/ItemId=4");
            _testItemIdentity5 = new ContentIdentity("/ItemId=5");
            var draftItem = new ContentItem {
                VersionRecord = new ContentItemVersionRecord {
                    Id = 1234, Published = false, Latest = true, ContentItemRecord = new ContentItemRecord {
                        Id = 1
                    }
                }
            };
            var publishedItem = new ContentItem {
                VersionRecord = new ContentItemVersionRecord {
                    Id = 1234, Published = true, Latest = true, ContentItemRecord = new ContentItemRecord {
                        Id = 1
                    }
                }
            };

            var draftItem5 = new ContentItem {
                VersionRecord = new ContentItemVersionRecord {
                    Id = 1234, Published = false, Latest = true, ContentItemRecord = new ContentItemRecord {
                        Id = 5
                    }
                }
            };
            var publishedItem5 = new ContentItem {
                VersionRecord = new ContentItemVersionRecord {
                    Id = 1234, Published = true, Latest = true, ContentItemRecord = new ContentItemRecord {
                        Id = 5
                    }
                }
            };

            _contentManager = new Mock <IContentManager>();
            _contentManager.Setup(m => m.Get(It.Is <int>(v => v == 1), It.Is <VersionOptions>(v => v.IsDraftRequired))).Returns(draftItem);
            _contentManager.Setup(m => m.Get(It.Is <int>(v => v == 1), It.Is <VersionOptions>(v => !v.IsDraftRequired))).Returns(publishedItem);

            _contentManager.Setup(m => m.Get(It.Is <int>(v => v == 5), It.Is <VersionOptions>(v => v.IsDraftRequired))).Returns(draftItem5);
            _contentManager.Setup(m => m.Get(It.Is <int>(v => v == 5), It.Is <VersionOptions>(v => !v.IsDraftRequired))).Returns(publishedItem5);

            _contentManager.Setup(m => m.GetItemMetadata(It.Is <IContent>(c => c.Id == 1))).Returns(new ContentItemMetadata {
                Identity = _testItemIdentity1
            });
            _contentManager.Setup(m => m.GetItemMetadata(It.Is <IContent>(c => c.Id == 5))).Returns(new ContentItemMetadata {
                Identity = _testItemIdentity5
            });

            _contentManager.Setup(m => m.New(It.IsAny <string>())).Returns(draftItem5);

            _contentManager.Setup(m => m.ResolveIdentity(It.Is <ContentIdentity>(id => id.Get("ItemId") == "1"))).Returns(publishedItem);
        }
コード例 #31
0
        internal static FragmentSource GetFragmentSource(string path, ContentIdentity identity)
        {
            const string prefix = "library:";

            if (path.StartsWith(prefix))
            {
                string resourceName = path.Substring(prefix.Length);
                return(new EmbeddedFragmentSource("Library." + resourceName + ".fragment"));
            }
            return(new FileFragmentSource(path, identity));
        }
コード例 #32
0
        /// <summary>
        /// The main Process method converts an intermediate format content pipeline
        /// NodeContent tree to a ModelContent object with embedded animation data.
        /// </summary>
        public override ModelContent Process(NodeContent input,
                                             ContentProcessorContext context)
        {
            rootIdentity = input.Identity;

            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));
            }

            // Convert animation data to our runtime format.
            Dictionary <string, AnimationClip> animationClips;

            animationClips = ProcessAnimations(skeleton.Animations, bones);

            // 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(animationClips, bindPose,
                                         inverseBindPose, skeletonHierarchy);

            return(model);
        }
コード例 #33
0
ファイル: DataRecipeHandler.cs プロジェクト: kanujhun/orchard
        private Dictionary<ContentIdentity, XElement> CreateElementDictionary(XElement step) {
            var elementDictionary = new Dictionary<ContentIdentity, XElement>(new ContentIdentity.ContentIdentityEqualityComparer());
            foreach (var element in step.Elements()) {
                if (element.Attribute("Id") == null || string.IsNullOrEmpty(element.Attribute("Id").Value))
                    continue;

                var identity = new ContentIdentity(element.Attribute("Id").Value);
                elementDictionary[identity] = element;
            }
            return elementDictionary;
        }
コード例 #34
0
        private IEnumerable<ContentItem> ResolveIdentity(ContentIdentity identity) {
            var identifier = identity.Get("User.UserName");

            if (identifier == null) {
                return null;
            }

            return _contentManager
                .Query<UserPart, UserPartRecord>()
                .Where(p => p.NormalizedUserName == identifier)
                .List<ContentItem>();
        }
コード例 #35
0
        private IEnumerable<ContentItem> ResolveIdentity(ContentIdentity identity) {
            var identifier = identity.Get("alias");

            if (identifier == null) {
                return null;
            }

            return _contentManager
                .Query<AutoroutePart, AutoroutePartRecord>()
                .Where(p => p.DisplayAlias == identifier)
                .List<ContentItem>();
        }
コード例 #36
0
        public IdentityResolverSelectorResult GetResolver(ContentIdentity contentIdentity)
        {
            if (contentIdentity.Has("Identifier"))
            {
                return(new IdentityResolverSelectorResult {
                    Priority = 5,
                    Resolve = ResolveIdentity
                });
            }

            return(null);
        }
コード例 #37
0
        public void Store(string id, ContentItem item) {
            var contentIdentity = new ContentIdentity(id);
            if (_identities.ContainsKey(contentIdentity)) {
                _identities.Remove(contentIdentity);
                _contentItemIds.Remove(item.Id);
            }
            _identities.Add(contentIdentity, item);

            if (!_contentItemIds.ContainsKey(item.Id)) {
                _contentItemIds.Add(item.Id, contentIdentity);
            }
        }
コード例 #38
0
        public IdentityResolverSelectorResult GetResolver(ContentIdentity contentIdentity)
        {
            if (contentIdentity.Has("User.UserName"))
            {
                return(new IdentityResolverSelectorResult {
                    Priority = 0,
                    Resolve = ResolveIdentity
                });
            }

            return(null);
        }
        private IEnumerable<ContentItem> ResolveIdentity(ContentIdentity identity) {
            var packageVersionId = identity.Get("package-version-id");

            if (packageVersionId == null) {
                return null;
            }

            return _contentManager
                .Query<PackageVersionPart, PackageVersionPartRecord>(VersionOptions.Latest)
                .Where(p => p.PackageVersionId == packageVersionId)
                .List<ContentItem>();
        }
コード例 #40
0
        /// <summary>
        /// Tries to locate the specified file.
        /// </summary>
        /// <param name="path">
        /// The name of the file. May include a relative or absolute path.
        /// </param>
        /// <param name="identity">The content identity.</param>
        /// <returns>The full path and file name.</returns>
        public static string FindFile(string path, ContentIdentity identity)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            // ---- 1. Check whether path is a valid absolute path.
            if (Path.IsPathRooted(path) && File.Exists(path))
            {
                return(Path.GetFullPath(path));
            }

            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }

            // ----- 2. Check whether path is relative to asset.
            string folder = Path.GetDirectoryName(identity.SourceFilename) ?? String.Empty;

            // Try relative path.
            string relativeFilename = Path.Combine(folder, path);

            if (File.Exists(relativeFilename))
            {
                return(Path.GetFullPath(relativeFilename));
            }

            // Try file name only.
            string fileName = Path.GetFileName(path);

            relativeFilename = Path.Combine(folder, fileName);
            if (File.Exists(relativeFilename))
            {
                return(Path.GetFullPath(relativeFilename));
            }

            // ----- 3. Check whether path is relative to the current directory.
            if (File.Exists(path))
            {
                return(Path.GetFullPath(path));
            }

            if (File.Exists(fileName))
            {
                return(Path.GetFullPath(fileName));
            }

            string message = String.Format(CultureInfo.InvariantCulture, "File \"{0}\" not found.", path);

            throw new InvalidContentException(message, identity);
        }
コード例 #41
0
        public IdentityResolverSelectorResult GetResolver(ContentIdentity contentIdentity)
        {
            if (contentIdentity.Has("package-version-id"))
            {
                return(new IdentityResolverSelectorResult {
                    Priority = 0,
                    Resolve = ResolveIdentity
                });
            }

            return(null);
        }
コード例 #42
0
        public void ContentIdentitiesWithKeysAddedInDifferentOrderAreEqual()
        {
            var comparer = new ContentIdentity.ContentIdentityEqualityComparer();

            var identity1 = new ContentIdentity("/foo=bar");

            Assert.That(comparer.Equals(identity1, new ContentIdentity(identity1.ToString())));

            var identity2 = new ContentIdentity(@"/foo=bar/abaz=quux\/fr\\ed=foo/yarg=yiu=foo");

            Assert.That(comparer.Equals(identity2, new ContentIdentity(identity2.ToString())));
        }
コード例 #43
0
        /// <summary>
        /// Called by the framework when importing a game asset. This is the method called by XNA when
        /// an asset is to be imported into an object that can be recognized by the Content Pipeline.
        /// </summary>
        /// <param name="filename">Name of a game asset file.</param>
        /// <param name="context">
        /// Contains information for importing a game asset, such as a logger interface.
        /// </param>
        /// <returns>Resulting game asset.</returns>
        public override DRMaterialContent Import(string filename, ContentImporterContext context)
        {
            string name       = Path.GetFileNameWithoutExtension(filename);
            var    identity   = new ContentIdentity(filename);
            var    definition = XDocument.Load(filename, LoadOptions.SetLineInfo);

            return(new DRMaterialContent
            {
                Name = name,
                Identity = identity,
                Definition = definition
            });
        }
コード例 #44
0
        public void ContentIdentitiesAreEncodedWhenOutput()
        {
            var identity1 = new ContentIdentity("/foo=bar");

            Assert.That(identity1.ToString(), Is.EqualTo("/foo=bar"));

            var identity2 = new ContentIdentity(@"/foo=bar/abaz=quux\/fr\\ed=foo/yarg=yiu=foo");

            Assert.That(identity2.Get("foo"), Is.EqualTo("bar"));
            Assert.That(identity2.Get("abaz"), Is.EqualTo(@"quux/fr\ed=foo"));
            Assert.That(identity2.Get("yarg"), Is.EqualTo("yiu=foo"));
            Assert.That(identity2.ToString(), Is.EqualTo(@"/foo=bar/abaz=quux\/fr\\ed=foo/yarg=yiu=foo"));
        }
コード例 #45
0
        private IEnumerable<ContentItem> ResolveIdentity(ContentIdentity identity) {
            var identifier = identity.Get("Layer.LayerName");

            if (identifier == null) {
                return null;
            }

            return _contentManager
                .Query<LayerPart, LayerPartRecord>()
                .Where(p => p.Name == identifier)
                .List<ContentItem>()
                .Where(c => ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(
                    identity, _contentManager.GetItemMetadata(c).Identity));
        }
コード例 #46
0
        public ContentItem Get(string id) {
            var contentIdentity = new ContentIdentity(id);

            // lookup in local cache
            if (_identities.ContainsKey(contentIdentity))
                return _identities[contentIdentity];

            // no result ? then check if there are some more content items to load from the db

            if(_lastIndex == int.MaxValue) {
                // everything has already been loaded from db
                return null;
            }

            var equalityComparer = new ContentIdentity.ContentIdentityEqualityComparer();
            IEnumerable<ContentItem> block;
            
            // load identities in blocks
            while ((block = _contentManager.HqlQuery()
                .ForVersion(VersionOptions.Latest)
                .OrderBy(x => x.ContentItemVersion(), x => x.Asc("Id"))
                .Slice(_lastIndex, BulkPage)).Any()) {

                    foreach (var item in block) {
                        _lastIndex++;

                        // ignore content item if it has already been imported
                        if (_contentItemIds.ContainsKey(item.Id)) {
                            continue;
                        }

                        var identity = _contentManager.GetItemMetadata(item).Identity;

                        // ignore content item if the same identity is already present
                        if (_identities.ContainsKey(identity)) {
                            continue;
                        }

                        _identities.Add(identity, item);
                        _contentItemIds.Add(item.Id, identity);
                        
                        if (equalityComparer.Equals(identity, contentIdentity)) {
                            return item;
                        }
                    }
            }

            _lastIndex = int.MaxValue;
            return null;
        }
コード例 #47
0
        private IEnumerable<ContentItem> ResolveIdentity(ContentIdentity identity) {
            var identifier = identity.Get("Identifier");

            if (identifier == null) {
                return null;
            }

            return _contentManager
                .Query<IdentityPart, IdentityPartRecord>(VersionOptions.Latest)
                .Where(p => p.Identifier == identifier)
                .List<ContentItem>()
                .Where(c => ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(
                    identity, _contentManager.GetItemMetadata(c).Identity));
        }
コード例 #48
0
        private IEnumerable<ContentItem> ResolveIdentity(ContentIdentity identity) {
            var identifier = identity.Get("User.UserName");

            if (identifier == null) {
                return null;
            }

            var comparer = new ContentIdentity.ContentIdentityEqualityComparer();
            return _contentManager
                .Query<UserPart, UserPartRecord>()
                .Where(p => p.UserName == identifier)
                .List<ContentItem>()
                .Where(c => comparer.Equals(identity, _contentManager.GetItemMetadata(c).Identity));
        }
コード例 #49
0
        public ContentItem Get(string id) {
            var contentIdentity = new ContentIdentity(id);

            if (_dictionary.ContainsKey(contentIdentity))
                return _dictionary[contentIdentity];

            foreach (var item in _contentManager.Query(VersionOptions.Latest).List()) {
                var identity = _contentManager.GetItemMetadata(item).Identity;
                var equalityComparer = new ContentIdentity.ContentIdentityEqualityComparer();
                if (equalityComparer.Equals(identity, contentIdentity)) {
                    _dictionary.Add(identity, item);
                    return item;
                }
            }

            return null;
        }
コード例 #50
0
 public ContentItemMetadata() {
     Identity = new ContentIdentity();
 }
コード例 #51
0
 public void Set(string id, string contentType) {
     var contentIdentity = new ContentIdentity(id);
     _contentTypes[contentIdentity] = contentType;
 }
コード例 #52
0
 public override void LogWarning(string helpLink, ContentIdentity contentIdentity, string message, params object[] messageArgs)
 {
     var msg = string.Format(message, messageArgs);
     var fileName = GetCurrentFilename(contentIdentity);
     Console.WriteLine("{0}: {1}", fileName, msg);
 }
コード例 #53
0
        public ContentItem Get(string id, string contentTypeHint = null) {
            var contentIdentity = new ContentIdentity(id);

            // lookup in local cache
            if (_identities.ContainsKey(contentIdentity)) {
                var result = _contentManager.Get(_identities[contentIdentity], VersionOptions.DraftRequired);

                // if two identities are conflicting, then ensure that there types are the same
                // e.g., importing a blog as home page (alias=) and the current home page is a page, the blog
                // won't be imported, and blog posts will be attached to the page
                if (contentTypeHint == null || result.ContentType == contentTypeHint) {
                    return result;
                }
            }

            // no result ? then check if there are some more content items to load from the db
            if(_lastIndex != int.MaxValue) {
                
                var equalityComparer = new ContentIdentity.ContentIdentityEqualityComparer();
                IEnumerable<ContentItem> block;
            
                // load identities in blocks
                while ((block = _contentManager.HqlQuery()
                    .ForVersion(VersionOptions.Latest)
                    .OrderBy(x => x.ContentItemVersion(), x => x.Asc("Id"))
                    .Slice(_lastIndex, BulkPage)).Any()) {

                        foreach (var item in block) {
                            _lastIndex++;

                            // ignore content item if it has already been imported
                            if (_contentItemIds.ContainsKey(item.Id)) {
                                continue;
                            }

                            var identity = _contentManager.GetItemMetadata(item).Identity;

                            // ignore content item if the same identity is already present
                            if (_identities.ContainsKey(identity)) {
                                continue;
                            }

                            _identities.Add(identity, item.Id);
                            _contentItemIds.Add(item.Id, identity);
                        
                            if (equalityComparer.Equals(identity, contentIdentity)) {
                                return _contentManager.Get(item.Id, VersionOptions.DraftRequired);
                            }
                        }

                    _contentManager.Flush();
                    _contentManager.Clear();
                }
            }

            _lastIndex = int.MaxValue;

            if(!_contentTypes.ContainsKey(contentIdentity)) {
                throw new ArgumentException("Unknown content type for " + id);
                
            }

            var contentItem = _contentManager.Create(_contentTypes[contentIdentity], VersionOptions.Draft);
            _identities[contentIdentity] = contentItem.Id;
            _contentItemIds[contentItem.Id] = contentIdentity;

            return contentItem;
        }
コード例 #54
0
 public void Set(string id, string contentType)
 {
     var contentIdentity = new ContentIdentity(id);
     _contentTypes[contentIdentity] = contentType;
     _allIdentitiesForImport.Add(contentIdentity);
     _allIdentitiesForImportStatus[contentIdentity] = false;
 }
コード例 #55
0
        public ContentItem Get(string id, VersionOptions versionOptions, string contentTypeHint = null)
        {
            var contentIdentity = new ContentIdentity(id);

            // lookup in local cache
            if (_identities.ContainsKey(contentIdentity)) {
                if (_draftVersionRecordIds.ContainsKey(_identities[contentIdentity])) {
                    //draft was previously created. Recall.
                    versionOptions = VersionOptions.VersionRecord(_draftVersionRecordIds[_identities[contentIdentity]]);
                }
                var result = _contentManager.Get(_identities[contentIdentity], versionOptions);

                // if two identities are conflicting, then ensure that there types are the same
                // e.g., importing a blog as home page (alias=) and the current home page is a page, the blog
                // won't be imported, and blog posts will be attached to the page
                if (contentTypeHint == null || result.ContentType == contentTypeHint) {
                    return result;
                }
            }

            ContentItem existingItem  = _contentManager.ResolveIdentity(contentIdentity);

            //ensure we have the correct version
            if (existingItem != null) {
                existingItem = _contentManager.Get(existingItem.Id, versionOptions);
            }

            if (existingItem == null && _identities.ContainsKey(contentIdentity)) {
                existingItem = _contentManager.Get(_identities[contentIdentity], versionOptions);
            }

            if (existingItem != null) {
                _identities[contentIdentity] = existingItem.Id;
                if (versionOptions.IsDraftRequired) {
                    _draftVersionRecordIds[existingItem.Id] = existingItem.VersionRecord.Id;
                }
                return existingItem;
            }

            //create item if not found and draft was requested, or it is found later in the import queue
            if (versionOptions.IsDraftRequired || _allIdentitiesForImportStatus.ContainsKey(contentIdentity)) {
                var contentType = _contentTypes.ContainsKey(contentIdentity) ? _contentTypes[contentIdentity] : contentTypeHint;

                if (!_contentTypes.ContainsKey(contentIdentity)) {
                    throw new ArgumentException("Unknown content type for " + id);
                }

                var contentItem = _contentManager.Create(contentType, VersionOptions.Draft);

                _identities[contentIdentity] = contentItem.Id;

                //store versionrecordid in case a draft is requested again
                _draftVersionRecordIds[contentItem.Id] = contentItem.VersionRecord.Id;

                //add the requested item as a dependency if it is not the currently running item
                if (_allIdentitiesForImportStatus.ContainsKey(contentIdentity) &&
                    !_allIdentitiesForImportStatus[contentIdentity]) {
                    _dependencyIdentities.Enqueue(contentIdentity);
                }

                return contentItem;
            }

            return null;
        }
コード例 #56
0
        private void Replace(ImportSyncAction action, ImportContentSession session)
        {
            // update the identifier on the item in the local instance
            // then let the import continue so the existing item gets paved over
            if (action.Action == "Replace" && !string.IsNullOrWhiteSpace(action.TargetId))
            {
                var item = session.Get(action.TargetId);

                if (item == null)
                {
                    return;
                }

                var newIdentifier = action.Step.Step.Attribute("Id");
                if (newIdentifier == null)
                    return;

                var newIdentity = new ContentIdentity(newIdentifier.Value);
                var existingIdentity = new ContentIdentity(action.TargetId);
                if (!newIdentity.Equals(existingIdentity))
                {
                    Logger.Debug("import - items {0} and {1} have different identifiers", existingIdentity.Get("Identifier"), newIdentity.Get("Identifier"));

                    item.As<IdentityPart>().Identifier = newIdentity.Get("Identifier");
                    session.Store(newIdentity.Get("Identifier"), item);
                }
            }

        }
コード例 #57
0
 public void ContentIdentityCanSeeFullMatchesAreEquivalent() {
     var identity1 = new ContentIdentity(@"/foo=bar/bar=baz/glop=glop");
     var identity2 = new ContentIdentity(@"/foo=bar/bar=baz/glop=glop");
     Assert.That(ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(identity1, identity2));
     Assert.That(ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(identity2, identity1));
 }
コード例 #58
0
 public void ContentIdentityCanSeeNonMatchesAreNotEquivalent() {
     var identity1 = new ContentIdentity(@"/a=b/foo=baz");
     var identity2 = new ContentIdentity(@"/foo=bar/bar=baz/glop=glop");
     Assert.IsFalse(ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(identity1, identity2));
     Assert.IsFalse(ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(identity2, identity1));
 }