当前位置: 首页>>代码示例>>C#>>正文


C# Type.GetEvent方法代码示例

本文整理汇总了C#中Type.GetEvent方法的典型用法代码示例。如果您正苦于以下问题:C# Type.GetEvent方法的具体用法?C# Type.GetEvent怎么用?C# Type.GetEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Type的用法示例。


在下文中一共展示了Type.GetEvent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HasEvent

 internal bool HasEvent(Type type, string name)
 {
     if (this._targetFrameworkProvider == null)
     {
         return (type.GetEvent(name) != null);
     }
     return (this._targetFrameworkProvider.GetReflectionType(type).GetEvent(name) != null);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ClientBuildManagerTypeDescriptionProviderBridge.cs

示例2: HasEvent

    internal bool HasEvent(Type type, string name) {
        
        if (_targetFrameworkProvider == null) {
            EventInfo runtimeEventInfo = type.GetEvent(name);
            return runtimeEventInfo != null;
        }

        Type reflectionType = _targetFrameworkProvider.GetReflectionType(type);
        EventInfo reflectionEventInfo = reflectionType.GetEvent(name);

        return reflectionEventInfo != null;
    }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:ClientBuildManagerTypeDescriptionProviderBridge.cs

示例3: ComAwareEventInfo

 public ComAwareEventInfo(Type type, string eventName)
 {
     _innerEventInfo = type.GetEvent(eventName);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:4,代码来源:ComAwareEventInfo.cs

示例4: GetEvent

 public static EventInfo GetEvent(Type type, string name, BindingFlags bindingAttr)
 {
     Requires.NotNull(type, "type");
     return type.GetEvent(name, bindingAttr);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:5,代码来源:TypeExtensions.CoreCLR.cs

示例5: test

	public static bool test (Type type) { return type.GetEvent ("Elapsed").IsSpecialName; }	
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:1,代码来源:test-276.cs

示例6: AppendMember

    private List<string> AppendMember(string id, Type type, JObject properties, bool isField)
    {
        var list = new List<string>();
        var MemberName = isField ? string.Format("this.{0}", id) : id;
        Members.Add(id, type);
        if (isField)
        {
            list.Add("//");
            list.Add(string.Format("// {0}", id));
            list.Add("//");
        }
        foreach (var p in properties.Properties().OrderBy(c => c.Name))
        {
            if (p.Name == "ID")
            {
                continue;
            }
            var property = type.GetProperty(p.Name);
            if (property != null)
            {
                if (typeof(System.Collections.IList).IsAssignableFrom(property.PropertyType))
                {
                    var value = (JArray)properties[p.Name];
                    if (value != null && value.Count > 0)
                    {
                        var itemType = property.PropertyType.GetProperty("Item"
                            , System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).PropertyType;

                        foreach (JObject item in value)
                        {
                            var itemID = GetNewMemberID(itemType);
                            item["ID"] = itemID;
                            list.AddRange(AppendMember(itemID, itemType, item, false));
                        }
                        foreach (JObject item in value)
                        {
                            var itemID = (string)item["ID"];
                            list.Add(string.Format("{0}.{1}.Add({2});", MemberName, p.Name, itemID));
                        }
                    }
                }
                else
                {
                    var value = ((JValue)properties[p.Name]).ToString();
                    if (property.PropertyType.IsEnum)
                    {
                        value = string.Format("{0}.{1}", property.PropertyType.FullName, value);
                    }
                    else if (property.PropertyType == typeof(TimeSpan))
                    {
                        value = string.Format("System.TimeSpan.Parse(\"{0}\")", value);
                    }
                    else if (typeof(Component).IsAssignableFrom(property.PropertyType))
                    {
                        if (string.IsNullOrEmpty(value))
                        {
                            value = "null";
                        }
                    }
                    else if (property.PropertyType == typeof(string))
                    {
                        value = string.Format("\"{0}\"", value.Replace("\n", "\\n"));
                    }
                    list.Add(string.Format("{0}.{1} = {2};", MemberName, p.Name, value));
                }
            }
            else
            {
                var eventInfo = type.GetEvent(p.Name);
                if (eventInfo != null)
                {
                    var value = ((JValue)properties[p.Name]).ToString();
                    if (!string.IsNullOrEmpty(value))
                    {
                        list.Add(string.Format("{0}.{1} += new {2}({3});", MemberName, p.Name, eventInfo.EventHandlerType.FullName, value));
                    }
                }
            }
        }
        return list;
    }
开发者ID:san90279,项目名称:UK_OAS,代码行数:81,代码来源:CodeHelper.cs

示例7: GetEvent

 public static EventInfo GetEvent(Type type, string name) => type.GetEvent(name, AllFlags);
开发者ID:geoffkizer,项目名称:corefx,代码行数:1,代码来源:Helpers.cs

示例8: ValidateMembers

    static void ValidateMembers(Type type)
    {

        var constructors = type.GetConstructors();
        foreach (var constructorInfo in constructors)
        {
            Assert.IsTrue(constructorInfo.IsPublic);
        }

        var publicConstructor = constructors.First(x => x.GetParameters().Any(y => y.Name == "public"));
        Assert.IsFalse(publicConstructor.ContainsHideAttribute());
        var internalConstructor = constructors.First(x => x.GetParameters().Any(y => y.Name == "internal"));
        Assert.IsTrue(internalConstructor.ContainsHideAttribute());
        var privateConstructor = constructors.First(x => x.GetParameters().Any(y => y.Name == "private"));
        Assert.IsTrue(privateConstructor.ContainsHideAttribute());

        var publicProperty = type.GetProperty("PublicProperty");
        Assert.IsFalse(publicProperty.GetSetMethod().ContainsHideAttribute());
        Assert.IsFalse(publicProperty.GetGetMethod().ContainsHideAttribute());

        var privateProperty = type.GetProperty("PrivateProperty");
        Assert.IsTrue(privateProperty.GetSetMethod().ContainsHideAttribute());
        Assert.IsTrue(privateProperty.GetGetMethod().ContainsHideAttribute());

        var internalProperty = type.GetProperty("InternalProperty");
        Assert.IsTrue(internalProperty.GetSetMethod().ContainsHideAttribute());
        Assert.IsTrue(internalProperty.GetGetMethod().ContainsHideAttribute());

        var publicMethod = type.GetMethod("PublicMethod");
        Assert.IsFalse(publicMethod.ContainsHideAttribute());

        var privateMethod = type.GetMethod("PrivateMethod");
        Assert.IsTrue(privateMethod.ContainsHideAttribute());

        var internalMethod = type.GetMethod("InternalMethod");
        Assert.IsTrue(internalMethod.ContainsHideAttribute());

        var publicField = type.GetField("PublicField");
        Assert.IsFalse(publicField.ContainsHideAttribute());

        var privateField = type.GetField("PrivateField");
        Assert.IsTrue(privateField.ContainsHideAttribute());

        var internalField = type.GetField("InternalField");
        Assert.IsTrue(internalField.ContainsHideAttribute());

        var publicEvent = type.GetEvent("PublicEvent");
        Assert.IsFalse(publicEvent.GetRemoveMethod().ContainsHideAttribute());
        Assert.IsFalse(publicEvent.GetAddMethod().ContainsHideAttribute());

        var privateEvent = type.GetEvent("PrivateEvent");
        Assert.IsTrue(privateEvent.GetRemoveMethod().ContainsHideAttribute());
        Assert.IsTrue(privateEvent.GetAddMethod().ContainsHideAttribute());

        var internalEvent = type.GetEvent("InternalEvent");
        Assert.IsTrue(internalEvent.GetRemoveMethod().ContainsHideAttribute());
        Assert.IsTrue(internalEvent.GetAddMethod().ContainsHideAttribute());
    }
开发者ID:Fody,项目名称:Publicize,代码行数:58,代码来源:IntegrationTests.cs


注:本文中的Type.GetEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。