Exemplo n.º 1
0
        public void TestInstanceGetStringValues()
        {
            StringEnum stringEnum = new StringEnum(typeof(EnumWithoutStrings));

            Assert.AreEqual(0, stringEnum.GetStringValues().Length);

            stringEnum = new StringEnum(typeof(EnumPartialStrings));
            Assert.AreEqual(1, stringEnum.GetStringValues().Length);
            Assert.AreEqual("Jack be nimble", stringEnum.GetStringValues().GetValue(0).ToString());
        }
Exemplo n.º 2
0
    //�Public�Methods�(4)�

    public static List <EnumMember> GetAllEnumMembers <T>(this Enum en)
    {
        List <EnumMember> res = new List <EnumMember>();
        StringEnum        se  = new StringEnum(en.GetType());
        Array             arr = se.GetStringValues();

        foreach (var v in arr)
        {
            res.Add(new EnumMember
            {
                Name        = Enum.GetName(typeof(T), ("".GetEnum <T>(v.ToString()))),
                StringValue = v.ToString()
            });
        }
        return(res);
    }
Exemplo n.º 3
0
        /// <summary>
        /// IshBackgroundTask creation through an ishbackgroundTask xml element.
        /// Incoming is: &lt;ishbackgroundtask ishtaskref="169075" ishhistoryref="122259"&gt;
        /// </summary>
        /// <param name="xmlIshBackgroundTask">One ishbackgroundTask xml.</param>
        public IshBackgroundTask(XmlElement xmlIshBackgroundTask)
        {
            _backgroundTaskRef = new Dictionary <Enumerations.ReferenceType, string>();
            StringEnum stringEnum = new StringEnum(typeof(Enumerations.ReferenceType));

            // Loop all reference attributes present in the xml
            foreach (string refType in stringEnum.GetStringValues())
            {
                if (xmlIshBackgroundTask.HasAttribute(refType))
                {
                    Enumerations.ReferenceType enumValue = (Enumerations.ReferenceType)StringEnum.Parse(typeof(Enumerations.ReferenceType), refType);
                    _backgroundTaskRef.Add(enumValue, xmlIshBackgroundTask.Attributes[refType].Value);
                }
            }
            _ishFields = new IshFields((XmlElement)xmlIshBackgroundTask.SelectSingleNode("ishfields"));
            _ishRef    = _ishFields.GetFieldValue("TASKID", Enumerations.Level.Task, Enumerations.ValueType.Value);
        }
Exemplo n.º 4
0
        /// <summary>
        /// IshEvent creation through an ishevent xml element.
        /// Incoming is: <ishevent ishprogressref="807"/> or <ishevent ishprogressref="807" ishdetailref="16317"/>
        /// </summary>
        /// <param name="xmlIshEvent">One ishevent xml.</param>
        public IshEvent(XmlElement xmlIshEvent)
        {
            _eventRef = new Dictionary <Enumerations.ReferenceType, string>();
            StringEnum stringEnum = new StringEnum(typeof(Enumerations.ReferenceType));

            // Loop all reference attributes present in the xml
            foreach (string refType in stringEnum.GetStringValues())
            {
                if (xmlIshEvent.HasAttribute(refType))
                {
                    Enumerations.ReferenceType enumValue = (Enumerations.ReferenceType)StringEnum.Parse(typeof(Enumerations.ReferenceType), refType);
                    _eventRef.Add(enumValue, xmlIshEvent.Attributes[refType].Value);
                }
            }
            _ishFields    = new IshFields((XmlElement)xmlIshEvent.SelectSingleNode("ishfields"));
            _ishEventData = new IshEventData((XmlElement)xmlIshEvent.SelectSingleNode("ishdata"));
            _ishRef       = _ishFields.GetFieldValue("EVENTID", Enumerations.Level.Progress, Enumerations.ValueType.Value);
        }
