예제 #1
0
        public override EventPropertyWriter GetWriter(String propertyName)
        {
            if (WritablePropertyDescriptors == null)
            {
                InitializeWriters();
            }
            var pair = PropertyWriters.Get(propertyName);

            if (pair != null)
            {
                return(pair.Second);
            }

            var property = PropertyParser.ParseAndWalk(propertyName, false);

            if (property is MappedProperty)
            {
                var mapProp = (MappedProperty)property;
                return(new MapEventBeanPropertyWriterMapProp(mapProp.PropertyNameAtomic, mapProp.Key));
            }

            if (property is IndexedProperty)
            {
                var indexedProp = (IndexedProperty)property;
                return(new MapEventBeanPropertyWriterIndexedProp(indexedProp.PropertyNameAtomic, indexedProp.Index));
            }

            return(null);
        }
예제 #2
0
        private void StructureParseTypes(CSharpProject project, SDRepository sdRepository)
        {
            var types = project.Compilation.MainAssembly.TopLevelTypeDefinitions.ToList();

            for (int j = 0; j < types.Count; j++)
            {
                var type = types[j];
                if (types[j].Kind != TypeKind.Delegate)
                {
                    PostParseMessage(_parserStrings.ParsingClass + ": " + string.Format("{0}.{1}", types[j].Namespace, types[j].Name));

                    var nameSpace    = sdRepository.GetNamespaceByIdentifier(type.Namespace);
                    var namespaceRef = nameSpace ?? new SDNamespace(type.Namespace)
                    {
                        IsProjectStranger = true
                    };

                    var sdType = new SDType(type.GetIdentifier(), type.Name, namespaceRef)
                    {
                        Accessibility = type.GetDefinition().Accessibility.ToString().ToLower()
                    };

                    sdRepository.AddType(sdType);

                    EventParser.ParseMinimalFields(sdType, types[j]);
                    PropertyParser.ParseMinimalProperties(sdType, types[j]);
                    FieldParser.ParseMinimalFields(sdType, types[j]);
                    MethodParser.ParseMinimalConstructors(sdType, types[j]);
                    MethodParser.ParseMinimalMethods(sdType, types[j]);

                    sdRepository.AddNamespaceTypeRelation(types[j].Namespace, sdType.Identifier);
                }
            }
        }
        private static Pair <int, string> GetStreamIndex(string resolvedPropertyName)
        {
            var property = PropertyParser.ParseAndWalkLaxToSimple(resolvedPropertyName);

            if (!(property is NestedProperty))
            {
                throw new IllegalStateException("Expected a nested property providing an index for array match '" + resolvedPropertyName + "'");
            }
            var nested = (NestedProperty)property;

            if (nested.Properties.Count < 2)
            {
                throw new IllegalStateException("Expected a nested property name for array match '" + resolvedPropertyName + "', none found");
            }
            if (!(nested.Properties[0] is IndexedProperty))
            {
                throw new IllegalStateException("Expected an indexed property for array match '" + resolvedPropertyName + "', please provide an index");
            }
            var index = ((IndexedProperty)nested.Properties[0]).Index;

            nested.Properties.RemoveAt(0);
            var writer = new StringWriter();

            nested.ToPropertyEPL(writer);
            return(new Pair <int, string>(index, writer.ToString()));
        }
예제 #4
0
        public void SingleLine03()
        {
            Reader      reader = Reader.CreateStringReader(ExampleStrings.Property.SingleLine03);
            IDataParser parser = CreateDataParser(reader, PropertyParser.HierarchyParser(2));

            AssertParsedUsingXml(parser, new HierarchyModel(PropertyModel.Factory("Property", "KEY-004", "[ 1] key of MSF004 FK:0")));
        }
예제 #5
0
        public void GetPropertiesTable7()
        {
            Hashtable propertiesTable;

            // This is a failure case.
            Assert.False(PropertyParser.GetTable(null, "Properties", new string[] { "=Debug" }, out propertiesTable));
        }
