Exemplo n.º 1
0
        public PropTempl CreatePropTempl(EntityTempl entityTempl, PropGroupTempl propertyParent, TextCode tcKey, TextCode tcValue)
        {
            // check the entity parent
            if (entityTempl == null)
            {
                return(null);
            }

            // transform the key
            PropKeyTemplTextCode propKeyTextCode = new PropKeyTemplTextCode();

            propKeyTextCode.TextCodeId = tcKey.Id;

            // transform the value
            ValTextCodeId valTextCodeId = null;

            if (tcValue != null)
            {
                valTextCodeId = new ValTextCodeId();
                // can be null (to set on instantiation)
                valTextCodeId.TextCodeId = tcValue.Id;
            }

            PropValueTempl propValue = PropValueTemplTool.CreatePropValueTemplFromValue(valTextCodeId);

            return(CreatePropTempl(entityTempl, propertyParent, propKeyTextCode, propValue));
        }
Exemplo n.º 2
0
        public PropTempl CreatePropTempl(EntityTempl entityTempl, PropGroupTempl propertyParent, TextCode tcKey, string value)
        {
            // check the entity parent
            if (entityTempl == null)
            {
                return(null);
            }

            PropKeyTemplTextCode propKeyTextCode = new PropKeyTemplTextCode();

            propKeyTextCode.TextCodeId = tcKey.Id;

            // create the property value template
            PropValueTempl propValue = PropValueTemplTool.CreatePropValueTemplFromValue(value);

            return(CreatePropTempl(entityTempl, propertyParent, propKeyTextCode, propValue));
        }
Exemplo n.º 3
0
        // is the property key a textCode?
        private bool IsKeyMatchProperty(PropTemplBase property, string key, TextCode tcKey)
        {
            PropKeyTemplTextCode keyTextCode = property.Key as PropKeyTemplTextCode;

            if (keyTextCode != null)
            {
                if (tcKey != null)
                {
                    // the key to find is a TextCode
                    if (keyTextCode.TextCodeId.Equals(tcKey.Id))
                    {
                        return(true);
                    }
                }
                else
                {
                    // the property key is a textCode, load it to get the code, because the key is a string
                    TextCode tcPropKey = _reposit.Finder.FindTextCodeById(keyTextCode.TextCodeId);
                    if (tcPropKey.Code.Equals(key))
                    {
                        return(true);
                    }
                }
            }

            // is the property key a string?
            PropKeyTemplString keyString = property.Key as PropKeyTemplString;

            if (keyString != null)
            {
                // compare strings
                if (keyString.Key.Equals(key))
                {
                    return(true);
                }
            }

            // the property doesn't match the key (string or TextCode)
            return(false);
        }
Exemplo n.º 4
0
        public string GetPropKeyTemplString(PropKeyTemplBase propKey)
        {
            string keyString = "";

            PropKeyTemplString propKeyTemplString = propKey as PropKeyTemplString;

            if (propKeyTemplString != null)
            {
                keyString = propKeyTemplString.Key;
                return(keyString);
            }

            PropKeyTemplTextCode propKeyTemplTextCode = propKey as PropKeyTemplTextCode;

            if (propKeyTemplTextCode != null)
            {
                // load the textCode
                keyString = _reposit.Finder.FindTextCodeById(propKeyTemplTextCode.TextCodeId).Code;
                return(keyString);
            }

            return(null);
        }
        /// <summary>
        /// Create a property key, based on the template.
        /// </summary>
        /// <param name="propTempl"></param>
        /// <returns></returns>
        public PropertyKeyBase CreatePropKeyFromTempl(PropTemplBase propTempl)
        {
            // create the key of the property, from the template
            PropKeyTemplTextCode templKeyTextCode = propTempl.Key as PropKeyTemplTextCode;

            if (templKeyTextCode != null)
            {
                PropertyKeyTextCode propKey = new PropertyKeyTextCode();
                propKey.TextCodeId = templKeyTextCode.TextCodeId;
                return(propKey);
            }

            PropKeyTemplString templKeyString = propTempl.Key as PropKeyTemplString;

            if (templKeyString != null)
            {
                PropertyKeyString propKey = new PropertyKeyString();
                propKey.Key = templKeyString.Key;
                return(propKey);
            }

            throw new Exception("Property Key templ not yet implemented!");
        }