Ejemplo n.º 1
0
        public ResourcePropertiesDesc AddResourceDesc(ModelCode resourceId, string resourceName)
        {
            ResourcePropertiesDesc desc = new ResourcePropertiesDesc(resourceId, resourceName);

            this.resourceDescs[((long)resourceId & (long)ModelCodeMask.MASK_INHERITANCE_ONLY)] = desc;
            return(desc);
        }
Ejemplo n.º 2
0
        private void Initialize()
        {
            // populating model type and property descriptions
            this.resourceDescs = new Dictionary <long, ResourcePropertiesDesc>();

            ResourcePropertiesDesc desc = null;

            InitializeTypeIdsInInsertOrder();

            //// Initialize metadata for core entities
            InitializeNotSettablePropertyIds();
            InitializePropertyNames();

            foreach (ModelCode code in Enum.GetValues(typeof(ModelCode)))
            {
                allModelCodes.Add(code);
            }

            foreach (DMSType type in Enum.GetValues(typeof(DMSType)))
            {
                allDMSTypes.Add(type);
            }


            # region get all class model codes from core
Ejemplo n.º 3
0
 /// <summary>
 /// Adds new model type description to collection.
 /// </summary>
 /// <param name="resourceId">Code of the model type</param>
 /// <param name="desc">Model type description</param>
 public void AddResourceDesc(ModelCode resourceId, ResourcePropertiesDesc desc)
 {
     this.resourceDescs[((long)resourceId & (long)ModelCodeMask.MASK_INHERITANCE_ONLY)] = desc;
 }
Ejemplo n.º 4
0
        private void Initialize()
        {
            // populating model type and property descriptions
            this.resourceDescs = new Dictionary <long, ResourcePropertiesDesc>();

            ResourcePropertiesDesc desc = null;

            InitializeTypeIdsInInsertOrder();

            //// Initialize metadata for core entities
            InitializeNotSettablePropertyIds();

            foreach (ModelCode code in Enum.GetValues(typeof(ModelCode)))
            {
                allModelCodes.Add(code);
            }

            foreach (DMSType type in Enum.GetValues(typeof(DMSType)))
            {
                allDMSTypes.Add(type);
            }

            #region get all class model codes from core

            //// Get all class model codes for all services and for all classes, abstract or not. Extensibility included
            List <ModelCode> classIds = new List <ModelCode>();
            foreach (ModelCode code in allModelCodes)
            {
                // don't insert attribute codes
                if (((long)code & (long)ModelCodeMask.MASK_ATTRIBUTE_TYPE) == 0)
                {
                    classIds.Add(code);
                }
            }

            #endregion get all class model codes from core

            #region Initialize non abstract class and resourceDescription map from core

            foreach (ModelCode classId in classIds)
            {
                //// Initialize leafs
                if (((long)classId & (long)ModelCodeMask.MASK_TYPE) != 0)
                {
                    nonAbstractClassIds.Add(classId);
                }

                //// Initialize resourceDescription map
                desc = this.AddResourceDesc(classId);
                long classIdMask = unchecked ((long)0xffffffff00000000);

                foreach (ModelCode propertyId in allModelCodes)
                {
                    PropertyType propertyType = Property.GetPropertyType(propertyId);

                    if (propertyType == 0)
                    {
                        continue;
                    }

                    if (((long)propertyId & classIdMask) == ((long)classId & classIdMask))
                    {
                        if (!desc.PropertyExists(propertyId))
                        {
                            desc.AddPropertyId(propertyId);
                        }
                    }
                }
            }

            #endregion Initialize non abstract class and resourceDescription map from core

            #region Initialize type 2 model code map

            //// Model codes names from enum, these are only names for core model codes
            string[] modelCodeNamesFromCore = Enum.GetNames(typeof(ModelCode));

            classIds = new List <ModelCode>();
            foreach (ModelCode code in allModelCodes)
            {
                // don't insert attribute codes
                if (((long)code & (long)ModelCodeMask.MASK_ATTRIBUTE_TYPE) == 0)
                {
                    classIds.Add(code);
                }
            }

            //// Initialize DMSType 2 ModelCode map
            foreach (DMSType t in allDMSTypes)
            {
                DMSType type = t & DMSType.MASK_TYPE;

                ////  if DMSType is not addad and it is not mask
                if (!this.type2modelCode.ContainsKey(type) && type != DMSType.MASK_TYPE)
                {
                    //// DMSTypes that have same name as appropriete model code
                    if (modelCodeNamesFromCore.Contains(type.ToString()))
                    {
                        this.type2modelCode[type] = GetModelCodeFromTypeForCore(type);
                    }
                    else // for DMSTypes which don't have it's ModelCode with same name or are not in core
                    {
                        try // for DMSTypes which have it's ModelCode but with different name
                        {
                            foreach (ModelCode classId in classIds)
                            {
                                if (GetTypeFromModelCode(classId) == type)
                                {
                                    this.type2modelCode[type] = classId;
                                    break;
                                }
                            }
                        }
                        catch { }
                    }
                }
            }

            #endregion Initialize type 2 model code map
        }