예제 #6
0
 /// <summary>
 ///     Create a Property object from an attribute specification.
 /// </summary>
 /// <param name="propertyList">The PropertyList object being built for this FO.</param>
 /// <param name="value">The attribute value.</param>
 /// <param name="fo">The current FO whose properties are being set.</param>
 /// <returns>The initialized Property object.</returns>
 public virtual Property Make(PropertyList propertyList, string value, FObj fo)
 {
     try
     {
         Property pret   = null;
         string   pvalue = value;
         pret = CheckEnumValues(value);
         if (pret == null)
         {
             pvalue = CheckValueKeywords(value);
             Property p = PropertyParser.parse(pvalue,
                                               new PropertyInfo(this,
                                                                propertyList, fo));
             pret = ConvertProperty(p, propertyList, fo);
         }
         else if (IsCompoundMaker())
         {
             pret = ConvertProperty(pret, propertyList, fo);
         }
         if (pret == null)
         {
             throw new PropertyException("No conversion defined");
         }
         else if (InheritsSpecified())
         {
             pret.SpecifiedValue = pvalue;
         }
         return(pret);
     }
     catch (PropertyException propEx)
     {
         throw new FonetException("Error in " + propName + " property value '" + value + "': " + propEx.Message);
     }
 }
        public void SetUp()
        {
            Configuration         = new CodeGeneratorConfiguration().MediaTypes;
            dataTypeConfiguration = TestDataTypeProvider.All;

            Parser = new PropertyParser(Configuration, dataTypeConfiguration);
        }
예제 #8
0
 private static void MergeIntoPropertyDictionary(
     PropertyDictionary <ProjectPropertyInstance> properties,
     string propertyNameAndValuesString,
     string syntaxName)
 {
     if (!string.IsNullOrEmpty(propertyNameAndValuesString))
     {
         if (PropertyParser.GetTableWithEscaping(
                 null,
                 null,
                 null,
                 propertyNameAndValuesString.Split(PropertySeparator, StringSplitOptions.RemoveEmptyEntries),
                 out Dictionary <string, string> propertiesTable))
         {
             foreach (KeyValuePair <string, string> pair in propertiesTable)
             {
                 properties[pair.Key] = ProjectPropertyInstance.Create(pair.Key, pair.Value);
             }
         }
         else
         {
             throw new InvalidProjectFileException(string.Format(
                                                       CultureInfo.InvariantCulture,
                                                       ResourceUtilities.GetResourceString("General.InvalidPropertyError"),
                                                       syntaxName,
                                                       propertyNameAndValuesString));
         }
     }
 }
예제 #9
0
        protected ParsedPropertyPath ParsePath(string path, Type entityType)
        {
            var propertyParser = new PropertyParser();
            var propertyPath   = propertyParser.ParsePropertyOfType(path, entityType);

            return(propertyPath);
        }
예제 #10
0
        private void ParseTypes()
        {
            var pi = 0;

            for (int i = 0; i < _solution.Projects.Count; i++)
            {
                pi = i;
                var types = _solution.Projects[i].Compilation.MainAssembly.TopLevelTypeDefinitions.ToList();
                for (int j = 0; j < types.Count; j++)
                {
                    if (types[j].Kind != TypeKind.Delegate)
                    {
                        PostProgress(_sdBuildStrings.ParsingClass + ": " + string.Format("{0}.{1}", types[j].Namespace, types[j].Name), j, types.Count, pi, _solution.Projects.Count);

                        var sdType = CreateSDType(types[j]);

                        EventParser.ParseMinimalFields(sdType, types[j]);
                        PropertyParser.ParseMinimalProperties(sdType, types[j]);
                        FieldParser.ParseMinimalFields(sdType, types[j]);
                        MethodParser.ParseMinimalConstructors(sdType, types[j]);
                        MethodParser.ParseMinimalMethods(sdType, types[j]);

                        _repository.AddNamespaceTypeRelation(types[j].Namespace, sdType.Identifier);
                    }
                }
            }
        }
예제 #11
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var registry = AvaloniaPropertyRegistry.Instance;
            var parser   = new PropertyParser();

            var(ns, owner, propertyName) = parser.Parse(new CharacterReader(((string)value).AsSpan()));
            var ownerType  = TryResolveOwnerByName(context, ns, owner);
            var targetType = context.GetFirstParent <ControlTemplate>()?.TargetType ??
                             context.GetFirstParent <Style>()?.Selector?.TargetType ??
                             typeof(Control);
            var effectiveOwner = ownerType ?? targetType;
            var property       = registry.FindRegistered(effectiveOwner, propertyName);

            if (property == null)
            {
                throw new XamlLoadException($"Could not find property '{effectiveOwner.Name}.{propertyName}'.");
            }

            if (effectiveOwner != targetType &&
                !property.IsAttached &&
                !registry.IsRegistered(targetType, property))
            {
                Logger.Warning(
                    LogArea.Property,
                    this,
                    "Property '{Owner}.{Name}' is not registered on '{Type}'.",
                    effectiveOwner,
                    propertyName,
                    targetType);
            }

            return(property);
        }
