Ejemplo n.º 1
0
        public ObjectClassController(IObjectClassService objectClassService, ITopicService topicService) : base(topicService)
        {
            #region validation

            if (objectClassService == null)
            {
                throw new ArgumentNullException(nameof(objectClassService));
            }

            #endregion

            ObjectClassService = objectClassService;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create objectclass with given name if currently not exists in collection of object classes.
        /// Returns newly generated object class or objectclass with given name.
        /// </summary>
        /// <param name="objectClassService">Objectclass service</param>
        /// <param name="topic">Topic for object classes</param>
        /// <param name="objectClassName">Name of object class</param>
        /// <returns>Newly created object class</returns>
        public static ObjectClass CreateIfNotExists(this IObjectClassService objectClassService, Topic topic, string objectClassName)
        {
            #region validation

            if (topic == null)
            {
                throw new ArgumentNullException(nameof(topic));
            }

            if (string.IsNullOrEmpty(objectClassName))
            {
                throw new ArgumentNullException(nameof(objectClassName));
            }

            #endregion

            objectClassName = objectClassName.Replace('\\', '_').Replace('/', '_').Replace(':', '_').Replace('*', '_')
                              .Replace('?', '_').Replace('^', '_').Replace('<', '_').Replace('<', '_').Replace('|', '_');

            // get list of all object classes
            IEnumerable <ObjectClass> objectClasses = objectClassService.GetObjectClasses(topic);

            // find object class with name
            ObjectClass objectClass = objectClasses.SingleOrDefault(o => o.Name.Equals(objectClassName, StringComparison.CurrentCultureIgnoreCase));

            if (objectClass == null)
            {
                // create object class
                objectClass = new ObjectClass()
                {
                    Name      = objectClassName,
                    ColorCode = ObjectClassColorUtil.GetDefaultColorCode((uint)objectClasses.Count())
                };

                objectClass = objectClassService.CreateObjectClass(topic, objectClass);
            }
            return(objectClass);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new controller instance.
 /// </summary>
 /// <param name="objectClassService">Objectclass service</param>
 /// <param name="topicService">Topic service</param>
 public ObjectClassController(IObjectClassService objectClassService, ITopicService topicService) : base(topicService)
 {
     ObjectClassService = objectClassService ?? throw new ArgumentNullException(nameof(objectClassService));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new controller instance.
 /// </summary>
 /// <param name="imageService">Image service</param>
 /// <param name="labelService">Label service</param>
 /// <param name="objectClassService">Objectclass service</param>
 /// <param name="topicService">Topic service</param>
 public ImagesLabelController(IImageService imageService, ILabelService labelService, IObjectClassService objectClassService, ITopicService topicService) : base(topicService)
 {
     ImageService       = imageService ?? throw new ArgumentNullException(nameof(imageService));
     LabelService       = labelService ?? throw new ArgumentNullException(nameof(labelService));
     ObjectClassService = objectClassService ?? throw new ArgumentNullException(nameof(objectClassService));
 }