当前位置: 首页>>代码示例>>C#>>正文


C# IO.UFile类代码示例

本文整理汇总了C#中SiliconStudio.Core.IO.UFile的典型用法代码示例。如果您正苦于以下问题:C# UFile类的具体用法?C# UFile怎么用?C# UFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UFile类属于SiliconStudio.Core.IO命名空间,在下文中一共展示了UFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestUpdateAssetUrl

        public void TestUpdateAssetUrl()
        {
            var projectDir = new UFile(Path.Combine(Environment.CurrentDirectory, "testxk"));
            
            // Create a project with an asset reference a raw file
            var project = new Package { FullPath = projectDir };
            var assetItem = new AssetItem("test", new AssetObjectTest() { Reference =  new AssetReference<AssetObjectTest>(Guid.Empty, "good/location")});
            project.Assets.Add(assetItem);
            var goodAsset = new AssetObjectTest();
            project.Assets.Add(new AssetItem("good/location", goodAsset));

            // Add the project to the session to make sure analysis will run correctly
            var session = new PackageSession(project);

            // Create a session with this project
            var analysis = new PackageAnalysis(project,
                new PackageAnalysisParameters()
                    {
                        IsProcessingAssetReferences = true,
                        ConvertUPathTo = UPathType.Absolute,
                        IsProcessingUPaths = true
                    });
            var result = analysis.Run();
            Assert.IsFalse(result.HasErrors);
            Assert.AreEqual(1, result.Messages.Count);
            Assert.IsTrue(result.Messages[0].ToString().Contains("changed"));

            var asset = (AssetObjectTest)assetItem.Asset;
            Assert.AreEqual(goodAsset.Id, asset.Reference.Id);
            Assert.AreEqual("good/location", asset.Reference.Location);
        }
开发者ID:cg123,项目名称:xenko,代码行数:31,代码来源:TestAssetReferenceAnalysis.cs

