/// <summary> /// Adds an attribute with a value. /// </summary> /// <param name="attributeName">The attribute name</param> /// <param name="value">The value of the attribute, this can be any premitive value</param> /// <returns></returns> public Entity AddAttribute(string attributeName, object value) { CustomAttributes.TryAdd(attributeName, value.ValidateTypeForPremitiveValue()); return(this); }
private void HandleItem(FieldDefinition fdef) { _fdef = fdef; Attributes.Bind(fdef); CustomAttributes.Bind(fdef); }
void IHandler.OnConfigurationChanged(object sender, EventArgs e) { CustomAttributes.Rehash(); }
public string GetParameterString(Scope usingScope, bool emitPointer = false, bool compileAttributes = false) => IsRetval? null : $"{CustomAttributes.ToString(usingScope, inline: true, emitPointer: emitPointer, mustCompile: compileAttributes).Replace("[ParamArray]", "params")}" + (Position == 0 && DeclaringMethod.GetCustomAttributes("System.Runtime.CompilerServices.ExtensionAttribute").Any()? "this ":"") + $"{getCSharpSignatureString(usingScope)} {CSharpSafeName}" + (IsOptional? " = " + DefaultValue.ToCSharpValue(ParameterType, usingScope)
private void HandleItem(PropertyDefinition pdef) { _pdef = pdef; Attributes.Bind(pdef); CustomAttributes.Bind(pdef); }
public Property(PropertyInfo propertyInfo, CustomAttributes customAttributes) { PropertyInfo = propertyInfo; CustomAttributes = customAttributes; }
private void BuildEvent(ILConversion conversion, ConvertedTypeDefinitionWithEvents_I converted, EventDefinition eventDefinition) { var eventAttributes = GetEventAttributes(eventDefinition); var eventType = Execution.Types.Ensuring.EnsureToType(conversion, eventDefinition.EventType); var builder = converted.TypeBuilder.DefineEvent(eventDefinition.Name, eventAttributes, eventType); var entry = new ConvertedEvent() { Name = eventDefinition.Name, Builder = builder, EventDefinition = eventDefinition }; if (!converted.Events.ByName.TryGetValue(entry.Name, out List <SemanticEventMask_I> propertyList)) { propertyList = new List <SemanticEventMask_I>(); converted.Events.ByName.Add(entry.Name, propertyList); } propertyList.Add(entry); if (eventDefinition.InvokeMethod != null) { var invokeMethod = Methods.Getting.GetMethod(converted, eventDefinition.InvokeMethod); if (invokeMethod?.UnderlyingMethod == null) { throw new System.Exception("Expected an invoke method"); } builder.SetRaiseMethod((MethodBuilder)invokeMethod?.UnderlyingMethod); } if (eventDefinition.AddMethod != null) { var addMethod = Methods.Getting.GetMethod(converted, eventDefinition.AddMethod); if (addMethod?.UnderlyingMethod == null) { throw new System.Exception("Expected an add method"); } builder.SetAddOnMethod((MethodBuilder)addMethod?.UnderlyingMethod); } if (eventDefinition.RemoveMethod != null) { var removeMethod = Methods.Getting.GetMethod(converted, eventDefinition.RemoveMethod); if (removeMethod?.UnderlyingMethod == null) { throw new System.Exception("Expected a remove method"); } builder.SetRemoveOnMethod((MethodBuilder)removeMethod?.UnderlyingMethod); } CustomAttributes.BuildCustomAttributes(conversion, converted, entry); }
public bool AddCustomAttribute(CustomAttributes customAttribute) { return(API.addCustomAttributeToDatabase(customAttribute)); }
void HandleItem(FieldDefinition fdef) { this.fdef = fdef; Attributes.Bind(fdef); CustomAttributes.Bind(fdef); }
/// <summary>Initializes a new instance of the <see cref="PropertyOrField"/> class.</summary> /// <param name="memberInfo">The member information.</param> /// <param name="customAttributes">The custom attributes.</param> public PropertyOrField(MemberInfo memberInfo, CustomAttributes customAttributes) { MemberInfo = memberInfo; CustomAttributes = customAttributes; }
/// <summary> /// Does this object have any dependent objects? (If it does have dependent objects, these would need to be deleted before this object could be deleted.) /// </summary> /// <returns></returns> public bool HasDependentObjects() { return(CustomAttributes.Any() || MaintenanceRecordObservations.Any() || TreatmentBMPTypeCustomAttributeTypes.Any()); }
public virtual bool IsDefined(Type attributeType, bool inherit) => CustomAttributes.Any(x => x.GetType() == attributeType);
public bool IsDefined(Type attributeType) => CustomAttributes.Any(attr => attr.AttributeType == attributeType) || CustomAttributes.Any(attr => attr.AttributeType.IsSubclassOf(attributeType));
/// <summary> /// 是否定义了指定类型属性标记。 /// </summary> /// <param name="attributeType">属性类型。</param> /// <returns></returns> #if NET40 public bool IsDefined(Type attributeType) => CustomAttributes.Any(attr => attr.Constructor.DeclaringType == attributeType) || CustomAttributes.Any(attr => attr.Constructor.DeclaringType.IsSubclassOf(attributeType));
protected override string ResolveCore(Enum source) { return(CustomAttributes.GetDescription(source)); }
public TAttribute CustomAttribute <TAttribute>() where TAttribute : Attribute { return(CustomAttributes.OfType <TAttribute>().FirstOrDefault()); }
public EffectData(String name, CustomAttributes attributes) { Name = name; Attributes = attributes; }
public override MobileBlockResponse HandleRequest(string request, Dictionary <string, string> Body) { body = Body; RockContext rockContext = new RockContext(); PrayerRequestService prayerRequestService = new PrayerRequestService(rockContext); PrayerRequest prayerRequest = new PrayerRequest(); prayerRequest.EnteredDateTime = RockDateTime.Now; prayerRequest.FirstName = GetItem("firstName"); prayerRequest.LastName = GetItem("lastName"); prayerRequest.Text = GetItem("request"); prayerRequest.RequestedByPersonAliasId = CurrentPersonAliasId; if (!string.IsNullOrWhiteSpace(GetItem("campus"))) { prayerRequest.CampusId = GetItem("campus").AsInteger(); } bool isAutoApproved = GetAttributeValue("EnableAutoApprove").AsBoolean(); if (isAutoApproved) { prayerRequest.ApprovedByPersonAliasId = CurrentPersonAliasId; prayerRequest.ApprovedOnDateTime = RockDateTime.Now; var expireDays = GetAttributeValue("ExpireDays").AsDouble(); prayerRequest.ExpirationDate = RockDateTime.Now.AddDays(expireDays); } //Category if (GetItem("category").AsInteger() != 0) { prayerRequest.CategoryId = GetItem("category").AsInteger(); } else { Guid defaultCategoryGuid = GetAttributeValue("DefaultCategory").AsGuid(); var defaultCategory = CategoryCache.Read(defaultCategoryGuid); if (defaultCategory != null) { prayerRequest.CategoryId = defaultCategory.Id; } } if (GetItem("urgent").AsBoolean()) { prayerRequest.IsUrgent = true; } else { prayerRequest.IsUrgent = false; } if (GetItem("allowComments").AsBoolean()) { prayerRequest.AllowComments = true; } else { prayerRequest.AllowComments = false; } if (GetItem("allowPublication").AsBoolean()) { prayerRequest.IsPublic = true; } else { prayerRequest.IsPublic = false; } prayerRequestService.Add(prayerRequest); rockContext.SaveChanges(); Guid?workflowTypeGuid = GetAttributeValue("Workflow").AsGuidOrNull(); if (workflowTypeGuid.HasValue) { prayerRequest.LaunchWorkflow(workflowTypeGuid, prayerRequest.Name); } AvalancheUtilities.SetActionItems(GetAttributeValue("ActionItem"), CustomAttributes, CurrentPerson, AvalancheUtilities.GetMergeFields(CurrentPerson)); var response = new FormResponse { Success = true, Message = GetAttributeValue("SaveSuccessText") }; if (CustomAttributes.ContainsKey("ActionType") && CustomAttributes["ActionType"] != "0") { response.ActionType = CustomAttributes["ActionType"]; } if (CustomAttributes.ContainsKey("Resource")) { response.Resource = CustomAttributes["Resource"]; } if (CustomAttributes.ContainsKey("Parameter")) { response.Parameter = CustomAttributes["Parameter"]; } return(new MobileBlockResponse() { Request = request, Response = JsonConvert.SerializeObject(response), TTL = 0 }); }
public void OnConfigurationChanged(object sender, EventArgs e) { CustomAttributes.Rehash(); }
public override MobileBlock GetMobile(string parameter) { var form = new List <FormElementItem>(); var firstName = new FormElementItem { Type = FormElementType.Entry, Key = "firstName", Label = "First Name", Required = true }; if (CurrentPerson != null) { firstName.Value = CurrentPerson.NickName; } form.Add(firstName); var lastName = new FormElementItem { Type = FormElementType.Entry, Key = "lastName", Label = "Last Name", Required = GetAttributeValue("RequireLastName").AsBoolean() }; if (CurrentPerson != null) { lastName.Value = CurrentPerson.LastName; } form.Add(lastName); var email = new FormElementItem { Type = FormElementType.Entry, Key = "email", Label = "Email", Required = false, Keyboard = Keyboard.Email }; if (CurrentPerson != null) { email.Value = CurrentPerson.Email; } form.Add(email); if (GetAttributeValue("ShowCampus").AsBoolean()) { var campus = new FormElementItem { Type = FormElementType.Picker, Key = "campus", Label = "Campus", Options = CampusCache.All().ToDictionary(c => c.Id.ToString(), c => c.Name), Required = GetAttributeValue("RequireCampus").AsBoolean() }; if (CurrentPerson != null) { campus.Value = CurrentPerson.GetCampus().Id.ToString(); } form.Add(campus); } if (!string.IsNullOrWhiteSpace(GetAttributeValue("CategorySelection"))) { var categoryGuid = GetAttributeValue("CategorySelection").AsGuid(); var categoryList = CategoryCache.Read(categoryGuid).Categories.ToDictionary(c => c.Id.ToString(), c => c.Name); var category = new FormElementItem { Type = FormElementType.Picker, Key = "category", Label = "Category", Options = categoryList, Required = true }; form.Add(category); } var request = new FormElementItem { Type = FormElementType.Editor, Label = "Request", Key = "request", HeightRequest = 100, Required = true }; form.Add(request); if (GetAttributeValue("EnableUrgentFlag").AsBoolean()) { var urgent = new FormElementItem { Type = FormElementType.Switch, Key = "urgent", Label = "Urgent?" }; form.Add(urgent); } if (GetAttributeValue("DefaultAllowCommentsSetting").AsBoolean()) { var allowComments = new FormElementItem { Type = FormElementType.Switch, Key = "allowComments", Label = "Allow Encouraging Comments?" }; form.Add(allowComments); } if (GetAttributeValue("EnablePublicDisplayFlag").AsBoolean()) { var allowPublication = new FormElementItem { Type = FormElementType.Switch, Key = "allowPublication", Label = "Allow Publication?" }; form.Add(allowPublication); } var button = new FormElementItem { Type = FormElementType.Button, Label = "Save Request", Key = "save" }; form.Add(button); CustomAttributes.Add("FormElementItems", JsonConvert.SerializeObject(form)); return(new MobileBlock() { BlockType = "Avalanche.Blocks.FormBlock", Attributes = CustomAttributes }); }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(Label)) { labelTD.Visible = false; } if (string.IsNullOrWhiteSpace(ItemLabelColumnName) || string.IsNullOrWhiteSpace(ItemValueColumnName) || Items == null) { return; } int idx = 0; if (string.IsNullOrWhiteSpace(SelectAll)) { SelectAll = "false"; } if (string.IsNullOrWhiteSpace(IgnoreDefaultItems)) { IgnoreDefaultItems = "false"; } Dictionary <string, int> counts = new Dictionary <string, int>(); if (ShowChildCount && OptionGroupValueColumnName != null) { foreach (DataRow row in Items.Rows) { string groupValue = row[OptionGroupValueColumnName].ToString(); if (!counts.ContainsKey(groupValue)) { counts[groupValue] = 0; } string itemValue = row[ItemValueColumnName].ToString(); if (!string.IsNullOrWhiteSpace(itemValue)) { if (IgnoreDefaultItems.ToUpper() == "TRUE" && (itemValue == "0" || itemValue == "-1")) { continue; } counts[groupValue]++; } } } string[] customAttributes = !string.IsNullOrWhiteSpace(CustomAttributes) ? CustomAttributes.Split(',') : null; List <string> selList = new List <string>("t,true,y,yes,1".Split(',')); ddlItems.Items.Clear(); foreach (DataRow row in Items.Rows) { string itemLabel = row[ItemLabelColumnName] != DBNull.Value ? row[ItemLabelColumnName].ToString() : ""; string itemValue = row[ItemValueColumnName] != DBNull.Value ? row[ItemValueColumnName].ToString() : ""; string itemSelected = !string.IsNullOrWhiteSpace(ItemSelectedColumnName) ? (row[ItemSelectedColumnName] != DBNull.Value ? row[ItemSelectedColumnName].ToString() : null) : null; if (itemValue == "") { itemValue = "MISSING"; } if (IgnoreDefaultItems.ToUpper() == "TRUE") { if (string.IsNullOrWhiteSpace(itemValue) || itemValue == "0" || itemValue == "-1") { continue; } } itemValue = (!string.IsNullOrWhiteSpace(OptionGroupValueColumnName) ? row[OptionGroupValueColumnName].ToString() + "___" : "") + itemValue; if (itemSelected == null) { itemSelected = ""; } bool selected = false; if (SelectAll.ToString().ToUpper() == "TRUE") { selected = true; } else if (!string.IsNullOrWhiteSpace(SelectedItems)) { selected = ("," + SelectedItems.ToLower() + ",").IndexOf("," + itemValue.ToLower() + ",") != -1; } else { selected = selList.Contains(itemSelected.ToLower()); } ListItem li = new ListItem(itemLabel, itemValue); li.Selected = selected; li.Attributes.Add("RowIdx", idx.ToString()); if (customAttributes != null && customAttributes.Length > 0) { for (int x = 0; x < customAttributes.Length; x++) { li.Attributes.Add(customAttributes[x].Trim(), row[customAttributes[x].Trim()].ToString()); } } if (OptionGroupLabelColumnName != null && OptionGroupValueColumnName != null) { string groupValue = row[OptionGroupValueColumnName].ToString(); string groupLabel = row[OptionGroupLabelColumnName].ToString() + (ShowChildCount ? " (" + counts[groupValue] + ")" : ""); if (!Groups.Contains(groupLabel)) { Groups.Add(groupLabel.Replace(";", "<semicolon>").Replace("'", "")); } li.Attributes.Add("OptionGroup", groupLabel); li.Attributes.Add("OptionGroupValue", groupValue); } ddlItems.Items.Add(li); idx++; } base.Visible = IsVisible; }
public CategoryViewModel() { Items = new List <CategoryViewModel>(); Attributes = new CustomAttributes(); }
protected override string ResolveCore(int source) { return(CustomAttributes.GetDescription((PaymentMethod)source)); }
void HandleItem(EventDefinition edef) { this.edef = edef; Attributes.Bind(edef); CustomAttributes.Bind(edef); }
private void HandleItem(EventDefinition edef) { _edef = edef; Attributes.Bind(edef); CustomAttributes.Bind(edef); }
public IWorkflowBuilder WithCustomAttribute(string name, object value) { CustomAttributes.Set(name, value); return(this); }
private void CustomAttributes_GridUpdated(object sender, EventArgs e) { CustomAttributes.Rehash(); }
public AddUpdatedNodesHelper(Lazy <IMethodAnnotations> methodAnnotations, Lazy <IResourceNodeFactory> resourceNodeFactory, IDocumentTreeView documentTreeView, ModuleDocumentNode modNode, ModuleImporter importer) { asmNode = modNode.TreeNode.Parent?.Data as AssemblyDocumentNode; this.modNode = modNode; var dict = new Dictionary <string, List <TypeDef> >(StringComparer.Ordinal); foreach (var t in importer.NewNonNestedTypes) { var ns = (t.TargetType !.Namespace ?? UTF8String.Empty).String; if (!dict.TryGetValue(ns, out var list)) { dict[ns] = list = new List <TypeDef>(); } list.Add(t.TargetType); } newTypeNodeCreators = dict.Values.Select(a => new TypeNodeCreator(modNode, a)).ToArray(); existingTypeNodeUpdaters = importer.MergedNonNestedTypes.Select(a => new ExistingTypeNodeUpdater(methodAnnotations, modNode, a)).ToArray(); if (!importer.MergedNonNestedTypes.All(a => a.TargetType !.Module == modNode.Document.ModuleDef)) { throw new InvalidOperationException(); } newAssemblyDeclSecurities = importer.NewAssemblyDeclSecurities; newAssemblyCustomAttributes = importer.NewAssemblyCustomAttributes; newModuleCustomAttributes = importer.NewModuleCustomAttributes; newExportedTypes = importer.NewExportedTypes; newAssemblyVersion = importer.NewAssemblyVersion; if (!(newAssemblyDeclSecurities is null)) { origAssemblyDeclSecurities = modNode.Document.AssemblyDef?.DeclSecurities.ToArray(); } if (!(newAssemblyCustomAttributes is null)) { origAssemblyCustomAttributes = modNode.Document.AssemblyDef?.CustomAttributes.ToArray(); } if (!(newModuleCustomAttributes is null)) { origModuleCustomAttributes = modNode.Document.ModuleDef !.CustomAttributes.ToArray(); } if (!(newExportedTypes is null)) { origExportedTypes = modNode.Document.ModuleDef !.ExportedTypes.ToArray(); } if (!(newAssemblyVersion is null)) { origAssemblyVersion = modNode.Document.AssemblyDef?.Version; } if (importer.NewResources !.Length != 0) { var module = modNode.Document.ModuleDef !; var rsrcListNode = GetResourceListTreeNode(modNode); Debug2.Assert(!(rsrcListNode is null)); if (!(rsrcListNode is null)) { var newNodes = new NodeAndResource[importer.NewResources.Length]; var treeNodeGroup = documentTreeView.DocumentTreeNodeGroups.GetGroup(DocumentTreeNodeGroupType.ResourceTreeNodeGroup); for (int i = 0; i < newNodes.Length; i++) { var resource = importer.NewResources[i]; var node = (DocumentTreeNodeData)documentTreeView.TreeView.Create(resourceNodeFactory.Value.Create(module, resource, treeNodeGroup)).Data; newNodes[i] = new NodeAndResource(node); } resourceNodeCreator = new ResourceNodeCreator(rsrcListNode, newNodes); } } }
public sealed override IList <CustomAttributeData> GetCustomAttributesData() => CustomAttributes.ToReadOnlyCollection();