Beispiel #1
0
 public static VNodeInfo FromMemberInfo(MemberInfo member)
 {
     return new VNodeInfo(member.InstanceId, 0,
                          member.InternalTcpEndPoint, member.InternalSecureTcpEndPoint,
                          member.ExternalTcpEndPoint, member.ExternalSecureTcpEndPoint,
                          member.InternalHttpEndPoint, member.ExternalHttpEndPoint);
 }
Beispiel #2
0
 public static List<FamilyMember> GetFamilyMembers(int MemberMasterID)
 {
     MemberInfo mInfo;
     mInfo = new MemberInfo(MemberMasterID, 1);
     List<FamilyMember> siblings = mInfo.familyMembers;
     return siblings;
 }
        public static IList<CustomAttributeData> GetCustomAttributes(MemberInfo target)
        {
            if (target == null)
                throw new ArgumentNullException("target");

            IList<CustomAttributeData> cad = GetCustomAttributes(target.Module, target.MetadataToken);

            int pcaCount = 0;
            Attribute[] a = null;
            if (target is RuntimeType)
                a = PseudoCustomAttribute.GetCustomAttributes((RuntimeType)target, typeof(object), false, out pcaCount);
            else if (target is RuntimeMethodInfo)
                a = PseudoCustomAttribute.GetCustomAttributes((RuntimeMethodInfo)target, typeof(object), false, out pcaCount);
            else if (target is RuntimeFieldInfo)
                a = PseudoCustomAttribute.GetCustomAttributes((RuntimeFieldInfo)target, typeof(object), out pcaCount);

            if (pcaCount == 0)
                return cad;

            CustomAttributeData[] pca = new CustomAttributeData[cad.Count + pcaCount];
            cad.CopyTo(pca, pcaCount);
            for (int i = 0; i < pcaCount; i++)
            {
                if (PseudoCustomAttribute.IsSecurityAttribute(a[i].GetType()))
                    continue;

                pca[i] = new CustomAttributeData(a[i]);
            }

            return Array.AsReadOnly(pca);
        }
    /// <summary>
    ///     Additional checks for slot & item type
    /// </summary>
    /// <param name="memberData">Member info</param>
    /// <returns>True if the field should be shown</returns>
    protected override bool ShouldShowField(MemberInfo memberData)
    {
        if (!base.ShouldShowField(memberData))
            return false;

        var limitSlotsAttr = memberData.GetAttribute<ItemDatablockEquipmentSlotAttribute>();
        if (limitSlotsAttr != null)
        {
            FieldInfo slotField = itemDatablock.GetType().GetField("equipmentSlot");
            var datablockSlot = itemDatablock.GetFieldValue<ItemDatablock.Slot>(slotField);
            foreach (ItemDatablock.Slot slot in limitSlotsAttr.slots)
            {
                if (datablockSlot == slot)
                    return true;
            }

            return false;
        }

        var limitTypeAttr = memberData.GetAttribute<ItemDatablockItemTypeAttribute>();
        if (limitTypeAttr != null)
        {
            FieldInfo itemTypeField = itemDatablock.GetType().GetField("itemType");
            var datablockType = itemDatablock.GetFieldValue<ItemDatablock.ItemType>(itemTypeField);
            foreach (ItemDatablock.ItemType type in limitTypeAttr.types)
            {
                if (datablockType == type)
                    return true;
            }

            return false;
        }

        return true;
    }
Beispiel #5
0
    public static string MemberToString(MemberInfo member, object instance)
    {
        StringBuilder o = new StringBuilder();

        XPathAttribute[] attrs = (XPathAttribute[]) member.GetCustomAttributes(typeof(XPathAttribute), true);
        if (attrs.Length == 0)
            return String.Empty;

        o.AppendFormat("{0}: ", member.Name);

        Type member_type;
        if (member is PropertyInfo)
            member_type = ((PropertyInfo)member).PropertyType;
        else
            member_type = ((FieldInfo)member).FieldType;

        if (member_type.IsArray) {
            object[] items = (object[])GetMemberValue(member, instance);
            if (items != null) {
                StringBuilder arr = new StringBuilder();
                foreach (object item in items)
                    arr.AppendFormat("{0}{1}", (arr.Length == 0) ? "" : ", ",
                                     DebugExtractInfo.ToString(item));

                o.AppendFormat("[{0}]", arr);
            }
            else
                o.Append("[]");
        }
        else
            o.Append(DebugExtractInfo.ToString(GetMemberValue(member, instance)));

        return o.ToString();
    }
