本文整理汇总了C#中TypeFilter类的典型用法代码示例。如果您正苦于以下问题:C# TypeFilter类的具体用法?C# TypeFilter怎么用?C# TypeFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeFilter类属于命名空间,在下文中一共展示了TypeFilter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FindInterfaces
public virtual Type[] FindInterfaces(TypeFilter filter, object filterCriteria)
{
if (filter == null)
{
throw new ArgumentNullException("filter");
}
Type[] interfaces = this.GetInterfaces();
int num = 0;
for (int i = 0; i < interfaces.Length; i++)
{
if (!filter(interfaces[i], filterCriteria))
{
interfaces[i] = null;
}
else
{
num++;
}
}
if (num == interfaces.Length)
{
return interfaces;
}
Type[] typeArray2 = new Type[num];
num = 0;
for (int j = 0; j < interfaces.Length; j++)
{
if (interfaces[j] != null)
{
typeArray2[num++] = interfaces[j];
}
}
return typeArray2;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:Type.cs
示例2: ContactPageIdentifier
public static string ContactPageIdentifier(this HtmlHelper helper)
{
var filter = new TypeFilter(typeof(ContactFormPage));
var page = Find.StartPage.GetChildren(filter).FirstOrDefault();
return page != null ? page.Name : string.Empty;
}
开发者ID:Davgus,项目名称:olandskonservatorn,代码行数:7,代码来源:HtmlHelperExtensions.cs
示例3: CanFilterTwoItemsWithFilterInstance
public void CanFilterTwoItemsWithFilterInstance()
{
ItemFilter filter = new TypeFilter(typeof(FirstItem));
ItemList list = CreateList();
filter.Filter(list);
Assert.AreEqual(1, list.Count);
}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:7,代码来源:TypeFilterTests.cs
示例4: Module
static Module()
{
__Filters _fltObj;
_fltObj = new __Filters();
FilterTypeName = new TypeFilter(_fltObj.FilterTypeName);
FilterTypeNameIgnoreCase = new TypeFilter(_fltObj.FilterTypeNameIgnoreCase);
}
开发者ID:AtsushiKan,项目名称:coreclr,代码行数:7,代码来源:Module.cs
示例5: FindTypes
public virtual Type[] FindTypes(TypeFilter filter, object filterCriteria)
{
Type[] types = this.GetTypes();
int num = 0;
for (int i = 0; i < types.Length; i++)
{
if ((filter != null) && !filter(types[i], filterCriteria))
{
types[i] = null;
}
else
{
num++;
}
}
if (num == types.Length)
{
return types;
}
Type[] typeArray2 = new Type[num];
num = 0;
for (int j = 0; j < types.Length; j++)
{
if (types[j] != null)
{
typeArray2[num++] = types[j];
}
}
return typeArray2;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:Module.cs
示例6: Run
public static void Run()
{
//FirstMember
TypeFilter filt = new TypeFilter(DbElementTypeInstance.NOZZLE);
DbElement nozz1 = filt.FirstMember(Example.Instance.mEqui);
DbElementType type = nozz1.GetElementType();
//NextMember
DbElement nozz2 = filt.Next(nozz1);
//NextMember
DbElement[] members = filt.Members(Example.Instance.mEqui);
//parent
TypeFilter filt2 = new TypeFilter(DbElementTypeInstance.SITE);
DbElement site = filt2.Parent(nozz1);
type = site.GetElementType();
//Valid
AndFilter andFilt4 = new AndFilter();
andFilt4.Add(new TypeFilter(DbElementTypeInstance.EQUIPMENT));
andFilt4.Add(new TrueFilter());
bool valid = andFilt4.Valid(Example.Instance.mEqui);
// attribute true
AttributeTrueFilter filt1 = new AttributeTrueFilter(DbAttributeInstance.ISNAME);
//should be true for named element
bool named = filt1.Valid(Example.Instance.mEqui);
//for first member it is also true
named = filt1.Valid(Example.Instance.mEqui.FirstMember());
//Element type at or below
BelowOrAtType filt3 = new BelowOrAtType(DbElementTypeInstance.EQUIPMENT);
bool below = filt3.ScanBelow(Example.Instance.mEqui);
}
开发者ID:freudshow,项目名称:raffles-codes,代码行数:35,代码来源:ExampleFilters.cs
示例7: Run
public static void Run()
{
// Set up a navigator which looks at sites/pipes/Nozzles/Tee only
TypeFilter filt = new TypeFilter();
filt.Add(DbElementTypeInstance.SITE);
filt.Add(DbElementTypeInstance.PIPE);
filt.Add(DbElementTypeInstance.NOZZLE);
filt.Add(DbElementTypeInstance.TEE);
CompoundFilter filt2 = new CompoundFilter();
filt2.AddShow(filt);
ElementTreeNavigator navi = new ElementTreeNavigator(DbElement.GetElement("/*"), filt2);
// Test FirstMember
DbElement site = navi.FirstMemberInScan(Example.Instance.mWorld);
DbElement nozz = navi.FirstMemberInScan(Example.Instance.mZone);
nozz = navi.FirstMemberInScan(Example.Instance.mEqui);
DbElement ele = navi.FirstMemberInScan(nozz);
// Next
DbElement zone = site.FirstMember();
DbElement next = navi.NextInScan(zone);
// parent
DbElement parent = navi.Parent(Example.Instance.mEqui);
parent = navi.Parent(nozz);
parent = navi.Parent(parent);
//All Members
DbElement[] tees = navi.MembersInScan(Example.Instance.mPipe);
}
开发者ID:freudshow,项目名称:raffles-codes,代码行数:30,代码来源:ExampleTreeNavigator.cs
示例8: FindInterfaces
public static Type[] FindInterfaces(this Type type, TypeFilter filter, object filterCriteria)
{
if (filter == null)
{
throw new ArgumentNullException("filter");
}
var interfaces = type.GetInterfaces();
var count = 0;
for (var i = 0; i < interfaces.Length; i++)
{
if (!filter(interfaces[i], filterCriteria))
{
interfaces[i] = null;
}
else
{
count++;
}
}
if (count == interfaces.Length)
{
return interfaces;
}
var array = new Type[count];
count = 0;
foreach (var t in interfaces.Where(t => t != null))
{
array[count++] = t;
}
return array;
}
开发者ID:usausa,项目名称:Smart-Net-CE,代码行数:35,代码来源:TypeExtensionsCE.cs
示例9: PASS_Serialize
public void PASS_Serialize()
{
TypeFilter filter = new TypeFilter("type");
string json = JsonConvert.SerializeObject(filter);
Assert.IsNotNull(json);
string expectedJson = "{\"type\":{\"value\":\"type\"}}";
Assert.AreEqual(expectedJson, json);
}
开发者ID:kbolay,项目名称:Bolay.Elastic,代码行数:9,代码来源:UnitTests_TypeFilter.cs
示例10: RoleSet
public RoleSet(Type _Class)
{
TypeFilter filter = new TypeFilter(RoleFilter);
Type[] Roles = _Class.FindInterfaces(filter, (object)__RoleTypes);
_Set = new HashSet<Type>();
foreach (Type r in Roles) {
_Set.Add(r);
}
}
开发者ID:lokeldigital,项目名称:CoolFramework,代码行数:9,代码来源:Roles.cs
示例11: ReadJson
public override object ReadJson(JsonReader reader, System.Type objectType, object existingValue, JsonSerializer serializer)
{
Dictionary<string, object> fieldDict = serializer.Deserialize<Dictionary<string, object>>(reader);
if (fieldDict.ContainsKey(FilterTypeEnum.Type.ToString()))
fieldDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(fieldDict.First().Value.ToString());
TypeFilter filter = new TypeFilter(fieldDict.GetString(_TYPE));
filter.FilterName = fieldDict.GetStringOrDefault(FilterSerializer._FILTER_NAME);
return filter;
}
开发者ID:kbolay,项目名称:Bolay.Elastic,代码行数:11,代码来源:TypeSerializer.cs
示例12: FAIL_CreateFilter
public void FAIL_CreateFilter()
{
try
{
TypeFilter filter = new TypeFilter(null);
Assert.Fail();
}
catch (ArgumentNullException ex)
{
Assert.AreEqual("documentType", ex.ParamName);
}
}
开发者ID:kbolay,项目名称:Bolay.Elastic,代码行数:12,代码来源:UnitTests_TypeFilter.cs
示例13: RenderMainMenu
public static string RenderMainMenu(this HtmlHelper helper)
{
var builder = new StringBuilder();
var formatString = "<li> <a href=\"#{0}\" class=\"jump {1}\">{2}</a>";
var filter = new TypeFilter(typeof(AbstractPage));
foreach (var child in Find.StartPage.GetChildren(filter))
{
builder.Append(string.Format(formatString, child.Name, child is ContactFormPage ? "contact-page" : string.Empty, child.Title));
}
return builder.ToString();
}
开发者ID:Davgus,项目名称:El,代码行数:13,代码来源:HtmlHelperExtensions.cs
示例14: FindInterfaces
public static Type[] FindInterfaces(this Type myType, TypeFilter TypeFilter, Object FilterCriteria)
{
if (TypeFilter == null)
throw new ArgumentNullException("filter");
var Interfaces = new List<Type>();
foreach (var Interface in myType.GetInterfaces())
{
if (TypeFilter(Interface, FilterCriteria))
Interfaces.Add(Interface);
}
return Interfaces.ToArray();
}
开发者ID:Vanaheimr,项目名称:Illias,代码行数:14,代码来源:SilverlightExtensions.cs
示例15: FindInterfaces
public static Type[] FindInterfaces(this Type type, TypeFilter filter, object filterCriteria)
{
if (filter == null)
throw new ArgumentNullException("filter");
List<Type> ifaces = new List<Type>();
foreach (Type iface in type.GetInterfaces())
{
if (filter(iface, filterCriteria))
ifaces.Add(iface);
}
return ifaces.ToArray();
}
开发者ID:Jarvin-Guan,项目名称:CleanAOP,代码行数:14,代码来源:SilverlightExtensions.cs
示例16: RenderPagesHtml
public static string RenderPagesHtml(this HtmlHelper helper)
{
var builder = new StringBuilder();
var formatString = "<div class=\"sub\" id=\"{0}\"><h1>{1}</h1>{2}</div>";
var filter = new TypeFilter(typeof(ContentPage));
foreach (ContentPage child in Find.StartPage.GetChildren(filter).OrderBy(x => x.SortOrder))
{
builder.Append(string.Format(formatString, child.Name, child.Title, child.Text));
}
filter = new TypeFilter(typeof(ContactFormPage));
foreach (ContactFormPage child in Find.StartPage.GetChildren(filter))
{
builder.Append(string.Format(formatString, child.Name, child.Title, child.Text));
}
return builder.ToString();
}
开发者ID:Davgus,项目名称:olandskonservatorn,代码行数:18,代码来源:HtmlHelperExtensions.cs
示例17: InitLibs
internal static void InitLibs()
{
// load dumplib for reflection
Assembly dumplib3 = Assembly.ReflectionOnlyLoadFrom("DumpLib.dll");
Assembly dumplibasm = Assembly.LoadFile(Path.Combine(Program.WorkDir, "DumpLib.dll"));
// get a list of all the external assemblies and load them
AssemblyName[] dumplib_refs = dumplibasm.GetReferencedAssemblies();
for (int h = 0; h < dumplib_refs.Length; h++)
Assembly.ReflectionOnlyLoad(dumplib_refs[h].FullName);
var filter = new TypeFilter(InterfaceFilter);
var j = dumplibasm.GetTypes();
Type[] ifaces = null;
foreach (var type in j)
{
ifaces = type.FindInterfaces(filter, "dumplib.Gfx.IColorConverter");
if (ifaces.Length > 0)
{
dumplib.Gfx.IColorConverter newinstance = (dumplib.Gfx.IColorConverter)Activator.CreateInstance(type);
Program.ColorConverters.Add(newinstance.ID, newinstance);
}
ifaces = type.FindInterfaces(filter, "dumplib.Gfx.ITileConverter");
if (ifaces.Length > 0)
{
dumplib.Gfx.ITileConverter newinstance = (dumplib.Gfx.ITileConverter)Activator.CreateInstance(type);
Program.TileConverters.Add(newinstance.ID, newinstance);
}
ifaces = type.FindInterfaces(filter, "dumplib.Gfx.IPaletteConverter");
if (ifaces.Length > 0)
{
dumplib.Gfx.IPaletteConverter newinstance = (dumplib.Gfx.IPaletteConverter)Activator.CreateInstance(type);
Program.PaletteConverters.Add(newinstance.ID, newinstance);
}
//if (type.BaseType != null && type.BaseType.FullName == "dumplib.Image.MediaImage") Program.MediaImages.Add((dumplib.Image.MediaImage)Activator.CreateInstance(type));
}
Console.WriteLine(ifaces.ToString());
// load teh same from other DLLs
}
开发者ID:RyogaMasaki,项目名称:dumpster,代码行数:44,代码来源:libloader.cs
示例18: Run
//Create and iterate through collections
public static void Run()
{
//Scan Nozzles below equi
TypeFilter filt = new TypeFilter(DbElementTypeInstance.NOZZLE);
DBElementCollection collection = new DBElementCollection(Example.Instance.mEqui, filt);
DbAttribute att = DbAttributeInstance.FLNN;
foreach (DbElement ele in collection)
{
Console.WriteLine(ele.GetAsString(att));
}
//Scan branches below site
DBElementCollection coll = new DBElementCollection(Example.Instance.mSite);
coll.IncludeRoot = true;
coll.Filter = new TypeFilter(DbElementTypeInstance.BRANCH);
DBElementEnumerator iter = (DBElementEnumerator)coll.GetEnumerator();
while (iter.MoveNext())
{
Console.WriteLine(iter.Current.ToString());
}
}
开发者ID:freudshow,项目名称:raffles-codes,代码行数:22,代码来源:ExampleCollections.cs
示例19: FindTypes
public virtual Type[] FindTypes(TypeFilter filter, object filterCriteria)
{
Type[] c = GetTypes();
int cnt = 0;
for (int i = 0; i < c.Length; i++)
{
if (filter != null && !filter(c[i], filterCriteria))
c[i] = null;
else
cnt++;
}
if (cnt == c.Length)
return c;
Type[] ret = new Type[cnt];
cnt = 0;
for (int i = 0; i < c.Length; i++)
{
if (c[i] != null)
ret[cnt++] = c[i];
}
return ret;
}
开发者ID:tijoytom,项目名称:corert,代码行数:23,代码来源:Module.cs
示例20: FindInterfaces
public Type[] FindInterfaces(TypeFilter filter, object filterCriteria)
{
List<Type> list = new List<Type>();
foreach (Type type in GetInterfaces())
{
if (filter(type, filterCriteria))
{
list.Add(type);
}
}
return list.ToArray();
}
开发者ID:ngraziano,项目名称:mono,代码行数:12,代码来源:Type.cs
注:本文中的TypeFilter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论