Esempio n. 1
0
        public DefaultField AddField(string name)
        {
            DefaultField field = new DefaultField(this, name);

            Fields.Add(field);
            return(field);
        }
Esempio n. 2
0
        public void LocalVariableAndFieldAreNotSimilarMembers()
        {
            IField field = new DefaultField(dummyClass.DefaultReturnType, "Test", ModifierEnum.None, DomRegion.Empty, dummyClass);
            IField local = new DefaultField.LocalVariableField(dummyClass.DefaultReturnType, "Test", DomRegion.Empty, dummyClass);

            Assert.IsFalse(MemberLookupHelper.IsSimilarMember(local, field));
        }
Esempio n. 3
0
        public override void OnEnumMember(AST.EnumMember node)
        {
            DefaultField field = new DefaultField(OuterClass.DefaultReturnType, node.Name, ModifierEnum.Const | ModifierEnum.Public, GetRegion(node), OuterClass);

            ConvertAttributes(node, field);
            OuterClass.Fields.Add(field);
        }
Esempio n. 4
0
        public override void OnField(AST.Field node)
        {
            DefaultField field = new DefaultField(CreateReturnType(node), node.Name, GetModifier(node), GetRegion(node), OuterClass);

            ConvertAttributes(node, field);
            OuterClass.Fields.Add(field);
        }
Esempio n. 5
0
        protected override IEnumerable <FieldPairReference> GetFieldPairReferences(SchemaFile file, SetVariableStatement setVariableStatement)
        {
            var variable = setVariableStatement.Variable.GetField(null, Logger, file);
            var value    = (Field)null;

            if (setVariableStatement.FunctionCallExists)
            {
                var functionName = setVariableStatement.Identifier.Value;
                value = new DefaultField()
                {
                    Type       = FieldType.Xml, // TODO : can this only be xml?
                    Origin     = OriginType.FunctionReturn,
                    IsNullable = false,
                };
            }
            else
            {
                value = setVariableStatement.Expression.GetField(null, Logger, file);
            }

            return(new List <FieldPairReference>()
            {
                new FieldPairReference()
                {
                    Fragment = setVariableStatement,
                    Left = variable,
                    Right = value,
                }
            });
        }
        public override IEntity VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
        {
            bool         isSingleField = fieldDeclaration.Variables.Count() == 1;
            Modifiers    modifiers     = fieldDeclaration.Modifiers;
            DefaultField field         = null;

            foreach (VariableInitializer vi in fieldDeclaration.Variables)
            {
                field = new DefaultField(currentTypeDefinition, vi.Name);

                field.Region     = isSingleField ? MakeRegion(fieldDeclaration) : MakeRegion(vi);
                field.BodyRegion = MakeRegion(vi);
                ConvertAttributes(field.Attributes, fieldDeclaration.Attributes);

                ApplyModifiers(field, modifiers);
                field.IsVolatile = (modifiers & Modifiers.Volatile) != 0;
                field.IsReadOnly = (modifiers & Modifiers.Readonly) != 0;

                field.ReturnType = ConvertType(fieldDeclaration.ReturnType);
                if ((modifiers & Modifiers.Fixed) != 0)
                {
                    field.ReturnType = PointerTypeReference.Create(field.ReturnType);
                }

                if ((modifiers & Modifiers.Const) != 0)
                {
                    field.ConstantValue = ConvertConstantValue(field.ReturnType, vi.Initializer);
                }

                currentTypeDefinition.Fields.Add(field);
            }
            return(isSingleField ? field : null);
        }