예제 #12
0
        public static bool Parse(SyntaxContext context, int position)
        {
            var list     = context.list;
            var offset   = 0;
            var index    = position;
            var count    = 0;
            var isMissed = false;

            if (!ParserHelper.IsKeyword(list[index], "not"))
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            while (ParenParser.Parse(context, index))
            {
                ;
            }
            while (TableIParser.Parse(context, index))
            {
                ;
            }
            while (TableSParser.Parse(context, index))
            {
                ;
            }
            while (ListParser.Parse(context, index))
            {
                ;
            }
            while (PropertyParser.Parse(context, index))
            {
                ;
            }
            while (IndexParser.Parse(context, index))
            {
                ;
            }
            while (CallParser.Parse(context, index))
            {
                ;
            }
            if (!list[index].isRightValue)
            {
                return(false);
            }
            else
            {
                // ignored
            }
            offset += 1;
            index   = position + offset;
            context.Insert(position, ExpressionCreator.CreateNot(list, position, offset));
            context.Remove(position + 1, offset);
            return(true);
        }
예제 #13
0
        public void RegisterXML(
            EventTypeMetadata metadata,
            string representsFragmentOfProperty,
            string representsOriginalTypeName)
        {
            var existing = _xmlFragmentEventTypeFactory.GetTypeByName(metadata.Name);
            if (existing != null) {
                HandleRegister(existing);
                return;
            }

            var schemaType = _xmlFragmentEventTypeFactory.GetRootTypeByName(representsOriginalTypeName);
            if (schemaType == null) {
                throw new EPException("Failed to find XML schema type '" + representsOriginalTypeName + "'");
            }

            var prop = PropertyParser.ParseAndWalkLaxToSimple(representsFragmentOfProperty);
            var schemaModelRoot = SchemaUtil.FindRootElement(
                schemaType.SchemaModel,
                schemaType.ConfigurationEventTypeXMLDOM.RootElementNamespace,
                schemaType.RootElementName);
            var item = prop.GetPropertyTypeSchema(schemaModelRoot);
            var complex = (SchemaElementComplex) item;
            var eventType = _xmlFragmentEventTypeFactory.GetCreateXMLDOMType(
                representsOriginalTypeName,
                metadata.Name,
                metadata.ModuleName,
                complex,
                representsFragmentOfProperty);
            HandleRegister(eventType);
        }
예제 #14
0
        public List<Message> getPropertyUrlsFromPropertyListPage(WebScraperModularized.data.Message propertyPageMessage)
        {
            URL myUrl = new URL();
            myUrl.url = propertyPageMessage.url;
            myUrl.zip_code = int.Parse(propertyPageMessage.zipcode);

            var response = client.GetAsync(myUrl.url).Result; //make an HTTP call and get the html for this URL

            string content = response.Content.ReadAsStringAsync().Result; //save HTML into string
            PropertyParser parser = new PropertyParser(content, myUrl);

            //parse the html
            PropertyData propData = parser.parse();

            //insert into DB
            DBHelper.insertParsedProperties(propData);

            Console.WriteLine("Stored {0} properties",
                (propData != null && propData.urlList != null) ? propData.urlList.Count : 0);

            List<Message> listOfPropertyUrl = new List<Message>();

            foreach (var each in propData.urlList)
            {
                each.properties.ForEach(eachProperty =>
                {
                    Message message = new Message();
                    message.url = eachProperty.url.url;
                    message.id = eachProperty.id;
                    listOfPropertyUrl.Add(message);
                });
            }

            return listOfPropertyUrl;
        }
예제 #15
0
        public void GetTable1()
        {
            Assert.True(PropertyParser.GetTable(null, "Properties", null, out Dictionary<string, string> propertiesTable));

            // We should have null table.
            Assert.Null(propertiesTable);
        }
예제 #16
0
        private void ShouldParseGivenName()
        {
            const string expected = "some_name";

            var actual = PropertyParser.ParsePerson($"{nameof(Person.GivenName)}", expected, null);

            Assert.Equal(actual.GivenName, expected);
        }
예제 #17
0
        private void ShouldParseName()
        {
            const string expected = "some_name";

            var actual = PropertyParser.ParseActivityCategory($"{nameof(ActivityCategory.Name)}", expected, null);

            Assert.Equal(expected, actual.Name);
        }
