Пример #1
0
        private IEnumerable <InterfaceProperty> GetProperties()
        {
            var allPropertyMethods = TypeToWrap
                                     .GetFlattenMethods()
                                     .Where(_ => _.Info.Name.StartsWith("get_") || _.Info.Name.StartsWith("set_"))
                                     .ToList();

            while (allPropertyMethods.Count > 0)
            {
                if (allPropertyMethods[0].Info.Name.StartsWith("get_"))
                {
                    var getAccessor  = allPropertyMethods[0];
                    var propertyName = getAccessor.Info.Name.Substring(4);
                    allPropertyMethods.RemoveAt(0);

                    var setAccessor = allPropertyMethods.FirstOrDefault(_ => _.Info.Name == "set_" + propertyName);
                    if (setAccessor != null)
                    {
                        allPropertyMethods.Remove(setAccessor);
                    }

                    yield return(new InterfaceProperty(getAccessor, setAccessor));
                }
                else
                {
                    var setAccessor  = allPropertyMethods[0];
                    var propertyName = setAccessor.Info.Name.Substring(4);
                    allPropertyMethods.RemoveAt(0);

                    var getAccessor = allPropertyMethods.FirstOrDefault(_ => _.Info.Name == "get_" + propertyName);
                    if (getAccessor != null)
                    {
                        allPropertyMethods.Remove(getAccessor);
                    }

                    yield return(new InterfaceProperty(getAccessor, setAccessor));
                }
            }
        }
Пример #2
0
 private IEnumerable <InterfaceMethod> GetMethods() => TypeToWrap
 .GetFlattenMethods()
 .Where(_ => !_.Info.Name.StartsWith("get_") && !_.Info.Name.StartsWith("set_") && !_.Info.Name.StartsWith("add_") && !_.Info.Name.StartsWith("remove_"));