Esempio n. 7
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = PageSizeSet.GetHashCode();
         hashCode = (hashCode * 397) ^ (Query != null ? Query.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TotalSize != null ? TotalSize.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TransformerParameters != null ? TransformerParameters.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Start;
         hashCode = (hashCode * 397) ^ (IsDistinct ? 1 : 0);
         hashCode = (hashCode * 397) ^ (FieldsToFetch != null ? FieldsToFetch.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SortedFields != null ? SortedFields.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SortHints != null ? SortHints.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Cutoff.GetHashCode();
         hashCode = (hashCode * 397) ^ WaitForNonStaleResultsAsOfNow.GetHashCode();
         hashCode = (hashCode * 397) ^ (CutoffEtag != null ? CutoffEtag.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DefaultField != null ? DefaultField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)DefaultOperator;
         hashCode = (hashCode * 397) ^ (SkippedResults != null ? SkippedResults.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DebugOptionGetIndexEntries.GetHashCode();
         hashCode = (hashCode * 397) ^ (HighlightedFields != null ? HighlightedFields.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HighlighterPreTags != null ? HighlighterPreTags.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HighlighterPostTags != null ? HighlighterPostTags.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HighlighterKeyName != null ? HighlighterKeyName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ResultsTransformer != null ? ResultsTransformer.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ShowTimings ? 1 : 0);
         hashCode = (hashCode * 397) ^ DisableCaching.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 新增或者修改
        /// </summary>
        /// <param name="input">输入的实体</param>
        public void AddOrUpdate(DefaultFieldInput input)
        {
            var data = new DefaultField();
            var list = new List <DefaultField>();

            if (input.Id == 0)
            {
                list = _defaultFieldRepository
                       .GetAllList(a => (a.FieldName == input.FieldName ||
                                         a.FieldCode.ToLower() == input.FieldCode.ToLower()) && a.DbTypeId == input.DbTypeId);
                input.CreateTime = DateTime.Now;
                data             = input.MapTo <DefaultField>();
            }
            else
            {
                list = _defaultFieldRepository
                       .GetAllList(a => (a.FieldName == input.FieldName ||
                                         a.FieldCode.ToLower() == input.FieldCode.ToLower()) && a.Id != input.Id && a.DbTypeId == input.DbTypeId);
                var item = _defaultFieldRepository.Get(input.Id);
                input.CreateTime = item.CreateTime;
                data             = input.MapTo <DefaultFieldInput, DefaultField>(item);
            }
            if (list.Count > 0)
            {
                "字段重复".ErrorMsg();
            }
            if (!Regex.IsMatch(input.FieldCode, @"^[a-zA-Z][a-zA-Z_]*$"))
            {
                "字段编码只能输入字母和下滑线的组合".ErrorMsg();
            }
            _defaultFieldRepository.InsertOrUpdate(data);
        }
Esempio n. 9
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = PageSizeSet.GetHashCode();
         hashCode = (hashCode * 397) ^ (Query != null ? Query.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TotalSize != null ? TotalSize.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (QueryInputs != null ? QueryInputs.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Start;
         hashCode = (hashCode * 397) ^ (int)AggregationOperation;
         hashCode = (hashCode * 397) ^ (GroupBy != null ? GroupBy.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (FieldsToFetch != null ? FieldsToFetch.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SortedFields != null ? SortedFields.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Cutoff.GetHashCode();
         hashCode = (hashCode * 397) ^ (CutoffEtag != null ? CutoffEtag.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DefaultField != null ? DefaultField.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)DefaultOperator;
         hashCode = (hashCode * 397) ^ SkipTransformResults.GetHashCode();
         hashCode = (hashCode * 397) ^ (SkippedResults != null ? SkippedResults.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DebugOptionGetIndexEntries.GetHashCode();
         hashCode = (hashCode * 397) ^ (HighlightedFields != null ? HighlightedFields.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HighlighterPreTags != null ? HighlighterPreTags.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HighlighterPostTags != null ? HighlighterPostTags.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ResultsTransformer != null ? ResultsTransformer.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DisableCaching.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 10
0
 // Set up Only Field Buy
 public void Setup(DefaultField currentField, ShopScrollList currentScrollList)
 {
     field          = currentField;
     nameLabel.text = "Land";
     priceText.text = currentField.cost.ToString() + " Baht.";
     scrollList     = currentScrollList;
     buttonComponent.onClick.AddListener(HandleClickField);
 }
Esempio n. 11
0
 /// <summary>
 /// Copies fields from one class to another.
 /// </summary>
 /// <param name="oldClass">Source class</param>
 /// <param name="newClass">Target class</param>
 private void copyFields(IClass oldClass, IClass newClass)
 {
     foreach (IField element in oldClass.Fields)
     {
         DefaultField newField = new DefaultField(element.ReturnType, element.Name, element.Modifiers, element.Region, newClass);
         newClass.Fields.Add(newField);
     }
 }
Esempio n. 12
0
        ///
        /// Creates the mood window dialog but does not display it. 
        /// (use Run()).
        ///
        /// cred and mood are directly modified on successful validation.
        ///
        public MoodDialog( Gtk.Window        parent,
                         IEngine           backend,
                         Credentials      cred,
                         Mood             mood,
                         DefaultField      defaultField )
        {
            Debug.Assert( null != backend );

             _backend = backend;    // Save for later...

             Glade.XML glade = new Glade.XML( null,
                                          "tam.GtkPlayer.exe.glade",
                                          "_moodDialog",
                                          null );

             glade.Autoconnect( this );

             Debug.Assert( null != _moodDialog );
             Debug.Assert( null != _userCombo );
             Debug.Assert( null != _moodCombo );

             _moodDialog.TransientFor = parent;

             // Set up the available users list.

             Credentials [] credList = backend.GetUserList();
             string [] credNameList = new string[ credList.Length ];
             for (int i = 0; i < credList.Length; i++)
            credNameList[i] = ((Credentials)credList[i]).name;

             _userCombo.PopdownStrings = credNameList;

             // Set default values for the entry fields AFTER the dropdown
             // lists are initialized, otherwise it will default to the first
             // value in the list

             if (null != cred)
            _userCombo.Entry.Text = cred.name;

             _UpdateUserBtns();

             if (null != mood)
            _moodCombo.Entry.Text = mood.name;

             _UpdateMoodBtns();

             switch (defaultField)
             {
             case DefaultField.USER:
             default:
            _userCombo.Entry.GrabFocus();
            break;

             case DefaultField.MOOD:
            _moodCombo.Entry.GrabFocus();
            break;
             }
        }
        DefaultField AddTestFieldDefinedAsTestMemberToClass(string name)
        {
            var field = new DefaultField(fakeClass, name);

            fakeClass.Fields.Add(field);
            fakeRegisteredTestFrameworks.AddTestMember(field);

            return(field);
        }
Esempio n. 14
0
 public void Display(Player player, DefaultField field)
 {
     this.currentPlayer    = player;
     this.currentField     = field;
     landNameText.text     = "Province Name : " + this.currentField.name;
     seedNameText.text     = "Detail :" + this.currentField.seed.name;
     currentMoneyText.text = "Current Money :" + this.currentPlayer.money;
     buyoutPriceText.text  = "Buy out Price : " + this.currentField.getBuyOutPrice();
 }
        void ExpandAutomaticProperty(object sender, EventArgs e)
        {
            MenuCommand item       = (MenuCommand)sender;
            IProperty   member     = (IProperty)item.Tag;
            ITextEditor textEditor = FindReferencesAndRenameHelper.JumpToDefinition(member);

            if (textEditor != null)
            {
                CodeGenerator codeGen = member.DeclaringType.ProjectContent.Language.CodeGenerator;
                IField        field   = new DefaultField(member.ReturnType, codeGen.GetFieldName(member.Name),
                                                         member.Modifiers & ModifierEnum.Static, DomRegion.Empty, member.DeclaringType);
                ClassFinder finder = new ClassFinder(member);

                Ast.PropertyDeclaration p = codeGen.CreateProperty(field, member.CanGet, member.CanSet);

                p.Modifier = CodeGenerator.ConvertModifier(member.Modifiers, finder);

                PropertyDeclaration oldProp = ParseMember <PropertyDeclaration>(Path.GetExtension(textEditor.FileName), GetMemberText(member, textEditor));

                if (member.CanGet)
                {
                    p.GetRegion.Modifier = CodeGenerator.ConvertModifier(member.GetterModifiers, finder);
                }

                if (member.CanSet)
                {
                    p.SetRegion.Modifier = CodeGenerator.ConvertModifier(member.SetterModifiers, finder);
                }

                int startOffset = textEditor.Document.PositionToOffset(member.Region.BeginLine, member.Region.BeginColumn);
                int endOffset   = textEditor.Document.PositionToOffset(member.Region.EndLine, member.Region.EndColumn);

                if (!member.BodyRegion.IsEmpty)
                {
                    endOffset = textEditor.Document.PositionToOffset(member.BodyRegion.EndLine, member.BodyRegion.EndColumn);
                }

                FieldDeclaration f = CodeGenerator.ConvertMember(field, finder);

                f.Fields[0].Initializer = oldProp.Initializer;

                using (textEditor.Document.OpenUndoGroup()) {
                    textEditor.Document.Remove(startOffset, endOffset - startOffset);

                    if (codeGen.Options.EmptyLinesBetweenMembers)
                    {
                        var line = textEditor.Document.GetLine(member.Region.BeginLine);
                        textEditor.Document.Remove(line.Offset, line.TotalLength);
                    }

                    codeGen.InsertCodeInClass(member.DeclaringType, new RefactoringDocumentAdapter(textEditor.Document), member.Region.BeginLine - 1, f, p);
                }

                ParserService.ParseCurrentViewContent();
            }
        }
Esempio n. 16
0
 // Use this for initialization
 // void Awake ()
 // {
 //      buttonComponent.onClick.AddListener (HandleClick);
 // }
 //Set up  Field Buy and seed
 public void Setup(DefaultField currentField, Seed currentItem, ShopScrollList currentScrollList)
 {
     item           = currentItem;
     field          = currentField;
     nameLabel.text = item.name;
     priceText.text = (item.cost + field.cost).ToString() + " Baht.";
     scrollList     = currentScrollList;
     buttonComponent.onClick.AddListener(HandleClickSeed);
     Debug.Log(item);
 }
Esempio n. 17
0
        public void IsTestMember_FieldThatStartsWithTest_ReturnsFalse()
        {
            CreateTestFramework();
            MockClass c     = MockClass.CreateMockClassWithoutAnyAttributes();
            var       field = new DefaultField(c, "testField");

            bool result = testFramework.IsTestMember(field);

            Assert.IsFalse(result);
        }
Esempio n. 18
0
        public void FindFieldFromArrayReturnsExpectedNullForUnknownField()
        {
            DefaultClass c     = CreateClass();
            DefaultField field = new DefaultField(c, "field");

            ArrayList items = new ArrayList();

            items.Add(field);

            Assert.IsNull(PythonCompletionItemsHelper.FindFieldFromCollection("unknown-field-name", items));
        }
		public override PropertyDeclaration CreateProperty(IField field, bool createGetter, bool createSetter)
		{
			string propertyName = GetPropertyName(field.Name);
			if (string.Equals(propertyName, field.Name, StringComparison.InvariantCultureIgnoreCase)) {
				if (HostCallback.RenameMember(field, "m_" + field.Name)) {
					field = new DefaultField(field.ReturnType, "m_" + field.Name,
					                         field.Modifiers, field.Region, field.DeclaringType);
				}
			}
			return base.CreateProperty(field, createGetter, createSetter);
		}
Esempio n. 20
0
        public void FindFieldFromArrayReturnsExpectedField()
        {
            DefaultClass c     = CreateClass();
            DefaultField field = new DefaultField(c, "field");

            ArrayList items = new ArrayList();

            items.Add(field);

            Assert.AreEqual(field, PythonCompletionItemsHelper.FindFieldFromCollection("field", items));
        }
Esempio n. 21
0
 public override PropertyDeclaration CreateProperty(IField field, bool createGetter, bool createSetter)
 {
     string propertyName = GetPropertyName(field.Name);
     if (propertyName == field.Name && GetParameterName(propertyName) != propertyName) {
         string newName = GetParameterName(propertyName);
         if (HostCallback.RenameMember(field, newName)) {
             field = new DefaultField(field.ReturnType, newName,
                                      field.Modifiers, field.Region, field.DeclaringType);
         }
     }
     return base.CreateProperty(field, createGetter, createSetter);
 }
Esempio n. 22
0
 void AddFieldToDeclaringType(string fieldName)
 {
     if (fieldName != null)
     {
         if (!fieldNamesAdded.Contains(fieldName))
         {
             DefaultField field = new DefaultField(declaringType, fieldName);
             declaringType.Fields.Add(field);
             fieldNamesAdded.Add(fieldName);
         }
     }
 }
Esempio n. 23
0
		public override PropertyDeclaration CreateProperty(IField field, bool createGetter, bool createSetter)
		{
			string propertyName = GetPropertyName(field.Name);
			if (propertyName == field.Name && GetParameterName(propertyName) != propertyName) {
				string newName = GetParameterName(propertyName);
				if (HostCallback.RenameMember(field, newName)) {
					field = new DefaultField(field.ReturnType, newName,
					                         field.Modifiers, field.Region, field.DeclaringType);
				}
			}
			return base.CreateProperty(field, createGetter, createSetter);
		}
Esempio n. 24
0
 public void Display(Player player, DefaultField field)
 {
     this.seed     = null;
     currentPlayer = player;
     currentField  = field;
     Debug.Log(currentPlayer.buyQouta);
     myGoldDisplay.text = "Money : " + currentPlayer.money.ToString();
     qoutaDisplay.text  = "Qouta : " + currentPlayer.buyQouta.ToString();
     selectionText.text = "Selection : ";
     statusText.text    = "Choose Seed to Plant";
     // RemoveButtons();
     AddButtons();
 }
Esempio n. 25
0
        /// <summary>
        /// Get Field Value from Filter
        /// </summary>
        /// <param name="FilterContainer">Filter container</param>
        /// <param name="ConfigProperty">Config property instance</param>
        /// <returns>Value of Field in Filter</returns>
        public object GetFieldValue_From_Filter(Control FilterContainer, ConfigProperty ConfigProperty)
        {
            DefaultField defaultField = (DefaultField)FilterContainer.Controls.Find(ConfigProperty.PropertyInfo.Name, true).First();

            if (defaultField.Value != null)
            {
                return(defaultField.Value);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 26
0
        public void IsTestMember_FieldHasOneAttribute_ReturnsFalseAndDoesNotThrowInvalidCastException()
        {
            CreateTestFramework();
            MockClass mockClass     = MockClass.CreateMockClassWithoutAnyAttributes();
            var       field         = new DefaultField(mockClass, "MyField");
            var       testAttribute = new MockAttribute("Test");

            field.Attributes.Add(testAttribute);

            bool result = testFramework.IsTestMember(field);

            Assert.IsFalse(result);
        }
Esempio n. 27
0
        public override PropertyDeclaration CreateProperty(IField field, bool createGetter, bool createSetter)
        {
            string propertyName = GetPropertyName(field.Name);

            if (string.Equals(propertyName, field.Name, StringComparison.InvariantCultureIgnoreCase))
            {
                if (HostCallback.RenameMember(field, "m_" + field.Name))
                {
                    field = new DefaultField(field.ReturnType, "m_" + field.Name,
                                             field.Modifiers, field.Region, field.DeclaringType);
                }
            }
            return(base.CreateProperty(field, createGetter, createSetter));
        }
Esempio n. 28
0
        private void DefaultField_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            DefaultField defaultField = (DefaultField)sender;
            string       message      = Glossary.Entering_this_field_is_mandatory;

            // à vérifer avec les second
            if (defaultField.isEmpty)
            {
                errorProvider.Clear();
                errorProvider.SetError(defaultField, message);
                errorProvider.SetIconPadding(defaultField, -20);
                errorProvider.BlinkStyle = ErrorBlinkStyle.BlinkIfDifferentError;

                e.Cancel = true;
            }
        }
Esempio n. 29
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = PageSizeSet.GetHashCode();
         hashCode = (hashCode * 397) ^ (Query?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ Start;
         hashCode = (hashCode * 397) ^ (IsDistinct ? 1 : 0);
         hashCode = (hashCode * 397) ^ (FieldsToFetch?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (WaitForNonStaleResultsTimeout != null ? WaitForNonStaleResultsTimeout.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ WaitForNonStaleResultsAsOfNow.GetHashCode();
         hashCode = (hashCode * 397) ^ (CutoffEtag != null ? CutoffEtag.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DefaultField?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)DefaultOperator;
         return(hashCode);
     }
 }
Esempio n. 30
0
        /// <summary>
        /// Create Field in Filter
        /// </summary>
        /// <param name="param">Parameters</param>
        /// <returns>The created field</returns>
        public BaseField CreateField_In_Filter(CreateField_In_Filter_Params param)
        {
            DefaultField defaultField = new DefaultField();

            defaultField.StopAutoSizeConfig();
            defaultField.Name             = param.ConfigProperty.PropertyInfo.Name;
            defaultField.SizeLabel        = param.SizeLabel;
            defaultField.SizeControl      = param.SizeControl;
            defaultField.OrientationField = Orientation.Horizontal;
            defaultField.TabIndex         = param.TabIndex;
            defaultField.Text_Label       = param.ConfigProperty.DisplayProperty.Title;

            defaultField.ConfigSizeField();
            param.FilterContainer.Controls.Add(defaultField);

            return(defaultField);
        }
        public override object VisitFieldDeclaration(NRefactoryAST.FieldDeclaration fieldDeclaration, object data)
        {
            DomRegion    region   = GetRegion(fieldDeclaration.StartLocation, fieldDeclaration.EndLocation);
            DefaultClass c        = GetCurrentClass();
            ModifierEnum modifier = ConvertModifier(fieldDeclaration.Modifier,
                                                    (c.ClassType == ClassType.Struct && this.IsVisualBasic)
                                                                ? ModifierEnum.Public : ModifierEnum.Private);
            string doku = GetDocumentation(region.BeginLine, fieldDeclaration.Attributes);

            if (currentClass.Count > 0)
            {
                for (int i = 0; i < fieldDeclaration.Fields.Count; ++i)
                {
                    NRefactoryAST.VariableDeclaration field = (NRefactoryAST.VariableDeclaration)fieldDeclaration.Fields[i];

                    IReturnType retType;
                    if (c.ClassType == ClassType.Enum)
                    {
                        retType = c.DefaultReturnType;
                    }
                    else
                    {
                        retType = CreateReturnType(fieldDeclaration.GetTypeForField(i));
                        if (!field.FixedArrayInitialization.IsNull)
                        {
                            retType = new ArrayReturnType(cu.ProjectContent, retType, 1);
                        }
                    }
                    DefaultField f = new DefaultField(retType, field.Name, modifier, region, c);
                    ConvertAttributes(fieldDeclaration, f);
                    f.Documentation = doku;
                    if (c.ClassType == ClassType.Enum)
                    {
                        f.Modifiers = ModifierEnum.Const | ModifierEnum.Public;
                    }

                    c.Fields.Add(f);
                    mapField(fieldDeclaration, f);
                }
            }

            return(null);
        }
Esempio n. 32
0
        public void Resolve_FieldHasNoReturnType_DoesNotThrowNullReferenceException()
        {
            MockProjectContent projectContent = new MockProjectContent();

            UnitTestingUtils.MockClass c = new UnitTestingUtils.MockClass(projectContent, "Test");
            projectContent.SetClassToReturnFromGetClass("self", c);
            DefaultField field = c.AddField("randomNumber");

            field.ReturnType = null;
            ParseInformation parseInfo = new ParseInformation(c.CompilationUnit);

            ExpressionResult            expression            = new ExpressionResult("self.randomNumber.randint", ExpressionContext.Default);
            PythonClassResolver         classResolver         = new PythonClassResolver();
            PythonLocalVariableResolver localVariableResolver = new PythonLocalVariableResolver(classResolver);
            PythonMemberResolver        resolver = new PythonMemberResolver(classResolver, localVariableResolver);

            PythonResolverContext context = new PythonResolverContext(parseInfo, expression, "class Test:\r\npass");

            Assert.DoesNotThrow(delegate { resolver.Resolve(context); });
        }
Esempio n. 33
0
        /// <summary>
        /// Step1 : CreateField in EntryForm
        /// </summary>
        /// <param name="param">
        /// </param>
        /// <returns>the created field</returns>
        public BaseField CreateField_In_EntryForm(CreateFieldParams param)
        {
            // Set ErrorProvider Instance
            this.errorProvider = param.errorProvider;

            DefaultField defaultField = new DefaultField();

            defaultField.StopAutoSizeConfig();
            defaultField.Name             = param.PropertyInfo.Name;
            defaultField.Location         = param.Location;
            defaultField.OrientationField = param.OrientationField;
            defaultField.SizeLabel        = param.SizeLabel;
            defaultField.SizeControl      = param.SizeControl;
            defaultField.TabIndex         = param.TabIndex;
            defaultField.Text_Label       = param.ConfigProperty.DisplayProperty.Title;
            defaultField.ConfigSizeField();

            //Validating
            if (param.ConfigProperty.EntryForm.isRequired)
            {
                defaultField.Validating += DefaultField_Validating;
            }

            // Type of Property
            defaultField.PropertyInfo = param.ConfigProperty.PropertyInfo;

            // Can not Update Not supported Type , you can Just read it value
            // NB : String is not a primitve type
            if (
                !param.ConfigProperty.PropertyInfo.PropertyType.IsPrimitive &&
                !(param.ConfigProperty.PropertyInfo.PropertyType == typeof(string))
                )
            {
                defaultField.Enabled = false;
            }


            // Insertion à l'interface
            param.ConteneurFormulaire.Controls.Add(defaultField);
            return(defaultField);
        }
		public override object VisitFieldDeclaration(AST.FieldDeclaration fieldDeclaration, object data)
		{
			DomRegion region = GetRegion(fieldDeclaration.StartLocation, fieldDeclaration.EndLocation);
			DefaultClass c = GetCurrentClass();
			ModifierEnum modifier = ConvertModifier(fieldDeclaration.Modifier,
			                                        (c.ClassType == ClassType.Struct && this.IsVisualBasic)
			                                        ? ModifierEnum.Public : ModifierEnum.Private);
			string doku = GetDocumentation(region.BeginLine, fieldDeclaration.Attributes);
			if (currentClass.Count > 0) {
				for (int i = 0; i < fieldDeclaration.Fields.Count; ++i) {
					AST.VariableDeclaration field = (AST.VariableDeclaration)fieldDeclaration.Fields[i];
					
					IReturnType retType;
					if (c.ClassType == ClassType.Enum) {
						retType = c.DefaultReturnType;
					} else {
						retType = CreateReturnType(fieldDeclaration.GetTypeForField(i));
						if (!field.FixedArrayInitialization.IsNull)
							retType = new ArrayReturnType(cu.ProjectContent, retType, 1);
					}
					DefaultField f = new DefaultField(retType, field.Name, modifier, region, c);
					ConvertAttributes(fieldDeclaration, f);
					f.Documentation = doku;
					if (c.ClassType == ClassType.Enum) {
						f.Modifiers = ModifierEnum.Const | ModifierEnum.Public;
					}
					
					c.Fields.Add(f);
				}
			}
			return null;
		}