示例2: AssetToImport

 /// <summary>
 /// Initializes a new instance of the <see cref="AssetToImport"/> class.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <exception cref="System.ArgumentNullException">file</exception>
 internal AssetToImport(UFile file)
 {
     if (file == null) throw new ArgumentNullException("file");
     this.file = file;
     ByImporters = new List<AssetToImportByImporter>();
     Enabled = true;
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:12,代码来源:AssetToImport.cs

示例3: GetAbsolutePath

 /// <summary>
 /// Returns the absolute path on the disk of an <see cref="UFile"/> that is relative to the asset location.
 /// </summary>
 /// <param name="assetItem">The asset on which is based the relative path.</param>
 /// <param name="relativePath">The path relative to the asset path that must be converted to an absolute path.</param>
 /// <returns>The absolute path on the disk of the <see cref="relativePath"/> argument.</returns>
 /// <exception cref="ArgumentException">The <see cref="relativePath"/> argument is a null or empty <see cref="UFile"/>.</exception>
 protected static UFile GetAbsolutePath(AssetItem assetItem, UFile relativePath)
 {
     if (string.IsNullOrEmpty(relativePath)) throw new ArgumentException("The relativePath argument is null or empty");
     var assetDirectory = assetItem.FullPath.GetParent();
     var assetSource = UPath.Combine(assetDirectory, relativePath);
     return assetSource;
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:14,代码来源:AssetCompilerBase.cs

示例4: ImportScene

        public static EntityHierarchyData ImportScene(UFile sourceUrl, EntityGroupAssetBase source, Guid sourceRootEntity)
        {
            if (source == null) throw new ArgumentNullException("source");

            // Extract the scene starting from given root
            var newAsset = ExtractSceneClone(source, sourceRootEntity);

            // Generate entity mapping
            var reverseEntityMapping = new Dictionary<Guid, Guid>();
            foreach (var entityDesign in newAsset.Hierarchy.Entities)
            {
                // Generate new Id
                var newEntityId = Guid.NewGuid();

                // Update mappings
                reverseEntityMapping.Add(entityDesign.Entity.Id, newEntityId);

                // Update entity with new id
                entityDesign.Entity.Id = newEntityId;
            }

            // Rewrite entity references
            // Should we nullify invalid references?
            EntityAnalysis.RemapEntitiesId(newAsset.Hierarchy, reverseEntityMapping);

            return newAsset.Hierarchy;
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:27,代码来源:EntityGroupAssetOperations.cs

示例5: Load

 public object Load(Stream stream, UFile filePath, ILogger log, out bool aliasOccurred, out Dictionary<YamlAssetPath, OverrideType> overrides)
 {
     PropertyContainer properties;
     var result = AssetYamlSerializer.Default.Deserialize(stream, null, log != null ? new SerializerContextSettings { Logger = log } : null, out aliasOccurred, out properties);
     properties.TryGetValue(AssetObjectSerializerBackend.OverrideDictionaryKey, out overrides);
     return result;
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:YamlAssetSerializer.cs

示例6: Load

        public object Load(Stream stream, UFile filePath, ILogger log, out bool aliasOccurred, out Dictionary<YamlAssetPath, OverrideType> overrides)
        {
            aliasOccurred = false;

            var assetFileExtension = filePath.GetFileExtension().ToLowerInvariant();
            var type = AssetRegistry.GetAssetTypeFromFileExtension(assetFileExtension);
            var asset = (SourceCodeAsset)Activator.CreateInstance(type);

            var textAccessor = asset.TextAccessor as SourceCodeAsset.DefaultTextAccessor;
            if (textAccessor != null)
            {
                // Don't load the file if we have the file path
                textAccessor.FilePath = filePath;

                // Set the assets text if it loaded from an in-memory version
                // TODO: Propagate dirtiness?
                if (stream is MemoryStream)
                {
                    var reader = new StreamReader(stream, Encoding.UTF8);
                    textAccessor.Set(reader.ReadToEnd());
                }
            }

            // No override in source code assets
            overrides = new Dictionary<YamlAssetPath, OverrideType>();

            return asset;
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:28,代码来源:SourceCodeAssetSerializer.cs

示例7: IsSupportingFile

        public static bool IsSupportingFile(this IAssetImporter importer, UFile file)
        {
            if (file == null) throw new ArgumentNullException("file");
            if (file.GetFileExtension() == null) return false;

            return FileUtility.GetFileExtensionsAsSet(importer.SupportedFileExtensions).Contains(file.GetFileExtension());
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:7,代码来源:IAssetImporter.cs

示例8: DoCommandOverride

        protected override Task<ResultStatus> DoCommandOverride(ICommandContext commandContext)
        {
            // This path for effects xml is now part of this tool, but it should be done in a separate exporter?
            using (var inputStream = File.OpenRead(SourcePath))
            using (var outputStream = AssetManager.FileProvider.OpenStream(Location, VirtualFileMode.Create, VirtualFileAccess.Write))
            {
                inputStream.CopyTo(outputStream);

                var objectURL = new ObjectUrl(UrlType.ContentLink, Location);

                if (DisableCompression)
                    commandContext.AddTag(objectURL, DisableCompressionSymbol);
            }

            if (SaveSourcePath)
            {
                // store absolute path to source
                // TODO: the "/path" is hardcoded, used in EffectSystem and ShaderSourceManager. Find a place to share this correctly.
                var pathLocation = new UFile(Location.FullPath + "/path");
                using (var outputStreamPath = AssetManager.FileProvider.OpenStream(pathLocation, VirtualFileMode.Create, VirtualFileAccess.Write))
                {
                    using (var sw = new StreamWriter(outputStreamPath))
                    {
                        sw.Write(SourcePath.FullPath);
                    }
                }
            }

            return Task.FromResult(ResultStatus.Successful);
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:30,代码来源:ImportStreamCommand.cs

示例9: SettingsEntry

 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsEntry"/> class.
 /// </summary>
 /// <param name="profile">The profile this <see cref="SettingsEntry"/>belongs to.</param>
 /// <param name="name">The name associated to this <see cref="SettingsEntry"/>.</param>
 protected SettingsEntry(SettingsProfile profile, UFile name)
 {
     if (profile == null) throw new ArgumentNullException("profile");
     if (name == null) throw new ArgumentNullException("name");
     Profile = profile;
     Name = name;
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:12,代码来源:SettingsEntry.cs

示例10: IsSupportingFile

        public virtual bool IsSupportingFile(string filePath)
        {
            if (filePath == null) throw new ArgumentNullException("filePath");
            var file = new UFile(filePath);
            if (file.GetFileExtension() == null) return false;

            return FileUtility.GetFileExtensionsAsSet(SupportedFileExtensions).Contains(file.GetFileExtension());
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:8,代码来源:AssetImporterBase.cs

示例11: SettingsKey

 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsKey"/> class.
 /// </summary>
 /// <param name="name">The name of this settings key. Must be unique amongst the application.</param>
 /// <param name="container">The <see cref="SettingsContainer"/> containing this <see cref="SettingsKey"/>.</param>
 /// <param name="defaultValue">The default value associated to this settings key.</param>
 protected SettingsKey(UFile name, SettingsContainer container, object defaultValue)
 {
     Name = name;
     DisplayName = name;
     DefaultObjectValue = defaultValue;
     Container = container;
     Container.RegisterSettingsKey(name, defaultValue, this);
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:14,代码来源:SettingsKey.cs

示例12: PackageLoadingAssetFile

        /// <summary>
        /// Initializes a new instance of the <see cref="PackageLoadingAssetFile" /> class.
        /// </summary>
        /// <param name="package">The package this asset will be part of.</param>
        /// <param name="filePath">The relative file path (from default asset folder).</param>
        /// <param name="sourceFolder">The source folder (optional, can be null).</param>
        /// <exception cref="System.ArgumentException">filePath must be relative</exception>
        public PackageLoadingAssetFile(Package package, UFile filePath, UDirectory sourceFolder)
        {
            if (filePath.IsAbsolute)
                throw new ArgumentException("filePath must be relative", filePath);

            SourceFolder = UPath.Combine(package.RootDirectory, sourceFolder ?? package.GetDefaultAssetFolder());
            FilePath = UPath.Combine(SourceFolder, filePath);
        }
开发者ID:robterrell,项目名称:paradox,代码行数:15,代码来源:PackageLoadingAssetFile.cs

示例13: SettingsKey

 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsKey"/> class.
 /// </summary>
 /// <param name="name">The name of this settings key. Must be unique amongst the application.</param>
 /// <param name="group">The <see cref="SettingsGroup"/> containing this <see cref="SettingsKey"/>.</param>
 /// <param name="defaultValueCallback">A function that returns the default value associated to this settings key.</param>
 protected SettingsKey(UFile name, SettingsGroup group, Func<object> defaultValueCallback)
 {
     Name = name;
     DisplayName = name;
     DefaultObjectValueCallback = defaultValueCallback;
     Group = group;
     Group.RegisterSettingsKey(name, defaultValueCallback(), this);
 }
开发者ID:robterrell,项目名称:paradox,代码行数:14,代码来源:SettingsKey.cs

示例14: Import

        /// <summary>
        /// Imports the model.
        /// </summary>
        /// <param name="localPath">The path of the asset.</param>
        /// <param name="importParameters">The parameters used to import the model.</param>
        /// <returns>A collection of assets.</returns>
        public override IEnumerable<AssetItem> Import(UFile localPath, AssetImporterParameters importParameters)
        {
            var rawAssetReferences = new List<AssetItem>(); // the asset references without subdirectory path

            var entityInfo = GetEntityInfo(localPath, importParameters.Logger);

            //var isImportingEntity = importParameters.IsTypeSelectedForOutput<EntityAsset>();

            var isImportingModel = importParameters.IsTypeSelectedForOutput<ModelAsset>();

            var isImportingMaterial = importParameters.IsTypeSelectedForOutput<MaterialAsset>() ||
                                      isImportingModel;

            var isImportingTexture = importParameters.IsTypeSelectedForOutput<TextureAsset>() ||
                                     isImportingMaterial;

            // 1. Textures
            if (isImportingTexture)
            {
                ImportTextures(entityInfo.TextureDependencies, rawAssetReferences);
            }

            // 2. Skeleton
            AssetItem skeletonAsset = null;
            if (importParameters.IsTypeSelectedForOutput<SkeletonAsset>())
            {
                skeletonAsset = ImportSkeleton(rawAssetReferences, localPath, localPath, entityInfo);
            }

            // 3. Animation
            if (importParameters.IsTypeSelectedForOutput<AnimationAsset>())
            {
                ImportAnimation(rawAssetReferences, localPath, entityInfo.AnimationNodes, isImportingModel, skeletonAsset);
            }

            // 4. Materials
            if (isImportingMaterial)
            {
                ImportMaterials(rawAssetReferences, entityInfo.Materials);
            }

            // 5. Model
            if (isImportingModel)
            {
                var modelItem = ImportModel(rawAssetReferences, localPath, localPath, entityInfo, false, skeletonAsset);

                // 5. Entity (currently disabled)
                //if (isImportingEntity)
                //{
                //    var entityAssetItem = ImportEntity(rawAssetReferences, localPath, modelItem);
                //
                //    // Apply EntityAnalysis 
                //    EntityAnalysis.UpdateEntityReferences(((EntityAsset)entityAssetItem.Asset).Hierarchy);
                //}
            }

            return rawAssetReferences;
        }
开发者ID:joewan,项目名称:xenko,代码行数:64,代码来源:ModelAssetImporter.cs

示例15: Import

        public override IEnumerable<AssetItem> Import(UFile rawAssetPath, AssetImporterParameters importParameters)
        {
            var asset = new TextureAsset { Source = rawAssetPath };

            // Creates the url to the texture
            var textureUrl = new UFile(rawAssetPath.GetFileName(), null);

            yield return new AssetItem(textureUrl, asset);
        }
开发者ID:releed,项目名称:paradox,代码行数:9,代码来源:TextureImporter.cs


注:本文中的SiliconStudio.Core.IO.UFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。