Ejemplo n.º 1
0
        public static Identity GetIdentity(object item, DataDestination destination)
        {
            IdentityConfiguration[] keys = destination.GetIdentityKeys();
            Identity identity            = new Identity(item);

            foreach (IdentityConfiguration ic in keys)
            {
                string       key = ic.Property;
                PropertyInfo pi  = item.GetType().GetProperty(key);
                if (pi != null)
                {
                    try
                    {
                        identity[key] = pi.GetValue(item, new object[0]);
                    }
                    catch (Exception ex)
                    {
                        throw new FluorineException(__Res.GetString(__Res.Identity_Failed, key), ex);
                    }
                }
                else
                {
                    try
                    {
                        FieldInfo fi = item.GetType().GetField(key, BindingFlags.Public | BindingFlags.Instance);
                        if (fi != null)
                        {
                            identity[key] = fi.GetValue(item);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new FluorineException(__Res.GetString(__Res.Identity_Failed, key), ex);
                    }
                }
            }
            return(identity);
        }
Ejemplo n.º 2
0
		public static Identity GetIdentity(object item, DataDestination destination)
		{
            IdentityConfiguration[] keys = destination.GetIdentityKeys();
			Identity identity = new Identity(item);
			foreach(IdentityConfiguration ic in keys)
			{
                string key = ic.Property;
				PropertyInfo pi = item.GetType().GetProperty(key);
				if( pi != null )
				{
					try
					{
						identity[key] = pi.GetValue( item, new object[0] );
					}
					catch(Exception ex)
					{
						throw new FluorineException(__Res.GetString(__Res.Identity_Failed, key), ex);
					}
				}
				else
				{				
					try
					{
						FieldInfo fi = item.GetType().GetField(key, BindingFlags.Public | BindingFlags.Instance);
						if( fi != null )
						{
							identity[key] = fi.GetValue( item );
						}
					}
					catch(Exception ex)
					{
						throw new FluorineException(__Res.GetString(__Res.Identity_Failed, key), ex);
					}
				}
			}
			return identity;
		}