private void testCase_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (PropertyMap.ContainsKey(e.PropertyName))
     {
         foreach (var property in PropertyMap[e.PropertyName])
         {
             OnPropertyChanged(property);
         }
     }
 }
 /// <summary>
 /// Adds or overrides value in the cache.
 /// </summary>
 /// <param name="Property">The property info of the class.</param>
 /// <param name="Value">The value to store.</param>
 public void SetValue(PropertyInfo Property, object Value)
 {
     if (PropertyMap.ContainsKey(Property))
     {
         PropertyMap[Property] = Value;
     }
     else
     {
         PropertyMap.Add(Property, Value);
     }
 }
 /// <summary>
 /// Override to populate the properties from the implemented entity.
 /// </summary>
 protected override sealed void LoadProperties()
 {
     foreach (ColumnSchema column in EntitySource.Columns)
     {
         var property = new TableProperty(column, this);
         if (!Configuration.Instance.ExcludeRegexIsMatch(column.FullName) && !PropertyMap.ContainsKey(column.Name))
         {
             PropertyMap.Add(column.Name, property);
         }
     }
 }
        protected override void LoadProperties()
        {
            var queryParams = EntitySource.Root.Descendants("return-scalar", XmlNamespace);

            foreach (var queryParam in queryParams)
            {
                var property = new NHibernateCommandProperty(queryParam, this);
                if (!PropertyMap.ContainsKey(property.Name))
                {
                    PropertyMap.Add(property.Name, property);
                }
            }
        }
        protected virtual T Get <T>(T defaultValue, [CallerMemberName] string name = null)
        {
            if (!PropertyMap.ContainsKey(name))
            {
                return(defaultValue);
            }

            var result = PropertyMap[name];

            if (result == null)
            {
                return(default(T));
            }
            return((T)result);
        }
        private string GetTsDataType(Type propertyType)
        {
            var name = propertyType.ToString();

            name = CheckNullability(name); // Check if nullable and clean
            name = CheckEnumerable(name);  // Check if Enumeable and clean
            name = CleanNamespace(name);   // Remove namespace and make a clean name

            if (PropertyMap.ContainsKey(name))
            {
                return(PropertyMap[name]);
            }

            return(name);
        }
        /// <summary>
        /// Override to populate the properties from the implemented entity.
        /// </summary>
        protected override void LoadProperties()
        {
            foreach (var prop in EntitySource.Properties)
            {
                var property = new ConceptualProperty(prop, this);
                if (!Configuration.Instance.ExcludeRegexIsMatch(prop.Name) && !PropertyMap.ContainsKey(property.Name))
                {
                    PropertyMap.Add(property.Name, property);
                }
            }

            if (PropertyMap.Values.Where(em => (em.PropertyType & PropertyType.Concurrency) == PropertyType.Concurrency).Count() > 1)
            {
                throw new Exception(String.Format("More than one Concurrency property in {0}", EntityKeyName));
            }
        }
        /// <summary>
        /// Stores or updates the value in a dictionary and optionally raises the prop changed event if the value changes
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <param name="name"></param>
        /// <param name="raisePropChanged"></param>
        /// <returns>True if property was changed (value was different).  False if not</returns>
        protected virtual bool Set <T>(T value, [CallerMemberName] string name = null, bool raisePropChanged = true)
        {
            T currentValue = default(T);

            lock (PropertyMap)
            {
                if (PropertyMap.ContainsKey(name))
                {
                    currentValue = (T)PropertyMap[name];
                    if (currentValue == null && value == null)
                    {
                        return(false);
                    }

                    if (currentValue != null && currentValue.Equals(value))
                    {
                        return(false);
                    }

                    if (OnPropertyChanging(name, currentValue, raisePropChanged, value))
                    {
                        PropertyMap[name] = value;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (OnPropertyChanging(name, currentValue, raisePropChanged, value))
                {
                    PropertyMap.Add(name, value);
                }
                else
                {
                    return(false);
                }
            }



            if (raisePropChanged)
            {
                RaisePropertyChanged(name);
            }

            return(true);
        }
Esempio n. 9
0
        public override bool TrySetMember(SetMemberBinder binder, object value)
        {
            var propertyName = binder.Name;
            var success      = false;

            if (PropertyMap.ContainsKey(propertyName))
            {
                var setExpression = PropertyMap[propertyName].Item2;
                if (setExpression != null && Entity != null)
                {
                    setExpression.Invoke(Entity, value);
                    OnPropertyChanged(propertyName);
                    success = true;
                }
            }

            return(success);
        }
Esempio n. 10
0
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            string propertyName = binder.Name;

            result = null;
            bool success = false;

            if (PropertyMap.ContainsKey(propertyName))
            {
                Func <MODEL, object> value = PropertyMap[propertyName].Item1;
                if (Entity != null)
                {
                    result = value.Invoke(Entity);
                }
                success = true;
            }

            return(success);
        }
Esempio n. 11
0
        public static PropertyMap GeneratePropertyMap <T> (IEnumerable <T> exchangeInfo) where T : ExchangePropertyInfo
        {
            PropertyMap propertyMap = new PropertyMap();

            foreach (T property in exchangeInfo)
            {
                int columnIndex = property.MappedColumn;

                if (propertyMap.ContainsKey(columnIndex))
                {
                    propertyMap [columnIndex].Add(property.PropertyInfo);
                }
                else
                {
                    propertyMap.Add(columnIndex, new List <PropertyInfo> (new [] { property.PropertyInfo }));
                }
            }

            return(propertyMap);
        }
Esempio n. 12
0
        public PropertyMap LoadProperties(Annotation annotation, Context context, DocEntryList entries)
        {
            PropertyMap props = new PropertyMap();

            foreach (DocEntry entry in entries)
            {
                Property prop = LoadProperty(annotation, context, entry);
                if (prop == null)
                {
                    continue;
                }
                if (props.ContainsKey(prop.GetName()))
                {
                    throw new SyntaxError("Duplicate property: " + prop.GetName());
                }
                else
                {
                    props[prop.GetName()] = prop;
                }
            }
            return(props);
        }
        protected override void LoadProperties()
        {
            var properties = EntitySource.Root
                             .Descendants("property", XmlNamespace)
                             .ToList();

            var version = EntitySource.Root.Descendant("version", XmlNamespace);

            if (version != null)
            {
                properties.Add(version);
            }

            foreach (var prop in properties)
            {
                var propName = prop.Attribute("name");
                if (propName == null)
                {
                    continue;
                }

                if (Configuration.Instance.ExcludeRegexIsMatch(propName.Value) || PropertyMap.ContainsKey(propName.Value))
                {
                    continue;
                }

                var property = new NHibernateProperty(prop, this);
                if (!PropertyMap.ContainsKey(property.Name))
                {
                    PropertyMap.Add(property.Name, property);
                }
            }

            if (PropertyMap.Values.Count(em => em.IsType(PropertyType.Concurrency)) > 1)
            {
                throw new Exception(String.Format("More than one Concurrency property in {0}", EntityKeyName));
            }
        }
Esempio n. 14
0
 /// <summary>
 /// Sets the PropertyMap for all columns
 /// </summary>
 protected override void LoadProperties()
 {
     try {
         foreach (ViewColumnSchema column in EntitySource.Columns)
         {
             if (!Configuration.Instance.ExcludeRegexIsMatch(column.FullName) && !PropertyMap.ContainsKey(column.Name))
             {
                 PropertyMap.Add(column.Name, new ViewProperty(column, this));
             }
         }
     } catch (NotSupportedException) {
         string message = String.Format("This provider does not support Views. Please disable the generation of views by setting IncludeViews to false.");
         Trace.WriteLine(message);
         Debug.WriteLine(message);
     }
 }
 /// <summary>
 /// Sets the PropertyMap for all columns.
 /// </summary>
 protected override void LoadProperties()
 {
     try {
         if (EntitySource != null && EntitySource.CommandResults.Count > 0)
         {
             foreach (CommandResultColumnSchema column in EntitySource.CommandResults[0].Columns)
             {
                 var property = new CommandProperty(column, this);
                 if (!Configuration.Instance.ExcludeRegexIsMatch(column.FullName) && !PropertyMap.ContainsKey(column.Name.ToLower()))
                 {
                     PropertyMap.Add(column.Name.ToLower(), property);
                 }
             }
         }
     } catch (NotSupportedException) {
         string message = String.Format("This provider does not support Commands. Please disable the generation of commands by setting IncludeFunctions to false.");
         Trace.WriteLine(message);
         Debug.WriteLine(message);
     } catch (Exception ex) {
         string message = String.Format("Unable to load properties for Command Entity '{0}'. Exception: {1}", EntityKeyName, ex.Message);
         Trace.WriteLine(message);
         Debug.WriteLine(message);
     }
 }