當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。