当前位置: 首页>>代码示例>>C#>>正文


C# IGetter.Get方法代码示例

本文整理汇总了C#中IGetter.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IGetter.Get方法的具体用法?C# IGetter.Get怎么用?C# IGetter.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGetter的用法示例。


在下文中一共展示了IGetter.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetUnsavedIdentifierValue

		/// <summary>
		/// Return an IdentifierValue for the specified unsaved-value. If none is specified,
		/// guess the unsaved value by instantiating a test instance of the class and
		/// reading it's id property, or if that is not possible, using the java default
		/// value for the type
		/// </summary>
		public static IdentifierValue GetUnsavedIdentifierValue(
			string unsavedValue,
			IGetter identifierGetter,
			IType identifierType,
			ConstructorInfo constructor)
		{
			if (unsavedValue == null)
			{
				if (identifierGetter != null && constructor != null)
				{
					// use the id value of a newly instantiated instance as the unsaved-value
					object defaultValue = identifierGetter.Get(Instantiate(constructor));
					return new IdentifierValue(defaultValue);
				}
				var idTypeAsPrimitiveType = identifierType as PrimitiveType;
				if (identifierGetter != null && idTypeAsPrimitiveType != null)
				{
					object defaultValue = idTypeAsPrimitiveType.DefaultValue;
					return new IdentifierValue(defaultValue);
				}
				return IdentifierValue.SaveNull;
			}
			if ("null" == unsavedValue)
			{
				return IdentifierValue.SaveNull;
			}
			if ("undefined" == unsavedValue)
			{
				return IdentifierValue.Undefined;
			}
			if ("none" == unsavedValue)
			{
				return IdentifierValue.SaveNone;
			}
			if ("any" == unsavedValue)
			{
				return IdentifierValue.SaveAny;
			}
			try
			{
				return new IdentifierValue(((IIdentifierType) identifierType).StringToObject(unsavedValue));
			}
			catch (InvalidCastException cce)
			{
				throw new MappingException("Bad identifier type: " + identifierType.Name, cce);
			}
			catch (Exception e)
			{
				throw new MappingException("Could not parse identifier unsaved-value: " + unsavedValue, e);
			}
		}
开发者ID:KaraokeStu,项目名称:nhibernate-core,代码行数:57,代码来源:UnsavedValueFactory.cs

示例2: GetUnsavedVersionValue

		public static Cascades.VersionValue GetUnsavedVersionValue(
			String versionUnsavedValue, 
			IGetter versionGetter,
			IVersionType versionType,
			ConstructorInfo constructor) 
		{
		
			if ( versionUnsavedValue == null ) 
			{
				if ( constructor!=null ) 
				{
					Object defaultValue = versionGetter.Get( Instantiate(constructor) );
					// if the version of a newly instantiated object is not the same
					// as the version seed value, use that as the unsaved-value
					return versionType.Equals( versionType.Seed, defaultValue ) ?
						Cascades.VersionValue.VersionUndefined :
						new Cascades.VersionValue( defaultValue );
				}
				else 
				{
					return Cascades.VersionValue.VersionUndefined;
				}
			}
			else if ( "undefined" == versionUnsavedValue )
			{
				return Cascades.VersionValue.VersionUndefined;
			}
			else if ( "null" == versionUnsavedValue ) 
			{
				return Cascades.VersionValue.VersionSaveNull;
			}
			else if ( "negative" == versionUnsavedValue ) 
			{
				return Cascades.VersionValue.VersionNegative;
			}
			else 
			{
				// NHibernate-specific
				try
				{
					return new Cascades.VersionValue( versionType.StringToObject( versionUnsavedValue ) );
				}
				catch( InvalidCastException ice )
				{
					throw new MappingException( "Bad version type: " + versionType.Name, ice );
				}
				catch( Exception e )
				{
					throw new MappingException( "Could not parse version unsaved-value: " + versionUnsavedValue, e );
				}
			}
		
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:53,代码来源:UnsavedValueFactory.cs

示例3: GetUnsavedIdentifierValue

		/// <summary>
		/// Return an IdentifierValue for the specified unsaved-value. If none is specified,
		/// guess the unsaved value by instantiating a test instance of the class and
		/// reading it's id property, or if that is not possible, using the java default
		/// value for the type
		/// </summary>
		public static Cascades.IdentifierValue GetUnsavedIdentifierValue(
			string unsavedValue,
			IGetter identifierGetter,
			IType identifierType,
			ConstructorInfo constructor )
		{
			if( unsavedValue == null )
			{
				if( identifierGetter != null && constructor != null )
				{
					// use the id value of a newly instantiated instance as the unsaved-value
					object defaultValue = identifierGetter.Get( Instantiate( constructor ) );
					return new Cascades.IdentifierValue( defaultValue );
				}
				// TODO: NH - the branch below is actually never visited, so it's commented out
				/*
				else if( identifierGetter != null && ( identifierType is ValueTypeType ) )
				{
					object defaultValue = ( ( ValueTypeType ) identifierType ).DefaultValue;
					return new Cascades.IdentifierValue( defaultValue );
				}
				*/
				else
				{
					return Cascades.IdentifierValue.SaveNull;
				}
			}
			else if( "null" == unsavedValue )
			{
				return Cascades.IdentifierValue.SaveNull;
			}
			// TODO: H3 only, IdentifierValue.IsUnsaved may return true/false/null in H3
			// and SaveUndefined always returns null.
			/*
			else if( "undefined" == unsavedValue )
			{
				return Cascades.IdentifierValue.SaveUndefined;
			}
			*/
			else if( "none" == unsavedValue )
			{
				return Cascades.IdentifierValue.SaveNone;
			}
			else if( "any" == unsavedValue )
			{
				return Cascades.IdentifierValue.SaveAny;
			}
			else
			{
				try
				{
					return new Cascades.IdentifierValue( ( ( IIdentifierType ) identifierType ).StringToObject( unsavedValue ) );
				}
				catch( InvalidCastException cce )
				{
					throw new MappingException( "Bad identifier type: " + identifierType.Name, cce );
				}
				catch( Exception e )
				{
					throw new MappingException( "Could not parse identifier unsaved-value: " + unsavedValue, e );
				}
			}
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:69,代码来源:UnsavedValueFactory.cs


注:本文中的IGetter.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。