예제 #1
0
        public Exceptional<Boolean> RenameType(GraphDBType myType, String newName)
        {
            if (myType == null)
                return new Exceptional<Boolean>(new Error_ArgumentNullOrEmpty("myType"));

            if (String.IsNullOrEmpty(newName))
                return new Exceptional<Boolean>(new Error_ArgumentNullOrEmpty("newName"));

            if (GetTypeByName(newName) != null)
                return new Exceptional<Boolean>(new Error_TypeAlreadyExist(newName));

            String oldName = myType.Name;
            String oldLocation = myType.ObjectLocation.ToString();

            var retVal = myType.Rename(newName);

            if (retVal.Failed())
                return new Exceptional<Boolean>(retVal);

            _TypesNameLookUpTable.Remove(oldName);
            _TypesNameLookUpTable.Add(newName, myType);
            _ObjectLocationsOfAllUserDefinedDatabaseTypes.Remove(oldLocation);
            _ObjectLocationsOfAllUserDefinedDatabaseTypes.Add(myType.ObjectLocation.ToString());

            var saveResult = _ObjectLocationsOfAllUserDefinedDatabaseTypes.Save();
            if (!saveResult.Success())
            {
                return new Exceptional<bool>(saveResult);
            }

            return new Exceptional<Boolean>(true);
        }