當前位置: 首頁>>代碼示例>>C#>>正文


C# PropertyDefinition.GetAlreadyNotifies方法代碼示例

本文整理匯總了C#中Mono.Cecil.PropertyDefinition.GetAlreadyNotifies方法的典型用法代碼示例。如果您正苦於以下問題:C# PropertyDefinition.GetAlreadyNotifies方法的具體用法?C# PropertyDefinition.GetAlreadyNotifies怎麽用?C# PropertyDefinition.GetAlreadyNotifies使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.PropertyDefinition的用法示例。


在下文中一共展示了PropertyDefinition.GetAlreadyNotifies方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetPropertyData

    //if (AlreadyContainsNotification(propertyData.PropertyDefinition, node.EventInvoker.MethodReference.Name))
    //          {
    //              moduleWeaver.LogInfo(string.Format("\t{0} Already has notification functionality. Property will be ignored.", propertyData.PropertyDefinition.GetName()));
    //              continue;
    //          }
    void GetPropertyData(PropertyDefinition propertyDefinition, TypeNode node)
    {
        var notifyPropertyData = ReadAlsoNotifyForData(propertyDefinition, node.AllProperties);
        var dependenciesForProperty = node.PropertyDependencies
            .Where(x => x.WhenPropertyIsSet == propertyDefinition)
            .Select(x => x.ShouldAlsoNotifyFor);

        var backingFieldReference = node.Mappings.First(x => x.PropertyDefinition == propertyDefinition).FieldDefinition;
        if (notifyPropertyData == null)
        {
            if (node.EventInvoker == null)
            {
                return;
            }
            node.PropertyDatas.Add(new PropertyData
                                       {
                                           BackingFieldReference = backingFieldReference,
                                           PropertyDefinition = propertyDefinition,
                                           // Compute full dependencies for the current property
                                           AlsoNotifyFor = GetFullDependencies(propertyDefinition, dependenciesForProperty, node),
                                           AlreadyNotifies = propertyDefinition.GetAlreadyNotifies(node.EventInvoker.MethodReference.Name).ToList()
                                       });
            return;
        }

        if (node.EventInvoker == null)
        {
            throw new WeavingException(string.Format(
                @"Could not find field for PropertyChanged event on type '{0}'.
        Looked for 'PropertyChanged', 'propertyChanged', '_PropertyChanged' and '_propertyChanged'.
        The most likely cause is that you have implemented a custom event accessor for the PropertyChanged event and have called the PropertyChangedEventHandler something stupid.", node.TypeDefinition.FullName));
        }
        node.PropertyDatas.Add(new PropertyData
                                   {
                                       BackingFieldReference = backingFieldReference,
                                       PropertyDefinition = propertyDefinition,
                                       // Compute full dependencies for the current property
                                       AlsoNotifyFor = GetFullDependencies(propertyDefinition, notifyPropertyData.AlsoNotifyFor.Union(dependenciesForProperty), node),
                                       AlreadyNotifies = propertyDefinition.GetAlreadyNotifies(node.EventInvoker.MethodReference.Name).ToList()
                                   });
    }
開發者ID:halad,項目名稱:PropertyChanged,代碼行數:46,代碼來源:PropertyDataWalker.cs


注:本文中的Mono.Cecil.PropertyDefinition.GetAlreadyNotifies方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。