public void Set <T>(string name, T value) { bool valueSet = false; T existingValue; if (_props.TryGetValue(name, out existingValue)) { if (!existingValue.Equals(value)) { _props.Set(name, value); valueSet = true; } } else { _props.Set(name, value); valueSet = true; } if (valueSet) { OnSettingChanged(new SettingChangeEventArgs(name)); } }
private static string GetNotificationDisplayName(string indicationType, PropertyBag props, PropertyBag sourceInstanceProperties) { var builder = new StringBuilder(); const string timeFormat = "HH:mm:ss.fff"; object indicationTimeObj; if (props.TryGetValue("IndicationTime", out indicationTimeObj) && indicationTimeObj is DateTime) { builder.Append(((DateTime)indicationTimeObj).ToLocalTime().ToString(timeFormat)); } else { builder.Append(DateTime.Now.ToString(timeFormat)); } object indicationSequence; if (props.TryGetValue("IndicationSequence", out indicationSequence)) { builder.Append(" #"); builder.Append(indicationSequence); } builder.Append(" - "); builder.Append(indicationType); object queryText; if (props.TryGetValue("QueryText", out queryText)) { builder.Append(" #"); var text = queryText.ToString(); builder.Append(text.Substring(0, Math.Min(text.Length, 50))); } object sourceInstanceType; if (props.TryGetValue("SourceInstanceType", out sourceInstanceType)) { builder.Append(" - "); builder.Append(sourceInstanceType); } else if (sourceInstanceProperties != null && sourceInstanceProperties.TryGetValue("InstanceType", out sourceInstanceType)) { builder.Append(" - "); builder.Append(sourceInstanceType); } object uri; if (sourceInstanceProperties != null && sourceInstanceProperties.TryGetValue("Uri", out uri)) { builder.Append(" - "); builder.Append(uri); } return(builder.ToString()); }
private string GetPropertyValue([CallerMemberName] string name = null) { string value; PropertyBag.TryGetValue(name, out value); return(value); }
// Token: 0x0600036C RID: 876 RVA: 0x00015654 File Offset: 0x00013854 public void OnIndication(string subscriptionId, string indicationType, PropertyBag indicationProperties, PropertyBag sourceInstanceProperties) { if (OrionCoreNotificationSubscriber.log.IsDebugEnabled) { OrionCoreNotificationSubscriber.log.DebugFormat("Indication of type \"{0}\" arrived.", indicationType); } try { object obj; if (indicationType == IndicationHelper.GetIndicationType(1) && sourceInstanceProperties.TryGetValue("InstanceType", out obj) && string.Equals(obj as string, "Orion.Nodes", StringComparison.OrdinalIgnoreCase)) { if (sourceInstanceProperties.ContainsKey("NodeID")) { int nodeId = Convert.ToInt32(sourceInstanceProperties["NodeID"]); this.InsertIntoDeletedTable(nodeId); } else { OrionCoreNotificationSubscriber.log.WarnFormat("Indication is type of {0} but does not contain NodeID", indicationType); } } } catch (Exception ex) { OrionCoreNotificationSubscriber.log.Error(string.Format("Exception occured when processing incomming indication of type \"{0}\"", indicationType), ex); } }
private void ComposeDetail(StringBuilder sb, string dictionaryEntryName, string displayHeading) { object item = string.Empty; var results = PropertyBag.TryGetValue(dictionaryEntryName, out item) && (item as string).Count() > 0 ? $"\r\n## **{displayHeading}**\r\n---\r\n{CreateTruncatedList(new string[] { item as string }, maxTermLength:500)}" : string.Empty; if (!string.IsNullOrWhiteSpace(results)) { sb.AppendLine(results); } }
public int ReadSolutionProps(IVsHierarchy pHierarchy, string pszProjectName, string pszProjectMk, string pszKey, int fPreLoad, IPropertyBag pPropBag) { try { using (IPropertyMap map = new PropertyBag(pPropBag)) { bool preload = (fPreLoad != 0); switch (pszKey) { case SubversionPropertyCategory: if (preload && pHierarchy == null) { string value; bool register; if (!map.TryGetValue(ManagedPropertyName, out value)) { register = false; } else if (string.IsNullOrEmpty(value) || !bool.TryParse(value, out register)) { register = false; } if (register) { Scc.RegisterAsPrimarySccProvider(); Scc.LoadingManagedSolution(true); } } break; case AnkhId.SvnOriginName: Scc.ReadProjectProperties(pHierarchy, pszProjectName, pszProjectMk, map); break; } } return(VSErr.S_OK); } catch (Exception ex) { IAnkhErrorHandler handler = GetService <IAnkhErrorHandler>(); if (handler != null) { handler.OnError(ex); } return(Marshal.GetHRForException(ex)); } }
// Token: 0x06000930 RID: 2352 RVA: 0x0004246C File Offset: 0x0004066C private static bool GetRequiredProperties(PropertyBag sourceInstanceProperties, out string agentId, out AgentStatus agentStatus) { agentId = null; agentStatus = 0; if (sourceInstanceProperties == null) { return(false); } object obj; if (!sourceInstanceProperties.TryGetValue("AgentId", out obj) || obj == null) { return(false); } object obj2; if (!sourceInstanceProperties.TryGetValue("AgentStatus", out obj2) || obj2 == null) { return(false); } agentId = obj.ToString(); agentStatus = (AgentStatus)obj2; return(true); }
private static MoveInfo ParseMove(PropertyBag property) { MoveInfo info = new MoveInfo(); // odds PropertyBag odds; if (property.TryGetValue("odds", out odds)) { // get the odds of performing the move (should be like "1 in 4") string[] oddsParts = odds.Value.Split(' '); info.Chance = Int32.Parse(oddsParts[0]); info.Range = Int32.Parse(oddsParts[2]); } info.Radius = property.GetOrDefault("radius", info.Radius); info.Noun = property.GetOrDefault("noun", value => new Noun(value), info.Noun); info.Verb = property.GetOrDefault("verb", info.Verb); info.Damage = property.GetOrDefault("damage", value => Roller.Parse(value), info.Damage); info.Element = property.GetOrDefault("element", value => (Element)Enum.Parse(typeof(Element), value, true), info.Element); info.Effect = property.GetOrDefault("effect", value => (EffectType)Enum.Parse(typeof(EffectType), value, true), info.Effect); return(info); }
private static void AddTypeToNamespaceNode(PropertyBag node, Type type) { object value; var name = type.GetRootName(); if (!node.TryGetValue(name, out value)) { node.SetPropertyNoCheck(name, HostType.Wrap(type)); return; } var hostType = value as HostType; if (hostType != null) { var types = new[] { type }.Concat(hostType.Types).ToArray(); var groups = types.GroupBy(testType => testType.GetGenericParamCount()).ToIList(); if (groups.Any(group => group.Count() > 1)) { types = groups.Select(ResolveTypeConflict).ToArray(); } node.SetPropertyNoCheck(name, HostType.Wrap(types)); return; } if (value is PropertyBag) { throw new OperationCanceledException(MiscHelpers.FormatInvariant("Type conflicts with namespace at '{0}'", type.GetLocator())); } throw new OperationCanceledException(MiscHelpers.FormatInvariant("Type conflicts with '{0}' at '{1}'", value.GetFriendlyName(), type.GetLocator())); }
/// <summary> /// Gets the property instance. /// </summary> /// <param name="propertyBag">The property bag.</param> /// <param name="complexProperty">The property instance.</param> /// <returns>True if the instance is newly created.</returns> private bool GetPropertyInstance(PropertyBag propertyBag, out object complexProperty) { complexProperty = null; if (!propertyBag.TryGetValue(this, out complexProperty) || !this.HasFlag(PropertyDefinitionFlags.ReuseInstance, propertyBag.Owner.Service.RequestedServerVersion)) { complexProperty = this.CreatePropertyInstance(propertyBag.Owner); return true; } return false; }
// Token: 0x06000601 RID: 1537 RVA: 0x00023D38 File Offset: 0x00021F38 public void OnIndication(string subscriptionId, string indicationType, PropertyBag indicationProperties, PropertyBag sourceInstanceProperties) { Stopwatch stopwatch = new Stopwatch(); try { stopwatch.Start(); if (sourceInstanceProperties == null) { throw new ArgumentNullException("sourceInstanceProperties"); } if (DowntimeMonitoringNotificationSubscriber.log.IsDebugEnabled) { DowntimeMonitoringNotificationSubscriber.log.Debug(this.DetailInfo(subscriptionId, indicationType, indicationProperties, sourceInstanceProperties)); } string text = sourceInstanceProperties.TryGet <string>("InstanceType") ?? sourceInstanceProperties.TryGet <string>("SourceInstanceType"); if (text == null) { DowntimeMonitoringNotificationSubscriber.log.Error("Wrong PropertyBag data. InstanceType or SourceInstanceType are null"); } else { string netObjectIdColumnForSwisEntity = this.GetNetObjectIdColumnForSwisEntity(text); object obj; if (netObjectIdColumnForSwisEntity == null) { DowntimeMonitoringNotificationSubscriber.log.DebugFormat("Not a supported instance type: {0}", text); } else if (!sourceInstanceProperties.TryGetValue(netObjectIdColumnForSwisEntity, out obj)) { DowntimeMonitoringNotificationSubscriber.log.DebugFormat("Unable to get Entity ID. InstanceType : {0}, ID Field: {1}", text, netObjectIdColumnForSwisEntity); } else if (indicationType == IndicationHelper.GetIndicationType(2) || indicationType == IndicationHelper.GetIndicationType(0)) { object obj2; sourceInstanceProperties.TryGetValue("Status", out obj2); if (obj2 == null) { DowntimeMonitoringNotificationSubscriber.log.DebugFormat("No Status reported for InstanceType : {0}", text); } else { if (this._nodeNetObjectIdColumn == null) { this._nodeNetObjectIdColumn = this.GetNetObjectIdColumnForSwisEntity("Orion.Nodes"); } object obj3; sourceInstanceProperties.TryGetValue(this._nodeNetObjectIdColumn, out obj3); if (obj3 == null) { DowntimeMonitoringNotificationSubscriber.log.DebugFormat("SourceBag must include NodeId. InstanceType : {0}", text); } else { this._netObjectDowntimeDal.Insert(new NetObjectDowntime { EntityID = obj.ToString(), NodeID = this.ExtractStatusID(obj3), EntityType = text, DateTimeFrom = (DateTime)indicationProperties[IndicationConstants.IndicationTime], StatusID = this.ExtractStatusID(obj2) }); } } } else if (indicationType == IndicationHelper.GetIndicationType(1)) { this._netObjectDowntimeDal.DeleteDowntimeObjects(obj.ToString(), text); } } } catch (Exception ex) { DowntimeMonitoringNotificationSubscriber.log.Error(string.Format("Exception occured when processing incoming indication of type \"{0}\"", indicationType), ex); } finally { stopwatch.Stop(); DowntimeMonitoringNotificationSubscriber.log.DebugFormat("Downtime notification has been processed in {0} miliseconds.", stopwatch.ElapsedMilliseconds); } }
public static IPropertyBag GetTypeLibEnums(this ITypeInfo typeInfo) { var typeLib = typeInfo.GetContainingTypeLib(); var typeLibName = typeLib.GetName(); var rootNode = new PropertyBag(true); var typeInfoCount = typeLib.GetTypeInfoCount(); for (var typeInfoIndex = 0; typeInfoIndex < typeInfoCount; typeInfoIndex++) { typeLib.GetTypeInfo(typeInfoIndex, out typeInfo); var typeInfoName = typeInfo.GetName(); var typeAttr = typeInfo.GetTypeAttr(); if (typeAttr.typekind == TYPEKIND.TKIND_ALIAS) { ITypeInfo refTypeInfo; typeInfo.GetRefTypeInfo(unchecked ((int)(long)typeAttr.tdescAlias.lpValue), out refTypeInfo); typeInfo = refTypeInfo; typeAttr = typeInfo.GetTypeAttr(); } if (typeAttr.typekind == TYPEKIND.TKIND_ENUM) { var varCount = typeAttr.cVars; for (var varIndex = 0; varIndex < varCount; varIndex++) { IntPtr pVarDesc; typeInfo.GetVarDesc(varIndex, out pVarDesc); try { var varDesc = (VARDESC)Marshal.PtrToStructure(pVarDesc, typeof(VARDESC)); if (varDesc.varkind == VARKIND.VAR_CONST) { var varName = typeInfo.GetMemberName(varDesc.memid); object typeLibNodeObj; if (!rootNode.TryGetValue(typeLibName, out typeLibNodeObj) || !(typeLibNodeObj is PropertyBag)) { typeLibNodeObj = new PropertyBag(true); rootNode.SetPropertyNoCheck(typeLibName, typeLibNodeObj); } object typeInfoNodeObj; var typeLibNode = (PropertyBag)typeLibNodeObj; if (!typeLibNode.TryGetValue(typeInfoName, out typeInfoNodeObj) || !(typeInfoNodeObj is PropertyBag)) { typeInfoNodeObj = new PropertyBag(true); typeLibNode.SetPropertyNoCheck(typeInfoName, typeInfoNodeObj); } var typeInfoNode = (PropertyBag)typeInfoNodeObj; typeInfoNode.SetPropertyNoCheck(varName, Marshal.GetObjectForNativeVariant(varDesc.desc.lpvarValue)); } } finally { typeInfo.ReleaseVarDesc(pVarDesc); } } } } return(rootNode); }
private static Race LoadRace(PropertyBag raceProp, DropMacroCollection <Item> dropMacros, Content content, out int depth, out int rarity) { Character character = new Character('*', TermColor.Purple); PropertyBag art; if (raceProp.TryGetValue("art", out art)) { //### bob: old style color and glyph combined character = Character.Parse(art.Value); } else { // separate glyph and color character = new Character( Character.ParseGlyph(raceProp["glyph"].Value), TermColors.FromName(raceProp["color"].Value)); } // depth depth = raceProp["depth"].ToInt32(); // speed int speed = raceProp.GetOrDefault("speed", 0) + Energy.NormalSpeed; // health Roller health = Roller.Parse(raceProp["health"].Value); // rarity rarity = raceProp.GetOrDefault("rarity", 1); // create the race Race race = new Race(content, raceProp.Name, depth, character, speed, health); // attacks PropertyBag attacks; if (raceProp.TryGetValue("attacks", out attacks)) { foreach (PropertyBag attackProp in attacks) { string[] attackParts = attackProp.Value.Split(' '); // create the attack Roller damage = Roller.Parse(attackParts[0]); FlagCollection flags = new FlagCollection(); Element element = Element.Anima; // add the flags or element for (int i = 1; i < attackParts.Length; i++) { try { // see if the part is an element element = (Element)Enum.Parse(typeof(Element), attackParts[i], true); } catch (ArgumentException) { // must be a flag flags.Add(attackParts[i]); } } //### bob: need to support different effect types Attack attack = new Attack(damage, 0, 1.0f, element, attackProp.Name, EffectType.Hit, flags); race.Attacks.Add(attack); } } // moves PropertyBag moves; if (raceProp.TryGetValue("moves", out moves)) { foreach (PropertyBag moveProp in moves) { string moveName = moveProp.Name; // if an explicit move field is provided, then the prop name is not the name of the move itself PropertyBag explicitMove; if (moveProp.TryGetValue("move", out explicitMove)) { moveName = explicitMove.Value; } // parse the specific move info MoveInfo info = ParseMove(moveProp); Move move; // construct the move switch (moveName) { case "haste self": move = new HasteSelfMove(); break; case "ball self": move = new BallSelfMove(); break; case "cone": move = new ElementConeMove(); break; case "breathe": move = new BreatheMove(); break; case "bolt": move = new BoltMove(); break; case "message": move = new MessageMove(); break; case "breed": move = new BreedMove(); break; default: throw new Exception("Unknown move \"" + moveName + "\"."); } move.BindInfo(info); race.Moves.Add(move); } } // flags foreach (PropertyBag childProp in raceProp) { if (childProp.Name.StartsWith("+ ")) { string flag = childProp.Name.Substring(2).Trim(); // handle the flags switch (flag) { case "groups": race.SetGroupSize(GroupSize.Group); break; case "packs": race.SetGroupSize(GroupSize.Pack); break; case "swarms": race.SetGroupSize(GroupSize.Swarm); break; case "hordes": race.SetGroupSize(GroupSize.Horde); break; case "very-bright": race.SetLightRadius(2); break; case "bright": race.SetLightRadius(1); break; case "glows": race.SetLightRadius(0); break; case "unmoving": race.SetPursue(Pursue.Unmoving); break; case "slightly-erratic": race.SetPursue(Pursue.SlightlyErratically); break; case "erratic": race.SetPursue(Pursue.Erratically); break; case "very-erratic": race.SetPursue(Pursue.VeryErratically); break; case "unique": race.SetFlag(RaceFlags.Unique); break; case "boss": race.SetFlag(RaceFlags.Boss); break; case "opens-doors": race.SetFlag(RaceFlags.OpensDoors); break; default: Console.WriteLine("Unknown flag \"{0}\"", flag); break; } } } // resists PropertyBag resists; if (raceProp.TryGetValue("resists", out resists)) { ParseResists(resists.Value, race); } // drops PropertyBag drops; if (raceProp.TryGetValue("drops", out drops)) { var parser = new ItemDropParser(content); IDrop <Item> drop = parser.ParseDefinition(drops, dropMacros); race.SetDrop(drop); } // description PropertyBag description; if (raceProp.TryGetValue("description", out description)) { race.SetDescription(description.Value); } // groups PropertyBag groups; if (raceProp.TryGetValue("groups", out groups)) { race.SetGroups(groups.Value.Split(' ')); } return(race); }
// Token: 0x06000027 RID: 39 RVA: 0x000027E0 File Offset: 0x000009E0 public void OnIndication(string subscriptionId, string indicationType, PropertyBag indicationProperties, PropertyBag sourceInstanceProperties) { if (AuditingNotificationSubscriber.log.IsDebugEnabled) { AuditingNotificationSubscriber.log.DebugFormat("OnIndication type: {0} SubscriptionId: {1}", indicationType, subscriptionId); } if (this.checkAuditingSetting) { try { object value; if (IndicationHelper.GetIndicationType(2) == indicationType && sourceInstanceProperties != null && sourceInstanceProperties.TryGet <string>("SettingsID") == "SWNetPerfMon-AuditingTrails" && sourceInstanceProperties.TryGet <string>("InstanceType") == "Orion.Settings" && sourceInstanceProperties.TryGetValue("CurrentValue", out value)) { this.AuditingTrailsEnabled = Convert.ToBoolean(value); } else if (!this.AuditingTrailsEnabled) { return; } } catch (Exception ex) { AuditingNotificationSubscriber.log.FatalFormat("Auditing check error - will be forciby enabled. {0}", ex); this.AuditingTrailsEnabled = true; this.checkAuditingSetting = false; } } AuditNotificationContainer auditNotificationContainer = new AuditNotificationContainer(indicationType, indicationProperties, sourceInstanceProperties); Func <AuditDataContainer, AuditDataContainer> < > 9__0; Func <string, KeyValuePair <string, object>, string> < > 9__1; Func <string, KeyValuePair <string, object>, string> < > 9__2; foreach (IAuditing2 auditing in this.subscriptionIdToAuditingInstances[subscriptionId]) { try { if (AuditingNotificationSubscriber.log.IsTraceEnabled) { AuditingNotificationSubscriber.log.TraceFormat("Trying plugin {0}", new object[] { auditing }); } IEnumerable <AuditDataContainer> enumerable = auditing.ComposeDataContainers(auditNotificationContainer); if (enumerable != null) { if (AuditingNotificationSubscriber.log.IsTraceEnabled) { AuditingNotificationSubscriber.log.Trace("Storing notification."); } CultureInfo currentUICulture = Thread.CurrentThread.CurrentUICulture; try { Thread.CurrentThread.CurrentUICulture = LocaleConfiguration.GetNonNeutralLocale(LocaleConfiguration.PrimaryLocale); } catch (Exception ex2) { AuditingNotificationSubscriber.log.Warn("Unable set CurrentUICulture to PrimaryLocale.", ex2); } IEnumerable <AuditDataContainer> source = enumerable; Func <AuditDataContainer, AuditDataContainer> selector; if ((selector = < > 9__0) == null) { selector = (< > 9__0 = ((AuditDataContainer composedDataContainer) => new AuditDataContainer(composedDataContainer, auditNotificationContainer.AccountId))); } foreach (AuditDataContainer auditDataContainer in source.Select(selector)) { AuditDatabaseDecoratedContainer auditDatabaseDecoratedContainer = new AuditDatabaseDecoratedContainer(auditDataContainer, auditNotificationContainer, auditing.GetMessage(auditDataContainer)); int insertedId = this.auditingDAL.StoreNotification(auditDatabaseDecoratedContainer); this.PublishModificationOfAuditingEvents(auditDatabaseDecoratedContainer, insertedId); } try { Thread.CurrentThread.CurrentUICulture = currentUICulture; continue; } catch (Exception ex3) { AuditingNotificationSubscriber.log.Warn("Unable set CurrentUICulture back to original locale.", ex3); continue; } } if (AuditingNotificationSubscriber.log.IsTraceEnabled) { AuditingNotificationSubscriber.log.Trace("ComposeDataContainers returned null."); } } catch (Exception ex4) { string text = string.Empty; if (indicationProperties != null) { string newLine = Environment.NewLine; Func <string, KeyValuePair <string, object>, string> func; if ((func = < > 9__1) == null) { func = (< > 9__1 = ((string current, KeyValuePair <string, object> item) => current + this.FormatPropertyData("Indication Property: ", item.Key, item.Value))); } text = indicationProperties.Aggregate(newLine, func); } if (sourceInstanceProperties != null) { string seed = text; Func <string, KeyValuePair <string, object>, string> func2; if ((func2 = < > 9__2) == null) { func2 = (< > 9__2 = ((string current, KeyValuePair <string, object> item) => current + this.FormatPropertyData("SourceInstance Property: ", item.Key, item.Value))); } text = sourceInstanceProperties.Aggregate(seed, func2); } AuditingNotificationSubscriber.log.ErrorFormat("Auditing translation failed. IndicationType: {0}, {1} PluginName: {2}, subscriptionId: {3} Exception: {4}", new object[] { indicationType, text, auditing.PluginName, subscriptionId, ex4 }); } } }