本文整理汇总了C#中ResourceAttributes类的典型用法代码示例。如果您正苦于以下问题:C# ResourceAttributes类的具体用法?C# ResourceAttributes怎么用?C# ResourceAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceAttributes类属于命名空间,在下文中一共展示了ResourceAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateResource
/// <summary>
/// Creates a resource, given a metadata block of values.
/// </summary>
/// <param name="attribs"></param>
/// <returns></returns>
public static MediaResource CreateResource(ResourceAttributes attribs)
{
MediaResource newRes = new MediaResource();
SetCommonAttributes(newRes, attribs);
return newRes;
}
示例2: ResWriterData
internal ResWriterData(ResourceWriter resWriter, Stream memoryStream, string strName, string strFileName, string strFullFileName, ResourceAttributes attribute)
{
this.m_resWriter = resWriter;
this.m_memoryStream = memoryStream;
this.m_strName = strName;
this.m_strFileName = strFileName;
this.m_strFullFileName = strFullFileName;
this.m_nextResWriter = null;
this.m_attribute = attribute;
}
示例3: SetCommonAttributes
/// <summary>
/// Constructors use this method to set the properties of a resource.
/// Programmers can use this method also, but the method is not
/// guaranteed to be thread safe. As a general rule, programmers shouldn't
/// be changing the values of resources after they've instantiated them.
/// </summary>
/// <param name="res"></param>
/// <param name="attribs"></param>
public static void SetCommonAttributes(MediaResource res, ResourceAttributes attribs)
{
res.ProtocolInfo = attribs.protocolInfo;
res.ContentUri = attribs.contentUri.Trim();
if ((attribs.importUri != null) && (attribs.importUri != ""))
{
res[T[_RESATTRIB.importUri]] = attribs.importUri;
}
TransferValue("bitrate", res, attribs);
TransferValue("bitsPerSample", res, attribs);
TransferValue("colorDepth", res, attribs);
TransferValue("duration", res, attribs);
TransferValue("nrAudioChannels", res, attribs);
TransferValue("protection", res, attribs);
TransferValue("resolution", res, attribs);
TransferValue("sampleFrequency", res, attribs);
TransferValue("size", res, attribs);
}
示例4: AddResourceFile
public void AddResourceFile(string name, string fileName, ResourceAttributes attribs)
{
ResourceFile resfile = new ResourceFile();
resfile.Name = name;
resfile.FileName = fileName;
resfile.Attributes = attribs;
resourceFiles.Add(resfile);
}
示例5: DefineManifestResource
public void DefineManifestResource (string name, Stream stream, ResourceAttributes attribute) {
if (name == null)
throw new ArgumentNullException ("name");
if (name == String.Empty)
throw new ArgumentException ("name cannot be empty");
if (stream == null)
throw new ArgumentNullException ("stream");
if (transient)
throw new InvalidOperationException ("The module is transient");
if (!assemblyb.IsSave)
throw new InvalidOperationException ("The assembly is transient");
if (resources != null) {
MonoResource[] new_r = new MonoResource [resources.Length + 1];
System.Array.Copy(resources, new_r, resources.Length);
resources = new_r;
} else {
resources = new MonoResource [1];
}
int p = resources.Length - 1;
resources [p].name = name;
resources [p].attrs = attribute;
resources [p].stream = stream;
}
示例6: LinkedResource
public LinkedResource (string name, string file, bool isPrivate)
{
this.name = name;
this.file = file;
this.attribute = isPrivate ? ResourceAttributes.Private : ResourceAttributes.Public;
}
示例7: DefineResourceNoLock
private IResourceWriter DefineResourceNoLock(string name, string description, ResourceAttributes attribute)
{
if (this.IsTransient())
{
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
}
if (name == null)
{
throw new ArgumentNullException("name");
}
if (name.Length == 0)
{
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
}
if (!this.m_assemblyBuilder.IsPersistable())
{
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
}
this.m_assemblyBuilder.m_assemblyData.CheckResNameConflict(name);
MemoryStream stream = new MemoryStream();
ResourceWriter resWriter = new ResourceWriter(stream);
ResWriterData data = new ResWriterData(resWriter, stream, name, string.Empty, string.Empty, attribute) {
m_nextResWriter = this.m_moduleData.m_embeddedRes
};
this.m_moduleData.m_embeddedRes = data;
return resWriter;
}
示例8: DefineResource
public IResourceWriter DefineResource (string name, string description, ResourceAttributes attribute)
{
if (name == null)
throw new ArgumentNullException ("name");
if (name == String.Empty)
throw new ArgumentException ("name cannot be empty");
if (transient)
throw new InvalidOperationException ("The module is transient");
if (!assemblyb.IsSave)
throw new InvalidOperationException ("The assembly is transient");
ResourceWriter writer = new ResourceWriter (new MemoryStream ());
if (resource_writers == null)
resource_writers = new Hashtable ();
resource_writers [name] = writer;
// The data is filled out later
if (resources != null) {
MonoResource[] new_r = new MonoResource [resources.Length + 1];
System.Array.Copy(resources, new_r, resources.Length);
resources = new_r;
} else {
resources = new MonoResource [1];
}
int p = resources.Length - 1;
resources [p].name = name;
resources [p].attrs = attribute;
return writer;
}
示例9: AddResourceFile
public void AddResourceFile(string name, string file, ResourceAttributes attribute)
{
IResourceWriter rw = _myModule.DefineResource(Path.GetFileName(file), name, attribute);
string ext = Path.GetExtension(file);
if(String.Equals(ext, ".resources", StringComparison.OrdinalIgnoreCase)) {
ResourceReader rr = new ResourceReader(file);
using (rr) {
System.Collections.IDictionaryEnumerator de = rr.GetEnumerator();
while (de.MoveNext()) {
string key = de.Key as string;
rw.AddResource(key, de.Value);
}
}
} else {
rw.AddResource(name, File.ReadAllBytes(file));
}
}
示例10: DefineResourceNoLock
private IResourceWriter DefineResourceNoLock(string name, string description, string fileName, ResourceAttributes attribute)
{
ResourceWriter writer;
string fullPath;
if (name == null)
{
throw new ArgumentNullException("name");
}
if (name.Length == 0)
{
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), name);
}
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
if (fileName.Length == 0)
{
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyFileName"), "fileName");
}
if (!string.Equals(fileName, Path.GetFileName(fileName)))
{
throw new ArgumentException(Environment.GetResourceString("Argument_NotSimpleFileName"), "fileName");
}
this.m_assemblyData.CheckResNameConflict(name);
this.m_assemblyData.CheckFileNameConflict(fileName);
if (this.m_assemblyData.m_strDir == null)
{
fullPath = Path.Combine(Environment.CurrentDirectory, fileName);
writer = new ResourceWriter(fullPath);
}
else
{
fullPath = Path.Combine(this.m_assemblyData.m_strDir, fileName);
writer = new ResourceWriter(fullPath);
}
fullPath = Path.GetFullPath(fullPath);
fileName = Path.GetFileName(fullPath);
this.m_assemblyData.AddResWriter(new ResWriterData(writer, null, name, fileName, fullPath, attribute));
return writer;
}
示例11: AddResourceFile
public void AddResourceFile(string name, string fileName, ResourceAttributes attribute)
{
lock (this.SyncRoot)
{
this.AddResourceFileNoLock(name, fileName, attribute);
}
}
示例12: AddResourceFile
private void AddResourceFile (string name, string fileName, ResourceAttributes attribute, bool fileNeedsToExists)
{
check_name_and_filename (name, fileName, fileNeedsToExists);
// Resource files are created/searched under the assembly storage
// directory
if (dir != null)
fileName = Path.Combine (dir, fileName);
if (resources != null) {
MonoResource[] new_r = new MonoResource [resources.Length + 1];
System.Array.Copy(resources, new_r, resources.Length);
resources = new_r;
} else {
resources = new MonoResource [1];
}
int p = resources.Length - 1;
resources [p].name = name;
resources [p].filename = fileName;
resources [p].attrs = attribute;
}
示例13: TransferValue
/// <summary>
/// <para>
/// This method allows a generalized implementation of transfering
/// a value from a
/// <see cref="ResourceBuilder.ResourceAttributes"/>
/// to a
/// <see cref="MediaResource"/>
/// object.
/// </para>
///
/// <para>
/// Classes derived from the
/// <see cref="ResourceBuilder.ResourceAttributes"/>
/// class have fields, with names that match against fields in a
/// <see cref="MediaResource"/>
/// object.
/// </para>
/// </summary>
/// <param name="attribName">name of the attribute to transfer</param>
/// <param name="res">The
/// <see cref="MediaResource"/>
/// object to transfer to.
/// </param>
/// <param name="attribs">
/// The
/// <see cref="ResourceBuilder.ResourceAttributes"/>
/// object to transfer from.
/// </param>
private static void TransferValue(string attribName, MediaResource res, ResourceAttributes attribs)
{
object val = null;
System.Type type = attribs.GetType();
FieldInfo info = type.GetField(attribName);
if (info != null)
{
val = info.GetValue(attribs);
if (val != null)
{
IValueType ivt = val as IValueType;
bool ok = true;
if (ivt != null)
{
ok = ivt.IsValid;
}
if (ok)
{
//res.m_Attributes[attribName] = val;
res[attribName] = val;
}
}
}
}
示例14: AddResourceFileNoLock
private void AddResourceFileNoLock(string name, string fileName, ResourceAttributes attribute)
{
string fullPath;
if (name == null)
{
throw new ArgumentNullException("name");
}
if (name.Length == 0)
{
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), name);
}
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
if (fileName.Length == 0)
{
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyFileName"), fileName);
}
if (!string.Equals(fileName, Path.GetFileName(fileName)))
{
throw new ArgumentException(Environment.GetResourceString("Argument_NotSimpleFileName"), "fileName");
}
this.m_assemblyData.CheckResNameConflict(name);
this.m_assemblyData.CheckFileNameConflict(fileName);
if (this.m_assemblyData.m_strDir == null)
{
fullPath = Path.Combine(Environment.CurrentDirectory, fileName);
}
else
{
fullPath = Path.Combine(this.m_assemblyData.m_strDir, fileName);
}
fullPath = Path.GetFullPath(fullPath);
fileName = Path.GetFileName(fullPath);
if (!File.Exists(fullPath))
{
throw new FileNotFoundException(Environment.GetResourceString("IO.FileNotFound_FileName", new object[] { fileName }), fileName);
}
this.m_assemblyData.AddResWriter(new ResWriterData(null, null, name, fileName, fullPath, attribute));
}
示例15: DefineResource
/**********************************************
*
* Define embedded managed resource to be stored in this module
*
*
**********************************************/
/// <include file='doc\ModuleBuilder.uex' path='docs/doc[@for="ModuleBuilder.DefineResource1"]/*' />
public IResourceWriter DefineResource(
String name,
String description,
ResourceAttributes attribute)
{
CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
try
{
Enter();
BCLDebug.Log("DYNIL","## DYNIL LOGGING: ModuleBuilder.DefineResource( " + name + ")");
if (IsTransient())
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
if (name == null)
throw new ArgumentNullException("name");
if (name.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
Assembly assembly = this.Assembly;
if (assembly is AssemblyBuilder)
{
AssemblyBuilder asmBuilder = (AssemblyBuilder)assembly;
if (asmBuilder.IsPersistable())
{
asmBuilder.m_assemblyData.CheckResNameConflict(name);
MemoryStream stream = new MemoryStream();
ResourceWriter resWriter = new ResourceWriter(stream);
ResWriterData resWriterData = new ResWriterData( resWriter, stream, name, String.Empty, String.Empty, attribute);
// chain it to the embedded resource list
resWriterData.m_nextResWriter = m_moduleData.m_embeddedRes;
m_moduleData.m_embeddedRes = resWriterData;
return resWriter;
}
else
{
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
}
}
else
{
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
}
}
finally
{
Exit();
}
}