Beispiel #6
0
    private string GetNarrative()
    {
        MemberInfo mi = new MemberInfo(CurrentUserID);
        DataSet dsNarrative = mi.GetNarrative(MemberMasterID, AssessmentID);
        DataTable dtMemberInfo = new DataTable();
        DataTable dtNarration = new DataTable();
        string Narration = string.Empty;
        if (dsNarrative.Tables.Count > 0)
        {
            dtMemberInfo = dsNarrative.Tables[0];
            dtNarration = dsNarrative.Tables[1];
        }

        if (dtNarration.Rows.Count > 0)
        {
            Narration = dtNarration.Rows[0]["NARRATION"].ToString();
        }
        if (dtMemberInfo.Rows.Count > 0)
        {
            for (int i = 0; i < dtMemberInfo.Columns.Count; i++)
            {
                Narration = Narration.Replace(dtMemberInfo.Columns[i].ColumnName, dtMemberInfo.Rows[0][i].ToString());
            }
        }
        return Narration;
    }
	public static Object[] GetObjectData(Object obj, MemberInfo[] members)
			{
				if(obj == null)
				{
					throw new ArgumentNullException("obj");
				}
				if(members == null)
				{
					throw new ArgumentNullException("members");
				}
				Object[] data = new Object [members.Length];
				int index;
				for(index = 0; index < members.Length; ++index)
				{
					if(members[index] == null)
					{
						throw new ArgumentNullException
							("members[" + index.ToString() + "]");
					}
					if(!(members[index] is FieldInfo))
					{
						throw new SerializationException
							(_("Serialize_NotField"));
					}
					data[index] = ((FieldInfo)(members[index])).GetValue(obj);
				}
				return data;
			}
        private Issue AnalyzeMember(MemberInfo memberInfo, SemanticModel model, ClassInfo classInfo)
        {
            foreach (BlockSyntax block in memberInfo.Blocks)
            {
                var identifiers = block.DescendantNodes().OfType<IdentifierNameSyntax>().ToList();

                foreach (IdentifierNameSyntax identifierName in identifiers)
                {
                    SymbolInfo identifierSymbol = model.GetSymbolInfo(identifierName);

                    //Does this symbol refer to a GuardedField?
                    GuardedFieldInfo foundGuardedField = classInfo.GuardedFields.FirstOrDefault(field => field.Symbol == identifierSymbol.Symbol);

                    if (foundGuardedField != null)
                    {
                        //We must be inside a lock statement
                        LockHierarchy controlFlowHierarchy = CreateLockHiearchyFromIdentifier(identifierName);

                        bool lockHierarchySatisfied = LockHierarchy.IsSatisfiedBy(foundGuardedField.DeclaredLockHierarchy, controlFlowHierarchy);

                        if (!lockHierarchySatisfied)
                        {
                            return new Issue(
                                ErrorCode.GUARDED_FIELD_ACCESSED_OUTSIDE_OF_LOCK,
                                identifierName,
                                identifierSymbol.Symbol);
                        }
                    }
                }
            }

            return null;
        }
        public MemberInfoDto(MemberInfo member)
        {
            InstanceId = member.InstanceId;

            TimeStamp = member.TimeStamp;
            State = member.State;
            IsAlive = member.IsAlive;

            InternalTcpIp = member.InternalTcpEndPoint.Address.ToString();
            InternalTcpPort = member.InternalTcpEndPoint.Port;
            InternalSecureTcpPort = member.InternalSecureTcpEndPoint == null ? 0 : member.InternalSecureTcpEndPoint.Port;
            
            ExternalTcpIp = member.ExternalTcpEndPoint.Address.ToString();
            ExternalTcpPort = member.ExternalTcpEndPoint.Port;
            ExternalSecureTcpPort = member.ExternalSecureTcpEndPoint == null ? 0 : member.ExternalSecureTcpEndPoint.Port;

            InternalHttpIp = member.InternalHttpEndPoint.Address.ToString();
            InternalHttpPort = member.InternalHttpEndPoint.Port;

            ExternalHttpIp = member.ExternalHttpEndPoint.Address.ToString();
            ExternalHttpPort = member.ExternalHttpEndPoint.Port;

            LastCommitPosition = member.LastCommitPosition;
            WriterCheckpoint = member.WriterCheckpoint;
            ChaserCheckpoint = member.ChaserCheckpoint;
            
            EpochPosition = member.EpochPosition;
            EpochNumber = member.EpochNumber;
            EpochId = member.EpochId;

            NodePriority = member.NodePriority;
        }
 public override string GetColumnDbType(MappingEntity entity, MemberInfo member)
 {
     AttributeMappingMember mm = ((AttributeMappingEntity)entity).GetMappingMember(member.Name);
     if (mm != null && mm.Column != null && !string.IsNullOrEmpty(mm.Column.DbType))
         return mm.Column.DbType;
     return null;
 }
Beispiel #11
0
 public override Lilium.Controls.Control CreateControl(MemberInfo memberInfo, object obj)
 {
     var fieldInfo = memberInfo as FieldInfo;
     Func<string> func;
     if(fieldInfo.FieldType == typeof(SharpDX.Vector3))
     {
         func = () =>
             {
                 var vec = (SharpDX.Vector3)fieldInfo.GetValue(obj);
                 return vec.ToString("0.###");
             };
     }
     else if(fieldInfo.FieldType == typeof(SharpDX.Vector4))
     {
         func = () =>
             {
                 var vec = (SharpDX.Vector4)fieldInfo.GetValue(obj);
                 return vec.ToString("0.###");
             };
     }
     else
     {
         func = ()=> fieldInfo.GetValue(obj).ToString();
     }
     return new Lilium.Controls.Label(memberInfo.Name, func);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConstructorInitializedMemberException"/> class.
 /// </summary>
 /// <param name="constructorInfo">The Constructor.</param>
 /// <param name="missingParameter">The parameter that was not exposed as a field or property.</param>
 /// <param name="message">
 /// The error message that explains the reason for the exception.
 /// </param>
 /// <param name="innerException">
 /// The exception that is the cause of the current exception.
 /// </param>
 public ConstructorInitializedMemberException(ConstructorInfo constructorInfo, ParameterInfo missingParameter, string message,
     Exception innerException)
     : base(message, innerException)
 {
     this.memberInfo = constructorInfo;
     this.missingParameter = missingParameter;
 }
    void RunField(MemberInfo member, Assembly assembly)
    {
      var fieldInfo = (FieldInfo)member;
      var context = _explorer.FindContexts(fieldInfo);

      StartRun(CreateMap(assembly, new[] {context}));
    }
 public void ReadPacket(PacketReader reader)
 {
     RankList = new List<MemberInfo>();
     var count = reader.ReadInt32();
     for (int i = 0; i < count; i++)
     {
         var memberInfo = new MemberInfo();
         memberInfo.Unknown1 = reader.ReadInt64();
         memberInfo.Name = reader.ReadString();
         memberInfo.Rank = reader.ReadInt32();
         memberInfo.Trophies = reader.ReadInt32();
         memberInfo.Unknown2 = reader.ReadInt32();
         memberInfo.Level = reader.ReadInt32();
         memberInfo.AttacksWon = reader.ReadInt32();
         memberInfo.AttacksLost = reader.ReadInt32();
         memberInfo.DefencesWon = reader.ReadInt32();
         memberInfo.DefencesLost = reader.ReadInt32();
         memberInfo.Unknown3 = reader.ReadInt32();
         memberInfo.CountryCode = reader.ReadString();
         memberInfo.Unknown4 = reader.ReadInt64();
         memberInfo.Unknown5 = reader.ReadInt64();
         if (reader.ReadBoolean())
         {
             memberInfo.Clan = new Clan();
             memberInfo.Clan.ID = reader.ReadInt64();
             memberInfo.Clan.Name = reader.ReadString();
             memberInfo.Clan.Badge = reader.ReadInt32();
         }
         RankList.Add(memberInfo);
     }
 }
Beispiel #15
0
        public static IList<CustomAttributeData> GetCustomAttributes(MemberInfo target)
        {
            if (target == null)
                throw new ArgumentNullException("target");

            return target.GetCustomAttributesData();
        }
Beispiel #16
0
        public object ResolveMemberInvoke(object obj, MemberInfo memberInfo)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");
            if (memberInfo == null)
                throw new ArgumentNullException("memberInfo");

            if (memberInfo.MemberType == MemberType.Function)
            {
                var methodInfo = obj.GetType().GetMethod(memberInfo.Name);
                if (methodInfo == null)
                {
                    throw new MissingMemberException(obj.GetType().FullName, memberInfo.Name);
                }

                return methodInfo.Invoke(obj, memberInfo.Arguments.ToArray());
            }

            if (memberInfo.MemberType == MemberType.Property || memberInfo.MemberType == MemberType.Array)
            {
                var propertyInfo = obj.GetType().GetProperty(memberInfo.Name);
                if (propertyInfo == null)
                {
                    throw new MissingMemberException(obj.GetType().FullName, memberInfo.Name);
                }
                object[] index = null;
                if (memberInfo.MemberType == MemberType.Array)
                {
                    index = memberInfo.Arguments.ToArray();
                }
                return propertyInfo.GetValue(obj, index);
            }

            throw new NotImplementedException();
        }
    private static void ShowAttributes(MemberInfo attributeTarget)
    {
        Attribute[] attributes = Attribute.GetCustomAttributes(attributeTarget);

        Console.WriteLine("Attributes applied to {0}: {1}",
           attributeTarget.Name, (attributes.Length == 0 ? "None" : String.Empty));

        foreach (Attribute attribute in attributes)
        {
            // Display the type of each applied attribute
            Console.WriteLine("  {0}", attribute.GetType().ToString());

            if (attribute is DefaultMemberAttribute)
                Console.WriteLine("    MemberName={0}",
                   ((DefaultMemberAttribute)attribute).MemberName);

            if (attribute is ConditionalAttribute)
                Console.WriteLine("    ConditionString={0}",
                   ((ConditionalAttribute)attribute).ConditionString);

            if (attribute is CLSCompliantAttribute)
                Console.WriteLine("    IsCompliant={0}",
                   ((CLSCompliantAttribute)attribute).IsCompliant);

            DebuggerDisplayAttribute dda = attribute as DebuggerDisplayAttribute;
            if (dda != null)
            {
                Console.WriteLine("    Value={0}, Name={1}, Target={2}",
                   dda.Value, dda.Name, dda.Target);
            }
        }
        Console.WriteLine();
    }