Exemplo n.º 5
0
        /// <summary>
        /// IshObject creation through an ishobject xml element.
        /// Incoming is: <ishobject ishref="D1E1030" ishtype="ISHModule" ishlogicalref="26288" ishversionref="26291" ishlngref="39490" />
        /// </summary>
        /// <param name="xmlIshObject">One ishobject xml.</param>
        public IshObject(XmlElement xmlIshObject)
        {
            _ishType   = (Enumerations.ISHType)Enum.Parse(typeof(Enumerations.ISHType), xmlIshObject.Attributes["ishtype"].Value);
            _ishRef    = xmlIshObject.Attributes["ishref"].Value;
            _objectRef = new Dictionary <Enumerations.ReferenceType, string>();
            StringEnum stringEnum = new StringEnum(typeof(Enumerations.ReferenceType));

            // Loop all reference attributes present in the xml
            foreach (string refType in stringEnum.GetStringValues())
            {
                if (xmlIshObject.HasAttribute(refType))
                {
                    Enumerations.ReferenceType enumValue = (Enumerations.ReferenceType)StringEnum.Parse(typeof(Enumerations.ReferenceType), refType);
                    _objectRef.Add(enumValue, xmlIshObject.Attributes[refType].Value);
                }
            }
            _ishFields = new IshFields((XmlElement)xmlIshObject.SelectSingleNode("ishfields"));
            _ishData   = new IshData((XmlElement)xmlIshObject.SelectSingleNode("ishdata"));
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializing by something that looks like
 /// <![CDATA[
 /// <?xml version="1.0" encoding="utf-16"?>
 /// <ishdataobjects>
 ///   <ishdataobject ishlngref="1826972" ishdataref="1826973"
 ///   ed="GUID-7EE439B0-EE28-463A-A409-7AB83DE2E92D" edt="EDTCHM"
 ///   size="35802" mimetype="application/mshelp" fileextension="chm" />
 /// </ishdataobjects>
 /// ]]>
 /// </summary>
 public IshDataObject(XmlElement ishData)
 {
     if (ishData != null)
     {
         _edt           = ishData.Attributes["edt"].Value;
         _ed            = ishData.Attributes["ed"].Value;
         _mimeType      = ishData.Attributes["mimetype"].Value;
         _fileExtension = ishData.Attributes["fileextension"].Value;
         _ishDataRef    = ishData.Attributes["ishdataref"].Value;
         _objectRef     = new Dictionary <Enumerations.ReferenceType, string>();
         StringEnum stringEnum = new StringEnum(typeof(Enumerations.ReferenceType));
         // Loop all reference attributes present in the xml
         foreach (string refType in stringEnum.GetStringValues())
         {
             if (ishData.HasAttribute(refType))
             {
                 Enumerations.ReferenceType enumValue = (Enumerations.ReferenceType)StringEnum.Parse(typeof(Enumerations.ReferenceType), refType);
                 _objectRef.Add(enumValue, ishData.Attributes[refType].Value);
             }
         }
         int.TryParse(ishData.Attributes["size"].Value, out _size);
     }
 }
        /// <summary>
        /// Setups the message settings.
        /// </summary>
        public void SetupMessageSettings()
        {   
            // First option is any channels
            if (cboChannel.Items.Count > 0)
                cboChannel.Items.Clear();
            cboChannel.Items.Add(Resources.AnyChannels);

            // Load all channels
            foreach (GatewayConfig g in GatewayConfig.All().OrderBy(gw => gw.Id))
            {
                cboChannel.Items.Add(string.Join(GuiHelper.FieldSplitter, new string[]{g.Id, g.ComPort}));
            }
            cboChannel.SelectedIndex = 0;

            // Load message format
            cboMessageFormat.Items.Clear();
            StringEnum e = new StringEnum(typeof(MessageFormat));    
            foreach (string s in e.GetStringValues())
            {
                cboMessageFormat.Items.Add(s);
            }
            cboMessageFormat.SelectedIndex = 0;

            // Load message status report
            cboStatusReport.Items.Clear();
            e = new StringEnum(typeof(MessageStatusReport));
            foreach (string s in e.GetStringValues())
            {
                cboStatusReport.Items.Add(s);
            }
            cboStatusReport.SelectedIndex = 0;
   
            // Load message type
            cboMessageType.Items.Clear();
            e = new StringEnum(typeof(OutgoingMessageType));
            foreach (string s in e.GetStringValues())
            {
                cboMessageType.Items.Add(s);
            }
            cboMessageType.SelectedIndex = 0;

            // Load priority
            cboPriority.Items.Clear();
            cboPriority.Items.AddRange(EnumMatcher.MessagePriority.Keys.ToArray());
            cboPriority.SelectedIndex = 1;

            cboMessageClass.Items.Clear();
            cboMessageClass.Items.AddRange(EnumMatcher.MessageClass.Keys.ToArray());
            cboMessageClass.SelectedIndex = 0;

            npdQuantity.Value = 1;
            dtpScheduleTime.Value = DateTime.Now;
            //txtMessageContent.Text = string.Empty;

            // WAP push signal
            cboWapPushSignal.Items.Clear();
            cboWapPushSignal.Items.AddRange(EnumMatcher.ServiceIndication.Keys.ToArray());
            cboWapPushSignal.SelectedIndex = 0;

            if (this.Message != null)
            {
                PresetMessageDetails(this.Message);
            }
        }