本文整理匯總了C#中ProtoBuf.Meta.BasicList.IndexOfString方法的典型用法代碼示例。如果您正苦於以下問題:C# BasicList.IndexOfString方法的具體用法?C# BasicList.IndexOfString怎麽用?C# BasicList.IndexOfString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ProtoBuf.Meta.BasicList
的用法示例。
在下文中一共展示了BasicList.IndexOfString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: WriteAssemblyAttributes
private void WriteAssemblyAttributes(CompilerOptions options, string assemblyName, AssemblyBuilder asm)
{
if (!Helpers.IsNullOrEmpty(options.TargetFrameworkName))
{
// get [TargetFramework] from mscorlib/equivalent and burn into the new assembly
Type versionAttribType = null;
try
{ // this is best-endeavours only
versionAttribType = GetType("System.Runtime.Versioning.TargetFrameworkAttribute", MapType(typeof(string)).Assembly);
}
catch { /* don't stress */ }
if (versionAttribType != null)
{
PropertyInfo[] props;
object[] propValues;
if (Helpers.IsNullOrEmpty(options.TargetFrameworkDisplayName))
{
props = new PropertyInfo[0];
propValues = new object[0];
}
else
{
props = new PropertyInfo[1] { versionAttribType.GetProperty("FrameworkDisplayName") };
propValues = new object[1] { options.TargetFrameworkDisplayName };
}
CustomAttributeBuilder builder = new CustomAttributeBuilder(
versionAttribType.GetConstructor(new Type[] { MapType(typeof(string)) }),
new object[] { options.TargetFrameworkName },
props,
propValues);
asm.SetCustomAttribute(builder);
}
}
// copy assembly:InternalsVisibleTo
Type internalsVisibleToAttribType = null;
#if !FX11
try
{
internalsVisibleToAttribType = MapType(typeof(System.Runtime.CompilerServices.InternalsVisibleToAttribute));
}
catch { /* best endeavors only */ }
#endif
if (internalsVisibleToAttribType != null)
{
BasicList internalAssemblies = new BasicList(), consideredAssemblies = new BasicList();
foreach (MetaType metaType in types)
{
Assembly assembly = metaType.Type.Assembly;
if (consideredAssemblies.IndexOfReference(assembly) >= 0) continue;
consideredAssemblies.Add(assembly);
AttributeMap[] assemblyAttribsMap = AttributeMap.Create(this, assembly);
for (int i = 0; i < assemblyAttribsMap.Length; i++)
{
if (assemblyAttribsMap[i].AttributeType != internalsVisibleToAttribType) continue;
object privelegedAssemblyObj;
assemblyAttribsMap[i].TryGet("AssemblyName", out privelegedAssemblyObj);
string privelegedAssemblyName = privelegedAssemblyObj as string;
if (privelegedAssemblyName == assemblyName || Helpers.IsNullOrEmpty(privelegedAssemblyName)) continue; // ignore
if (internalAssemblies.IndexOfString(privelegedAssemblyName) >= 0) continue; // seen it before
internalAssemblies.Add(privelegedAssemblyName);
CustomAttributeBuilder builder = new CustomAttributeBuilder(
internalsVisibleToAttribType.GetConstructor(new Type[] { MapType(typeof(string)) }),
new object[] { privelegedAssemblyName });
asm.SetCustomAttribute(builder);
}
}
}
}