Beispiel #18
0
 protected void Page_Load(object sender, EventArgs e)
 {
     MemberMasterID = Int32.Parse(Request.QueryString["ID"]);
     AssessmentID = Int32.Parse(Request.QueryString["AssessmentID"]);
     mInfo = new MemberInfo(MemberMasterID, CurrentUserID);
     Master.PageHeader = "Member HRA";
 }
Beispiel #19
0
        public IMember GetMember(IModuleContext context, string name) {
            if (_attrs == null) {
                Interlocked.CompareExchange(ref _attrs, new Dictionary<string, MemberInfo>(), null);
            }
            bool showClr = context == null || ((IronPythonModuleContext)context).ShowClr;

            MemberInfo member;
            if (!_attrs.TryGetValue(name, out member) || member.Member == null) {
                var res = Interpreter.Remote.GetMember(Value, name);
                if (!res.Equals(Value)) {
                    _attrs[name] = member = new MemberInfo(_interpreter.MakeObject(res));
                }
            }

            if (!showClr) {
                if (!(this is IronPythonNamespace)) {   // namespaces always show all of their members...
                    switch (member.ClrOnly) {
                        case IsClrOnly.NotChecked:
                            CreateNonClrAttrs();
                            if (_attrs.ContainsKey(name) && 
                                _attrs[name].ClrOnly == IsClrOnly.Yes) {
                                return null;
                            }
                            break;
                        case IsClrOnly.No:
                            break;
                        case IsClrOnly.Yes:
                            return null;
                    }
                }
            }

            return member.Member;
        }
Beispiel #20
0
 public static AttributeMap[] Create(TypeModel model, MemberInfo member, bool inherit)
 {
     #if FEAT_IKVM
     System.Collections.Generic.IList<CustomAttributeData> all = member.__GetCustomAttributes(model.MapType(typeof(Attribute)), inherit);
     AttributeMap[] result = new AttributeMap[all.Count];
     int index = 0;
     foreach (CustomAttributeData attrib in all)
     {
         result[index++] = new AttributeDataMap(attrib);
     }
     return result;
     #else
     #if WINRT
     Attribute[] all = System.Linq.Enumerable.ToArray(member.GetCustomAttributes(inherit));
     #else
     var all = member.GetCustomAttributes(inherit);
     #endif
     var result = new AttributeMap[all.Length];
     for (var i = 0; i < all.Length; i++)
     {
         result[i] = new ReflectionAttributeMap((Attribute) all[i]);
     }
     return result;
     #endif
 }
 public override void impUI(object pObject, MemberInfo pMemberInfo)
 {
     PropertyInfo pPropertyInfo = (PropertyInfo)pMemberInfo;
     float lValue = (float) pPropertyInfo.GetValue(pObject, null);
     var lNewValue = GUILayout.HorizontalSlider(lValue, leftValue, rightValue);
     if (lNewValue != lValue)
         pPropertyInfo.SetValue(pObject, lNewValue, null);
 }
Beispiel #22
0
		private static IEnumerable<object> GetAttributesForMethodAndType(MemberInfo memberInfo, Type type)
		{
			var declaringType = memberInfo.DeclaringType;
			if (declaringType == null)
				return memberInfo.GetCustomAttributes(type, true);
			return memberInfo.GetCustomAttributes(type, true)
				.Concat(declaringType.GetCustomAttributes(type, true));
		}
Beispiel #23
0
 private static string GetDescription(MemberInfo info)
 {
   DescriptionAttribute descriptionAttribute = Enumerable.FirstOrDefault<object>((IEnumerable<object>) info.GetCustomAttributes(typeof (DescriptionAttribute), false)) as DescriptionAttribute;
   if (descriptionAttribute != null)
     return descriptionAttribute.Description;
   else
     return (string) null;
 }
Beispiel #24
0
 internal ParameterInfo(MethodInfo owner, string name, Type parameterType, int position)
 {
     this.MemberImpl = owner;
     this.NameImpl = name;
     this.ClassImpl = parameterType;
     this.PositionImpl = position;
     this.AttrsImpl = ParameterAttributes.None;
 }
Beispiel #25
0
 private ParameterInfo(ParameterInfo accessor, MemberInfo member)
 {
     this.MemberImpl = member;
     this.NameImpl = accessor.Name;
     this.ClassImpl = accessor.ParameterType;
     this.PositionImpl = accessor.Position;
     this.AttrsImpl = accessor.Attributes;
 }
Beispiel #26
0
 // Returns the type for fields and properties and null for everything else
 static Type GetTypeForMember(MemberInfo mi)
 {
     if (mi is FieldInfo)
         return ((FieldInfo)mi).FieldType;
     else if (mi is PropertyInfo)
         return ((PropertyInfo)mi).PropertyType;
     return null;
 }
Beispiel #27
0
		public DebugParameterInfo(MemberInfo member, string name, Type parameterType, int position, ValueGetter getter)
		{
			this.member = member;
			this.name = name;
			this.parameterType = parameterType;
			this.position = position;
			this.getter = getter;
		}
Beispiel #28
0
        internal static bool CanWrite(TypeModel model, MemberInfo member)
        {
            if (member == null) throw new ArgumentNullException("member");

            PropertyInfo prop = member as PropertyInfo;
            if (prop != null) return prop.CanWrite || GetShadowSetter(model, prop) != null;

            return member is FieldInfo; // fields are always writeable; anything else: JUST SAY NO!
        }
 private static string GetCustomAttributeData(MemberInfo mi, Type attrType, out Type typeValue)
 {
     string str = GetCustomAttributeData(CustomAttributeData.GetCustomAttributes(mi), attrType, out typeValue, true, false);
     if (str != null)
     {
         return str;
     }
     return string.Empty;
 }
    public void RunMember(Assembly assembly, MemberInfo member)
    {
      _internalListener.OnRunStart();
      AppDomain appDomain = CreateAppDomain(assembly);

      CreateRunnerAndUnloadAppDomain("Member", appDomain, assembly, member);

      _internalListener.OnRunEnd();
    }
Beispiel #31
0
 public override Expression GetGeneratedIdExpression(MemberInfo member)
 {
     return(new FunctionExpression(TypeHelper.GetMemberType(member), "GETAUTOINCVALUE()", null));
 }
Beispiel #32
0
 int IEqualityComparer<MemberInfo>.GetHashCode(MemberInfo a) => GetHashCode(a);
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <TList> entry, GUIContent label)
        {
            var property    = entry.Property;
            var infoContext = property.Context.Get(this, "Context", (ListDrawerConfigInfo)null);
            var info        = infoContext.Value;

            bool isReadOnly = false;

            if (entry.TypeOfValue.IsArray == false)
            {
                for (int i = 0; i < entry.ValueCount; i++)
                {
                    if ((entry.WeakValues[i] as IList <TElement>).IsReadOnly)
                    {
                        isReadOnly = true;
                        break;
                    }
                }
            }

            if (info == null)
            {
                var customListDrawerOptions = property.Info.GetAttribute <ListDrawerSettingsAttribute>() ?? new ListDrawerSettingsAttribute();
                isReadOnly = entry.IsEditable == false || isReadOnly || customListDrawerOptions.IsReadOnlyHasValue && customListDrawerOptions.IsReadOnly;

                info = infoContext.Value = new ListDrawerConfigInfo()
                {
                    StartIndex              = 0,
                    Toggled                 = entry.Context.GetPersistent <bool>(this, "ListDrawerToggled", customListDrawerOptions.ExpandedHasValue ? customListDrawerOptions.Expanded : GeneralDrawerConfig.Instance.OpenListsByDefault),
                    RemoveAt                = -1,
                    label                   = new GUIContent(label == null || string.IsNullOrEmpty(label.text) ? property.ValueEntry.TypeOfValue.GetNiceName() : label.text, label == null ? string.Empty : label.tooltip),
                    ShowAllWhilePageing     = false,
                    EndIndex                = 0,
                    CustomListDrawerOptions = customListDrawerOptions,
                    IsReadOnly              = isReadOnly,
                    Draggable               = !isReadOnly && (!customListDrawerOptions.IsReadOnlyHasValue)
                };

                info.listConfig = GeneralDrawerConfig.Instance;
                info.property   = property;

                if (customListDrawerOptions.DraggableHasValue && !customListDrawerOptions.DraggableItems)
                {
                    info.Draggable = false;
                }

                if (info.CustomListDrawerOptions.OnBeginListElementGUI != null)
                {
                    string     errorMessage;
                    MemberInfo memberInfo = property.ParentType
                                            .FindMember()
                                            .IsMethod()
                                            .IsNamed(info.CustomListDrawerOptions.OnBeginListElementGUI)
                                            .HasParameters <int>()
                                            .ReturnsVoid()
                                            .GetMember <MethodInfo>(out errorMessage);

                    if (memberInfo == null || errorMessage != null)
                    {
                        Debug.LogError(errorMessage ?? "There should really be an error message here.");
                    }
                    else
                    {
                        info.OnBeginListElementGUI = EmitUtilities.CreateWeakInstanceMethodCaller <int>(memberInfo as MethodInfo);
                    }
                }

                if (info.CustomListDrawerOptions.OnEndListElementGUI != null)
                {
                    string     errorMessage;
                    MemberInfo memberInfo = property.ParentType
                                            .FindMember()
                                            .IsMethod()
                                            .IsNamed(info.CustomListDrawerOptions.OnEndListElementGUI)
                                            .HasParameters <int>()
                                            .ReturnsVoid()
                                            .GetMember <MethodInfo>(out errorMessage);

                    if (memberInfo == null || errorMessage != null)
                    {
                        Debug.LogError(errorMessage ?? "There should really be an error message here.");
                    }
                    else
                    {
                        info.OnEndListElementGUI = EmitUtilities.CreateWeakInstanceMethodCaller <int>(memberInfo as MethodInfo);
                    }
                }

                if (info.CustomListDrawerOptions.OnTitleBarGUI != null)
                {
                    string     errorMessage;
                    MemberInfo memberInfo = property.ParentType
                                            .FindMember()
                                            .IsMethod()
                                            .IsNamed(info.CustomListDrawerOptions.OnTitleBarGUI)
                                            .HasNoParameters()
                                            .ReturnsVoid()
                                            .GetMember <MethodInfo>(out errorMessage);

                    if (memberInfo == null || errorMessage != null)
                    {
                        Debug.LogError(errorMessage ?? "There should really be an error message here.");
                    }
                    else
                    {
                        info.OnTitleBarGUI = EmitUtilities.CreateWeakInstanceMethodCaller(memberInfo as MethodInfo);
                    }
                }

                if (info.CustomListDrawerOptions.ListElementLabelName != null)
                {
                    string     errorMessage;
                    MemberInfo memberInfo = typeof(TElement)
                                            .FindMember()
                                            .HasNoParameters()
                                            .IsNamed(info.CustomListDrawerOptions.ListElementLabelName)
                                            .HasReturnType <object>(true)
                                            .GetMember(out errorMessage);

                    if (memberInfo == null || errorMessage != null)
                    {
                        Debug.LogError(errorMessage ?? "There should really be an error message here.");
                    }
                    else
                    {
                        string methodSuffix = memberInfo as MethodInfo == null ? "" : "()";
                        info.GetListElementLabelText = DeepReflection.CreateWeakInstanceValueGetter(typeof(TElement), typeof(object), info.CustomListDrawerOptions.ListElementLabelName + methodSuffix);
                    }
                }
            }

            info.listConfig = GeneralDrawerConfig.Instance;
            info.property   = property;

            info.ListItemStyle.padding.left  = info.Draggable ? 25 : 7;
            info.ListItemStyle.padding.right = info.IsReadOnly ? 4 : 20;

            if (Event.current.type == EventType.Repaint)
            {
                info.DropZoneTopLeft = GUIUtility.GUIToScreenPoint(new Vector2(0, 0));
            }

            info.ListValueChanger = property.ValueEntry.GetListValueEntryChanger();
            info.Count            = property.Children.Count;
            info.IsEmpty          = property.Children.Count == 0;

            SirenixEditorGUI.BeginIndentedVertical(SirenixGUIStyles.PropertyPadding);
            this.BeginDropZone(info);
            {
                this.DrawToolbar(info);
                if (SirenixEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(property, this), info.Toggled.Value))
                {
                    GUIHelper.PushLabelWidth(EditorGUIUtility.labelWidth - info.ListItemStyle.padding.left);
                    this.DrawItems(info);
                    GUIHelper.PopLabelWidth();
                }
                SirenixEditorGUI.EndFadeGroup();
            }
            this.EndDropZone(info);
            SirenixEditorGUI.EndIndentedVertical();

            if (info.RemoveAt >= 0 && Event.current.type == EventType.Repaint)
            {
                info.ListValueChanger.RemoveListElementAt(info.RemoveAt, CHANGE_ID);

                info.RemoveAt = -1;
                GUIHelper.RequestRepaint();
            }

            if (info.ObjectPicker != null && info.ObjectPicker.IsReadyToClaim && Event.current.type == EventType.Repaint)
            {
                var value = info.ObjectPicker.ClaimObject();

                if (info.JumpToNextPageOnAdd)
                {
                    info.StartIndex = int.MaxValue;
                }

                object[] values = new object[info.ListValueChanger.ValueCount];

                values[0] = value;
                for (int j = 1; j < values.Length; j++)
                {
                    values[j] = SerializationUtility.CreateCopy(value);
                }

                info.ListValueChanger.AddListElement(values, CHANGE_ID);
            }
        }
        /// <summary>
        /// Retrieves a custom attribute of a specified type that is applied to a specified member,
        /// and optionally inspects the ancestors of that member.
        /// </summary>
        /// <typeparam name="T">The type of attribute to search for.</typeparam>
        /// <param name="element">The member to inspect.</param>
        /// <param name="inherit"><c>true</c> to inspect the ancestors of element; otherwise, <c>false</c>.</param>
        /// <returns>A custom attribute that matches <typeparamref name="T"/>, or <c>null</c> if no such attribute is found.</returns>
