本文整理汇总了C#中SiliconStudio.Core.IO.UFile.GetFullDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# UFile.GetFullDirectory方法的具体用法?C# UFile.GetFullDirectory怎么用?C# UFile.GetFullDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiliconStudio.Core.IO.UFile
的用法示例。
在下文中一共展示了UFile.GetFullDirectory方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindCodeAssetsInProject
public static List<string> FindCodeAssetsInProject(string projectFullPath, out string nameSpace)
{
var realFullPath = new UFile(projectFullPath);
var project = VSProjectHelper.LoadProject(realFullPath);
var dir = new UDirectory(realFullPath.GetFullDirectory());
var nameSpaceProp = project.AllEvaluatedProperties.FirstOrDefault(x => x.Name == "RootNamespace");
nameSpace = nameSpaceProp?.EvaluatedValue ?? string.Empty;
var result = project.Items.Where(x => (x.ItemType == "Compile" || x.ItemType == "None") && string.IsNullOrEmpty(x.GetMetadataValue("AutoGen")))
.Select(x => new UFile(x.EvaluatedInclude)).Where(x => AssetRegistry.IsProjectSourceCodeAssetFileExtension(x.GetFileExtension()))
.Select(projectItem => UPath.Combine(dir, projectItem)).Select(csPath => (string)csPath).ToList();
project.ProjectCollection.UnloadAllProjects();
project.ProjectCollection.Dispose();
return result;
}
示例2: SaveSettingsProfile
/// <summary>
/// Saves the given settings profile to a file at the given path.
/// </summary>
/// <param name="profile">The profile to save.</param>
/// <param name="filePath">The path of the file.</param>
/// <returns><c>true</c> if the file was correctly saved, <c>false</c> otherwise.</returns>
public bool SaveSettingsProfile(SettingsProfile profile, UFile filePath)
{
if (profile == null) throw new ArgumentNullException("profile");
try
{
profile.Saving = true;
Directory.CreateDirectory(filePath.GetFullDirectory());
var settingsFile = new SettingsFile();
EncodeSettings(profile, settingsFile.Settings);
using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Write))
{
YamlSerializer.Serialize(stream, settingsFile);
}
}
catch (Exception e)
{
Logger.Error("Error while saving settings file [{0}]: {1}", e, filePath, e.FormatForReport());
return false;
}
finally
{
profile.Saving = false;
}
return true;
}
示例3: SanityCheck
public static bool SanityCheck(UFile file)
{
var xmlDoc = XDocument.Load(file);
if (xmlDoc.Root == null) return false;
var nameSpace = xmlDoc.Root.Name.Namespace;
var cellMaps = xmlDoc.Descendants(nameSpace + "cellmapNames").Descendants(nameSpace + "value").ToList();
return cellMaps.Select(cellMap => UPath.Combine(file.GetFullDirectory(), new UFile(cellMap.Value))).All(fileName => File.Exists(fileName.ToWindowsPath()));
}
示例4: ParseCellMaps
public static bool ParseCellMaps(UFile file, List<UFile> textures, List<SpriteStudioCell> cells)
{
var xmlDoc = XDocument.Load(file);
if (xmlDoc.Root == null) return false;
var nameSpace = xmlDoc.Root.Name.Namespace;
var cellMaps = xmlDoc.Descendants(nameSpace + "cellmapNames").Descendants(nameSpace + "value");
foreach (var cellMap in cellMaps)
{
var mapFile = UPath.Combine(file.GetFullDirectory(), new UFile(cellMap.Value));
var cellDoc = XDocument.Load(mapFile);
if (cellDoc.Root == null) return false;
var cnameSpace = cellDoc.Root.Name.Namespace;
var cellNodes = cellDoc.Descendants(nameSpace + "cell");
foreach (var cellNode in cellNodes)
{
var cell = new SpriteStudioCell
{
Name = cellNode.Descendants(cnameSpace + "name").First().Value,
TextureIndex = textures.Count
};
var posData = cellNode.Descendants(nameSpace + "pos").First().Value;
var posValues = Regex.Split(posData, "\\s+");
var sizeData = cellNode.Descendants(nameSpace + "size").First().Value;
var sizeValues = Regex.Split(sizeData, "\\s+");
cell.Rectangle = new RectangleF(
float.Parse(posValues[0], CultureInfo.InvariantCulture),
float.Parse(posValues[1], CultureInfo.InvariantCulture),
float.Parse(sizeValues[0], CultureInfo.InvariantCulture),
float.Parse(sizeValues[1], CultureInfo.InvariantCulture));
var pivotData = cellNode.Descendants(nameSpace + "pivot").First().Value;
var pivotValues = Regex.Split(pivotData, "\\s+");
cell.Pivot = new Vector2((float.Parse(pivotValues[0], CultureInfo.InvariantCulture) + 0.5f) * cell.Rectangle.Width, (-float.Parse(pivotValues[1], CultureInfo.InvariantCulture) + 0.5f) * cell.Rectangle.Height);
cells.Add(cell);
}
var textPath = cellDoc.Descendants(nameSpace + "imagePath").First().Value;
textures.Add(UPath.Combine(file.GetFullDirectory(), new UFile(textPath)));
}
return true;
}
示例5: SaveSettingsProfile
/// <summary>
/// Saves the given settings profile to a file at the given path.
/// </summary>
/// <param name="profile">The profile to save.</param>
/// <param name="filePath">The path of the file.</param>
/// <returns><c>true</c> if the file was correctly saved, <c>false</c> otherwise.</returns>
public bool SaveSettingsProfile(SettingsProfile profile, UFile filePath)
{
if (profile == null) throw new ArgumentNullException(nameof(profile));
try
{
profile.Saving = true;
Directory.CreateDirectory(filePath.GetFullDirectory());
var settingsFile = new SettingsFile(profile);
using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Write))
{
SettingsYamlSerializer.Default.Serialize(stream, settingsFile);
}
if (filePath != profile.FilePath)
{
if (File.Exists(profile.FilePath))
{
File.Delete(profile.FilePath);
}
profile.FilePath = filePath;
}
}
catch (Exception e)
{
Logger.Error("Error while saving settings file [{0}]: {1}", e, filePath, e.FormatFull());
return false;
}
finally
{
profile.Saving = false;
}
return true;
}
示例6: SaveSettingsProfile
/// <summary>
/// Saves the given settings profile to a file at the given path.
/// </summary>
/// <param name="profile">The profile to save.</param>
/// <param name="filePath">The path of the file.</param>
/// <returns><c>true</c> if the file was correctly saved, <c>false</c> otherwise.</returns>
public bool SaveSettingsProfile(SettingsProfile profile, UFile filePath)
{
if (profile == null) throw new ArgumentNullException("profile");
try
{
profile.Saving = true;
Directory.CreateDirectory(filePath.GetFullDirectory());
var settingsFile = new SettingsFile();
foreach (var entry in profile.Settings.Values)
{
try
{
// Find key
SettingsKey key;
settingsKeys.TryGetValue(entry.Name, out key);
settingsFile.Settings.Add(entry.Name, entry.GetSerializableValue(key));
}
catch (Exception)
{
}
}
using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Write))
{
YamlSerializer.Serialize(stream, settingsFile);
}
}
catch (Exception e)
{
Logger.Error("Error while saving settings file [{0}]: {1}", e, filePath, e.FormatForReport());
return false;
}
finally
{
profile.Saving = false;
}
return true;
}