예제 #1
0
 private IEnumerable <string> GetPropertyNamespaces()
 {
     foreach (var ns in Type.GetUsedNamespaces())
     {
         yield return(ns);
     }
     if (BackingField != null)
     {
         foreach (var ns in BackingField.GetUsedNamespaces())
         {
             yield return(ns);
         }
     }
     if (HasGetter)
     {
         foreach (var ns in Getter.GetUsedNamespaces())
         {
             yield return(ns);
         }
     }
     if (HasSetter)
     {
         foreach (var ns in Setter.GetUsedNamespaces())
         {
             yield return(ns);
         }
     }
     if (ExplicitInterface != null)
     {
         foreach (var ns in ExplicitInterface.GetUsedNamespaces(true))
         {
             yield return(ns);
         }
     }
 }
        /// <summary>
        /// Emits the IL for a getter
        /// </summary>
        /// <param name="getterIL">ILGenerator</param>
        /// <param name="sourceField">The field where the source component is stored</param>
        /// <param name="nestedType">Builder for a nested type in case this property needs to make one</param>
        /// <param name="thisType">Builder for the declaring type</param>
        protected override void ProtectedEmitGetter(ILGenerator getterIL, FieldBuilder sourceField, Lazy <TypeSpecifier> nestedType, TypeSpecifier thisType, string name)
        {
            BackingField = thisType.TypeBuilder.DefineField(thisType.GetBackingFieldIdentifier(name), typeof(TField), FieldAttributes.Private);
            BackingField.SetCustomAttribute(Specification <string> .GeneratedCode);

            getterIL.Emit(OpCodes.Ldarg_0);
            getterIL.Emit(OpCodes.Ldfld, BackingField);
        }
예제 #3
0
 public ChangePropertyCommand(System.Type ownerType, BackingField <T> field, T newValue)
 {
     _name = "Change " + ObjectNames.NicifyVariableName(ownerType.Name)
             + " " + field.PropertyName;
     _field        = field;
     _initialValue = field.Value;
     _newValue     = newValue;
 }
예제 #4
0
        private static Order CreateOrder(ISpecimenBuilder fixture)
        {
            var callOffId = fixture.Create <CallOffId>();
            var order     = new Order
            {
                CallOffId = callOffId,
                Revision  = callOffId.Revision,
            };

            BackingField.SetValue(order, nameof(Order.Id), callOffId.Id);

            return(order);
        }
예제 #5
0
        internal SourcePrimaryConstructorParameterSymbolWithBackingField(
            Symbol owner,
            int ordinal,
            TypeSymbol parameterType,
            RefKind refKind,
            string name,
            ImmutableArray <Location> locations,
            ParameterSyntax syntax,
            ConstantValue defaultSyntaxValue,
            bool isParams,
            bool isExtensionMethodThis,
            DiagnosticBag diagnostics
            ) : base(owner, ordinal, parameterType, refKind, ImmutableArray <CustomModifier> .Empty, false, name, locations, syntax.GetReference(), defaultSyntaxValue, isParams, isExtensionMethodThis)
        {
            bool modifierErrors;
            var  modifiers = SourceMemberFieldSymbol.MakeModifiers(owner.ContainingType, syntax.Identifier, syntax.Modifiers, diagnostics, out modifierErrors, ignoreParameterModifiers: true);

            backingField = new BackingField(this, modifiers, modifierErrors, diagnostics);
        }
        internal SourcePrimaryConstructorParameterSymbolWithBackingField(
            Symbol owner,
            int ordinal,
            TypeSymbol parameterType,
            RefKind refKind,
            string name,
            ImmutableArray<Location> locations,
            ParameterSyntax syntax,
            ConstantValue defaultSyntaxValue,
            bool isParams,
            bool isExtensionMethodThis,
            DiagnosticBag diagnostics
        ) : base(owner, ordinal, parameterType, refKind, ImmutableArray<CustomModifier>.Empty, false, name, locations, syntax.GetReference(), defaultSyntaxValue, isParams, isExtensionMethodThis)
        {
            bool modifierErrors;
            var modifiers = SourceMemberFieldSymbol.MakeModifiers(owner.ContainingType, syntax.Identifier, syntax.Modifiers, diagnostics, out modifierErrors, ignoreParameterModifiers: true);

            backingField = new BackingField(this, modifiers, modifierErrors, diagnostics);
        }
예제 #7
0
 public void UpdateBackingField(TfProviderField field, bool isSet)
 {
     if (isSet)
     {
         BackingField?.RemoveUpdatedBy(this);
     }
     else
     {
         BackingField?.RemoveUsedBy(this);
     }
     BackingField = field;
     if (isSet)
     {
         BackingField?.AddUpdatedBy(this);
     }
     else
     {
         BackingField?.AddUsedBy(this);
     }
 }
예제 #8
0
		void CreateAutomaticProperty ()
		{
			// Create backing field
			Field field = new BackingField (this);
			if (!field.Define ())
				return;

			Parent.PartialContainer.Members.Add (field);

			FieldExpr fe = new FieldExpr (field, Location);
			if ((field.ModFlags & Modifiers.STATIC) == 0)
				fe.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);

			//
			// Create get block but we careful with location to
			// emit only single sequence point per accessor. This allow
			// to set a breakpoint on it even with no user code
			//
			Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
			Return r = new Return (fe, Get.Location);
			Get.Block.AddStatement (r);

			// Create set block
			Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location.Null);
			Assign a = new SimpleAssign (fe, new SimpleName ("value", Location.Null), Location.Null);
			Set.Block.AddStatement (new StatementExpression (a, Set.Location));
		}
예제 #9
0
파일: property.cs 프로젝트: afaerber/mono
		void CreateAutomaticProperty ()
		{
			// Create backing field
			Field field = new BackingField (this);
			if (!field.Define ())
				return;

			Parent.PartialContainer.AddField (field);

			FieldExpr fe = new FieldExpr (field, Location);
			if ((field.ModFlags & Modifiers.STATIC) == 0)
				fe.InstanceExpression = new CompilerGeneratedThis (fe.Type, Location);

			// Create get block
			Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location);
			Return r = new Return (fe, Location);
			Get.Block.AddStatement (r);

			// Create set block
			Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location);
			Assign a = new SimpleAssign (fe, new SimpleName ("value", Location));
			Set.Block.AddStatement (new StatementExpression (a));
		}
예제 #10
0
 public override void SetValue(Object obj, Object value)
 {
     BackingField.SetValue(obj, value);
 }
예제 #11
0
 public override Object GetValue(Object obj)
 {
     return(BackingField.GetValue(obj));
 }
예제 #12
0
 public void SetValue(object?obj, object?value)
 {
     BackingField.SetValue(obj, value);
 }
예제 #13
0
 public object?GetValue(object?obj)
 {
     return(BackingField.GetValue(obj));
 }