ESRI.ArcGIS.Client.Toolkit.DynamicCodedValueDomainColumn.DynamicCodedValueSourceSelectedItemConverter.Convert C# (CSharp) Méthode

Convert() public méthode

public Convert ( object value, Type targetType, object parameter, System culture ) : object
value object
targetType System.Type
parameter object
culture System
Résultat object
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                DynamicCodedValueSource dynamicCodedValueSource = parameter as DynamicCodedValueSource;
                if (value != null && string.IsNullOrEmpty(Field) != true
                    && string.IsNullOrEmpty(LookupField) != true && dynamicCodedValueSource != null)
                {
                #if SILVERLIGHT
                    PropertyInfo property = value.GetType().GetProperty(Field);
                    if (property == null)
                        return null;

                    var code = property.GetValue(value, null);
                #else
                    var code = value is Graphic ? (value as Graphic).Attributes[Field] : null;
                #endif
                    if(code == null)
                        return null;
                #if SILVERLIGHT
                    PropertyInfo lookupProperty = value.GetType().GetProperty(LookupField);
                    if(lookupProperty == null)
                        return null;

                    var key = lookupProperty.GetValue(value,null);
                #else
                    var key = value is Graphic ? (value as Graphic).Attributes[LookupField] : null;
                #endif
                    if(key == null)
                    {
                        if (NullableSources != null)
                        {
                            foreach (CodedValueSource source in NullableSources)
                                if (source.Code == null)
                                {
                                    if(code == null)
                                        return source;
                                }
                                else if (source.Code.ToString() == code.ToString())
                                    return source;
                        }
                        else
                        return null;
                    }

                    if(dynamicCodedValueSource.ContainsKey(key))
                    {
                        CodedValueSources codedValueSources = dynamicCodedValueSource[key];
                        if(codedValueSources != null)
                        {
                            CodedValueSource codedValueSource = codedValueSources.FirstOrDefault(x => x.Code != null && x.Code.ToString() == code.ToString());
                            return codedValueSource;
                        }
                    }
                    else if(dynamicCodedValueSource.ContainsKey(key.ToString()))
                    {
                        CodedValueSources codedValueSources = dynamicCodedValueSource[key.ToString()];
                        if(codedValueSources != null)
                        {
                            CodedValueSource codedValueSource = codedValueSources.FirstOrDefault(x => x.Code != null && x.Code.ToString() == code.ToString());
                            return codedValueSource;
                        }
                    }
                }
                return null;
            }
DynamicCodedValueDomainColumn.DynamicCodedValueSourceSelectedItemConverter