protected override void InitializeTarget() { base.InitializeTarget(); var uri = ConnectionStringName.GetConnectionString() ?? Uri; var nodes = uri.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(url => new Uri(url)); var connectionPool = new StaticConnectionPool(nodes); var config = new ConnectionConfiguration(connectionPool); if (RequireAuth) { config.BasicAuthentication(Username, Password); } if (ElasticsearchSerializer != null) { config = new ConnectionConfiguration(connectionPool, _ => ElasticsearchSerializer); } _client = new ElasticLowLevelClient(config); if (!string.IsNullOrEmpty(ExcludedProperties)) { _excludedProperties = ExcludedProperties.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties(value, attributes); List <PropertyDescriptor> result = new List <PropertyDescriptor>(props.Count); foreach (PropertyDescriptor prop in props) { PropertyDescriptor addProperty = prop; if (ExcludedProperties.Contains(prop.Name)) { continue; } if (PropertyAttributes.ContainsKey(prop.PropertyType)) { List <Attribute> attributeList = new List <Attribute>(prop.Attributes.OfType <Attribute>()); attributeList.AddRange(PropertyAttributes[prop.PropertyType]); addProperty = new PropertyGridPropertyDescriptor(prop, attributeList.ToArray()); } result.Add(addProperty); } return(new PropertyDescriptorCollection(result.ToArray())); }
// Fired when an item in the collection has changed private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (Tracking) { var entity = sender as ITrackable; if (entity == null) { return; } // Enable tracking on reference properties #if SILVERLIGHT || NET40 var prop = entity.GetType().GetProperty(e.PropertyName); if (prop != null && typeof(ITrackable).IsAssignableFrom(prop.PropertyType)) #else var prop = entity.GetType().GetTypeInfo().GetDeclaredProperty(e.PropertyName); if (prop != null && typeof(ITrackable).GetTypeInfo().IsAssignableFrom(prop.PropertyType.GetTypeInfo())) #endif { ITrackingCollection refPropChangeTracker = entity.GetRefPropertyChangeTracker(e.PropertyName); if (refPropChangeTracker != null) { refPropChangeTracker.Tracking = Tracking; } return; } if (e.PropertyName != Constants.TrackingProperties.TrackingState && e.PropertyName != Constants.TrackingProperties.ModifiedProperties && !ExcludedProperties.Contains(e.PropertyName)) { // If unchanged mark item as modified, fire EntityChanged event if (entity.TrackingState == TrackingState.Unchanged) { entity.TrackingState = TrackingState.Modified; if (EntityChanged != null) { EntityChanged(this, EventArgs.Empty); } } // Add prop to modified props, and fire EntityChanged event if (entity.TrackingState == TrackingState.Unchanged || entity.TrackingState == TrackingState.Modified) { if (entity.ModifiedProperties == null) { entity.ModifiedProperties = new List <string>(); } if (!entity.ModifiedProperties.Contains(e.PropertyName)) { entity.ModifiedProperties.Add(e.PropertyName); } } } } }
protected override void InitializeTarget() { base.InitializeTarget(); if (!string.IsNullOrEmpty(ExcludedProperties)) { _excludedProperties = ExcludedProperties.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .ToList(); } }
// Fired when an item in the collection has changed private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (Tracking) { var entity = sender as ITrackable; if (entity == null) { return; } // Enable tracking on reference properties var prop = PortableReflectionHelper.Instance.GetProperty(entity.GetType(), e.PropertyName); if (prop != null && PortableReflectionHelper.Instance.IsAssignable(typeof(ITrackable), prop.PropertyType)) { ITrackingCollection refPropChangeTracker = entity.GetRefPropertyChangeTracker(e.PropertyName); if (refPropChangeTracker != null) { refPropChangeTracker.Tracking = Tracking; } return; } if (e.PropertyName != Constants.TrackingProperties.TrackingState && e.PropertyName != Constants.TrackingProperties.ModifiedProperties && !ExcludedProperties.Contains(e.PropertyName)) { // If unchanged mark item as modified, fire EntityChanged event if (entity.TrackingState == TrackingState.Unchanged) { entity.TrackingState = TrackingState.Modified; if (EntityChanged != null) { EntityChanged(this, EventArgs.Empty); } } // Add prop to modified props, and fire EntityChanged event if (entity.TrackingState == TrackingState.Unchanged || entity.TrackingState == TrackingState.Modified) { if (entity.ModifiedProperties == null) { entity.ModifiedProperties = new HashSet <string>(); } entity.ModifiedProperties.Add(e.PropertyName); } } } }
private bool FindUnFlattenedMatchRecursive(string sourcePropertyName, Stack <PropertyInfo> path, Type targetType) { var properties = ReflectionUtils.GetProperties(targetType); var prefix = string.Join(string.Empty, path.Reverse().Select(p => p.Name)); if (targetType.IsValueType || targetType.IsPrimitive || targetType == typeof(String)) { return(false); } foreach (var property in properties) { // make sure we can write to it if (ExcludedProperties.Contains(property.Name) || !property.CanWrite || property.GetSetMethod() == null) { continue; } bool isMatch = IsCaseSensitive ? prefix + property.Name == sourcePropertyName : (prefix + property.Name).Equals(sourcePropertyName, StringComparison.InvariantCultureIgnoreCase); // found it! if (isMatch) { path.Push(property); return(true); } // if we don't have a match and it's a value type then we're done, continue searching if (property.PropertyType.IsValueType) { continue; } path.Push(property); // keep going down var result = FindUnFlattenedMatchRecursive(sourcePropertyName, path, property.PropertyType); if (result) { return(true); } path.Pop(); } return(false); }
protected override void InitializeTarget() { base.InitializeTarget(); var uri = GetConnectionString(ConnectionStringName) ?? Uri; var nodes = uri.Split(',').Select(url => new Uri(url)); var connectionPool = new StaticConnectionPool(nodes); var config = new ConnectionConfiguration(connectionPool); _client = new ElasticsearchClient(config, serializer: ElasticsearchSerializer); if (!String.IsNullOrEmpty(ExcludedProperties)) { _excludedProperties = new List <string>(ExcludedProperties.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries)); } }
protected override void InitializeTarget() { base.InitializeTarget(); var uri = Uri; var nodes = uri.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(url => new Uri(url)); var connectionPool = new StaticConnectionPool(nodes); IConnectionConfigurationValues config = new ConnectionConfiguration(connectionPool); if (ElasticsearchSerializer != null) { config = new ConnectionConfiguration(connectionPool, _ => ElasticsearchSerializer); } this.client = new ElasticLowLevelClient(config); if (!string.IsNullOrEmpty(ExcludedProperties)) { this.excludedProperties = ExcludedProperties.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } }
private void WriteInstances(TCLContainer nlc) { int instanceCount = 0; // GDN currnently only blockers re supported, overwrok twhen placing netlist!!! foreach (TCLInstance inst in nlc.Instances.Where(i => ((TCLInstance)i).BELType.Equals("GND"))) { m_sw.WriteLine("# instance " + instanceCount++); if (!string.IsNullOrEmpty(inst.BELType) && inst.OmitPlaceCommand) { // Used by blocker m_sw.WriteLine("create_cell -reference " + inst.BELType + " " + inst.Name); } else { m_sw.WriteLine("create_cell -reference " + inst.Properties.GetValue("REF_NAME") + " " + inst.Name); string belName = inst.Properties.GetValue("BEL"); belName = belName.Remove(0, belName.IndexOf('.') + 1); //this.m_sw.WriteLine("place_cell " + inst.Name + " " + inst.SliceName + "/" + belName); bool wrapCatch = inst.Properties.GetValue("REF_NAME").Equals("IBUF") || inst.Properties.GetValue("REF_NAME").Equals("OBUFT"); // we can not set "empty" values, e.g., "set_property ASYNC_REG [get_sites IOB_X0Y1]" foreach (TCLProperty prop in inst.Properties.Where(p => !string.IsNullOrEmpty(p.Value) && !p.ReadOnly && !ExcludedProperties.Contains(p.Name))) { string prefix = wrapCatch ? "catch {" : ""; string suffix = wrapCatch ? "}" : ""; string value = prop.Value.Contains(" ") ? ("\"" + prop.Value + "\"") : prop.Value; m_sw.WriteLine(prefix + "set_property " + prop.Name + " " + value + " [get_cells " + inst.Name + "]" + suffix); } } m_sw.WriteLine(""); } }
private O365MessageCard BuildBody(Event <LogEventData> evt) { // Build action var url = BaseUrl; if (string.IsNullOrWhiteSpace(url)) { url = Host.BaseUri; } var(openTitle, openUrl) = SeqEvents.GetOpenLink(url, evt); var action = new O365ConnectorCardOpenUri { Name = openTitle, Type = "OpenUri", //Failure to provide this will cause a 400 badrequest Targets = new[] { new O365ConnectorCardOpenUriTarget { Uri = openUrl, Os = "default" //Failure to provide this will cause a 400 badrequest } } }; // Build message var msg = evt.Data.RenderedMessage; if (msg.Length > 1000) { msg = msg.EscapeMarkdown().Substring(0, 1000); } var color = Color; if (string.IsNullOrWhiteSpace(color)) { color = LevelColorMap[evt.Data.Level]; } var body = new O365MessageCard { Title = evt.Data.Level.ToString().EscapeMarkdown(), ThemeColor = color, Text = msg, PotentialAction = new O365ConnectorCardActionBase[] { action } }; // Build sections var sections = new List <O365ConnectorCardSection>(); var config = new PropertyConfig { ExcludedProperties = ExcludedProperties?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List <string>(), JsonSerializedProperties = JsonSerializedProperties?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List <string>(), JsonSerializedPropertiesAsIndented = JsonSerializedPropertiesAsIndented }; if (!config.ExcludedProperties.Contains(ExcludeAllPropertyName)) { var properties = SeqEvents.GetProperties(evt, config); var facts = properties.Where(x => !string.IsNullOrEmpty(x.Value)).Select(x => new O365ConnectorCardFact { Name = x.Key, Value = x.Value }).ToArray(); if (facts.Any()) { sections.Add(new O365ConnectorCardSection { Facts = facts }); } } if (!string.IsNullOrWhiteSpace(evt.Data.Exception)) { sections.Add(new O365ConnectorCardSection { Title = "Exception", Text = evt.Data.Exception.EscapeMarkdown() }); } body.Sections = sections.ToArray(); return(body); }