#if !ASPNETCORE50
        public static T GetCustomAttribute <T>(this MemberInfo element, bool inherit) where T : Attribute
        {
            return((T)Attribute.GetCustomAttribute(element, typeof(T), inherit));
        }
Beispiel #35
0
 protected MemberAssignment UpdateMemberAssignment(MemberAssignment assignment, MemberInfo member, Expression expression)
 {
     if (expression != assignment.Expression || member != assignment.Member)
     {
         return Expression.Bind(member, expression);
     }
     return assignment;
 }
        protected override void Render(HtmlTextWriter writer)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            string       domainName     = Globals.DomainName;
            string       text           = HttpContext.Current.Request.UserAgent;
            bool         flag           = false;

            flag = (masterSettings.OpenWap == 1 && true);
            if (string.IsNullOrEmpty(text))
            {
                text = "";
            }
            if (text.ToLower().IndexOf("micromessenger") > -1 && masterSettings.OpenVstore == 1)
            {
                flag = true;
            }
            HiContext current = HiContext.Current;
            bool      flag2   = false;

            if (masterSettings.OpenMultStore)
            {
                flag2 = true;
            }
            string imageServerUrl = Globals.GetImageServerUrl();

            writer.Write("<script language=\"javascript\" type=\"text/javascript\"> \r\n                                var HasWapRight = {0};\r\n                                var IsOpenStores = {1};\r\n                                var ClientPath = \"{2}\";\r\n                                var ImageServerUrl = \"{3}\";\r\n                                var ImageUploadPath = \"{4}\";\r\n                                var StoreDefaultPage = \"{5}\";\r\n                                var qqMapAPIKey = \"{6}\";\r\n                            </script>", flag ? "true" : "false", flag2.ToString().ToLower(), HiContext.Current.GetClientPath, imageServerUrl, string.IsNullOrEmpty(imageServerUrl) ? "/admin/UploadHandler.ashx?action=newupload" : "/admin/UploadHandler.ashx?action=remoteupdateimages", masterSettings.Store_PositionRouteTo, string.IsNullOrEmpty(masterSettings.QQMapAPIKey) ? "SYJBZ-DSLR3-IWX3Q-3XNTM-ELURH-23FTP" : masterSettings.QQMapAPIKey);
            string text2 = HttpContext.Current.Request.Url.ToString().ToLower();

            if ((text2.Contains("/groupbuyproductdetails") || text2.Contains("/countdownproductsdetails") || (text2.Contains("/productdetails") && !text2.Contains("/appshop")) || text2.Contains("/membercenter") || text2.Contains("/membergroupdetails") || text2.Contains("/membergroupdetailsstatus") || text2.Contains("/fightgroupactivitydetails") || text2.Contains("/fightgroupactivitydetailssoon") || text2.Contains("/fightgroupdetails") || text2.Contains("/productlist") || text2.Contains("/default") || text2.Contains("/storehome") || text2.Contains("/storelist") || text2.Contains("/storeproductdetails") || text2.Contains("/presaleproductdetails") || text2.Contains("countdownstoreproductsdetails")) && masterSettings.MeiQiaActivated == "1")
            {
                string     empty     = string.Empty;
                string     empty2    = string.Empty;
                int        productId = 0;
                string     text3     = masterSettings.MeiQiaUnitid.ToNullString();
                string     text4     = string.Empty;
                string     text5     = string.Empty;
                string     empty3    = string.Empty;
                string     text6     = string.Empty;
                string     empty4    = string.Empty;
                string     empty5    = string.Empty;
                string     empty6    = string.Empty;
                string     empty7    = string.Empty;
                string     empty8    = string.Empty;
                string     text7     = string.Empty;
                string     text8     = string.Empty;
                string     text9     = string.Empty;
                string     text10    = string.Empty;
                string     empty9    = string.Empty;
                string     empty10   = string.Empty;
                string     text11    = string.Empty;
                string     text12    = string.Empty;
                string     text13    = string.Empty;
                string     text14    = string.Empty;
                string     text15    = string.Empty;
                MemberInfo user      = HiContext.Current.User;
                if (user != null)
                {
                    text4  = user.RealName.ToNullString();
                    empty8 = text4;
                    empty7 = user.UserName.ToNullString();
                    empty5 = ((user.Picture == null) ? "" : (masterSettings.SiteUrl + user.Picture));
                    text5  = ((user.Gender != Gender.Female) ? ((user.Gender != Gender.Male) ? "保密" : "男") : "女");
                    empty3 = user.BirthDate.ToNullString();
                    object obj;
                    if (!user.BirthDate.HasValue)
                    {
                        obj = "";
                    }
                    else
                    {
                        DateTime dateTime = DateTime.Now;
                        int      year     = dateTime.Year;
                        dateTime = user.BirthDate.Value;
                        obj      = (year - dateTime.Year).ToString();
                    }
                    text6  = (string)obj;
                    text7  = user.CellPhone.ToNullString();
                    text8  = user.Email.ToNullString();
                    text9  = RegionHelper.GetFullRegion(user.RegionId, "", true, 0) + user.Address;
                    text10 = user.QQ.ToNullString();
                    text11 = user.WeChat.ToNullString();
                    text12 = user.Wangwang.ToNullString();
                    DateTime createDate = user.CreateDate;
                    text13 = ((user.CreateDate < new DateTime(1000, 1, 1)) ? "" : user.CreateDate.ToNullString());
                    MemberGradeInfo memberGrade = MemberHelper.GetMemberGrade(user.GradeId);
                    text14 = ((memberGrade == null) ? "" : memberGrade.Name.ToNullString());
                }
                if (int.TryParse(this.Page.Request.QueryString["productId"], out productId))
                {
                    SiteSettings masterSettings2   = SettingsManager.GetMasterSettings();
                    ProductInfo  productSimpleInfo = ProductBrowser.GetProductSimpleInfo(productId);
                    if (productSimpleInfo != null && productSimpleInfo.SaleStatus != 0)
                    {
                        text15 = ",'商品名称': '{0}'\r\n                                    ,'售价': '{1}'\r\n                                    ,'市场价': '{2}'\r\n                                    ,'品牌': '{3}'\r\n                                    ,'商品编号': '{4}'\r\n                                    ,'商品货号': '{5}'\r\n                                    ,'浏览次数': '{6}'\r\n                                    ,'重量': '{7}'\r\n                                    ,'已经出售': '{8}'";
                        string empty11 = string.Empty;
                        empty11 = ((!(productSimpleInfo.MinSalePrice == productSimpleInfo.MaxSalePrice)) ? (productSimpleInfo.MinSalePrice.F2ToString("f2") + " - " + productSimpleInfo.MaxSalePrice.F2ToString("f2")) : productSimpleInfo.MinSalePrice.F2ToString("f2"));
                        string empty12 = string.Empty;
                        empty12 = ((!(productSimpleInfo.Weight > decimal.Zero)) ? "无" : string.Format("{0} g", productSimpleInfo.Weight.F2ToString("f2")));
                        string obj2 = string.Empty;
                        if (productSimpleInfo.BrandId.HasValue)
                        {
                            BrandCategoryInfo brandCategory = CatalogHelper.GetBrandCategory(productSimpleInfo.BrandId.Value);
                            if (brandCategory != null)
                            {
                                obj2 = brandCategory.BrandName;
                            }
                        }
                        text15 = string.Format(text15, productSimpleInfo.ProductName.ToNullString(), empty11, productSimpleInfo.MarketPrice.ToNullString(), obj2.ToNullString(), productSimpleInfo.ProductCode.ToNullString(), productSimpleInfo.SKU.ToNullString(), productSimpleInfo.VistiCounts.ToNullString(), empty12, productSimpleInfo.ShowSaleCounts.ToNullString());
                    }
                }
                empty = "<script type='text/javascript'>\r\n                                    (function (m, ei, q, i, a, j, s) {\r\n                                        m[a] = m[a] || function () {\r\n                                            (m[a].a = m[a].a || []).push(arguments)\r\n                                        };\r\n                                        j = ei.createElement(q),\r\n                                            s = ei.getElementsByTagName(q)[0];\r\n                                        j.async = true;\r\n                                        j.charset = 'UTF-8';\r\n                                        j.src = i;\r\n                                        s.parentNode.insertBefore(j, s)\r\n                                    })(window, document, 'script', '//eco-api.meiqia.com/dist/meiqia.js', '_MEIQIA');\r\n                                    _MEIQIA('entId', " + text3 + ");\r\n                                    _MEIQIA('metadata', { \r\n                                                address: '" + text9 + "', // 地址\r\n                                                age: '" + text6 + "', // 年龄\r\n                                                comment: '" + empty6 + "', // 备注\r\n                                                email: '" + text8 + "', // 邮箱\r\n                                                gender: '" + text5 + "', // 性别\r\n                                                name: '" + text4 + "', // 名字\r\n                                                qq: '" + text10 + "', // QQ\r\n                                                tel: '" + text7 + "', // 电话\r\n                                                weibo: '" + empty9 + "', // 微博\r\n                                                weixin: '" + empty10 + "', // 微信 \r\n                                                '会员等级': '" + text14 + "',\r\n                                                'MSN': '" + text11 + "',\r\n                                                '旺旺': '" + text12 + "',\r\n                                                '账号创建时间': '" + text13 + "' " + text15 + "\r\n                                    });\r\n                                </script>";
                writer.Write(empty);
            }
            writer.WriteLine();
        }
