private void ComponentNewEditXtraForm_Load(object sender, EventArgs e) { EnumWrapper <PartInspectionStatus> .LoadItems(localizedAllInspectionStatus, skip0 : true); EnumWrapper <DuplicateNumberEntityType> .LoadItems(localizedAllTypes, skip0 : true); BindToViewModel(); viewModel.PropertyChanged += (s, eve) => IsModified = true; viewModel.PropertyChanged += (s, eve) => { if (eve.PropertyName == "ComponentIsActive" && viewModel.ComponentIsActive) { deactivated.Reset(); } }; IsEditMode &= viewModel.ComponentIsActive; IsModified = false; repositoryInspectionDate.SetLimits(); componentLength.SetMask(Constants.PositiveDigitMask); inspectorColumn.SortMode = DevExpress.XtraGrid.ColumnSortMode.DisplayText; inspectorsPopupContainerEdit.SetSize(); type.ReadOnly = !IsEditMode || viewModel.HasConnectedConnectors; inspectionHistoryGridView.OptionsBehavior.Editable = !type.ReadOnly; BindCommands(); }
private void BindToViewModel() { MillPipeSearchBindingSource.DataSource = viewModel; foreach (var s in viewModel.PipeTypes) { pipeSize.Properties.Items.Add(s, true); } foreach (var item in EnumWrapper <PipeMillStatus> .EnumerateItems(skip0: true)) { pipeMillStatus.Properties.Items.Add(item.Item1, item.Item2, CheckState.Checked, enabled: true); } foreach (var item in EnumWrapper <ActivityCriteria> .EnumerateItems()) { pipeActivity.Properties.Items.Add(item.Item2); } viewModel.Activity = ActivityCriteria.StatusActive; pipesSearchResult.DataBindings .Add("DataSource", MillPipeSearchBindingSource, "Pipes"); pipeNumber.DataBindings .Add("EditValue", MillPipeSearchBindingSource, "PipeNumber"); pipeActivity.DataBindings .Add("SelectedIndex", MillPipeSearchBindingSource, "ActivityIndex"); weldingDate.DataBindings .Add("DateTime", MillPipeSearchBindingSource, "WeldingDate"); externalCoatingDate.DataBindings .Add("DateTime", MillPipeSearchBindingSource, "ExternalCoatingDate"); internalCoatingDate.DataBindings .Add("DateTime", MillPipeSearchBindingSource, "InternalCoatingDate"); heatNumber.DataBindings .Add("EditValue", MillPipeSearchBindingSource, "HeatNumber"); }
private void MillPipeNewEditXtraForm_Load(object sender, EventArgs e) { foreach (var item in EnumWrapper <PipeTestResultStatus> .EnumerateItems(skip0: true)) { localizedAllPipeTestResultStatus.Add(item.Item2); } foreach (var item in EnumWrapper <PipeMillStatus> .EnumerateItems()) { localizedAllPipeMillStatus.Add(item.Item2); } BindCommands(); BindToViewModel(); viewModel.PropertyChanged += (s, eve) => IsModified = true; IsEditMode = viewModel.PipeIsActive && !(viewModel.Pipe.Status == PipeMillStatus.Shipped); pipeNumber.SetMask(viewModel.Project.MillPipeNumberMaskRegexp); IsModified = false; pipeNumber.ToolTip = Program.LanguageManager.GetString(StringResources.MillPipeNumber_Mask_Hint) + viewModel.Project.MillPipeNumberMask; pipeCreationDate.SetLimits(); repositoryCoatingDate.SetLimits(); repositoryWeldingDate.SetLimits(); }
public void Test_ToString() { EnumWrapper wrapper = EnumWrapper.Get(TestAccessTypes.First); AccessType accessType = AccessType.Get(wrapper); Assert.That(accessType.ToString(), Is.EqualTo(wrapper.ToString())); }
public void Serialization() { EnumWrapper wrapper = EnumWrapper.Get("bla", "ble"); EnumWrapper deserializedWrapper = Serializer.SerializeAndDeserialize(wrapper); Assert.That(deserializedWrapper, Is.EqualTo(wrapper)); }
public void GetHashCode_EqualObjects() { EnumWrapper one = EnumWrapper.Get("123"); EnumWrapper two = EnumWrapper.Get("123"); Assert.That(one.GetHashCode(), Is.EqualTo(two.GetHashCode())); }
public void Serialization() { AccessType accessType = AccessType.Get(EnumWrapper.Get(TestAccessTypes.First)); AccessType deserializedAccessType = Serializer.SerializeAndDeserialize(accessType); Assert.That(deserializedAccessType, Is.EqualTo(accessType)); }
private string LocalizeStatus(GridView view, int p) { JointStatus status = (JointStatus)view.GetListSourceRowCellValue(p, "Status"); var wrp = new EnumWrapper <JointStatus>(status); return(wrp.Name); }
private void MillInspectionXtraForm_Load(object sender, EventArgs e) { resultType.Properties.Items.Clear(); controlType.Properties.Items.Clear(); frequencyMeasure.Properties.Items.Clear(); frequencyType.Properties.Items.Clear(); resultType.SelectedIndex = -1; controlType.SelectedIndex = -1; EnumWrapper <PipeTestResultType> .LoadItems(resultType.Properties.Items, skip0 : true); EnumWrapper <PipeTestControlType> .LoadItems(controlType.Properties.Items, skip0 : true); EnumWrapper <FrequencyMeasure> .LoadItems(frequencyMeasure.Properties.Items, skip0 : true); EnumWrapper <InspectionFrequencyType> .LoadItems(frequencyType.Properties.Items); BindToViewModel(); boolExpected_CheckedChanged(null, null); code.SetAsIdentifier(); code.SetRequiredText(); operationName.SetRequiredText(); controlType.SetRequiredCombo(); frequency.SetMask(Constants.PositiveDigitMask); frequencyMeasure.SetRequiredCombo(); resultType.SetRequiredCombo(); percentOfSelect.SetRequiredText(); minExpected.SetFloatMask(Constants.DigitsBeforeDecimalPoint); maxExpected.SetFloatMask(Constants.DigitsBeforeDecimalPoint); CheckFixedResultType(viewModel.Category); }
static void Main(string[] args) { var val = new EnumWrapper(B.f); Enum en = val.EnumVal; Console.WriteLine("{0}.{1}", en.GetType().Name, en); }
private void ConstructionReportsXtraForm_Load(object sender, EventArgs e) { viewModel = (ConstructionReportViewModel)Program.Kernel.GetService(typeof(ConstructionReportViewModel)); EnumWrapper <PartType> .LoadItems(type.Properties.Items, CheckState.Checked, enabled : true, skip0 : true); EnumWrapper <ReportType> .LoadItems(reportType.Properties.Items); EnumWrapper <PartType> .LoadItems(localizedAllPartType, skip0 : true); viewModel.LoadData(); start.Properties.DataSource = viewModel.JointsProjections; end.Properties.DataSource = viewModel.JointsProjections; startKPLookUp.Properties.DataSource = viewModel.AllKP; endKPLookUp.Properties.DataSource = viewModel.AllKP; BindToViewModel(); BindCommands(); RefreshTypes(); viewModel.ReportTypeIndex = reportType.SelectedIndex = 0; tracingModeRadioGroup_SelectedIndexChanged(tracingModeRadioGroup, e); viewModel.StartPK = int.MinValue; viewModel.EndPK = int.MinValue; }
public void ValidateUniqueStateCombinations_DoubleStateCombinationAndObjectIsDeleted() { AccessControlTestHelper testHelper = new AccessControlTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { SecurableClassDefinition orderClass = testHelper.CreateOrderClassDefinition(); List <StateCombination> stateCombinations = testHelper.CreateOrderStateAndPaymentStateCombinations(orderClass); var states = stateCombinations[0].GetStates(); StatePropertyDefinition orderStateProperty = states[0].StateProperty; StatePropertyDefinition paymentProperty = states[1].StateProperty; using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope()) { testHelper.CreateStateCombination( orderClass, ClientTransaction.Current, orderStateProperty[EnumWrapper.Get(OrderState.Received).Name], paymentProperty[EnumWrapper.Get(PaymentState.Paid).Name]); Assert.That(orderClass.StateCombinations, Is.Not.Empty); orderClass.Delete(); SecurableClassValidationResult result = new SecurableClassValidationResult(); orderClass.ValidateUniqueStateCombinations(result); Assert.That(result.IsValid, Is.True); Assert.That(orderClass.State, Is.EqualTo(StateType.Deleted)); } } }
private void SpoolsXtraForm_Load(object sender, System.EventArgs e) { EnumWrapper <PartInspectionStatus> .LoadItems(localizedAllInspectionStatus, skip0 : true); EnumWrapper <DuplicateNumberEntityType> .LoadItems(localizedAllPartTypes, skip0 : true); BindToViewModel(); attachmentsButton.Enabled = (!viewModel.IsNew || viewModel.SpoolNumber != String.Empty); viewModel.PropertyChanged += (s, eve) => IsModified = true; viewModel.PropertyChanged += (s, eve) => { if (eve.PropertyName == "SpoolIsActive" && viewModel.SpoolIsActive) { deactivated.Reset(); } }; IsEditMode = ((this.Id != Guid.Empty || viewModel.SpoolNumber != String.Empty) && viewModel.SpoolIsActive); BindCommands(); inspectionDateEdit.SetLimits(); spoolNumber.SetAsIdentifier(); inspectorsGridColumn.SortMode = DevExpress.XtraGrid.ColumnSortMode.DisplayText; inspectorsPopupContainerEdit.SetSize(); }
private void SerializeArguments() { for (var i = 0; i < Arguments.Length; i++) { if (Arguments[i].GetType().IsEnum) { Arguments[i] = new EnumWrapper(Arguments[i]); } if (Arguments[i] is Vector2) { Arguments[i] = (SerializableVector2)(Vector2)Arguments[i]; } if (Arguments[i] is Vector3) { Arguments[i] = (SerializableVector3)(Vector3)Arguments[i]; } if (Arguments[i] is Vector4) { Arguments[i] = (SerializableVector4)(Vector4)Arguments[i]; } if (Arguments[i] is Quaternion) { Arguments[i] = (SerializableQuaternion)(Quaternion)Arguments[i]; } } }
public static EnumWrapper <T>[] GetEnumWrappers <T>() { List <EnumWrapper <T> > ret = new List <EnumWrapper <T> >(); string[] names = Enum.GetNames(typeof(T)); for (int i = 0; i < names.Length; i++) { EnumWrapper <T> newWrapper = new EnumWrapper <T>(); newWrapper.Name = names[i]; newWrapper.Value = (T)Enum.Parse(typeof(T), names[i]); DescriptionAttribute[] descAtts = typeof(T).GetField(names[i]).GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[]; if (descAtts != null && descAtts.Any()) { newWrapper.Descriptor = descAtts.First().Description; } else { newWrapper.Descriptor = names[i]; } ret.Add(newWrapper); } return(ret.ToArray()); }
private void InspectionAddEditXtraForm_Load(object sender, EventArgs e) { status.Properties.Items.Clear(); EnumWrapper <PipeTestResultStatus> .LoadItems(status.Properties.Items, skip0 : true); BindToViewModel(); if (listOfInspectors != null) { var insp = (List <Inspector>)listOfInspectors.Where(_ => _.Key == viewModel.Code).FirstOrDefault().Value; if (insp != null) { viewModel.TestResult.Inspectors = insp; } else { viewModel.TestResult.Inspectors = new List <Inspector>(); } inspectors.SelectInspectors(viewModel.SelectInspectors()); } inspectors.InspectionDate = viewModel.Date; factBool_CheckedChanged(null, null); date.SetLimits(); }
public MainViewModel() { this.selectedLanguage = CultureInfo.CurrentUICulture; // Initialize RadioFrequency enums using EnumWrapper explicitly this.RadioFrequencies = new EnumWrapperCollection<RadioFrequency>(); this.radioFrequency = this.RadioFrequencies.FirstOrDefault(); // Initialize PartyMode enum without EnumWrapper this.PartyModes = Enum.GetValues(typeof(PartyMode)).OfType<PartyMode>(); this.selectedPartyMode = this.PartyModes.FirstOrDefault(); this.EditCommand = new RelayCommand( () => { this.ChangeDate = DateTime.Now; this.IsEditing = true; }); this.CancelCommand = new RelayCommand( () => { this.IsEditing = false; }); this.NextPartyModeCommand = new RelayCommand( () => { // Cycle through PartyMode enum: this.SelectedPartyMode = (PartyMode)((int)(this.SelectedPartyMode + 1) % Enum.GetValues(this.SelectedPartyMode.GetType()).Length); }); }
private void HistoryExportImport_Load(object sender, EventArgs e) { EnumWrapper <WorkstationType> .LoadItems(localizedAllWorkstations); EnumWrapper <SynchType> .LoadItems(localizedSynchType); gridControlHistory.DataSource = exporter.GetAllPortions(); }
public AException(ErrorCode errorCode) { var enumDescription = EnumWrapper.GetEnumDescription(errorCode); ErrorCode = (int)errorCode; ZHMessage = enumDescription.ZH; ENMessage = enumDescription.EN; }
private void NumbersDialog_Load(object sender, EventArgs e) { foreach (var item in EnumWrapper <PartType> .EnumerateItems(skip0: true)) { localizedPartTypes.Add(item.Item2); } searchResults.DataSource = parts; }
public void Find_ValidOneAbstractRole() { var abstractRoles = new[] { EnumWrapper.Get(ProjectRoles.QualityManager) }; var result = AbstractRoleDefinition.Find(abstractRoles); Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result[0].Name, Is.EqualTo(abstractRoles[0].Name)); }
private void LoadStatuses() { CheckedStatusTypes = new HashSet <PipeMillStatus>(); foreach (var item in EnumWrapper <PipeMillStatus> .EnumerateItems(skip0: true)) { CheckedStatusTypes.Add((PipeMillStatus)item.Item1); } }
private void FirstSetupXtraForm_Load(object sender, EventArgs e) { foreach (var item in EnumWrapper <WorkstationType> .EnumerateItems()) { localizedAllWorkstations.Add(item.Item2); } BindToViewModel(); pipeNumberMaskRulesLabel.Text = Program.LanguageManager.GetString(StringResources.Mask_Label); }
public override int GetHashCode() { var hashCode = -1129657248; hashCode = hashCode * -1521134295 + base.GetHashCode(); hashCode = hashCode * -1521134295 + TypeDefName.GetHashCode(); hashCode = hashCode * -1521134295 + EnumWrapper.GetHashCode(); return(hashCode); }
public void shortAndByteBasedEnumToJsonTest() { var enumWrapper = new EnumWrapper(); Assert.DoesNotThrow(() => { var json = JsonMapper.ToJson(enumWrapper); }); }
private void LoadPipeMillStatuses() { StatusTypes = new List <EnumWrapper <PipeMillStatus> >(); foreach (var item in EnumWrapper <PipeMillStatus> .EnumerateItems(skip0: true)) { StatusTypes.Add(new EnumWrapper <PipeMillStatus>(item.Item2)); } }
private void LoadJointOperationTypes() { JointOperationTypes = new List <EnumWrapper <JointOperationType> >(); foreach (var item in EnumWrapper <JointOperationType> .EnumerateItems(skip0: true)) { JointOperationTypes.Add(new EnumWrapper <JointOperationType>((JointOperationType)item.Item1)); // TODO: binding list vs localization - ? } }
public void CreateSecurityContextWithAbstractRole() { Enum[] abstractRoles = new Enum[] { TestAbstractRoles.QualityEngineer, TestAbstractRoles.Developer }; SecurityContext context = CreateTestSecurityContextWithAbstractRoles(abstractRoles); Assert.That( context.AbstractRoles, Is.EquivalentTo(new[] { EnumWrapper.Get(TestAbstractRoles.QualityEngineer), EnumWrapper.Get(TestAbstractRoles.Developer) })); }
protected override EnumWrapper Clone(EnumWrapper src) { EnumWrapper dst = new EnumWrapper(typeof(E)); if (src != null) { dst.Enum = src.Enum; } return(dst); }
public static void LoadItems(List <string> list, bool skip0 = false) { if (list != null && list.Count == 0) { foreach (var item in EnumWrapper <PartType> .EnumerateItems(skip0)) { list.Add(item.Item2); } } }
public override bool DrawValue(int i, EnumWrapper w) { E e = (E)Enum.Parse(typeof(E), w.Enum.ToString()); if (EditorGUILayoutEx.Popup <E>(ref e, preset, layout)) { w.Enum = (Enum)Enum.Parse(typeof(E), e.ToString()); return(true); } return(false); }
public static void Save(IValueSink sink, EnumWrapper value) { Value<Enumerated>.Save(sink, value.Item); }
public Value (EnumWrapper wrap, string type_name) { type = IntPtr.Zero; pad1 = new Padding (); pad2 = new Padding (); g_value_init (ref this, GType.FromName (type_name).Val); if (wrap.flags) g_value_set_flags (ref this, (uint) (int) wrap); else g_value_set_enum (ref this, (int) wrap); }
private string LocalizeStatus(GridView view, int p) { JointStatus status = (JointStatus)view.GetListSourceRowCellValue(p, "Status"); var wrp = new EnumWrapper<JointStatus>(status); return wrp.Name; }
public Value (Gst.GLib.Object obj, string prop_name, EnumWrapper wrap) { type = IntPtr.Zero; pad1 = new Padding (); pad2 = new Padding (); InitForProperty (obj.NativeType, prop_name); if (wrap.flags) g_value_set_flags (ref this, (uint) (int) wrap); else g_value_set_enum (ref this, (int) wrap); }
/// <summary> /// Main executor function. /// </summary> /// <returns>A CodeCompileUnit.</returns> public CodeCompileUnit Execute() { var codeCompileUnit = new CodeCompileUnit(); // Set namespace var nsWrap = new NamespaceWrapper(new CodeNamespace(_codeNamespace)); // Set class var codeClass = new CodeTypeDeclaration(_schemaDocument.Title) {Attributes = MemberAttributes.Public}; var clWrap = new ClassWrapper(codeClass); // Add imports for interfaces and dependencies nsWrap.AddImportsFromWrapper(_schemaWrapper); // Add comments and attributes for class if (!String.IsNullOrEmpty(_schemaDocument.Description)) { clWrap.AddComment(_schemaDocument.Description); } // Add extended class if (_schemaDocument.Extends != null && _schemaDocument.Extends.Count > 0) { clWrap.AddInterface(JsonSchemaUtils.GetType(_schemaDocument.Extends[0], _codeNamespace).Name); } // Add interfaces foreach (Type t in _schemaWrapper.Interfaces) { clWrap.AddInterface(t.Name); } // Add properties with getters/setters if (_schemaDocument.Properties != null) { foreach (var i in _schemaDocument.Properties) { JsonSchema schema = i.Value; // Sanitize inputs if (!String.IsNullOrEmpty(schema.Description)) { schema.Description = Regex.Unescape(schema.Description); } // If it is an enum var propertyName = i.Key.Capitalize(); if (schema.Enum != null) { var enumField = new CodeTypeDeclaration(propertyName); var enumWrap = new EnumWrapper(enumField); // Add comment if not null if (!String.IsNullOrEmpty(schema.Description)) { enumField.Comments.Add(new CodeCommentStatement(schema.Description)); } foreach (JToken j in schema.Enum) { enumWrap.AddMember(j.ToString().SanitizeIdentifier()); } // Add to namespace nsWrap.AddClass(enumWrap.Property); } else { // WARNING: This assumes the namespace of the property is the same as the parent. // This should not be a problem since imports are handled for all dependencies at the beginning. Type type = JsonSchemaUtils.GetType(schema, _codeNamespace); bool isCustomType = type.Namespace != null && type.Namespace.Equals(_codeNamespace); string strType = String.Empty; // Add imports nsWrap.AddImport(type.Namespace); nsWrap.AddImportsFromSchema(schema); // Get the property type if (isCustomType) { strType = JsonSchemaUtils.IsArray(schema) ? string.Format("{0}<{1}>", JsonSchemaUtils.GetArrayType(schema), type.Name) : type.Name; } else if (JsonSchemaUtils.IsArray(schema)) { strType = string.Format("{0}<{1}>", JsonSchemaUtils.GetArrayType(schema), new CSharpCodeProvider().GetTypeOutput(new CodeTypeReference(type))); } //var field = new CodeMemberField //{ // Attributes = MemberAttributes.Private, // Name = "_" + i.Key, // Type = // TypeUtils.IsPrimitive(type) && !JsonSchemaUtils.IsArray(schema) // ? new CodeTypeReference(type) // : new CodeTypeReference(strType) //}; //clWrap.Property.Members.Add(field); var property = CreateProperty(propertyName, TypeUtils.IsPrimitive(type) && !JsonSchemaUtils.IsArray(schema) ? new CodeTypeReference(type) : new CodeTypeReference(strType)); var prWrap = new PropertyWrapper(property); // Add comments and attributes prWrap.Populate(schema, _attributeType); // Add default, if any if (schema.Default != null) { clWrap.AddDefault(propertyName, property.Type, schema.Default.ToString()); } clWrap.Property.Members.Add(property); } } } // Add class to namespace nsWrap.AddClass(clWrap.Property); codeCompileUnit.Namespaces.Add(nsWrap.Namespace); return codeCompileUnit; }