コード例 #1
0
        public TemplatePropTypeBundle(string szUser) : this()
        {
            UserProperties = new Collection <CustomPropertyType>(new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(szUser)));
            // For serialization to work with propertytemplates, the objects need to actually be propertytemplates, not subclasses.
            List <PropertyTemplate>        lst  = new List <PropertyTemplate>();
            IEnumerable <PropertyTemplate> rgpt = UserPropertyTemplate.TemplatesForUser(szUser, true);

            foreach (PropertyTemplate pt in rgpt)
            {
                lst.Add(new PropertyTemplate(pt));
            }
            UserTemplates = new Collection <PropertyTemplate>(lst);
        }
コード例 #2
0
        /// <summary>
        /// Returns a pseudo propertytemplate that reflects a merge of the provided templates.
        /// </summary>
        /// <param name="lstIn"></param>
        /// <returns></returns>
        public static PropertyTemplate MergedTemplate(IEnumerable <PropertyTemplate> lstIn)
        {
            if (lstIn == null)
            {
                return(null);
            }

            PropertyTemplate pt = new UserPropertyTemplate();

            foreach (PropertyTemplate ptIn in lstIn)
            {
                pt.m_propertyTypes.UnionWith(ptIn.m_propertyTypes);
            }

            return(pt);
        }
コード例 #3
0
        /// <summary>
        /// Creates a copy of a public template for the user.
        /// </summary>
        /// <param name="szUser"></param>
        public PersistablePropertyTemplate CopyPublicTemplate(string szUser)
        {
            if (String.IsNullOrWhiteSpace(szUser))
            {
                throw new MyFlightbookValidationException("Trying to consume for empty user");
            }
            if (!IsPublic)
            {
                throw new MyFlightbookValidationException("Can't consume a non-published template");
            }
            UserPropertyTemplate upt = new UserPropertyTemplate();

            // Initialize from this
            JsonConvert.PopulateObject(JsonConvert.SerializeObject(this), upt);
            upt.OriginalOwner = Owner;
            upt.Owner         = szUser;
            upt.ID            = (int)KnownTemplateIDs.ID_NEW;
            upt.IsPublic      = false;
            return(upt);
        }