Esempio n. 1
0
        /// <summary>
        /// Merge internal
        /// </summary>
        private static void MergeInternal(PropertyContainerDescription victim, PropertyContainerDescription merged)
        {
            if (victim.All && !merged.All)
            {
                merged.All = victim.All;
            }
            if (victim.Ref != merged.Ref && merged.Ref == null)
            {
                merged.Ref = victim.Ref;
            }
            if ((victim is PropertyModelDescription) &&
                (victim as PropertyModelDescription).Action != SerializationBehaviorType.Default &&
                (victim as PropertyModelDescription).Action < (merged as PropertyModelDescription)?.Action)
            {
                (merged as PropertyModelDescription).Action = (victim as PropertyModelDescription).Action;
            }

            foreach (var td in victim.Properties)
            {
                var mergeModel = merged.FindProperty(td.Name);
                if (mergeModel == null)
                {
                    merged.Properties.Add(td);
                }
                else
                {
                    MergeInternal(td, mergeModel);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Find description
        /// </summary>
        public PropertyContainerDescription FindDescription(Type rootType)
        {
            PropertyContainerDescription retVal = null;

            string rootTypeName = this.GetTypeName(rootType);

            // Type name
            if (!this.m_description.TryGetValue(rootTypeName, out retVal))
            {
                retVal = this.Model.FirstOrDefault(o => o.TypeName == rootTypeName);
                String typeName = rootTypeName;
                // Children from the heirarchy
                while (rootType != typeof(IdentifiedData) && retVal == null)
                {
                    rootType = rootType.GetTypeInfo().BaseType;
                    if (rootType == null)
                    {
                        break;
                    }
                    typeName = this.GetTypeName(rootType);

                    if (!this.m_description.TryGetValue(typeName, out retVal))
                    {
                        retVal = this.Model.FirstOrDefault(o => o.TypeName == typeName);
                    }
                }

                lock (this.m_lockObject)
                    if (!this.m_description.ContainsKey(rootTypeName))
                    {
                        this.m_description.Add(rootTypeName, retVal);
                    }
            }
            return(retVal);
        }
Esempio n. 3
0
        /// <summary>
        /// Find description
        /// </summary>
        public PropertyContainerDescription FindDescription(String propertyName, PropertyContainerDescription context)
        {
            if (propertyName == null)
            {
                return(null);
            }
            PropertyContainerDescription retVal = null;
            String pathName    = propertyName;
            var    pathContext = context;

            while (pathContext != null)
            {
                pathName    = pathContext.GetName() + "." + pathName;
                pathContext = pathContext.Parent;
            }

            if (!this.m_description.TryGetValue(pathName, out retVal))
            {
                // Find the property information
                retVal = context?.FindProperty(propertyName);
                if (retVal == null)
                {
                    retVal = context?.FindProperty("*");
                }
                lock (this.m_lockObject)
                    if (!this.m_description.ContainsKey(pathName))
                    {
                        this.m_description.Add(pathName, retVal);
                    }
            }
            return(retVal);
        }
 /// <summary>
 /// Initialize the parent structure
 /// </summary>
 public void Initialize(PropertyContainerDescription parent)
 {
     this.Parent = parent;
     foreach (var itm in this.Properties)
     {
         itm.Initialize(this);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Find description based on name
        /// </summary>
        public PropertyContainerDescription FindDescription(String name)
        {
            PropertyContainerDescription value = null;

            if (!this.m_description.TryGetValue(name, out value))
            {
                value = this.Model.Find(o => o.TypeName == name);
                lock (this.m_lockObject)
                    if (!this.m_description.ContainsKey(name))
                    {
                        this.m_description.Add(name, value);
                    }
            }
            return(value);
        }