Example #1
0
        /// <summary>
        /// This method is responsible for parsing an object property
        /// reference line from inside of a .con or .ai file, and converting
        /// the property into a C# property
        /// </summary>
        /// <remarks>
        /// The type of value is figured out within the method, but only certain types of
        /// object types can be parsed here.
        /// </remarks>
        /// <param name="token">The token for this ObjectProperty</param>
        /// <param name="objectLevel">Specifies the nested object level for this Property</param>
        public virtual void Parse(Token token, int objectLevel = 0)
        {
            // Seperate our property name and values
            TokenArgs tokenArgs = token.TokenArgs;
            string    propName  = tokenArgs.PropertyNames[objectLevel];

            // Fetch our property that we are setting the value to
            KeyValuePair <string, PropertyInfo> prop = GetProperty(propName);
            Type propType     = prop.Value.PropertyType;
            bool isCollection = propType.GetInterface("IObjectPropertyCollection") != null;

            // Get the value that is set
            var value = prop.Value.GetValue(this);

            // Is this an object method, or Object Property?
            if (propType.BaseType.Name == "ObjectMethod")
            {
                // Object methods are always instantiated in the object's constructor
                ObjectMethod method = (ObjectMethod)value;
                ConFileEntry item   = method.Invoke(token);

                // Add item to the file entry list
                if (item != null)
                {
                    token.File?.AddEntry(item, token);
                }
            }
            else
            {
                // If the value is null, then we create a new object property instance
                ObjectProperty obj = (ObjectProperty)value;
                if (obj == null)
                {
                    // Create instance and add it to the entries list
                    obj = ObjectProperty.Create(prop.Value, this, token);

                    // Add entry? Property Collections add thier own properties
                    if (!isCollection)
                    {
                        token.File?.AddProperty(obj);
                    }
                }

                // Create our instance, and parse
                obj.SetValue(token, objectLevel);
                prop.Value.SetValue(this, obj);
            }
        }
Example #2
0
        public RunStatement(Token token) : base(token)
        {
            // Load token args
            // Begin our array builder
            TokenArgs tokenArgs = new TokenArgs();

            // Split the line after the reference call into arguments
            string[] parts = token.Value.SplitWithQuotes(SplitChars, true);

            // Skip Run/Include
            parts = parts.Skip(1).ToArray();

            // Set internals
            FileName = parts[0];
            Arguments = parts.Skip(1).ToArray();
        }
Example #3
0
        public RunStatement(Token token) : base(token)
        {
            // Load token args
            // Begin our array builder
            TokenArgs tokenArgs = new TokenArgs();

            // Split the line after the reference call into arguments
            string[] parts = token.Value.SplitWithQuotes(SplitChars, true);

            // Skip Run/Include
            parts = parts.Skip(1).ToArray();

            // Set internals
            FileName  = parts[0];
            Arguments = parts.Skip(1).ToArray();
        }