Beispiel #37
0
 protected virtual Expression VisitMemberAndExpression(MemberInfo member, Expression expression)
 {
     return this.Visit(expression);
 }
Beispiel #38
0
        private MappingEntity CreateEntity(Type elementType, string tableId, Type entityType)
        {
            if (tableId == null)
            {
                tableId = this.GetTableId(elementType);
            }
            var members           = new HashSet <string>();
            var mappingMembers    = new List <AttributeMappingMember>();
            int dot               = tableId.IndexOf('.');
            var rootTableId       = dot > 0 ? tableId.Substring(0, dot) : tableId;
            var path              = dot > 0 ? tableId.Substring(dot + 1) : "";
            var mappingAttributes = this.GetMappingAttributes(rootTableId);
            var tableAttributes   = mappingAttributes.OfType <TableBaseAttribute>()
                                    .OrderBy(ta => ta.Name);
            var tableAttr = tableAttributes.OfType <TableAttribute>().FirstOrDefault();

            if (tableAttr != null && tableAttr.EntityType != null && entityType == elementType)
            {
                entityType = tableAttr.EntityType;
            }
            var memberAttributes = mappingAttributes.OfType <MemberAttribute>()
                                   .Where(ma => ma.Member.StartsWith(path))
                                   .OrderBy(ma => ma.Member);

            foreach (var attr in memberAttributes)
            {
                if (string.IsNullOrEmpty(attr.Member))
                {
                    continue;
                }
                string                 memberName = (path.Length == 0) ? attr.Member : attr.Member.Substring(path.Length + 1);
                MemberInfo             member     = null;
                MemberAttribute        attribute  = null;
                AttributeMappingEntity nested     = null;
                if (memberName.Contains('.')) // additional nested mappings
                {
                    string nestedMember = memberName.Substring(0, memberName.IndexOf('.'));
                    if (nestedMember.Contains('.'))
                    {
                        continue; // don't consider deeply nested members yet
                    }
                    if (members.Contains(nestedMember))
                    {
                        continue; // already seen it (ignore additional)
                    }
                    members.Add(nestedMember);
                    member = this.FindMember(entityType, nestedMember);
                    string newTableId = tableId + "." + nestedMember;
                    nested = (AttributeMappingEntity)this.GetEntity(TypeHelper.GetMemberType(member), newTableId);
                }
                else
                {
                    if (members.Contains(memberName))
                    {
                        throw new InvalidOperationException(string.Format("AttributeMapping: more than one mapping attribute specified for member '{0}' on type '{1}'", memberName, entityType.Name));
                    }
                    member    = this.FindMember(entityType, memberName);
                    attribute = attr;
                }
                mappingMembers.Add(new AttributeMappingMember(member, attribute, nested));
            }
            return(new AttributeMappingEntity(elementType, tableId, entityType, tableAttributes, mappingMembers));
        }
