コード例 #1
0
ファイル: EventId.cs プロジェクト: ru-petrovi4/Ssz.Utils
 public EventId(Ssz.Utils.DataAccess.EventId eventId)
 {
     SourceId = new InstanceId("", "", eventId.SourceElementId);
     if (eventId.MultiplexedAlarmContainer is not null)
     {
         MultiplexedAlarmContainer = new TypeId(eventId.MultiplexedAlarmContainer);
     }
     if (eventId.Conditions is not null)
     {
         Condition = new List <TypeId>(eventId.Conditions.Select(t => new TypeId(t)));
     }
     OccurrenceId = eventId.OccurrenceId;
     if (eventId.TimeLastActiveUtc is not null)
     {
         TimeLastActive = eventId.TimeLastActiveUtc.Value;
     }
 }
コード例 #2
0
        /// <summary>
        /// This static method checks the validity of an instance id.
        /// </summary>
        /// <param name="instanceId">
        /// The instance id to validate.
        /// </param>
        /// <returns>
        /// True if valid. False if not.
        /// </returns>
        public static bool IsValid(InstanceId instanceId)
        {
            bool valid = false;

            if ((instanceId is not null) && (string.IsNullOrEmpty(instanceId.FullyQualifiedId) == false))
            {
                int pos = instanceId.FullyQualifiedId.IndexOf("/");
                if ((pos >= 0) && (pos < instanceId.FullyQualifiedId.Length - 1))                 // between the beginning and second to last character inclusive
                {
                    string prefix = instanceId.FullyQualifiedId.Substring(0, pos);
                    pos = prefix.IndexOf(":");
                    if ((pos == -1) ||                     // no ResourceType - that's ok
                        (pos == 0) ||                          // no ResourceType - that's ok
                        (pos > 1))                             // ResourceType length > 2 - that's ok
                    {
                        valid = true;
                    }
                }
            }
            return(valid);
        }
コード例 #3
0
 /// <summary>
 /// This constructor creates an InstanceId from another InstanceId.
 /// </summary>
 /// <param name="instanceId">The instance id that is to be copied to
 /// the InstanceId being created.</param>
 public InstanceId(InstanceId instanceId)
 {
     FullyQualifiedId = instanceId.FullyQualifiedId;
 }