示例#1
0
        public static Identity GetIdentity(object item, DataDestination destination)
        {
            string[] identityKeys = destination.GetIdentityKeys();
            Identity identity     = new Identity(item);

            foreach (string str in identityKeys)
            {
                Exception    exception;
                PropertyInfo property = item.GetType().GetProperty(str);
                if (property != null)
                {
                    try
                    {
                        identity[str] = property.GetValue(item, new object[0]);
                    }
                    catch (Exception exception1)
                    {
                        exception = exception1;
                        throw new FluorineException(__Res.GetString("Identity_Failed", new object[] { str }), exception);
                    }
                }
                else
                {
                    try
                    {
                        FieldInfo field = item.GetType().GetField(str, BindingFlags.Public | BindingFlags.Instance);
                        if (field != null)
                        {
                            identity[str] = field.GetValue(item);
                        }
                    }
                    catch (Exception exception2)
                    {
                        exception = exception2;
                        throw new FluorineException(__Res.GetString("Identity_Failed", new object[] { str }), exception);
                    }
                }
            }
            return(identity);
        }
示例#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);
        }
示例#3
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;
		}