• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ISetter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


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


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


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


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


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


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


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


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


示例10: ReflectionOptimizer

 IReflectionOptimizer IBytecodeProvider.GetReflectionOptimizer( System.Type clazz, IGetter[] getters, ISetter[] setters )
 {
     return new ReflectionOptimizer( kernel, clazz, getters, setters );
 }
开发者ID:kensodemann,项目名称:HomeScrum,代码行数:4,代码来源:NinjectByteCodeProvider.cs


示例11: BuildProxyFactoryInternal

		protected virtual IProxyFactory BuildProxyFactoryInternal(PersistentClass @class, IGetter getter, ISetter setter)
		{
			return Cfg.Environment.BytecodeProvider.ProxyFactoryFactory.BuildProxyFactory();
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:4,代码来源:PocoEntityTuplizer.cs


示例12: BuildProxyFactory

		protected override IProxyFactory BuildProxyFactory(PersistentClass persistentClass, IGetter idGetter,
		                                                            ISetter idSetter)
		{
			bool needAccesorCheck = true; // NH specific (look the comment below)

			// determine the id getter and setter methods from the proxy interface (if any)
			// determine all interfaces needed by the resulting proxy
			var proxyInterfaces = new HashedSet<System.Type> {typeof (INHibernateProxy)};

			System.Type _mappedClass = persistentClass.MappedClass;
			System.Type _proxyInterface = persistentClass.ProxyInterface;

			if (_proxyInterface != null && !_mappedClass.Equals(_proxyInterface))
			{
				if (!_proxyInterface.IsInterface)
				{
					throw new MappingException("proxy must be either an interface, or the class itself: " + EntityName);
				}
				needAccesorCheck = false; // NH (the proxy is an interface all properties can be overridden)
				proxyInterfaces.Add(_proxyInterface);
			}

			if (_mappedClass.IsInterface)
			{
				needAccesorCheck = false; // NH (the mapped class is an interface all properties can be overridden)
				proxyInterfaces.Add(_mappedClass);
			}

			foreach (Subclass subclass in persistentClass.SubclassIterator)
			{
				System.Type subclassProxy = subclass.ProxyInterface;
				System.Type subclassClass = subclass.MappedClass;
				if (subclassProxy != null && !subclassClass.Equals(subclassProxy))
				{
					if (!subclassProxy.IsInterface)
					{
						throw new MappingException("proxy must be either an interface, or the class itself: " + subclass.EntityName);
					}
					proxyInterfaces.Add(subclassProxy);
				}
			}

			/* 
			 * NH Different Implementation (for Error logging):
			 * - Check if the logger is enabled
			 * - Don't need nothing to check if the mapped-class or proxy is an interface
			 */
			if (log.IsErrorEnabled && needAccesorCheck)
			{
				LogPropertyAccessorsErrors(persistentClass);
			}
			/**********************************************************/

			MethodInfo idGetterMethod = idGetter == null ? null : idGetter.Method;
			MethodInfo idSetterMethod = idSetter == null ? null : idSetter.Method;

			MethodInfo proxyGetIdentifierMethod = idGetterMethod == null || _proxyInterface == null ? null :
				ReflectHelper.TryGetMethod(_proxyInterface, idGetterMethod);

			MethodInfo proxySetIdentifierMethod = idSetterMethod == null || _proxyInterface == null ? null :
				ReflectHelper.TryGetMethod(_proxyInterface, idSetterMethod);

			IProxyFactory pf = BuildProxyFactoryInternal(persistentClass, idGetter, idSetter);
			try
			{
				pf.PostInstantiate(EntityName, _mappedClass, proxyInterfaces, proxyGetIdentifierMethod, proxySetIdentifierMethod,
				                   persistentClass.HasEmbeddedIdentifier ? (IAbstractComponentType) persistentClass.Identifier.Type: null);
			}
			catch (HibernateException he)
			{
				log.Warn("could not create proxy factory for:" + EntityName, he);
				pf = null;
			}
			return pf;
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:75,代码来源:PocoEntityTuplizer.cs


示例13: base

 internal ReflectionOptimizer
     (System.Type mappedType, 
      IGetter[] getters, 
      ISetter[] setters) : base(mappedType, getters, setters) { }
开发者ID:mynamespace,项目名称:NHibernate.Extensions,代码行数:4,代码来源:ReflectionOptimizer.cs


示例14: AutofacReflectionOptimizer

 /// <summary>
 /// Initializes a new instance of the <see cref="AutofacReflectionOptimizer"/> class.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="mappedType">The type being mapped.</param>
 /// <param name="getters">The getters.</param>
 /// <param name="setters">The setters.</param>
 public AutofacReflectionOptimizer(IComponentContext container, Type mappedType, IGetter[] getters, ISetter[] setters)
     : base(mappedType, getters, setters)
 {
     _container = container;
 }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:12,代码来源:AutofacReflectionOptimizer.cs


示例15: EmitIL

        private void EmitIL(AssemblyBuilder assemblyBuilder, ModuleBuilder moduleBuilder)
        {
            // Create a new type object for the the field accessor class.
            EmitType(moduleBuilder);

            // Create a new instance
            _emittedSetter = assemblyBuilder.CreateInstance("SetFor" + _targetType.FullName + _fieldName) as ISetter;

            this.nullInternal = this.GetNullInternal(_fieldType);

            if (_emittedSetter == null)
            {
                throw new NotSupportedException(
                    string.Format("Unable to create a set field accessor for '{0}' field on class  '{0}'.", _fieldName, _fieldType));
            }
        }
开发者ID:jihadbird,项目名称:firespider,代码行数:16,代码来源:EmitFieldSetter.cs


示例16: 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>
        public 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;

            instantiator = BuildInstantiator(mappingInfo);

            if (entityMetamodel.IsLazy)
            {
                /* NH Different implementation
                 * When we are using an interface we need to use the interface itself to have
                 * the getter and setter of the identifier to prevent proxy initialization.
                 * The BasicLazyInitializer use method.Equals to recognize the the identifier setter.
                 */
                IGetter pidGetter = idGetter;
                ISetter pidSetter = idSetter;
                if (mappingInfo.HasIdentifierProperty && mappingInfo.ProxyInterface != null)
                {
                    pidGetter = mappingInfo.IdentifierProperty.GetGetter(mappingInfo.ProxyInterface);
                    pidSetter = mappingInfo.IdentifierProperty.GetSetter(mappingInfo.ProxyInterface);
                }
                proxyFactory = BuildProxyFactory(mappingInfo, pidGetter, pidSetter);
                /*******************************************************************************/
                if (proxyFactory == null)
                {
                    entityMetamodel.IsLazy = false;
                }
            }
            else
            {
                proxyFactory = null;
            }

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


示例17: BindComponent


//.........这里部分代码省略.........
				else if( "many-to-one".Equals( name ) || "key-many-to-one".Equals( name ) )
				{
					value = new ManyToOne( model.Table );
					BindManyToOne( subnode, ( ManyToOne ) value, subpath, isNullable, mappings );
				}
				else if( "one-to-one".Equals( name ) )
				{
					value = new OneToOne( model.Table, model.Owner.Identifier );
					BindOneToOne( subnode, ( OneToOne ) value, isNullable, mappings );
				}
				else if( "any".Equals( name ) )
				{
					value = new Any( model.Table );
					BindAny( subnode, ( Any ) value, isNullable, mappings );
				}
				else if( "property".Equals( name ) || "key-property".Equals( name ) )
				{
					value = new SimpleValue( model.Table );
					BindSimpleValue( subnode, ( SimpleValue ) value, isNullable, subpath, mappings );
				}
				else if( "component".Equals( name ) || "dynamic-component".Equals( name ) || "nested-composite-element".Equals( name ) )
				{
					System.Type subreflectedClass = model.ComponentClass == null ?
						null :
						GetPropertyType( subnode, mappings, model.ComponentClass, propertyName );
					value = ( model.Owner != null ) ?
						new Component( model.Owner ) : // a class component
						new Component( model.Table ); // a composite element
					BindComponent( subnode, ( Component ) value, subreflectedClass, className, subpath, isNullable, mappings );
				}
				else if( "parent".Equals( name ) )
				{
					model.ParentProperty = propertyName;
				}

				if( value != null )
				{
					model.AddProperty( CreateProperty( value, propertyName, model.ComponentClass, subnode, mappings ) );
				}
			}

			int span = model.PropertySpan;
			string[ ] names = new string[span];
			IType[ ] types = new IType[span];
			Cascades.CascadeStyle[ ] cascade = new Cascades.CascadeStyle[span];
			OuterJoinFetchStrategy[ ] joinedFetch = new OuterJoinFetchStrategy[span];

			int i = 0;
			foreach( Mapping.Property prop in model.PropertyCollection )
			{
				if( prop.IsFormula )
				{
					throw new MappingException( "properties of components may not be formulas: " + prop.Name );
				}
				if( !prop.IsInsertable || !prop.IsUpdateable )
				{
					throw new MappingException( "insert=\"false\", update=\"false\" not supported for properties of components: " + prop.Name );
				}
				names[ i ] = prop.Name;
				types[ i ] = prop.Type;
				cascade[ i ] = prop.CascadeStyle;
				joinedFetch[ i ] = prop.Value.OuterJoinFetchSetting;
				i++;
			}

			IType componentType;
			if( model.IsDynamic )
			{
				componentType = new DynamicComponentType( names, types, joinedFetch, cascade );
			}
			else
			{
				IGetter[ ] getters = new IGetter[span];
				ISetter[ ] setters = new ISetter[span];
				bool foundCustomAccessor = false;
				i = 0;
				foreach( Mapping.Property prop in model.PropertyCollection )
				{
					setters[ i ] = prop.GetSetter( model.ComponentClass );
					getters[ i ] = prop.GetGetter( model.ComponentClass );
					if( !prop.IsBasicPropertyAccessor )
					{
						foundCustomAccessor = true;
					}
					i++;
				}

				componentType = new ComponentType(
					model.ComponentClass,
					names,
					getters,
					setters,
					foundCustomAccessor,
					types,
					joinedFetch,
					cascade,
					model.ParentProperty );
			}
			model.Type = componentType;
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:101,代码来源:Binder.cs


示例18: GetReflectionOptimizer

 /// <summary>
 /// Generate the IReflectionOptimizer object
 /// </summary>
 /// <param name="mappedClass">The target class</param>
 /// <param name="setters">Array of setters</param>
 /// <param name="getters">Array of getters</param>
 /// <returns><see langword="null" /> if the generation fails</returns>
 public IReflectionOptimizer GetReflectionOptimizer(
     System.Type mappedClass, IGetter[] getters, ISetter[] setters)
 {
     return new ReflectionOptimizer(mappedClass, getters, setters);
 }
开发者ID:zibler,项目名称:zibler,代码行数:12,代码来源:BytecodeProviderImpl.cs


示例19: GetReflectionOptimizer

		public override IReflectionOptimizer GetReflectionOptimizer(System.Type clazz, IGetter[] getters, ISetter[] setters)
		{
			return null;
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:4,代码来源:NullBytecodeProvider.cs


示例20: BuildProxyFactory

		/// <summary> Build an appropriate ProxyFactory for the given mapped entity. </summary>
		/// <param name="mappingInfo">The mapping information regarding the mapped entity. </param>
		/// <param name="idGetter">The constructed Getter relating to the entity's id property. </param>
		/// <param name="idSetter">The constructed Setter relating to the entity's id property. </param>
		/// <returns> An appropriate ProxyFactory instance. </returns>
		protected abstract IProxyFactory BuildProxyFactory(PersistentClass mappingInfo, IGetter idGetter, ISetter idSetter);
开发者ID:renefc3,项目名称:nhibernate,代码行数:6,代码来源:AbstractEntityTuplizer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISetting类代码示例发布时间:2022-05-24
下一篇:
C# ISet类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap