Esempio n. 1
0
        public static MemberInfo TryGetReflectedMember(this SDK.ContentObject nodeInstance, String key)
        {
            var pinfo = nodeInstance
                        .GetType()
                        .GetTypeInfo()
                        .FlattenedProperties()
                        .FirstOrDefault(item => item.Name == key);

            if (pinfo != null)
            {
                return(pinfo);
            }

            var minfo = nodeInstance
                        .GetType()
                        .GetTypeInfo()
                        .FlattenedMethods()
                        .FirstOrDefault(item => item.Name == key);

            if (minfo != null)
            {
                return(minfo);
            }

            return(null);
        }
Esempio n. 2
0
        private static Bindings.MemberBinding[] _CreateBindings(SDK.ContentObject source, Func <TypeInfo, IEnumerable <MemberInfo> > func, IPropertyProvider properties)
        {
            var members = func(source.GetType().GetTypeInfo());

            var bindings = new List <Bindings.MemberBinding>();

            foreach (var minfo in members)
            {
                var attrib = minfo.GetInputDescAttribute();
                if (attrib == null)
                {
                    continue;
                }

                var desc = new Bindings.MemberBinding.Description()
                {
                    Member     = minfo,
                    Properties = properties,
                    Target     = source
                };

                var binding = _CreateBinding(attrib, desc);
                if (binding == null)
                {
                    continue;
                }

                bindings.Add(binding);
            }

            if (true) // we interconnect all the VALUE bindings , so when a value of a binding is changed, all of them raise a NotifyPropertyChanged, so they can, more or less, work as a basic state machine
            {
                var valueBindings = bindings.OfType <Bindings.ValueBinding>().ToArray();

                foreach (var vb in valueBindings)
                {
                    vb._AllValueBindings = valueBindings;
                }
            }

            return(bindings.ToArray());
        }