public ActionResult Create(AdProductViewModel Adproduct) { if (ModelState.IsValid) { if (Adproduct != null) { //Add new ReadOnlyAttribute var newReadOnlyAttribute = new ReadOnlyAttribute(); { var user = User.Identity.GetUserName(); newReadOnlyAttribute.LastModified = DateTime.Now; newReadOnlyAttribute.Created = DateTime.Now; newReadOnlyAttribute.Version = 0; } db.ReadOnlyAttribute.Add(newReadOnlyAttribute); db.SaveChanges(); //Add new Product Adproduct.Product.ReadOnlyAttributeId = newReadOnlyAttribute.ReadOnlyAttributeId; Adproduct.Product.Created = DateTime.Now; Adproduct.Product.SubcategoryId = Adproduct.SubcategoryId; db.Products.Add(Adproduct.Product); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View()); }
public static MetaSaha GetMetaField <TSource, TProperty>(this TSource source, Expression <Func <TSource, TProperty> > propertyLambda) { PropertyInfo propInfo = (propertyLambda.Body as MemberExpression).Member as PropertyInfo; MetaSaha saha = new MetaSaha(); try { StringLengthAttribute StringLength = propInfo.GetCustomAttributes(typeof(StringLengthAttribute), true)[0] as StringLengthAttribute; saha.Uzunluk = StringLength.MaximumLength; } catch { } try { DisplayNameAttribute displayName = propInfo.GetCustomAttributes(typeof(DisplayNameAttribute), true)[0] as DisplayNameAttribute; saha.Etiket = displayName.DisplayName; } catch { } try { ReadOnlyAttribute readOnly = propInfo.GetCustomAttributes(typeof(ReadOnlyAttribute), true)[0] as ReadOnlyAttribute; saha.IsReadOnly = readOnly.IsReadOnly; } catch { } return(saha); }
public AssociationMetadata(PropertyDescriptor pd) { this.PropertyDescriptor = pd; AttributeCollection propertyAttributes = pd.ExplicitAttributes(); this.AssociationAttribute = (AssociationAttribute)propertyAttributes[typeof(AssociationAttribute)]; this.IsExternal = propertyAttributes[typeof(ExternalReferenceAttribute)] != null; this.IsCollection = EntityGenerator.IsCollectionType(pd.PropertyType); if (!this.IsCollection) { this.PropTypeName = CodeGenUtilities.GetTypeName(pd.PropertyType); this.AssociationTypeName = @"OpenRiaServices.DomainServices.Client.EntityRef<" + this.PropTypeName + ">"; this.Attributes = propertyAttributes.Cast <Attribute>().Where(a => a.GetType() != typeof(DataMemberAttribute)); } else { this.PropTypeName = CodeGenUtilities.GetTypeName(TypeUtility.GetElementType(pd.PropertyType)); this.AssociationTypeName = "OpenRiaServices.DomainServices.Client.EntityCollection<" + this.PropTypeName + ">"; List <Attribute> attributeList = propertyAttributes.Cast <Attribute>().ToList(); ReadOnlyAttribute readOnlyAttr = propertyAttributes.OfType <ReadOnlyAttribute>().SingleOrDefault(); if (readOnlyAttr != null && !propertyAttributes.OfType <EditableAttribute>().Any()) { attributeList.Add(new EditableAttribute(!readOnlyAttr.IsReadOnly)); } this.Attributes = attributeList.Where(a => a.GetType() != typeof(DataMemberAttribute)); } this.PropertyName = CodeGenUtilities.GetSafeName(pd.Name); this.FieldName = CodeGenUtilities.MakeCompliantFieldName(this.PropertyName); }
private static void SelectedObjectPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { PropertyGrid grid = (PropertyGrid)source; INotifyPropertyChanged pc = e.OldValue as INotifyPropertyChanged; if (pc != null) { pc.PropertyChanged -= grid.OnDispatcherSourcePropertyChanged; } if (e.NewValue == null) { grid.PropertiesSource.Source = null; return; } ReadOnlyAttribute roa = e.NewValue.GetType().GetAttribute <ReadOnlyAttribute>(); if (roa != null && roa.IsReadOnly) { grid.IsReadOnly = true; } else { grid.IsReadOnly = false; } pc = e.NewValue as INotifyPropertyChanged; if (pc != null) { pc.PropertyChanged += grid.OnDispatcherSourcePropertyChanged; } grid.PropertiesSource.Source = grid.CreateDataProvider(e.NewValue); }
private void trvOutpuColumns_AfterSelect(object sender, TreeViewEventArgs e) { //e.Node.Tag if (e.Node != null) { if (e.Node.Tag is RowNumberColumn) { //Update the RedOnly for Prescision and Scale based ont he DataType var val = ((RowNumberColumn)e.Node.Tag).DataType; PropertyDescriptor descriptor = TypeDescriptor.GetProperties(e.Node.Tag.GetType())["Precision"]; ReadOnlyAttribute attrib = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo isReadOnly = attrib.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); isReadOnly.SetValue(attrib, val == RowNumberColumn.RowNumberDataTypeType.DT_NUMERIC ? false : true); descriptor = TypeDescriptor.GetProperties(e.Node.Tag.GetType())["Scale"]; attrib = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)]; isReadOnly = attrib.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); isReadOnly.SetValue(attrib, val == RowNumberColumn.RowNumberDataTypeType.DT_NUMERIC ? false : true); } propOutputColumn.SelectedObject = e.Node.Tag; } else { propOutputColumn.SelectedObject = null; } btnRemoveColumn.Enabled = e.Node.Tag is RowNumberColumn; btnAddColumn.Enabled = !(e.Node.Tag is FormOutput && ((FormOutput)e.Node.Tag).Index != 0); }
/// <summary> /// Changes the state of the ReadOnly attribute regarding the isReadOnly flag value. /// </summary> /// <param name="selectedObject">The current object exposed by the PropertyGrid.</param> /// <param name="isReadOnly">The current read-only state of the PropertyGrid.</param> private void SetBrowsablePropertiesAsReadOnly(object selectedObject, bool isReadOnly) { if (selectedObject != null) { // Get all the properties of the selected object... PropertyDescriptorCollection props = TypeDescriptor.GetProperties(selectedObject.GetType()); foreach (PropertyDescriptor propDescript in props) { // Consider only the properties which are browsable and are not collections... if (propDescript.IsBrowsable && propDescript.PropertyType.GetInterface("ICollection", true) == null) { ReadOnlyAttribute attr = propDescript.Attributes[typeof(ReadOnlyAttribute)] as ReadOnlyAttribute; // If the current property has a ReadOnly attribute, // update its state regarding the current ReadOnly state of the PropertyGrid. if (attr != null) { FieldInfo field = attr.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); field.SetValue(attr, isReadOnly, BindingFlags.NonPublic | BindingFlags.Instance, null, null); } } } } }
private void CacheAttributes(IEnumerable <Attribute> attributes) { Display = attributes.OfType <DisplayAttribute>().FirstOrDefault(); DisplayFormat = attributes.OfType <DisplayFormatAttribute>().FirstOrDefault(); Editable = attributes.OfType <EditableAttribute>().FirstOrDefault(); ReadOnly = attributes.OfType <ReadOnlyAttribute>().FirstOrDefault(); }
public override bool IsReadOnly(PropertyEnumerator selfEnum) { if (!Grid.Grid.Enabled && (Grid.DisableMode == PropertyGrid.DisableModes.Simple)) { return(true); } if ((selfEnum.Parent.Property != null) && (selfEnum.Parent.Property.Value != null)) { if (!selfEnum.Parent.Property.Value.NoLinkWithChildren && (selfEnum.Parent.Property.Value.IsReadOnly(selfEnum.Parent))) { return(true); } } // Check if a UITypeEditor has been found. Even if the property is marked Readonly (has only a get // accessor for example), the presence of an editor makes it editable (this is the case for collections // for example in the .net framework) ReadOnlyAttribute manualReadOnlyAttr = (ReadOnlyAttribute)base.GetAttribute(typeof(ReadOnlyAttribute)); if ((mFeel is PropertyUITypeEditorFeel) && ((manualReadOnlyAttr == null) || !manualReadOnlyAttr.IsReadOnly)) { return(false); } ReadOnlyAttribute attr = (ReadOnlyAttribute)GetAttribute(typeof(ReadOnlyAttribute)); return((attr != null) && attr.IsReadOnly); }
/// <summary> /// Procerss the associated IDTSOutputColumn and retrieves the MetadataColumn specific Custom Properties /// </summary> protected override void DTSOutputColumnSetProcessing() { base.DTSOutputColumnSetProcessing(); if (DTSOutputColumn != null) { initialValueProperty = DTSOutputColumn.CustomPropertyCollection[Resources.RowNumberInitialValuePropertyName]; incrementByProperty = DTSOutputColumn.CustomPropertyCollection[Resources.RowNumberIncrementByPropertyName]; //Dynamically update the ReadOnly attribute of the RowNumberColumn depending on the DataType property var value = this.DataType; PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())["Precision"]; ReadOnlyAttribute attrib = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo isReadOnly = attrib.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); isReadOnly.SetValue(attrib, value == RowNumberDataTypeType.DT_NUMERIC ? false : true); descriptor = TypeDescriptor.GetProperties(this.GetType())["Scale"]; attrib = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)]; isReadOnly = attrib.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); isReadOnly.SetValue(attrib, value == RowNumberDataTypeType.DT_NUMERIC ? false : true); } else { initialValueProperty = null; incrementByProperty = null; } }
public void IEnumerableGetEnumerator_Invoke_Success() { var attribute1 = new BrowsableAttribute(true); var attribute2 = new ReadOnlyAttribute(true); var collection = new AttributeCollection(attribute1, attribute2); IEnumerable iEnumerable = collection; IEnumerator enumerator = iEnumerable.GetEnumerator(); for (int i = 0; i < 2; i++) { Assert.Throws <InvalidOperationException>(() => enumerator.Current); Assert.True(enumerator.MoveNext()); Assert.Equal(attribute1, enumerator.Current); Assert.True(enumerator.MoveNext()); Assert.Equal(attribute2, enumerator.Current); Assert.False(enumerator.MoveNext()); Assert.Throws <InvalidOperationException>(() => enumerator.Current); enumerator.Reset(); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { ReadOnlyAttribute att = (ReadOnlyAttribute)attribute; string val; switch (property.propertyType) { case SerializedPropertyType.Integer: val = property.intValue.ToString(); break; case SerializedPropertyType.Float: val = property.floatValue.ToString(); break; case SerializedPropertyType.String: val = property.stringValue.ToString(); break; default: val = "Unsupported type"; break; } EditorGUI.LabelField(position, string.Format("{0}: {1}", label.text, val)); }
/// <summary> /// 这里如果使用完全限定类型名的编辑器,则编辑器类不能跨越UnvaryingSagacity.Core.Dll /// 一定要使用时,需要在自身的程序集中继承类:CustomAttribute,UniqueChecker,ItemStylePropertyDescription /// 请参考UnvaryingSagacity.SuitSchemePrinter.DynamicPropertyDescriptor.cs /// </summary> /// <param name="item"></param> /// <param name="attributes"></param> public ItemStylePropertyDescription(CustomAttribute item, Attribute[] attributes) : base(item.Name, attributes) { _itemStyle = item; int i = base.AttributeArray.Length; _attribute = new Attribute[base.AttributeArray.Length + 6]; base.AttributeArray.CopyTo(_attribute, 0); //Array.Resize<Attribute>(ref _attribute, i + 1); _attribute[i] = new PropertyOrderAttribute(_itemStyle.Order); i++; //Array.Resize<Attribute>(ref _attribute, i + 1); _attribute[i] = new PropertyUniqueAttribute(_itemStyle.Checker != null ? true : false, _itemStyle.Checker != null ? _itemStyle.Checker.MethodName : ""); i++; _attribute[i] = new PropertyValidAttribute(_itemStyle.ValidChecker != null ? true : false, _itemStyle.ValidChecker != null ? _itemStyle.ValidChecker.MethodName : ""); i++; _attribute[i] = new PropertyValueCheckerAttribute(_itemStyle.ValueChecker != null ? true : false, _itemStyle.ValueChecker != null ? _itemStyle.ValueChecker.MethodName : ""); i++; //Array.Resize<Attribute>(ref _attribute, i + 1); _attribute[i] = new EditorAttribute(_itemStyle.EditorTypeName, typeof(System.Drawing.Design.UITypeEditor)); i++; //Array.Resize<Attribute>(ref _attribute, i + 1); _attribute[i] = new ReadOnlyAttribute(_itemStyle.ReadOnly); _attributeCollection = new AttributeCollection(_attribute); }
/// <summary> /// Returns whether the <paramref name="member"/> can be updated. /// </summary> /// <param name="member"></param> /// <returns></returns> private static bool CanWrite(MemberInfo member) { ReadOnlyAttribute readOnly = member.GetCustomAttribute <ReadOnlyAttribute>(); // if there is an attribute respect the value if (readOnly?.IsReadOnly == true) { return(false); } // otherwise, check the member type - if field or property, check readonly/private setter. switch (member.MemberType) { case MemberTypes.Field: { return(!((FieldInfo)member).IsInitOnly); } case MemberTypes.Property: { PropertyInfo property = (PropertyInfo)member; if (!property.CanWrite) { return(false); } return(property.SetMethod.IsPublic); } } // default return(true); }
public static bool IsEnabled(SerializedProperty property) { ReadOnlyAttribute readOnlyAttribute = GetAttribute <ReadOnlyAttribute>(property); EnableIfAttributeBase enableIfAttribute = GetAttribute <EnableIfAttributeBase>(property); return(IsEnabled(readOnlyAttribute, enableIfAttribute, property)); }
public void InitialAllReadonly() { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this.GetType())) { // 找元素名 if (Element.TryGetOidByName(descriptor.Name, out ElementOID oid) == false) { continue; } Element element = FindElement(oid); if (element != null) { ReadOnlyAttribute attrib = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo isReadOnly = attrib.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); isReadOnly.SetValue(attrib, element.Locked); } else { ReadOnlyAttribute attrib = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo isReadOnly = attrib.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); if (isReadOnly != null) { isReadOnly.SetValue(attrib, false); } } } }
private static RouteValueDictionary FormHtmlAttributes(LambdaExpression expression, Object attributes, String cssClass) { RouteValueDictionary htmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(attributes); htmlAttributes["class"] = String.Format("{0} {1}", cssClass, htmlAttributes["class"]).Trim(); if (!htmlAttributes.ContainsKey("autocomplete")) { htmlAttributes.Add("autocomplete", "off"); } if (htmlAttributes.ContainsKey("readonly")) { return(htmlAttributes); } MemberExpression memberExpression = expression.Body as MemberExpression; if (memberExpression == null) { throw new InvalidOperationException("Expression must be a member expression."); } ReadOnlyAttribute readOnly = memberExpression.Member.GetCustomAttribute <ReadOnlyAttribute>(); if (readOnly != null && readOnly.IsReadOnly) { htmlAttributes.Add("readonly", "readonly"); } return(htmlAttributes); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { ReadOnlyAttribute readOnlyAttribute = (ReadOnlyAttribute)attribute; // Use a specified name if there is one string displayName = (readOnlyAttribute.displayName != "") ? readOnlyAttribute.displayName : property.displayName; switch (property.propertyType) { case SerializedPropertyType.Float: EditorGUI.LabelField(position, displayName, property.floatValue.ToString()); break; case SerializedPropertyType.Integer: EditorGUI.LabelField(position, displayName, property.intValue.ToString()); break; case SerializedPropertyType.Vector3: EditorGUI.LabelField(position, displayName, property.vector3Value.ToString()); break; default: GUI.enabled = false; EditorGUI.PropertyField(position, property, label, true); GUI.enabled = true; break; } }
/// <summary> /// returns true if is read only /// </summary> /// <param name="prop"></param> /// <returns></returns> private static bool IsReadOnly(PropertyInfo prop) { ReadOnlyAttribute attrib = Attribute.GetCustomAttribute(prop, typeof(ReadOnlyAttribute)) as ReadOnlyAttribute; bool readOnly = !prop.CanWrite || (attrib != null && attrib.IsReadOnly); return(readOnly); }
public void Ctor_IsReadOnly(bool isReadOnly) { var attribute = new ReadOnlyAttribute(isReadOnly); Assert.Equal(isReadOnly, attribute.IsReadOnly); Assert.Equal(!isReadOnly, attribute.IsDefaultAttribute()); }
internal IEnumerable <Attribute> GetPropertyAttributes(PropertyDescriptor propertyDescriptor, Type propertyType) { List <Attribute> propertyAttributes = propertyDescriptor.ExplicitAttributes().Cast <Attribute>().ToList(); if (!propertyAttributes.OfType <DataMemberAttribute>().Any()) { propertyAttributes.Add(new DataMemberAttribute()); } ReadOnlyAttribute readOnlyAttr = propertyAttributes.OfType <ReadOnlyAttribute>().SingleOrDefault(); if (readOnlyAttr != null && !propertyAttributes.OfType <EditableAttribute>().Any()) { propertyAttributes.Add(new EditableAttribute(!readOnlyAttr.IsReadOnly)); } if (TypeUtility.IsSupportedComplexType(propertyType) && !propertyAttributes.OfType <DisplayAttribute>().Any()) { DisplayAttribute displayAttribute = new DisplayAttribute() { AutoGenerateField = false }; propertyAttributes.Add(displayAttribute); } // If the data contract type already contains the RoundtripOriginalAttribute, then we remove the attribute from properties. if (this.Type.Attributes()[typeof(RoundtripOriginalAttribute)] != null) { propertyAttributes.RemoveAll(attr => attr.GetType() == typeof(RoundtripOriginalAttribute)); } return(propertyAttributes); }
PropertyGridProperty GetReadOnlyProperty(string propertyName, bool browsable = true) { if (!browsable) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[propertyName]; ReadOnlyAttribute attribute = (ReadOnlyAttribute) descriptor.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo fieldToChange = attribute.GetType().GetField("isReadOnly", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); return(new PropertyGridProperty(attribute, fieldToChange)); } else { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[propertyName]; BrowsableAttribute attribute = (BrowsableAttribute) descriptor.Attributes[typeof(BrowsableAttribute)]; FieldInfo fieldToChange = attribute.GetType().GetField("browsable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); return(new PropertyGridProperty(attribute, fieldToChange)); } }
private void GenGetIdentityFieldEx(StringBuilder sb, Type type, List <string> generatedProperties, int outLang) { foreach (Type item in GetContractInterfaceTypes(type)) { GenGetIdentityFieldEx(sb, item, generatedProperties, outLang); } ReadOnlyAttribute read = GetEntityAttribute <ReadOnlyAttribute>(type); foreach (PropertyInfo item in CoreHelper.GetPropertiesFromType(type)) { //暂不支持关联处理,所以是类则跳过 if (item.PropertyType.IsInterface) { continue; } if (!generatedProperties.Contains(item.Name)) { if (!item.CanWrite) { if (read == null) { sb.Append((outLang == 0 ? "_" : "__") + "."); sb.Append(item.Name); sb.Append(", "); generatedProperties.Add(item.Name); } } } } }
private void CacheAttributes(IEnumerable<Attribute> attributes) { Display = attributes.OfType<DisplayAttribute>().FirstOrDefault(); DisplayFormat = attributes.OfType<DisplayFormatAttribute>().FirstOrDefault(); Editable = attributes.OfType<EditableAttribute>().FirstOrDefault(); ReadOnly = attributes.OfType<ReadOnlyAttribute>().FirstOrDefault(); }
public void Item_GetInvalidIndex_ThrowsIndexOutOfRangeException(int index) { var attribute = new ReadOnlyAttribute(true); var collection = new AttributeCollection(attribute); Assert.Throws <IndexOutOfRangeException>(() => collection[index]); }
public GeneratedMetadataPropertyDescriptor(PropertyDescriptor descriptor, Attribute[] newAttributes) : base(descriptor, newAttributes) { this.descriptor = descriptor; ReadOnlyAttribute attribute = newAttributes.OfType <ReadOnlyAttribute>().FirstOrDefault <ReadOnlyAttribute>(); this.isReadOnly = (attribute != null) ? attribute.IsReadOnly : false; }
public MetadataPropertyDescriptorWrapper(PropertyDescriptor descriptor, Attribute[] newAttributes) : base(descriptor, newAttributes) { this._descriptor = descriptor; ReadOnlyAttribute readOnlyAttribute = newAttributes.OfType <ReadOnlyAttribute>().FirstOrDefault <ReadOnlyAttribute>(); this._isReadOnly = (readOnlyAttribute != null && readOnlyAttribute.IsReadOnly); }
public void Equals_Object_ReturnsExpected(ReadOnlyAttribute attribute, object other, bool expected) { Assert.Equal(expected, attribute.Equals(other)); if (other is ReadOnlyAttribute) { Assert.Equal(expected, attribute.GetHashCode().Equals(other.GetHashCode())); } }
protected void SetReadonly(string property, bool value) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[property]; ReadOnlyAttribute attribute = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo fieldToChange = attribute.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); fieldToChange.SetValue(attribute, value); }
public void SetMobileEdit(bool allowEdit) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())["Mobile"]; ReadOnlyAttribute attrib = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo isReadOnly = attrib.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); isReadOnly.SetValue(attrib, !allowEdit); }
public void SetReadOnly(string property, bool value) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[property]; ReadOnlyAttribute attrib = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)]; FieldInfo isReadOnly = attrib.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); isReadOnly.SetValue(attrib, value); }
private void disableField(string Nombre, bool state) { PropertyDescriptor p1 = TypeDescriptor.GetProperties(this.GetType())[Nombre]; ReadOnlyAttribute attr = p1.Attributes[typeof(ReadOnlyAttribute)] as ReadOnlyAttribute; System.Reflection.FieldInfo aField = attr.GetType().GetField("isReadOnly", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); aField.SetValue(attr, state); }
public MetaTableMetadata(MetaTable table) { Debug.Assert(table != null); Attributes = table.BuildAttributeCollection(); _readOnlyAttribute = Attributes.FirstOrDefault<ReadOnlyAttribute>(); _displayNameAttribute = Attributes.FirstOrDefault<DisplayNameAttribute>(); DisplayColumnAttribute = Attributes.FirstOrDefault<DisplayColumnAttribute>(); ScaffoldTable = Attributes.GetAttributePropertyValue<ScaffoldTableAttribute, bool?>(a => a.Scaffold, null); }
public void GetIsReadOnly(bool value) { var attribute = new ReadOnlyAttribute(value); Assert.Equal(value, attribute.IsReadOnly); }
static ReadOnlyAttribute () { No = new ReadOnlyAttribute (false); Yes = new ReadOnlyAttribute (true); Default = new ReadOnlyAttribute (false); }
public void NameTests(ReadOnlyAttribute attribute, bool isReadOnly) { Assert.Equal(isReadOnly, attribute.IsReadOnly); }