本文整理汇总了C#中DataManager.ResolvePath方法的典型用法代码示例。如果您正苦于以下问题:C# DataManager.ResolvePath方法的具体用法?C# DataManager.ResolvePath怎么用?C# DataManager.ResolvePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataManager
的用法示例。
在下文中一共展示了DataManager.ResolvePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
internal void Save(DataManager data)
{
string fullPath = data.ResolvePath(FileName);
// We use the internal list to circumvent ignoring
// items where IsPublic is set to false.
if ( Entries.Count == 0 )
{
if ( File.Exists( fullPath ) )
{
File.Delete( fullPath );
}
}
else
{
System.Security.Principal.WindowsImpersonationContext wi = Impersonation.Impersonate();
FileStream fileStream = FileUtils.OpenForWrite(fullPath);
if ( fileStream != null )
{
try
{
XmlSerializer ser = new XmlSerializer(typeof(DayEntry),Data.NamespaceURI);
using (StreamWriter writer = new StreamWriter(fileStream))
{
ser.Serialize(writer, this);
}
}
catch(Exception e)
{
ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error,e);
}
finally
{
fileStream.Close();
}
}
wi.Undo();
}
}
示例2: Save
internal void Save(DataManager data)
{
FileStream fileStream = FileUtils.OpenForWrite(data.ResolvePath(FileName));
if (fileStream != null)
{
WindowsImpersonationContext wi = Impersonation.Impersonate();
try
{
XmlSerializer ser = new XmlSerializer(typeof (DayExtra), Data.NamespaceURI);
using (StreamWriter writer = new StreamWriter(fileStream))
{
ser.Serialize(writer, this);
}
}
catch (Exception e)
{
ErrorTrace.Trace(TraceLevel.Error, e);
// truncate the file if this fails
fileStream.SetLength(0);
}
finally
{
fileStream.Close();
}
wi.Undo();
}
}
示例3: Load
internal void Load(DataManager data)
{
if ( Loaded )
{
return;
}
lock(entriesLock)
{
if ( Loaded ) //SDH: standard thread-safe double check
{
return;
}
string fullPath = data.ResolvePath(FileName);
FileStream fileStream = FileUtils.OpenForRead(fullPath);
if ( fileStream != null )
{
try
{
XmlSerializer ser = new XmlSerializer(typeof(DayEntry),Data.NamespaceURI);
using (StreamReader reader = new StreamReader(fileStream))
{
//XmlNamespaceUpgradeReader upg = new XmlNamespaceUpgradeReader( reader, "", Data.NamespaceURI );
DayEntry e = (DayEntry)ser.Deserialize(reader);
Entries = e.Entries;
}
}
catch(Exception e)
{
ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error,e);
}
finally
{
fileStream.Close();
}
}
Entries.Sort((left,right) => right.CreatedUtc.CompareTo(left.CreatedUtc));
Loaded = true;
}
}
示例4: Load
internal void Load(DataManager data)
{
if (_loaded)
{
return;
}
if (data.Resolver != null)
{
string fullPath = data.ResolvePath(FileName);
string oldPath = data.ResolvePath(DateLocalTime.ToString("yyyy-MM-dd") + ".dayextra.xml");
if (UpgradeFilesToUtc && File.Exists(oldPath))
{
LoadDayExtra(oldPath);
// backup the old file
try
{
DirectoryInfo backup = new DirectoryInfo(Path.Combine(data.ResolvePath(""), "backup"));
if (!backup.Exists)
{
backup.Create();
}
FileInfo f = new FileInfo(oldPath);
f.MoveTo(Path.Combine(backup.FullName, f.Name));
}
catch (Exception e)
{
ErrorTrace.Trace(TraceLevel.Error, e);
}
// now write the new file
this.Save(data);
}
else if (File.Exists(fullPath))
{
LoadDayExtra(fullPath);
}
}
_loaded = true;
}