本文整理汇总了C#中ResourcePath.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# ResourcePath.Serialize方法的具体用法?C# ResourcePath.Serialize怎么用?C# ResourcePath.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourcePath
的用法示例。
在下文中一共展示了ResourcePath.Serialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResourceDisplayName
public string GetResourceDisplayName(ResourcePath path)
{
CpAction action = GetAction("GetResourceDisplayName");
IList<object> inParameters = new List<object> {path.Serialize()};
IList<object> outParameters = action.InvokeAction(inParameters);
return (string) outParameters[0];
}
示例2: ImportLocation
public void ImportLocation(ResourcePath path, IEnumerable<string> mediaCategories, ImportJobType importJobType)
{
CpAction action = GetAction("ImportLocation");
string importJobTypeStr;
switch (importJobType)
{
case ImportJobType.Import:
importJobTypeStr = "Import";
break;
case ImportJobType.Refresh:
importJobTypeStr = "Refresh";
break;
default:
throw new NotImplementedException(string.Format("Import job type '{0}' is not implemented", importJobType));
}
IList<object> inParameters = new List<object>
{
path.Serialize(),
StringUtils.Join(", ", mediaCategories),
importJobTypeStr
};
action.InvokeAction(inParameters);
}
示例3: GetResourceURL
public static string GetResourceURL(string baseURL, ResourcePath nativeResourcePath)
{
// Use UrlEncode to encode also # sign, UrlPathEncode doesn't do this.
return string.Format("{0}?{1}={2}", baseURL, RESOURCE_PATH_ARGUMENT_NAME, HttpUtility.UrlEncode(nativeResourcePath.Serialize()));
}
示例4: GetResourceAccessor
protected IFileSystemResourceAccessor GetResourceAccessor(ResourcePath resourcePath)
{
lock (_syncObj)
{
CachedResource resource;
string resourcePathStr = resourcePath.Serialize();
if (_resourceAccessorCache.TryGetValue(resourcePathStr, out resource))
return resource.ResourceAccessor;
// TODO: Security check. Only deliver resources which are located inside local shares.
ServiceRegistration.Get<ILogger>().Debug("ResourceAccessModule: Access of resource '{0}'", resourcePathStr);
IResourceAccessor ra;
if (!resourcePath.TryCreateLocalResourceAccessor(out ra))
throw new ArgumentException("Unable to access resource path '{0}'", resourcePathStr);
IFileSystemResourceAccessor fsra = ra as IFileSystemResourceAccessor;
if (fsra == null)
{
ra.Dispose();
throw new ArgumentException("The given resource path '{0}' doesn't denote a file system resource", resourcePathStr);
}
_resourceAccessorCache[resourcePathStr] = new CachedResource(fsra);
return fsra;
}
}
示例5: DoesResourceExist
public bool DoesResourceExist(ResourcePath path)
{
CpAction action = GetAction("DoesResourceExist");
IList<object> inParameters = new List<object> {path.Serialize()};
IList<object> outParameters = action.InvokeAction(inParameters);
return (bool) outParameters[0];
}
示例6: GetResourceInformation
public bool GetResourceInformation(ResourcePath path, out bool isFileSystemResource,
out bool isFile, out string resourcePathName, out string resourceName,
out DateTime lastChanged, out long size)
{
CpAction action = GetAction("GetResourceInformation");
IList<object> inParameters = new List<object> {path.Serialize()};
IList<object> outParameters = action.InvokeAction(inParameters);
isFileSystemResource = (bool) outParameters[0];
isFile = (bool) outParameters[1];
resourcePathName = (string) outParameters[2];
resourceName = (string) outParameters[3];
lastChanged = (DateTime) outParameters[4];
size = (long) (UInt64) outParameters[5];
return (bool) outParameters[6];
}
示例7: AddOrUpdateMediaItem
public Guid AddOrUpdateMediaItem(Guid parentDirectoryId, string systemId, ResourcePath path, IEnumerable<MediaItemAspect> mediaItemAspects)
{
// TODO: Avoid multiple write operations to the same media item
ISQLDatabase database = ServiceRegistration.Get<ISQLDatabase>();
ITransaction transaction = database.BeginTransaction();
try
{
Guid? mediaItemId = GetMediaItemId(transaction, systemId, path);
DateTime now = DateTime.Now;
MediaItemAspect importerAspect;
bool wasCreated = !mediaItemId.HasValue;
if (wasCreated)
{
mediaItemId = AddMediaItem(database, transaction);
MediaItemAspect pra = new MediaItemAspect(ProviderResourceAspect.Metadata);
pra.SetAttribute(ProviderResourceAspect.ATTR_SYSTEM_ID, systemId);
pra.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, path.Serialize());
pra.SetAttribute(ProviderResourceAspect.ATTR_PARENT_DIRECTORY_ID, parentDirectoryId);
_miaManagement.AddOrUpdateMIA(transaction, mediaItemId.Value, pra, true);
importerAspect = new MediaItemAspect(ImporterAspect.Metadata);
importerAspect.SetAttribute(ImporterAspect.ATTR_DATEADDED, now);
}
else
importerAspect = _miaManagement.GetMediaItemAspect(transaction, mediaItemId.Value, ImporterAspect.ASPECT_ID);
importerAspect.SetAttribute(ImporterAspect.ATTR_DIRTY, false);
importerAspect.SetAttribute(ImporterAspect.ATTR_LAST_IMPORT_DATE, now);
_miaManagement.AddOrUpdateMIA(transaction, mediaItemId.Value, importerAspect, wasCreated);
// Update
foreach (MediaItemAspect mia in mediaItemAspects)
{
if (!_miaManagement.ManagedMediaItemAspectTypes.ContainsKey(mia.Metadata.AspectId))
// Simply skip unknown MIA types. All types should have been added before import.
continue;
if (mia.Metadata.AspectId == ImporterAspect.ASPECT_ID ||
mia.Metadata.AspectId == ProviderResourceAspect.ASPECT_ID)
{ // Those aspects are managed by the MediaLibrary
ServiceRegistration.Get<ILogger>().Warn("MediaLibrary.AddOrUpdateMediaItem: Client tried to update either ImporterAspect or ProviderResourceAspect");
continue;
}
if (wasCreated)
_miaManagement.AddOrUpdateMIA(transaction, mediaItemId.Value, mia, true);
else
_miaManagement.AddOrUpdateMIA(transaction, mediaItemId.Value, mia);
}
transaction.Commit();
return mediaItemId.Value;
}
catch (Exception e)
{
ServiceRegistration.Get<ILogger>().Error("MediaLibrary: Error adding or updating media item(s) in path '{0}'", e, path.Serialize());
transaction.Rollback();
throw;
}
}
示例8: InsertShareCommand
public static IDbCommand InsertShareCommand(ITransaction transaction, Guid shareId, string systemId,
ResourcePath baseResourcePath, string shareName)
{
IDbCommand result = transaction.CreateCommand();
result.CommandText = "INSERT INTO SHARES (SHARE_ID, NAME, SYSTEM_ID, BASE_RESOURCE_PATH) VALUES (@SHARE_ID, @NAME, @SYSTEM_ID, @BASE_RESOURCE_PATH)";
ISQLDatabase database = transaction.Database;
database.AddParameter(result, "SHARE_ID", shareId, typeof(Guid));
database.AddParameter(result, "NAME", shareName, typeof(string));
database.AddParameter(result, "SYSTEM_ID", systemId, typeof(string));
database.AddParameter(result, "BASE_RESOURCE_PATH", baseResourcePath.Serialize(), typeof(string));
return result;
}
示例9: RelocateMediaItems
protected int RelocateMediaItems(ITransaction transaction,
string systemId, ResourcePath originalBasePath, ResourcePath newBasePath)
{
string originalBasePathStr = StringUtils.CheckSuffix(originalBasePath.Serialize(), "/");
string newBasePathStr = StringUtils.CheckSuffix(newBasePath.Serialize(), "/");
if (originalBasePathStr == newBasePathStr)
return 0;
string providerAspectTable = _miaManagement.GetMIATableName(ProviderResourceAspect.Metadata);
string systemIdAttribute = _miaManagement.GetMIAAttributeColumnName(ProviderResourceAspect.ATTR_SYSTEM_ID);
string pathAttribute = _miaManagement.GetMIAAttributeColumnName(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH);
ISQLDatabase database = transaction.Database;
using (IDbCommand command = transaction.CreateCommand())
{
command.CommandText = "UPDATE " + providerAspectTable + " SET " +
pathAttribute + " = " + database.CreateStringConcatenationExpression("@PATH",
database.CreateSubstringExpression(pathAttribute, (originalBasePathStr.Length + 1).ToString())) +
" WHERE " + systemIdAttribute + " = @SYSTEM_ID AND " +
database.CreateSubstringExpression(pathAttribute, "1", originalBasePathStr.Length.ToString()) + " = @ORIGBASEPATH";
database.AddParameter(command, "PATH", newBasePathStr, typeof(string));
database.AddParameter(command, "SYSTEM_ID", systemId, typeof(string));
database.AddParameter(command, "ORIGBASEPATH", originalBasePathStr, typeof(string));
return command.ExecuteNonQuery();
}
}
示例10: DeleteAllMediaItemsUnderPath
protected int DeleteAllMediaItemsUnderPath(ITransaction transaction, string systemId, ResourcePath basePath, bool inclusive)
{
MediaItemAspectMetadata providerAspectMetadata = ProviderResourceAspect.Metadata;
string providerAspectTable = _miaManagement.GetMIATableName(providerAspectMetadata);
string systemIdAttribute = _miaManagement.GetMIAAttributeColumnName(ProviderResourceAspect.ATTR_SYSTEM_ID);
string pathAttribute = _miaManagement.GetMIAAttributeColumnName(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH);
string commandStr = "DELETE FROM " + MediaLibrary_SubSchema.MEDIA_ITEMS_TABLE_NAME +
" WHERE " + MediaLibrary_SubSchema.MEDIA_ITEMS_ITEM_ID_COL_NAME + " IN (" +
// TODO: Replace this inner select statement by a select statement generated from an appropriate item query
"SELECT " + MIA_Management.MIA_MEDIA_ITEM_ID_COL_NAME + " FROM " + providerAspectTable +
" WHERE " + systemIdAttribute + " = @SYSTEM_ID";
ISQLDatabase database = transaction.Database;
using (IDbCommand command = transaction.CreateCommand())
{
database.AddParameter(command, "SYSTEM_ID", systemId, typeof(string));
if (basePath != null)
{
commandStr += " AND (";
if (inclusive)
commandStr += pathAttribute + " = @EXACT_PATH OR ";
commandStr +=
pathAttribute + " LIKE @LIKE_PATH1 ESCAPE @LIKE_ESCAPE1 OR " +
pathAttribute + " LIKE @LIKE_PATH2 ESCAPE @LIKE_ESCAPE2" +
")";
string path = StringUtils.RemoveSuffixIfPresent(basePath.Serialize(), "/");
string escapedPath = SqlUtils.LikeEscape(path, ESCAPE_CHAR);
if (inclusive)
{
// The path itself
database.AddParameter(command, "EXACT_PATH", path, typeof(string));
// Normal children and, if escapedPath ends with "/", the directory itself
database.AddParameter(command, "LIKE_PATH1", escapedPath + "/%", typeof(string));
database.AddParameter(command, "LIKE_ESCAPE1", ESCAPE_CHAR, typeof(char));
}
else
{
// Normal children, in any case excluding the escaped path, even if it is a directory which ends with "/"
database.AddParameter(command, "LIKE_PATH1", escapedPath + "/_%", typeof(string));
database.AddParameter(command, "LIKE_ESCAPE1", ESCAPE_CHAR, typeof(char));
}
// Chained children
database.AddParameter(command, "LIKE_PATH2", escapedPath + ">_%", typeof(string));
database.AddParameter(command, "LIKE_ESCAPE2", ESCAPE_CHAR, typeof(char));
}
commandStr = commandStr + ")";
command.CommandText = commandStr;
return command.ExecuteNonQuery();
}
}
示例11: GetMediaItemId
protected Guid? GetMediaItemId(ITransaction transaction, string systemId, ResourcePath resourcePath)
{
string providerAspectTable = _miaManagement.GetMIATableName(ProviderResourceAspect.Metadata);
string systemIdAttribute = _miaManagement.GetMIAAttributeColumnName(ProviderResourceAspect.ATTR_SYSTEM_ID);
string pathAttribute = _miaManagement.GetMIAAttributeColumnName(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH);
ISQLDatabase database = transaction.Database;
using (IDbCommand command = transaction.CreateCommand())
{
command.CommandText = "SELECT " + MIA_Management.MIA_MEDIA_ITEM_ID_COL_NAME + " FROM " + providerAspectTable +
" WHERE " + systemIdAttribute + " = @SYSTEM_ID AND " + pathAttribute + " = @PATH";
database.AddParameter(command, "SYSTEM_ID", systemId, typeof(string));
database.AddParameter(command, "PATH", resourcePath.Serialize(), typeof(string));
using (IDataReader reader = command.ExecuteReader())
{
if (!reader.Read())
return null;
return database.ReadDBValue<Guid>(reader, 0);
}
}
}
示例12: BuildLoadItemQuery
protected MediaItemQuery BuildLoadItemQuery(string systemId, ResourcePath path)
{
return new MediaItemQuery(new List<Guid>(), new List<Guid>(),
new BooleanCombinationFilter(BooleanOperator.And, new IFilter[]
{
new RelationalFilter(ProviderResourceAspect.ATTR_SYSTEM_ID, RelationalOperator.EQ, systemId),
new RelationalFilter(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, RelationalOperator.EQ, path.Serialize())
}));
}
示例13: GetResourceAccessor
protected IResourceAccessor GetResourceAccessor(ResourcePath resourcePath)
{
lock (_syncObj)
{
CachedResource resource;
string resourcePathStr = resourcePath.Serialize();
if (_resourceAccessorCache.TryGetValue(resourcePathStr, out resource))
return resource.ResourceAccessor;
// TODO: Security check. Only deliver resources which are located inside local shares.
ServiceRegistration.Get<ILogger>().Debug("ResourceAccessModule: Access of resource '{0}'", resourcePathStr);
IResourceAccessor result;
if(!resourcePath.TryCreateLocalResourceAccessor(out result))
ServiceRegistration.Get<ILogger>().Debug("ResourceAccessModule: Unable to access resource path '{0}'", resourcePathStr);
_resourceAccessorCache[resourcePathStr] = new CachedResource(result);
return result;
}
}
示例14: Combine
public static ResourcePath Combine(ResourcePath rootPath, string path)
{
return ResourcePath.Deserialize(Combine(rootPath.Serialize(), path));
}
示例15: DeleteMediaItemOrPath
public void DeleteMediaItemOrPath(string systemId, ResourcePath path, bool inclusive)
{
ISQLDatabase database = ServiceRegistration.Get<ISQLDatabase>();
ITransaction transaction = database.BeginTransaction();
try
{
DeleteAllMediaItemsUnderPath(transaction, systemId, path, inclusive);
transaction.Commit();
}
catch (Exception e)
{
ServiceRegistration.Get<ILogger>().Error("MediaLibrary: Error deleting media item(s) of system '{0}' in path '{1}'",
e, systemId, path.Serialize());
transaction.Rollback();
throw;
}
}