예제 #18
0
        public void MultiLineLevel03()
        {
            Reader      reader = Reader.CreateStringReader(ExampleStrings.Property.MultiLine03);
            IDataParser parser = CreateDataParser(reader, PropertyParser.HierarchyParser(2));

            AssertParsedUsingXml(parser,
                                 new HierarchyModel(PropertyModel.Factory("Property", "END-DATE", "[ 11] Ending date DATE\nDB")));
        }
예제 #19
0
        protected override Type DoResolvePropertyType(String propertyExpression)
        {
            var ast = PropertyParser.Parse(propertyExpression);

            return(PropertyParser.IsPropertyDynamic(ast)
                ? typeof(XNode)
                : typeof(string));
        }
예제 #20
0
        private void ShouldParseSimilarJsonShape()
        {
            const string expected = "some_name";

            var actual = PropertyParser.ParseCountry($"{nameof(Country.Name)}", expected, null);

            Assert.Equal(actual.Name, expected);
        }
예제 #21
0
        public void GetPropertiesTable8()
        {
            Hashtable propertiesTable;

            // This is a failure case.  (Second property "x86" doesn't have a value.)
            Assert.IsTrue(!PropertyParser.GetTable(null, "Properties",
                                                   new string[] { "Configuration=Debug", "x86" }, out propertiesTable));
        }
예제 #22
0
        private void ShouldParseSimilarJsonShape()
        {
            const string expected = "some_name";

            var actual = PropertyParser.ParseDataSourceClassification($"{nameof(DataSourceClassification.Name)}", expected, null);

            Assert.Equal(actual.Name, expected);
        }
예제 #23
0
        private void ShouldParseName()
        {
            const string expected = "some_name";

            var actual = PropertyParser.ParseRegion($"{nameof(Region.Name)}", expected, null);

            Assert.Equal(expected, actual.Name);
        }
예제 #24
0
        private void ShouldParseName()
        {
            const string expected = "some_name";

            var actual = PropertyParser.ParseSectorCode($"{nameof(SectorCode.Name)}", expected, null);

            Assert.Equal(actual.Name, expected);
        }
예제 #25
0
        protected override EventPropertyGetter DoResolvePropertyGetter(String propertyExpression)
        {
            var getter = _propertyGetterCache.Get(propertyExpression);

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

            if (!ConfigurationEventTypeXMLDOM.IsXPathPropertyExpr)
            {
                var prop = PropertyParser.ParseAndWalkLaxToSimple(propertyExpression);
                getter = prop.GetGetterDOM();
                if (!prop.IsDynamic)
                {
                    getter = new DOMConvertingGetter(propertyExpression, (DOMPropertyGetter)getter, typeof(string));
                }
            }
            else
            {
                try
                {
                    var ast       = PropertyParser.Parse(propertyExpression);
                    var isDynamic = PropertyParser.IsPropertyDynamic(ast);
                    var xPathExpr = SimpleXMLPropertyParser.Walk(
                        ast,
                        propertyExpression,
                        RootElementName,
                        _defaultNamespacePrefix,
                        _isResolvePropertiesAbsolute);

                    if (Log.IsInfoEnabled)
                    {
                        Log.Info("Compiling XPath expression for property '" + propertyExpression + "' as '" + xPathExpr +
                                 "'");
                    }

                    var xPathExpression = XPathExpression.Compile(xPathExpr, NamespaceContext);
                    var xPathReturnType = isDynamic ? XPathResultType.Any : XPathResultType.String;
                    getter = new XPathPropertyGetter(
                        propertyExpression,
                        xPathExpr,
                        xPathExpression,
                        xPathReturnType,
                        null,
                        null);
                }
                catch (XPathException e)
                {
                    throw new EPException(
                              "Error constructing XPath expression from property name '" + propertyExpression + '\'', e);
                }
            }

            // no fragment factory, fragments not allowed
            _propertyGetterCache.Put(propertyExpression, getter);
            return(getter);
        }
