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


C# IGetter类代码示例

本文整理汇总了C#中IGetter的典型用法代码示例。如果您正苦于以下问题:C# IGetter类的具体用法?C# IGetter怎么用?C# IGetter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DocumentIdMapping

 public DocumentIdMapping(string name, string propertyName, ITwoWayFieldBridge bridge, IGetter getter)
     : base(getter)
 {
     this.Name = name;
     this.PropertyName = propertyName;
     this.Bridge = bridge;
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:7,代码来源:DocumentIdMapping.cs

示例2: FieldMapping

        public FieldMapping(string name, IFieldBridge bridge, IGetter getter) : base(getter)
        {
            this.Name = name;
            this.Bridge = bridge;

            this.Store = Attributes.Store.No;
            this.Index = Attributes.Index.Tokenized;
        }
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:8,代码来源:FieldMapping.cs

示例3: EmbeddedMapping

        public EmbeddedMapping(DocumentMapping @class, IGetter getter)
            : base(getter)
        {
            this.Class = @class;
            this.Prefix = string.Empty;

            this.IsCollection = true;
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:8,代码来源:EmbeddedMapping.cs

示例4: GetUnsavedVersionValue

		public static VersionValue GetUnsavedVersionValue(
			String versionUnsavedValue,
			IGetter versionGetter,
			IVersionType versionType,
			ConstructorInfo constructor)
		{
			if (versionUnsavedValue == null)
			{
				if (constructor != null)
				{
					object defaultValue = versionGetter.Get(Instantiate(constructor));
					if (defaultValue != null && defaultValue.GetType().IsValueType)
						return new VersionValue(defaultValue);
					else
					{
						// 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.IsEqual(versionType.Seed(null), defaultValue)
								? VersionValue.VersionUndefined
								: new VersionValue(defaultValue);
					}
				}
				else
				{
					return VersionValue.VersionUndefined;
				}
			}
			else if ("undefined" == versionUnsavedValue)
			{
				return VersionValue.VersionUndefined;
			}
			else if ("null" == versionUnsavedValue)
			{
				return VersionValue.VersionSaveNull;
			}
			else if ("negative" == versionUnsavedValue)
			{
				return VersionValue.VersionNegative;
			}
			else
			{
				// NHibernate-specific
				try
				{
					return new VersionValue(versionType.FromStringValue(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:marchlud,项目名称:nhibernate-core,代码行数:57,代码来源:UnsavedValueFactory.cs

示例5: AbstractEntityTuplizer

		/// <summary> Constructs a new AbstractEntityTuplizer instance. </summary>
		/// <param name="entityMetamodel">The "interpreted" information relating to the mapped entity. </param>
		/// <param name="mappingInfo">The parsed "raw" mapping data relating to the given entity. </param>
		protected AbstractEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)
		{
			this.entityMetamodel = entityMetamodel;

			if (!entityMetamodel.IdentifierProperty.IsVirtual)
			{
				idGetter = BuildPropertyGetter(mappingInfo.IdentifierProperty, mappingInfo);
				idSetter = BuildPropertySetter(mappingInfo.IdentifierProperty, mappingInfo);
			}
			else
			{
				idGetter = null;
				idSetter = null;
			}

			propertySpan = entityMetamodel.PropertySpan;

			getters = new IGetter[propertySpan];
			setters = new ISetter[propertySpan];

			bool foundCustomAccessor = false;
			int i = 0;
			foreach (Mapping.Property property in mappingInfo.PropertyClosureIterator)
			{
				getters[i] = BuildPropertyGetter(property, mappingInfo);
				setters[i] = BuildPropertySetter(property, mappingInfo);
				if (!property.IsBasicPropertyAccessor)
					foundCustomAccessor = true;
				i++;				
			}
			if (log.IsDebugEnabled)
			{
				log.DebugFormat("{0} accessors found for entity: {1}", foundCustomAccessor ? "Custom" : "No custom",
				                mappingInfo.EntityName);
			}
			hasCustomAccessors = foundCustomAccessor;

			//NH-1587
			//instantiator = BuildInstantiator(mappingInfo);

			if (entityMetamodel.IsLazy)
			{
				proxyFactory = BuildProxyFactory(mappingInfo, idGetter, idSetter);
				if (proxyFactory == null)
				{
					entityMetamodel.IsLazy = false;
				}
			}
			else
			{
				proxyFactory = null;
			}

			Mapping.Component mapper = mappingInfo.IdentifierMapper;
			identifierMapperType = mapper == null ? null : (IAbstractComponentType)mapper.Type;
		}
开发者ID:renefc3,项目名称:nhibernate,代码行数:59,代码来源:AbstractEntityTuplizer.cs

示例6: AccessOptimizer

		public AccessOptimizer(GetPropertyValuesInvoker getDelegate, SetPropertyValuesInvoker setDelegate,
		                       IGetter[] getters, ISetter[] setters)
		{
			this.getDelegate = getDelegate;
			this.setDelegate = setDelegate;
			this.getters = getters;
			this.setters = setters;
			getterCallback = OnGetterCallback;
			setterCallback = OnSetterCallback;
		}
开发者ID:ray2006,项目名称:WCell,代码行数:10,代码来源:AccessOptimizer.cs

示例7: GetReflectionOptimizer

		public override IReflectionOptimizer GetReflectionOptimizer(System.Type clazz, IGetter[] getters, ISetter[] setters)
		{
			if (clazz.IsValueType)
			{
				// Cannot create optimizer for value types - the setter method will not work.
				log.Info("Disabling reflection optimizer for value type " + clazz.FullName);
				return null;
			}
			return new Generator(clazz, getters, setters).CreateReflectionOptimizer();
		}
开发者ID:paulbatum,项目名称:nhibernate,代码行数:10,代码来源:BytecodeProviderImpl.cs

示例8: Create

		/// <summary>
		/// Generate the IGetSetHelper object
		/// </summary>
		/// <param name="mappedClass">The target class</param>
		/// <param name="setters">Array of setters</param>
		/// <param name="getters">Array of getters</param>
		/// <returns>null if the generation fail</returns>
		public static IGetSetHelper Create( System.Type mappedClass, ISetter[] setters, IGetter[] getters )
		{
			if (mappedClass.IsValueType)
			{
				// Cannot create optimizer for value types - the setter method will not work.
				log.Info( "Disabling reflection optimizer for value type " + mappedClass.FullName );
				return null;
			}
			return new GetSetHelperFactory( mappedClass, setters, getters ).CreateGetSetHelper();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:17,代码来源:GetSetHelperFactory.cs

示例9: NoGetter

		public void NoGetter()
		{
			IGetter[] getters = new IGetter[]
				{
					new BasicPropertyAccessor.BasicGetter(typeof (NoGetterClass), typeof (NoGetterClass).GetProperty("Property"), "Property")
				};
			ISetter[] setters = new ISetter[]
				{
					new BasicPropertyAccessor.BasicSetter(typeof (NoGetterClass), typeof (NoGetterClass).GetProperty("Property"), "Property")
				};

			Assert.Throws<PropertyNotFoundException>(() => new ReflectionOptimizer(typeof (NoGetterClass), getters, setters));
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:13,代码来源:LcgFixture.cs

示例10: 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

示例11: ComponentType

		public ComponentType(System.Type componentClass,
		                     string[] propertyNames,
		                     IGetter[] propertyGetters,
		                     ISetter[] propertySetters,
		                     // currently not used, see the comment near the end of the method body
		                     bool foundCustomAcessor,
		                     IType[] propertyTypes,
		                     bool[] nullabilities,
		                     FetchMode[] joinedFetch,
		                     Cascades.CascadeStyle[] cascade,
		                     string parentProperty)
		{
			this.componentClass = componentClass;
			this.propertyTypes = propertyTypes;
			this.propertyNullability = nullabilities;
			propertySpan = propertyNames.Length;
			getters = propertyGetters;
			setters = propertySetters;
			string[] getterNames = new string[propertySpan];
			string[] setterNames = new string[propertySpan];
			System.Type[] propTypes = new System.Type[propertySpan];
			for (int i = 0; i < propertySpan; i++)
			{
				getterNames[i] = getters[i].PropertyName;
				setterNames[i] = setters[i].PropertyName;
				propTypes[i] = getters[i].ReturnType;
			}

			if (parentProperty == null)
			{
				parentSetter = null;
				parentGetter = null;
			}
			else
			{
				IPropertyAccessor pa = PropertyAccessorFactory.GetPropertyAccessor(null);
				parentSetter = pa.GetSetter(componentClass, parentProperty);
				parentGetter = pa.GetGetter(componentClass, parentProperty);
			}
			this.propertyNames = propertyNames;
			this.cascade = cascade;
			this.joinedFetch = joinedFetch;

			if (Environment.UseReflectionOptimizer)
			{
				// NH: reflection optimizer works with custom accessors
				this.optimizer = Environment.BytecodeProvider.GetReflectionOptimizer(componentClass, getters, setters);
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:49,代码来源:ComponentType.cs

示例12: ReflectionOptimizer

		/// <summary>
		/// Class constructor.
		/// </summary>
		public ReflectionOptimizer(System.Type mappedType, IGetter[] getters, ISetter[] setters)
		{
			// save off references
			this.mappedType = mappedType;
			typeOfThis = mappedType.IsValueType ? mappedType.MakeByRefType() : mappedType;
			//this.getters = getters;
			//this.setters = setters;

			GetPropertyValuesInvoker getInvoker = GenerateGetPropertyValuesMethod(getters);
			SetPropertyValuesInvoker setInvoker = GenerateSetPropertyValuesMethod(getters, setters);

			accessOptimizer = new AccessOptimizer(getInvoker, setInvoker, getters, setters);

			createInstanceMethod = CreateCreateInstanceMethod(mappedType);
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:18,代码来源:ReflectionOptimizer.cs

示例13: BuildProxyFactory

 protected internal override IProxyFactory BuildProxyFactory(PersistentClass mappingInfo, IGetter idGetter,
     ISetter idSetter)
 {
     IProxyFactory pf = new MapProxyFactory();
     try
     {
         //TODO: design new lifecycle for ProxyFactory
         pf.PostInstantiate(EntityName, null, null, null, null, null);
     }
     catch (HibernateException he)
     {
         log.Warn("could not create proxy factory for:" + EntityName, he);
         pf = null;
     }
     return pf;
 }
开发者ID:zibler,项目名称:zibler,代码行数:16,代码来源:DynamicMapEntityTuplizer.cs

示例14: PropertyAction

        /// <summary>
        /// 
        /// </summary>
        /// <param name="property"></param>
        /// <param name="getter"></param>
        /// <param name="setter"></param>
        public PropertyAction(PropertyInfo property, IGetter getter, ISetter setter)
        {
            if (property == null)
                throw new PropertyAccessorException("The propertyInfo for the current PropertyAction cannot be null.");

            if (getter == null && setter == null)
                throw new PropertyAccessorException(string.Format("The current PropertyAction doesn't have no accessor, property name: {0} - declaring type: {1}", property.Name, property.DeclaringType == null ? string.Empty : property.DeclaringType.FullName));

            if (getter != null && setter != null)
                this.accessType = AccessType.ReadWrite;
            else
                this.accessType = getter != null ? AccessType.Read : AccessType.Write;


            this.property = property;
            this.getter = getter;
            this.setter = setter;
        }
开发者ID:TheHunter,项目名称:NHibernate.Integration,代码行数:24,代码来源:PropertyAction.cs

示例15: GenerateSetPropertyValuesMethod

		/// <summary>
		/// Generates a dynamic method on the given type.
		/// </summary>
		/// <returns></returns>
		private SetPropertyValuesInvoker GenerateSetPropertyValuesMethod(IGetter[] getters, ISetter[] setters)
		{
			System.Type[] methodArguments = new System.Type[] { typeof(object), typeof(object[]), typeof(SetterCallback) };
			DynamicMethod method = CreateDynamicMethod(null, methodArguments);

			ILGenerator il = method.GetILGenerator();

			// Declare a local variable used to store the object reference (typed)
			LocalBuilder thisLocal = il.DeclareLocal(typeOfThis);
			il.Emit(OpCodes.Ldarg_0);
			EmitCastToReference(il, mappedType);
			il.Emit(OpCodes.Stloc, thisLocal.LocalIndex);

			for (int i = 0; i < setters.Length; i++)
			{
				// get the member accessor
				ISetter setter = setters[i];
				System.Type valueType = getters[i].ReturnType;

				IOptimizableSetter optimizableSetter = setter as IOptimizableSetter;

				if (optimizableSetter != null)
				{
					// load 'this'
					il.Emit(OpCodes.Ldloc, thisLocal);

					// load the value from the data array
					il.Emit(OpCodes.Ldarg_1);
					il.Emit(OpCodes.Ldc_I4, i);
					il.Emit(OpCodes.Ldelem_Ref);

					EmitUtil.PreparePropertyForSet(il, valueType);

					// using the setter's emitted IL
					optimizableSetter.Emit(il);
				}
				else
				{
					// using the setter itself via a callback
					MethodInfo invokeMethod =
						typeof(SetterCallback).GetMethod(
							"Invoke", new System.Type[] { typeof(object), typeof(int), typeof(object) });
					il.Emit(OpCodes.Ldarg_2);
					il.Emit(OpCodes.Ldarg_0);
					il.Emit(OpCodes.Ldc_I4, i);

					// load the value from the data array
					il.Emit(OpCodes.Ldarg_1);
					il.Emit(OpCodes.Ldc_I4, i);
					il.Emit(OpCodes.Ldelem_Ref);

					il.Emit(OpCodes.Callvirt, invokeMethod);
				}
			}

			// Setup the return
			il.Emit(OpCodes.Ret);

			return (SetPropertyValuesInvoker)method.CreateDelegate(typeof(SetPropertyValuesInvoker));
		}
开发者ID:pallmall,项目名称:WCell,代码行数:64,代码来源:ReflectionOptimizer.cs


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