Exemplo n.º 1
0
        /// <summary>
        /// Les données sont extraites de la ligne en cours du reader.
        /// </summary>
        public void SetValuesToClassProxy(ClassProxy _proxy, DBRow _row)
        {
            _proxy.ID = _row.GetId();

            for (int _i = 0; _i < _row.Count; _i++)
            {
                DBField _field        = _row.GetField(_i);
                string  _propertyName = _field.PropertyName;

                PropertyProxy _prProxy = _proxy.GetPropertyProxy(_propertyName);

                if (_prProxy != null)
                {
                    SetValueToProperty(_prProxy, _field.Value);
                }
            }
        }
Exemplo n.º 2
0
        public void AddProperty <TProperty, TValue>(TProperty property) where TProperty : IProperty <TContainer, TValue>
        {
            if (m_PropertiesDictionary.TryGetValue(property.GetName(), out var proxy))
            {
                if (proxy is PropertyProxy <TProperty, TValue> typedProxy && typedProxy.Property.GetType() == property.GetType())
                {
                    return; // Same property name and type, skip it
                }
                throw new InvalidOperationException($"A property with name '{property.GetName()}' already exist in property bag for type '{typeof(TContainer).FullName}'. This can be caused by class inheritance.");
            }

            proxy = new PropertyProxy <TProperty, TValue> {
                Property = property
            };
            m_PropertiesDictionary.Add(property.GetName(), proxy);
            m_PropertiesList.Add(proxy);
        }
Exemplo n.º 3
0
        private string IncludeQuery(ClassProxy _classProxy, string _memberName)
        {
            PropertyProxy _prProxy = _classProxy.GetPropertyProxy(_memberName);

            if (_prProxy is PropertyObjectProxy _prObjectProxy)
            {
                return(IncludeClassQuery(_prObjectProxy));
            }
            else
            if (_prProxy is PropertyListProxy _prListProxy)
            {
                return(IncludeListQuery(_prListProxy));
            }
            else
            {
                throw new Exception("Le type " + _prProxy.GetType().Name + " n'est pas prévu pour Include.");
            }
        }
Exemplo n.º 4
0
        void AssignPropertyProc(JavaScriptValue setTo, PropertyInfo[] props)
        {
            var getpropid = JavaScriptPropertyId.FromString("get");
            var setpropid = JavaScriptPropertyId.FromString("set");

            foreach (var info in props)
            {
                if (info.IsSpecialName)
                {
                    continue;
                }
                var desc  = JavaScriptValue.CreateObject();
                var id    = JavaScriptPropertyId.FromString(info.Name);
                var proxy = new PropertyProxy(info);
                desc.SetProperty(getpropid, JavaScriptValue.CreateFunction(PropertyProxy.PropertyGetterDg, GCHandle.ToIntPtr(proxy.thisPtr)), true);
                desc.SetProperty(setpropid, JavaScriptValue.CreateFunction(PropertyProxy.PropertySetterDg, GCHandle.ToIntPtr(proxy.thisPtr)), true);
                setTo.DefineProperty(id, desc);
                propertyWrappers.Add(proxy);
            }
        }
Exemplo n.º 5
0
        void AssignToObject(JavaScriptValue obj)
        {
            if (children == null)
            {
                return;
            }
            var getpropid = JavaScriptPropertyId.FromString("get");
            var setpropid = JavaScriptPropertyId.FromString("set");

            foreach (var kv in children)
            {
                var n     = kv.Value;
                var t     = n.type;
                var prop  = JavaScriptPropertyId.FromString(n.name);
                var desc  = JavaScriptValue.CreateObject();
                var proxy = new PropertyProxy(n);
                propertyProxies.Add(proxy);
                desc.SetProperty(getpropid, JavaScriptValue.CreateFunction(PropertyProxy.PropertyGetterDg, GCHandle.ToIntPtr(proxy.thisPtr)), true);
                desc.SetProperty(setpropid, JavaScriptValue.CreateFunction(PropertyProxy.PropertySetterDg, GCHandle.ToIntPtr(proxy.thisPtr)), true);
                obj.DefineProperty(prop, desc);
            }
        }
Exemplo n.º 6
0
 public void SetValue(Object obj)
 {
     Host        = new PropertyProxy(obj);
     PG.Instance = Host;
 }
Exemplo n.º 7
0
 private static string GetPropertyXPath(PropertyProxy property)
 {
     return(String.Format(CultureInfo.InvariantCulture, "/doc/members/member[@name = 'P:{0}.{1}']", property.DeclaringType.FullName, property.Name));
 }
Exemplo n.º 8
0
        private void SetValueToProperty(PropertyProxy _prProxy, object _value)
        {
            Type _valueType = _value.GetType();
            Type _prType    = _prProxy.Type;

            if (_value is DBNull)
            {
                if (TypeHelper.IsNullable(_prType))
                {
                    _prProxy.Value = null;
                }

                else
                if (_prProxy is PropertyObjectProxy _prObjectProxy)
                {
                    _prObjectProxy.Value = "";
                }

                else
                if (_prProxy is PropertyListProxy _prListProxy)
                {
                    _prListProxy.Parse("");
                }

                else
                if (_prType == typeof(bool))
                {
                    _prProxy.Value = false;
                }

                else
                if (_prType == typeof(int) ||
                    _prType == typeof(long) ||
                    _prType == typeof(double) ||
                    _prType == typeof(decimal))
                {
                    _prProxy.Value = 0;
                }

                else
                if (_prType == typeof(string))
                {
                    _prProxy.Value = "";
                }
            }

            else
            if (_prProxy is PropertyObjectProxy _prObjectProxy)
            {
                _prObjectProxy.Value = _value;
            }

            else
            if (_prProxy is PropertyListProxy _prListProxy)
            {
                _prListProxy.Parse((string)_value);
            }

            else
            if (_prProxy is PropertyEnumProxy _enumProxy)
            {
                _enumProxy.Value = _value;
            }

            else
            if (_valueType != _prType)
            {
                if (_valueType == typeof(decimal) && _prType == typeof(double))
                {
                    _prProxy.Value = Convert.ToDouble(_value);
                }
                else

                if (TypeHelper.IsNullable(_prType))
                {
                    if (_prType == typeof(bool?))
                    {
                        _prProxy.Value = (bool?)_value;
                    }
                    else
                    if (_prType == typeof(int?))
                    {
                        _prProxy.Value = (int?)_value;
                    }
                    else
                    if (_prType == typeof(long?))
                    {
                        _prProxy.Value = (long?)_value;
                    }
                    else
                    if (_prType == typeof(double?))
                    {
                        _prProxy.Value = (double?)_value;
                    }
                    else
                    if (_prType == typeof(decimal?))
                    {
                        _prProxy.Value = (decimal?)_value;
                    }
                    else
                    if (_prType == typeof(DateTime?))
                    {
                        _prProxy.Value = (DateTime?)_value;
                    }
                    else
                    if (_prType == typeof(TimeSpan?))
                    {
                        _prProxy.Value = (TimeSpan?)_value;
                    }
                }

                else
                {
                    throw new Exception("_propertyType = " + _prType.Name + Environment.NewLine +
                                        "_valueType = " + _valueType.Name + Environment.NewLine +
                                        "Cast de ces types non prévu dans cette fonction.");
                }
            }
            else
            {
                _prProxy.Value = _value;
            }
        }
 public void CallRegisterPropertyProxy(PropertyProxy proxy)
 => RegisterPropertyProxy(proxy);