Smartmobili.Cocoa.NSObjectDecoder.ResolveReference C# (CSharp) Method

ResolveReference() public method

public ResolveReference ( object instance, string propertyName, System.Xml.Linq.XElement xElement ) : object
instance object
propertyName string
xElement System.Xml.Linq.XElement
return object
        public object ResolveReference(object instance, string propertyName, XElement xElement)
        {
            id nsObj = null;

            if (instance == null || string.IsNullOrEmpty(propertyName) || xElement == null)
                return null;

            NSString refId = xElement.AttributeValueOrDefault("ref", "");
            if (!string.IsNullOrWhiteSpace(refId))
            {
                bool foundRefID = Document.ListOfReferenceId.TryGetValue(refId, out nsObj);
                if (!foundRefID)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Unknown ReferenceID {0}", refId));

                    System.Reflection.PropertyInfo prop = instance.GetType().GetProperty(propertyName);
                    Action<object> propAction = (Action<object>)Delegate.CreateDelegate(typeof(Action<object>), instance, prop.GetSetMethod());
                    Document.UnresolvedReferences.Add(refId, propAction);

                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Nil Reference"));
            }

            return nsObj;
        }