Beispiel #39
0
        public override bool IsPrimaryKey(MappingEntity entity, MemberInfo member)
        {
            AttributeMappingMember mm = ((AttributeMappingEntity)entity).GetMappingMember(member.Name);

            return(mm != null && mm.Column != null && mm.Column.IsPrimaryKey);
        }
Beispiel #40
0
 // public BuildValidationResult(int blockId, IO io, ResultType type, string message) { this.BlockId = blockId; this.IO = io; this.Member = null; this.Type = type; this.Message = message; }
 public BuildValidationResult(int blockId, MemberInfo member, ResultType type, string message)
 {
     this.BlockId = blockId; this.Member = member; this.Type = type; this.Message = message;
 }
Beispiel #41
0
        public override MappingEntity GetEntity(MemberInfo contextMember)
        {
            Type elementType = TypeHelper.GetElementType(TypeHelper.GetMemberType(contextMember));

            return(this.GetEntity(elementType, contextMember.Name));
        }
        public static string GetDescription(this MemberInfo member)
        {
            var att = member.GetCustomAttribute <DescriptionAttribute>(false);

            return(att == null ? member.Name : att.Description);
        }
Beispiel #43
0
 public T GetAttribute <T>(bool inherit = false) where T : Attribute
 {
     return(MemberInfo.GetCustomAttribute <T>(inherit));
 }
Beispiel #44
0
 internal ModifiedMemberInfo(MemberInfo member, object current, object original) {
   Member = member;
   CurrentValue = current;
   OriginalValue = original;
 }
 /// <summary>
 ///     Determines if type member should be ignored for translation using corresponding Typings attribute
 /// </summary>
 /// <param name="t">Type member info</param>
 /// <returns>True if type member should be ignored, false otherwise</returns>
 public static bool IsIgnored(this MemberInfo t)
 {
     return(ConfigurationRepository.Instance.IsIgnored(t));
 }
Beispiel #46
0
        public override bool IsAssociationRelationship(MappingEntity entity, MemberInfo member)
        {
            AttributeMappingMember mm = ((AttributeMappingEntity)entity).GetMappingMember(member.Name);

            return(mm != null && mm.Association != null);
        }