예제 #26
0
        public override ExprNode Validate(ExprValidationContext validationContext)
        {
            // rewrite expression into a table-access expression
            if (validationContext.StreamTypeService.HasTableTypes)
            {
                ExprTableIdentNode tableIdentNode = validationContext.TableService.GetTableIdentNode(validationContext.StreamTypeService, _unresolvedPropertyName, _streamOrPropertyName);
                if (tableIdentNode != null)
                {
                    return(tableIdentNode);
                }
            }

            string unescapedPropertyName = PropertyParser.UnescapeBacktick(_unresolvedPropertyName);
            Pair <PropertyResolutionDescriptor, string> propertyInfoPair = ExprIdentNodeUtil.GetTypeFromStream(validationContext.StreamTypeService, unescapedPropertyName, _streamOrPropertyName, false);

            _resolvedStreamName = propertyInfoPair.Second;
            int  streamNum    = propertyInfoPair.First.StreamNum;
            Type propertyType = propertyInfoPair.First.PropertyType;

            _resolvedPropertyName = propertyInfoPair.First.PropertyName;
            EventPropertyGetter propertyGetter;

            try {
                propertyGetter = propertyInfoPair.First.StreamEventType.GetGetter(_resolvedPropertyName);
            }
            catch (PropertyAccessException ex) {
                throw new ExprValidationException("Property '" + _unresolvedPropertyName + "' is not valid: " + ex.Message, ex);
            }

            if (propertyGetter == null)
            {
                throw new ExprValidationException("Property getter returned was invalid for property '" + _unresolvedPropertyName + "'");
            }

            var audit = AuditEnum.PROPERTY.GetAudit(validationContext.Annotations);

            if (audit != null)
            {
                _evaluator = new ExprIdentNodeEvaluatorLogging(streamNum, propertyGetter, propertyType, this, _resolvedPropertyName, validationContext.StatementName, validationContext.StreamTypeService.EngineURIQualifier);
            }
            else
            {
                _evaluator = new ExprIdentNodeEvaluatorImpl(streamNum, propertyGetter, propertyType, this);
            }

            // if running in a context, take the property value from context
            if (validationContext.ContextDescriptor != null && !validationContext.IsFilterExpression)
            {
                EventType fromType            = validationContext.StreamTypeService.EventTypes[streamNum];
                string    contextPropertyName = validationContext.ContextDescriptor.ContextPropertyRegistry.GetPartitionContextPropertyName(fromType, _resolvedPropertyName);
                if (contextPropertyName != null)
                {
                    EventType contextType = validationContext.ContextDescriptor.ContextPropertyRegistry.ContextEventType;
                    _evaluator = new ExprIdentNodeEvaluatorContext(streamNum, contextType.GetPropertyType(contextPropertyName), contextType.GetGetter(contextPropertyName));
                }
            }
            return(null);
        }
예제 #27
0
 private void LoadSettings()
 {
     try { PropertyParser.ReadObjectFromXml(fileBrowserBox.Filename, this); }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to parse property file\n" + ex + "\nInner: \n" + ex.InnerException);
     }
     SetDebugDisplays();
 }
예제 #28
0
        public Test_PropertyParser()
        {
            ComplexProp = new ComplexClass1();
            InitializeComponent();
            List <PropertyInfo> props = PropertyParser.getParseableProperties(this.GetType());

            debugCombo.Items.AddRange(props.ToArray());
            debugCombo.SelectedIndex = 0;
        }
예제 #29
0
        private string TryKey(string key)
        {
            string propertyName = "m(\"" + key + "\")";

            log.Debug(".tryKey propertyName=" + propertyName + " key=" + key);
            Property property = PropertyParser.ParseAndWalk(propertyName, false);

            return(((MappedProperty)property).Key);
        }
예제 #30
0
        public void GetTable1()
        {
            Hashtable propertiesTable;

            Assert.IsTrue(PropertyParser.GetTable(null, "Properties", null, out propertiesTable));

            // We should have null table.
            Assert.IsNull(propertiesTable);
        }
        public void Can_parse_properties_from_arguements()
        {
            var arguements = new List<string>();
            arguements.Add("-p:test1=1");
            arguements.Add("/p:test2=2");
            arguements.Add("\\p:test3=3");
            arguements.Add("-p:test4=\"4\"");
            var result = new PropertyParser().GetProperties(arguements, ref arguements);

            Assert.IsTrue(result["test1"].Equals("1"));
            Assert.IsTrue(result["test2"].Equals("2"));
            Assert.IsTrue(result["test3"].Equals("3"));
            Assert.IsTrue(result["test4"].Equals("4"));
        }
예제 #32
0
        public void Parse_Definition_WhenMissingOrUnknown_AndDefaultIsMissing_Throws()
        {
            CodeGenConfig = CodeGeneratorConfiguration.Create();
            CodeGenConfig.TypeMappings.DefaultDefinitionId = "";
            Configuration = CodeGenConfig.MediaTypes;
            Parser = new PropertyParser(Configuration, DataTypeConfiguration);

            ParseProperty(PureProperty);
        }