コード例 #1
0
 internal static ParsedProperty FromPropertyInfo(System.Reflection.PropertyInfo property)
 {
     ParsedProperty toReturn = new ParsedProperty();
     toReturn.Name = property.Name;
     toReturn.Type = new ParsedType(property.PropertyType.Name);
     
     return toReturn;
 }
コード例 #2
0
ファイル: ParsedClass.cs プロジェクト: vchelaru/FlatRedBall
        private void CreateParsedProperty()
        {
            // For now we'll assume that all properties are on 
            // the same line.  Eventually we may want to combine
            // all lines before the opening bracket

            string headerLine = mCurrentBlock[0];

            #region Get header information

            Scope scope;
            ParsedType type;
            string variableName;
            bool isConst; // will always be false for properties
            string valueToAssignTo;
            bool isVirtual;
            bool isOverride;
            bool isStatic;
            bool isNew;
            bool isAsync;

            ParsedMethod.GetLineInformation(headerLine, out scope, out type, out variableName, out isConst, out isVirtual, 
                out isOverride, out isStatic, out isNew, out isAsync, out valueToAssignTo );

            ParsedProperty parsedProperty = new ParsedProperty();
            parsedProperty.Scope = scope;
            parsedProperty.Type = type;
            parsedProperty.Name = variableName;
            parsedProperty.IsVirtual = isVirtual;
            parsedProperty.IsStatic = isStatic;

            #endregion

            StringBuilder getterLines = new StringBuilder();

            StringBuilder setterLines = new StringBuilder();

            bool hasGetter;
            bool hasSetter;

            bool hasAutomaticGetter;
            bool hasAutomaticSetter;

            FillGettersAndSetters(getterLines, setterLines, true, false, out hasGetter, out hasSetter, out hasAutomaticGetter, out hasAutomaticSetter);

            parsedProperty.HasAutomaticGetter = hasAutomaticGetter;
            parsedProperty.HasAutomaticSetter = hasAutomaticSetter;

            if (hasGetter)
            {
                parsedProperty.GetContents = getterLines.ToString();
            }
            else
            {
                parsedProperty.GetContents = null;
            }

            if (hasSetter)
            {
                parsedProperty.SetContents = setterLines.ToString();
            }
            else
            {
                parsedProperty.SetContents = null;
            }

            parsedProperty.Attributes.AddRange(CurrentAttributes);

            mParsedProperties.Add(parsedProperty);
        }
コード例 #3
0
ファイル: ParsedClass.cs プロジェクト: vchelaru/FlatRedBall
        public ParsedProperty GetProperty(string propertyName)
        {

            foreach (ParsedProperty parsedProperty in mParsedProperties)
            {
                if (parsedProperty.Name == propertyName)
                {
                    return parsedProperty;
                }
            }

            foreach (ParsedClass parentClass in mParentParsedClasses)
            {
                ParsedProperty parsedProperty = parentClass.GetProperty(propertyName);

                if (parsedProperty != null)
                {
                    return parsedProperty;
                }
            }

            if (this.RuntimeType != null)
            {
                PropertyInfo propertyInfo = RuntimeType.GetProperty(propertyName);

                if (propertyInfo != null)
                {
                    ParsedProperty property = new ParsedProperty(Scope.Public, propertyInfo.PropertyType.Name, propertyName);

                    return property;
                }
                    
            }

            return null;
        }