Beispiel #47
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType is null)
            {
                throw new ArgumentNullException(nameof(destinationType));
            }

            if (destinationType == typeof(InstanceDescriptor) && value is TreeNode)
            {
                TreeNode   node = (TreeNode)value;
                MemberInfo info = null;
                object[]   args = null;

                if (node.ImageIndex == -1 || node.SelectedImageIndex == -1)
                {
                    if (node.Nodes.Count == 0)
                    {
                        info = typeof(TreeNode).GetConstructor(new Type[] { typeof(string) });
                        args = new object[] { node.Text };
                    }
                    else
                    {
                        info = typeof(TreeNode).GetConstructor(new Type[] { typeof(string), typeof(TreeNode[]) });

                        TreeNode[] nodesArray = new TreeNode[node.Nodes.Count];
                        node.Nodes.CopyTo(nodesArray, 0);

                        args = new object[] { node.Text, nodesArray };
                    }
                }
                else
                {
                    if (node.Nodes.Count == 0)
                    {
                        info = typeof(TreeNode).GetConstructor(new Type[] {
                            typeof(string),
                            typeof(int),
                            typeof(int)
                        });
                        args = new object[] {
                            node.Text,
                            node.ImageIndex,
                            node.SelectedImageIndex
                        };
                    }
                    else
                    {
                        info = typeof(TreeNode).GetConstructor(new Type[] {
                            typeof(string),
                            typeof(int),
                            typeof(int),
                            typeof(TreeNode[])
                        });

                        TreeNode[] nodesArray = new TreeNode[node.Nodes.Count];
                        node.Nodes.CopyTo(nodesArray, 0);

                        args = new object[] {
                            node.Text,
                            node.ImageIndex,
                            node.SelectedImageIndex,
                            nodesArray
                        };
                    }
                }

                if (info != null)
                {
                    return(new InstanceDescriptor(info, args, false));
                }
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
Beispiel #48
0
        public override bool IsNestedEntity(MappingEntity entity, MemberInfo member)
        {
            AttributeMappingMember mm = ((AttributeMappingEntity)entity).GetMappingMember(member.Name);

            return(mm != null && mm.NestedEntity != null);
        }
			public void NonProxyableMemberNotification(Type type, MemberInfo memberInfo)
			{
			}
 void OnViolation(Type implementor, Type interfaceType, MemberInfo violator)
 {
     Console.WriteLine("{0} must explicitly implement the interface member {1}.{2}", implementor.Name, interfaceType.Name, violator.Name);
     violationCount++;
 }
        public static bool HasColumnAttribute(MemberInfo memberInfo)
        {
            var hasColumnAttribute = memberInfo.GetCustomAttributes(false).OfType <ColumnAttribute>().Any();

            return(hasColumnAttribute);
        }
 /// <summary>
 /// Determines whether the specified member is to be considered.
 /// </summary>
 /// <param name="member">The member.</param>
 /// <returns>
 ///   <c>true</c> if the specified member is to be considered; otherwise, <c>false</c>.
 /// </returns>
 protected override bool IsConsideredMember(MemberInfo member)
 {
     return(member is PropertyInfo && base.IsConsideredMember(member));
 }
Beispiel #53
0
        public override IEnumerable <MemberInfo> GetAssociationRelatedKeyMembers(MappingEntity entity, MemberInfo member)
        {
            AttributeMappingEntity thisEntity    = (AttributeMappingEntity)entity;
            AttributeMappingEntity relatedEntity = (AttributeMappingEntity)this.GetRelatedEntity(entity, member);
            AttributeMappingMember mm            = thisEntity.GetMappingMember(member.Name);

            if (mm != null && mm.Association != null)
            {
                return(this.GetReferencedMembers(relatedEntity, mm.Association.RelatedKeyMembers, "Association.RelatedKeyMembers", thisEntity.EntityType));
            }
            return(base.GetAssociationRelatedKeyMembers(entity, member));
        }
Beispiel #54
0
 protected MemberMemberBinding UpdateMemberMemberBinding(MemberMemberBinding binding, MemberInfo member, IEnumerable<MemberBinding> bindings)
 {
     if (bindings != binding.Bindings || member != binding.Member)
     {
         return Expression.MemberBind(member, bindings);
     }
     return binding;
 }
Beispiel #55
0
        public override string GetAlias(MappingEntity entity, MemberInfo member)
        {
            AttributeMappingMember mm = ((AttributeMappingEntity)entity).GetMappingMember(member.Name);

            return((mm != null && mm.Column != null) ? mm.Column.Alias : null);
        }
Beispiel #56
0
 internal AttributeMappingMember(MemberInfo member, MemberAttribute attribute, AttributeMappingEntity nested)
 {
     this.member    = member;
     this.attribute = attribute;
     this.nested    = nested;
 }
Beispiel #57
0
 /// <summary>
 /// Creates name for the type field
 /// </summary>
 /// <param name="member">The type member</param>
 /// <returns>The member name</returns>
 public string GetName(MemberInfo member)
 {
     return(this.Name ?? ToCamelCase(member.Name));
 }
Beispiel #58
0
 public T AllowPrivate(MemberInfo info)
 {
     return(AllowPrivate(info.DeclaringType));
 }
Beispiel #59
0
		public object ProvideValue(IServiceProvider serviceProvider)
		{
			if (Android == s_notset
				&& GTK == s_notset
				&& iOS == s_notset
				&& macOS == s_notset
				&& MacCatalyst == s_notset
				&& Tizen == s_notset
#pragma warning disable CS0618 // Type or member is obsolete
				&& UWP == s_notset
#pragma warning restore CS0618 // Type or member is obsolete
				&& WPF == s_notset
				&& WinUI == s_notset
				&& Default == s_notset)
			{
				throw new XamlParseException("OnPlatformExtension requires a value to be specified for at least one platform or Default.", serviceProvider);
			}

			var valueProvider = serviceProvider?.GetService<IProvideValueTarget>() ?? throw new ArgumentException();

			BindableProperty bp;
			PropertyInfo pi = null;
			Type propertyType = null;

			if (valueProvider.TargetObject is Setter setter)
				bp = setter.Property;
			else
			{
				bp = valueProvider.TargetProperty as BindableProperty;
				pi = valueProvider.TargetProperty as PropertyInfo;
			}
			propertyType = bp?.ReturnType
						?? pi?.PropertyType
						?? throw new InvalidOperationException("Cannot determine property to provide the value for.");

			if (!TryGetValueForPlatform(out var value))
			{
				if (bp != null)
					return bp.GetDefaultValue(valueProvider.TargetObject as BindableObject);
				if (propertyType.IsValueType)
					return Activator.CreateInstance(propertyType);
				return null;
			}

			if (Converter != null)
				return Converter.Convert(value, propertyType, ConverterParameter, CultureInfo.CurrentUICulture);

			var converterProvider = serviceProvider?.GetService<IValueConverterProvider>();
			if (converterProvider != null)
			{
				MemberInfo minforetriever()
				{
					if (pi != null)
						return pi;

					MemberInfo minfo = null;
					try
					{
						minfo = bp.DeclaringType.GetRuntimeProperty(bp.PropertyName);
					}
					catch (AmbiguousMatchException e)
					{
						throw new XamlParseException($"Multiple properties with name '{bp.DeclaringType}.{bp.PropertyName}' found.", serviceProvider, innerException: e);
					}
					if (minfo != null)
						return minfo;
					try
					{
						return bp.DeclaringType.GetRuntimeMethod("Get" + bp.PropertyName, new[] { typeof(BindableObject) });
					}
					catch (AmbiguousMatchException e)
					{
						throw new XamlParseException($"Multiple methods with name '{bp.DeclaringType}.Get{bp.PropertyName}' found.", serviceProvider, innerException: e);
					}
				}

				return converterProvider.Convert(value, propertyType, minforetriever, serviceProvider);
			}
			var ret = value.ConvertTo(propertyType, () => pi, serviceProvider, out Exception exception);
			if (exception != null)
				throw exception;
			return ret;
		}
Beispiel #60
0
 protected MemberListBinding UpdateMemberListBinding(MemberListBinding binding, MemberInfo member, IEnumerable<ElementInit> initializers)
 {
     if (initializers != binding.Initializers || member != binding.Member)
     {
         return Expression.ListBind(member, initializers);
     }
     return binding;
 }